1. sudo !! Command
If you run the command without a specific sudo command, an error is returned. Then, you don't need to rewrite the entire command, just enter '!! 'To capture the final command.
The Code is as follows:
$ Apt-get update
E: cocould not open lock file/var/lib/apt/lists/lock-open (13: Permission denied)
E: Unable to lock directory/var/lib/apt/lists/
E: cocould not open lock file/var/lib/dpkg/lock-open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
The Code is as follows:
$ Sudo !!
Sudo apt-get update
[Sudo] password for server:
...
..
Fetched 474 kB in 16 s (28.0 kB/s)
Reading package lists... Done
Server @ localhost :~ $
2. python commands
The following command produces a simple webpage that displays the folder structure tree through HTTP. It can be accessed through a browser on port 8000 until an interruption signal is sent.
The Code is as follows:
# Python-m SimpleHTTPServer
3. mtr command
Most of us are familiar with ping and traceroute. The mtr command combines the functions of the two commands. If mtr is not installed on your machine, the packages required by apt or yum.
The Code is 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 check the direct network connection between the host running the mtr and google.com.
The Code is as follows:
# Mtr google.com
3. mtr command
Most of us are familiar with ping and traceroute. The mtr command combines the functions of the two commands. If mtr is not installed on your machine, the packages required by apt or yum.
The Code is 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 check the direct network connection between the host running the mtr and google.com.
The Code is as follows: www.jbxue.com
# Mtr google.com
This command is very useful for administrators and developers. To automate daily tasks, the administrator needs to open the editor by entering vi, vim, nano, and so on.
Just press Ctrl-x-e from the command line to start working in the editor.
5. nl command
"Nl command" to add the number of lines to the file. A file named 'one.txt '. The content of each line is (Fedora, Debian, Arch, Slack, and Suse), and the row number is added to each line. First, use the catcommand to display the file content of mongoone.txt.
The Code is as follows:
# Cat one.txt
Fedora
Debian
Arch
Slack
Suse
Run the "nl command" to display it by adding a row number.
The Code is as follows:
# Nl one.txt
1 fedora
2 debian
3 arch
4 slack
5 suse
6. shuf command
The "Shut" command randomly selects lines/files/folders from a file or folder. First, use the ls command to display the folder content.
The Code is 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 www.jbxue.com
# Ls | shuf-n1
Videos
# Ls | shuf-n1
Templates
# Ls | shuf-n1
Downloads
Note: You can replace 'n1 'with 'n2' to output two random options or use numbers such as n3 and n4 to output other random options.
7. ss Command
"Ss" indicates socket statistics. This command investigates the socket and displays information similar to the netstat command. It can display more TCP and status information than other tools.
The Code is as follows:
# Ss
State Recv-Q Send-Q 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 FIG: 8000
8. last Command
The "last" command displays the historical information of the last logged-on user. This command searches for the file "/var/log/wtmp" to display the user list of logged-in, logged-out, and its tty's.
The Code is as follows:
# Last
Server pts/0: 0 Tue Oct 22 12:03 still logged in
Server tty8: 0 Tue Oct 22 :02 still logged in
...
...
(Unknown tty8: 0 Tue Oct 22)
Server pts/0: 0 Tue Oct 22)
Server tty7: 0 Tue Oct 22)
(Unknown tty7: 0 Tue Oct 22)
Reboot system boot 3.2.0-4-686-pae Tue Oct 22)
Wtmp begins Fri Oct 4 14:43:17 2007
9. curl ifconfig. me
How can I get your external IP address? Google? Then, this command outputs your external IP address on your terminal.
The Code is as follows:
# Curl ifconfig. me
Note: You may not follow the curl package. You need apt/yum to follow the package.
10. tree Command
Get the structure of the current folder in tree format.
The Code is 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 12:03:49. png
| '-- Screenshot from 12:12:38. png
| -- Public
| -- Templates
'-- Videos
10 directories, 23 files
11. pstree
This command displays all processes currently running and their associated sub-processes. The output is in a tree format similar to the 'tree' command.
The Code is 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
─ ── Rjthd
├ ── Colord ── {colord}
├ ── Colord-sane ── 2 * [{colord-sane}]
├ ── Console-kit-dae ── 64 * [{console-kit-dae}]
├ ── Cron
├ ── Cupsd
Example-2 * [Example-daemon]
├ ── Launch-launch
├ ── Dconf-service ── 2 * [{dconf-service}]
├ ── Dovecot-┬ ── andevil
│ ├ ── Config
│ Mongo── log
─ ── Exim4
├-Gconfd-2
├ ── Gdm3 ── gestation ─ simple-slav ── Xorg
│ Skip-TPD-session-wor-Skip-x-session-manag-Skip-evolution-a +
│ ─ ── Gdu-notific +
│ ── Gnome-scree +
│ ─ ── Gnome-setti +
│ ├-Gnome-shell ++
│ ├ ── Nm-applet ─+++
│ ─ ── Ssh-agent
│ ─ ── Tracker-min +
│ ─ ── Tracker-sto +
│ Sampled-3 * [{x-sessi +
│ Sampled-2 * [{TPD-session-wor}]
│ ─ ── {TPD-simple-slav}
│ ─ ── {Gdm3}
Capacity-6 * [getty]
─ ── Gnome-keyring-d ── 9 * [{gnome-keyring-d}]
─ ── Gnome-shell-cal ── 2 * [{gnome-shell-cal}]
Inclu── goa-daemon ── {goa-daemon}
├ ── Gsd-printer ── {gsd-printer}
├ ── Gvfs-afc-volume ── {gvfs-afc-volume}