11 Linux commands that are rarely known but useful

Source: Internet
Author: User
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

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

No specific inputSudo commandRunning will give an error with no permission. Then, you do not 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 !!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 commands

The following command produces a simple web page that displays the folder structure tree through HTTP.8000Access until the interruption signal is sent.

# python -m SimpleHTTPServer

3. mtr command

Most of us are familiarPingAndTraceroute. Then, the functions of the two commands are combined into one.Mtr commandAnd. IfMtrNot installed on your host,AptOrYumThe required package.

$ 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 inputVi,Vim,NanoOpen the editor.

Just press Ctrl-x-e from the command line to start working in the editor.

5. nl command

"Nl command"Number of lines added to the file. One is called'One.txt', The content of each line is (Fedora,Debian,Arch,SlackAndSuse) To add a row number to each row. First, use the cat command to display"One.txt.

# cat one.txt fedora debian arch slack suse

Run the "nl command" to display it by adding a row number.

# nl one.txt 1 fedora 2 debian 3 arch 4 slack 5 suse
6. shuf command

The "Shut" command is random fromFileOrFolderSelectRows/files/folders. First, use the ls command to display the folder content.

# 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 set'N1'Replace'N2'To output two random selections or useN3,N4And other random outputs.

7. ss command

"SsSocket statistics. This command investigates the socket and displays information similar to the netstat command. It can display moreTCPAnd status information.

# 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            127.0.0.1:8000
8. last Command

"Last"Command displays the historical information of the last logged-on user. This command is used to search for the file"/Var/log/wtmp", DisplayLogged-InAndLogged-outAndTty'sUser list.

#  last server   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

So how to get yourExternal IP addressWhat about it? Google? Then, this command outputs your external IP address on your terminal.

# curl ifconfig.me

Note:: You may not follow the curl package, you needApt/yumAccording to the package.

10. tree command

Get the structure of the current folder in tree format.

# 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 10 directories, 23 files
11. pstree

This command shows all processes currently running and their associated sub-processes. the output is similar'Tree'Command tree format.

# 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}

So far. In the next article, I will introduce some interesting Linux commands that few others know about. ConnectTecmintKeep watching. Like and Share will help us spread.

Address: http://www.tecmint.com/11-lesser-known-useful-linux-commands/

, Ten little-known Linux commands (3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.