The Linux command line attracts most Linux enthusiasts. A normal Linux user typically has about 50-60 commands to handle daily tasks. Linux commands and their transformations are the most valuable treasures for Linux users, Shell scripting programmers, and administrators. Some Linux commands are rarely known, but they are handy and useful, whether you're a novice or an advanced user.
1. sudo!! Command
Run without a specific input sudo command, an error with no permissions is given. Well, you don't need to rewrite the entire command, just type '!! ' You can grab the last command.
Copy Code code as follows:
$ apt-get Update
E:could not open lock File/var/lib/apt/lists/lock-open (13:permission denied)
E:unable to lock directory/var/lib/apt/lists/
E:could not open lock File/var/lib/dpkg/lock-open (13:permission denied)
E:unable to lock the Administration directory (/var/lib/dpkg/), are for you root?
Copy Code code as follows:
$ sudo!!
sudo apt-get update
[sudo] password for server:
...
..
Fetched 474 KB in 16s (28.0 kb/s)
Reading Package Lists ... Done
server@localhost:~$
2. Python command
The following command produces a simple Web page that displays the folder structure tree via HTTP, which can be accessed through the browser on port 8000 until the interrupt signal is issued.
Copy Code code as follows:
# python-m Simplehttpserver
3. MTR command
Most of us are familiar with Ping and traceroute. What about the MTR command to bring the two-order function into one? If MTR is not installed on your machine, apt or yum need the package.
Copy Code code as follows:
sudo apt-get install MTR (on Debian based Systems)
# yum Install MTR (on Red Hat based Systems)
Now run the MTR command to start viewing the MTR running host and google.com Direct network connection.
Copy Code code as follows:
3. MTR command
Most of us are familiar with Ping and traceroute. What about the MTR command to bring the two-order function into one? If MTR is not installed on your machine, apt or yum need the package.
Copy Code code as follows:
sudo apt-get install MTR (on Debian based Systems)
# yum Install MTR (on Red Hat based Systems)
Now run the MTR command to start viewing the MTR running host and google.com Direct network connection.
Copy Code code as follows:
4. Ctrl+x+e command
This command is useful for administrators and developers. To automate daily tasks, administrators need to open the editor by entering VI, VIM, nano, and so on.
By simply tapping the "ctrl-x-e" from the command line, you can start working in the editor.
5. NL command
The number of rows that the NL command added to the file. A file called ' One.txt ' whose contents are (Fedora, Debian, Arch, Slack, and SuSE), adding line numbers to each line. First, use the Cat command to display the contents of the "One.txt" file.
Copy Code code as follows:
# Cat One.txt
Fedora
Debian
Arch
Slack
Suse
Now run the NL command to display the line number in the way you want to add it.
Copy Code code as follows:
# NL One.txt
1 Fedora
2 Debian
3 Arch
4 slack
5 SuSE
6. Shuf command
The "shut" command randomly selects rows/files/folders from a file or folder. First, use the LS command to display the contents of the folder.
Copy Code code as follows:
# ls
Desktop Documents Downloads Music Pictures public Templates Videos
# ls | Shuf (Shuffle Input)
Music
Documents
Templates
Pictures
Public
Desktop
Downloads
Videos
# ls | SHUF-N1 (pick on random selection)
Public
# ls | Shuf-n1
Videos
# ls | Shuf-n1
Templates
# ls | Shuf-n1
Downloads
Note: You can replace ' N1 ' with ' N2 ' to output two random selections or use N3, N4, and other digital outputs for arbitrary random selections.
7. SS Command
"SS" represents the socket statistics. This command investigates the socket and displays information similar to the netstat command. It can display more TCP and state information than other tools.
Copy Code code as follows:
# SS
State Recv-q send-q The local address:port Peer address:port
Estab 0 0 192.168.1.198:41250 *.*.*.*:http
Close-wait 1 0 127.0.0.1:8000 127.0.0.1:41393
Estab 0 0 192.168.1.198:36239 *.*.*.*:http
Estab 310 0 127.0.0.1:8000 127.0.0.1:41384
Estab 0 0 192.168.1.198:41002 *.*.*.*:http
Estab 0 0 127.0.0.1:41384 127.0.0.1:8000
8. Last Order
The "Last" command displays historical information about the user who logged on to it. This command displays a list of users of Logged-in and Logged-out and their TTY ' s by searching for the file "/var/log/wtmp".
Copy Code code as follows:
# last
Server pts/0:0 Tue Oct 12:03 still logged in
Server tty8:0 Tue Oct 12:02 still logged in
...
...
(Unknown tty8:0 Tue Oct 22 12:02-12:02 (00:00)
Server pts/0:0 Tue Oct 22 10:33-12:02 (01:29)
Server tty7:0 Tue Oct 22 10:05-12:02 (01:56)
(Unknown tty7:0 Tue Oct 22 10:04-10:05 (00:00)
Reboot system boot 3.2.0-4-686-pae Tue Oct 22 10:04-12:44 (02:39)
Wtmp begins Fri Oct 4 14:43:17 2007
9. Curl Ifconfig.me
So how do you get your external IP address? Using Google? Then this command will output your external IP address at your terminal.
Copy Code code as follows:
Note: You may not follow the curl package, you need Apt/yum to follow the package.
Tree command
Gets the structure of the current folder in a tree format.
Copy Code code as follows:
# tree
.
|--Desktop
|--Documents
| '--37.odt
|--Downloads
| |--Attachments.zip
| |--Ttf-indic-fonts_0.5.11_all.deb
| |--Ttf-indic-fonts_1.1_all.deb
| '--wheezy-nv-install.sh
|--Music
|--Pictures
| |--screenshot from 2013-10-22 12:03:49.png
| '--screenshot from 2013-10-22 12:12:38.png
|--Public
|--Templates
'--Videos
directories, files
Pstree.
This command displays all currently running processes and their associated subprocess, and outputs a tree-like format that resembles the ' Trees ' command.
Copy Code code as follows:
# Pstree
Init─┬─networkmanager───{networkmanager}
├─accounts-daemon───{accounts-daemon}
├─acpi_fakekeyd
├─acpid
├─APACHE2───10*[APACHE2]
├─at-spi-bus-laun───2*[{at-spi-bus-laun}]
├─atd
├─avahi-daemon───avahi-daemon
├─bluetoothd
├─colord───{colord}
├─colord-sane───2*[{colord-sane}]
├─console-kit-dae───64*[{console-kit-dae}]
├─cron
├─cupsd
├─2*[dbus-daemon]
├─dbus-launch
├─dconf-service───2*[{dconf-service}]
├─dovecot─┬─anvil
│├─config
│└─log
├─exim4
├─gconfd-2
├─gdm3─┬─gdm-simple-slav─┬─xorg
││├─gdm-session-wor─┬─x-session-manag─┬─evolution-a+
││││├─gdu-notific+
││││├─gnome-scree+
││││├─gnome-setti+
││││├─gnome-shell+++
││││├─nm-applet──+++
││││├─ssh-agent
││││├─tracker-min+
││││├─tracker-sto+
││││└─3*[{x-sessi+
│││└─2*[{GDM-SESSION-WOR}]
││└─{gdm-simple-slav}
│└─{GDM3}
├─6*[getty]
├─GNOME-KEYRING-D───9*[{GNOME-KEYRING-D}]
├─gnome-shell-cal───2*[{gnome-shell-cal}]
├─goa-daemon───{goa-daemon}
├─gsd-printer───{gsd-printer}
├─gvfs-afc-volume───{gvfs-afc-volume}