Linux Command lines attract most Linux enthusiasts. A normal Linux User generally has about 50-60 commands to process daily tasks. Linux commands and their conversion are the most valuable treasures for Linux users, Shell script programmers, and administrators. Some Linux commands are rarely known, but they are very convenient and useful whether you are a beginner or an advanced user.
Linux commands that few people know
The purpose of this article is to introduce some Linux commands that are rarely known. They will help you efficiently manage your desktop/server.
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.
$ apt-get updateE: 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 you root?$ sudo !!sudoapt-get update[sudo] password forserver:…..Fetched 474 kB in16s (28.0 kB/s)Reading package lists... Doneserver@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.
# 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.
$ 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.
# Mtr google.com
Mtr command
4. Ctrl + x + e command
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.
# cat one.txtfedoradebianarchslacksuse
Run the "nl command" to display it by adding a row number.
# nl one.txt 1 fedora2 debian3 arch4 slack5 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.
# lsDesktop Documents Downloads Music Pictures Public Templates Videos# ls | shuf (shuffle Input)MusicDocumentsTemplatesPicturesPublicDesktopDownloadsVideos# ls | shuf -n1 (pick on random selection)Public# ls | shuf -n1Videos# ls | shuf -n1Templates# ls | shuf -n1Downloads
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.
# ssState 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 127.0.0.1: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.
# lastserver pts/0 :0 Tue Oct 22 12:03 still logged in server tty8 :0 Tue Oct 22 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
How can I get your external IP address? Google? Then, this command outputs your external IP address on your terminal.
# 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.
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.
So far. In the next article, I will introduce some interesting Linux commands that few others know about. At that time, connect to Tecmint to keep watching. Like and share will help us spread.