20 commands that are very useful to new Linux users. Are you going to switch from Windows to Linux, or are you just switching to Linux? Alas !!! What am I talking about? Why are you in my world. From my past experience, I was shocked when I first started using Linux, commands, terminals, and so on. I am worried about how many commands I should remember to help me complete all the tasks. Without a doubt, online documents, books, man pages, and communities have helped me a lot, but I still firmly believe that there is an article that records how to learn and understand commands in a simple way. This inspires me to master Linux and make it easy to use. This article is the ladder to it. 1. The ls command is used to List Directory Contents (List Directory Contents. Running it is to list the content in the folder, which may be a file or a folder. 1root @ tecmint :~ # Ls2 3Android-Games Music4Pictures Public5Desktop Tecmint. com6Documents TecMint-Sync7Downloads Templates "ls-l" command lists the contents of folders in detail mode (long listing fashion. 01root @ tecmint :~ # Ls-l02 03 total ready 2 ravisaive 4096 May 8 0:06 Android Games05drwxr-xr-x 2 ravisaive 4096 May 15 Desktop06drwxr-xr-x 2 ravisaive 4096 May 16 Documents07drwxr-xr-x 6 ravisaive 4096 May 16 Downloads08drwxr-xr-x 2 ravisaive 4096 Apr 30 Music09drwxr-xr-x 2 ravisaive 4096 May 9 Pictures10drwxrwxr- X 5 ravisaive 4096 May 3 Tecmint. the com11drwxr-xr-x 2 ravisaive 4096 Apr 30 Templates "ls-a" command lists all the contents in the folder, including ". "hidden file. 01root @ tecmint :~ # Ls-a02 03 .. gnupg. invalid. goutputstream-PI5VVW. mission-control04.adobe deja-dup. grsync. mozilla. themes05.gstreamer-0.10. mtpaint. thumbnails. gtk-bookmarks. thunderbird06.HotShots. mysql_history. htaccess. apport-ignore.xml. ICEauthority 07. profile. bash_history. icons. bash_logout. fbmessenger08.jedit. pulse. bashrc. liferea_1.8. pulse-cookie 09. xauthority. gconf. local. xauthority. HGHVWW. ca Che10.gftp. macromedia. remmina. cinnamon. gimp-2.811.ssh. xsession-errors. compiz. gnome teamviewer_linux.deb 12. xsession-errors.old. config. gnome2. zoncolor note: in Linux, "begins with a hidden file, and each file, folder, device, or command is treated as a file. Ls-l command output: d (representing the directory). rwxr-xr-x is the permissions of the file or directory to the user, the same group of users and other users. In the above example, the first ravisaive represents that the file belongs to the user ravisaive. In the above example, the second ravisaive represents that the file belongs to the user group ravisaive4096, indicating that the file size is 4096 bytes. may 8 represents the last modification date and time of the file. the last step is the name of the file/folder 2. the lsblk command "lsblk" is used to list Block devices. In addition to RAM, Block devices are displayed neatly in the standard tree output format. 01root @ tecmint :~ # Lsblk02 03 name maj: min rm size ro type MOUNTPOINT04sda 0 232.9G 0 disk05 running-sda1 80 46.6G 0 part/06 running-sda2 2 0 1 K 0 part07 running-sda5 5 0 190 M 0 part/boot08 parts ── sda6 0 3.7G 0 part [SWAP] 09 %─ sda7 0 93.1G 0 part/data10 %─ sda8 8:8 0 89.2G 0 part/personal11sr0 1 the 1024 M 0 rom "lsblk-l" command displays Block devices in the List format (instead of in the tree format ). 01root @ tecmint :~ # Lsblk-l02 03 name maj: min rm size ro type MOUNTPOINT04sda 0 232.9G 0 disk05sda1 80 46.6G 0 part/06sda2 2 0 1 K 0 part07sda5 5 0 190 M 0 part/boot08sda6 6 0 3.7G 0 part [SWAP] 09sda7 0 93.1G 0 part/data10sda8 0 89.2G 0 part/personal11sr0 1 1024 M 0 rom note: lsblk is the most useful and easiest way to understand the names of newly inserted USB devices, especially when you process disks/Block devices on a terminal. 3. The md5sum command "md5sum" is used to calculate and verify the MD5 information signature. Md5 checksum (usually called hash) uses to match or verify the integrity of the file, because the file may change due to transmission errors, disk errors, or malicious interference. 1root @ tecmint :~ # Md5sum teamviewer_linux.deb2 347790ed345a7b7970fc1f2ac50c97002 teamviewer_linux.deb Note: users can use the signature information provided by the official and md5sum pairs to check whether the file has changed. Md5sum does not have sha1sum security, which we will discuss later. 4. the dd command "dd" represents the conversion and copying of files. It can be used to convert and copy files. Most of the time it is used to copy iso files (or any other files) to a usb device (or any other place), so it can be used to create a USB initiator. 1root @ tecmint :~ # Dd if =/home/user/Downloads/debian. iso of =/dev/sdb1 bs = 512 M; sync note: In the above example, the usb device is sdb1 (you should verify it using the lsblk command, otherwise, you will overwrite your disk or system). Please use the disk name with caution. The dd command consumes several seconds to several minutes according to the file size and type, as well as the read/write speed of the usb device. 5. The uname command "uname" is short for Unix Name. Displays the machine name, operating system, and kernel details. 1root @ tecmint :~ # Uname-a2 3 Linux tecmint 3.8.0-19-generic # 30-Ubuntu SMP Wed May 1 16:36:13 UTC 2013 i686 i686 i686 GNU/Linux Note: uname displays the kernel category, uname-a displays details. The above output details the uname-a "Linux": the kernel name of the machine "tecmint": the node name of the machine "3.8.0-19-generic": kernel version "# 30-Ubuntu SMP": kernel version "i686": processor architecture "GNU/Linux": Operating System name 6. the history command "history" is a historical record. It shows the history of all commands executed in the terminal. 01root @ tecmint :~ # History02 03 1 sudo add-apt-repository ppa: tualatrix/ppa04 2 sudo apt-get update05 3 sudo apt-get install ubuntu-tweak06 4 sudo add-apt-repository ppa: diesch/testing07 5 sudo apt-get update08 6 sudo apt-get install indicator-privacy09 7 sudo add-apt-repository ppa: atareao/atareao10 8 sudo apt-get update11 9 sudo apt-get install my-weather-indicator12 10 pwd13 11 cd & sudo cp-r unity/6/usr/shar E/unity/14 12 cd/usr/share/unity/icons/15 13 cd/usr/share/unity note: press CTRL + R to search for commands that have been executed. It can be automatically completed when you write commands. 1 (reverse-I-search) 'if': ifconfig 7. sudo command "sudo" (super user do) command allows authorized users to execute commands of super users or other users. You can specify the security policy in the sudoers list. 1root @ tecmint :~ # Sudo add-apt-repository ppa: tualatrix/ppa Note: sudo allows users to borrow superuser permissions. However, the "su" Command actually allows users to log on as superusers. Therefore, sudo is safer than su. We do not recommend that you use sudo or su To handle routine usage, because it may cause serious errors. If you accidentally do something wrong, this is why the linux community has a popular saying: "To err is human, but to really foul up everything, you need root password. "" No one can do anything, but it's really impossible to have a root password." # Translate 8. Run the mkdir command "mkdir" (Make directory) to create a new directory under the named path. However, if the directory already exists, it will return an error message "folder cannot be created, folder already exists" ("cannot create folder, folder already exists") 1root @ tecmint: ~ # Mkdir tecmint Note: A directory can only be created in a directory with write permission. Mkdir: you cannot create the 'cmint' directory because the file already exists. (Do not be confused by files in the above output. Remember what I said at the beginning-in linux, files, folders, drivers, commands, and scripts are regarded as files.) 9. the touch command "touch" indicates updating the file access and modification time to the current time. The touch command creates a file only when the file does not exist. If the file already exists, it updates the timestamp but does not change the file content. 1root @ tecmint :~ # Touch tecmintfile Note: touch can be used to create a non-existent file in a directory with write permission. 10. the chmod command "chmod" is to change the mode bit of the file. Chmod changes the file mode (permission) of each given file, folder, script, and so on according to the required mode ). In a file (folder or other, for simplicity, we will use the file), there are 3 types of permissions 1 Read (r) = 42 Write (w) = 23 Execute (x) = 1. If you want to grant the File Read-Only permission, set it to '4'; write-only permission, set the permission to '2'; execute-only permission, set it to 1; read-write permission, 4 + 2 = 6, and so on. Now you need to set three types of user and user group permissions. The first is the owner, the group where the user is located, and the last is other users. 1rwxr-x -- x abc. sh here, the root permission is rwx (read/write and execution permissions), and the user group permission is r-x (only read and execution permissions, no write permissions ), other user permissions are-x (only the execution permission). In order to change its permissions, read, write, and execute permissions are provided for the owner, user group, and other users. 1root @ tecmint :~ # Chmod 777 abc. sh only has the read and write permissions 1root @ tecmint :~ # The chmod 666 abc. sh owner has the read and write permissions. the user's group and other users only have the executable permissions 1root @ tecmint :~ # Chmod 711 abc. sh note: this command is one of the most useful commands for System Administrators and Users. For a user in a multi-user environment or server, if the file is set to inaccessible, this command can be solved. If the wrong permission is set, therefore, authorized access is provided. 11. The chown command "chown" is to change the file owner and user group. Each file belongs to one user group and one user. Using "ls-l" in your directory, you will see something like this. 1root @ tecmint :~ # Ls-l2 3drwxr-xr-x 3 server root 4096 May 10 Binary4drwxr-xr-x 2 server 4096 May 13 Desktop here, directory Binary belongs to user "server", and user group "root ", the directory "Desktop" belongs to the user "server" and user group "server" and "chown" commands, which are used to change the ownership of files. Therefore, it is only used to manage and provide file users and user group authorization. 1root @ tecmint :~ # Chown server: server Binary2 3drwxr-xr-x 3 server 4096 May 10 Binary4drwxr-xr-x 2 server 4096 May 13 Desktop note: the file "chown" changes the ownership of users and groups to the new owner or existing users or user groups. 12. The apt command Debian series is based on the "apt" command, and "apt" represents the Advanced Package Tool. APT is an advanced Package Manager developed for Debian systems (Ubuntu, Kubuntu, and so on). On Gnu/Linux systems, APT automatically and intelligently searches and installs packages, upgrade and resolve dependencies. 01root @ tecmint :~ # Apt-get install mplayer02 03 Reading package lists... done04Building dependency tree 05 Reading state information... done06The following package was automatically installed and is no longer required: 07 java-wrappers08Use 'apt-get autoremove 'to remove it.09The following extra packages will be installed: 10 esound-common libaudiofile1 libesd0 libopenal-data libopenal1 libsvga1 libvdpau1 libxvidcore41 1 Suggested packages: 12 pulseaudio-esound-compat libroar-compat2 nvidia-vdpau-driver mplayer-doc netselect fping13The following NEW packages will be installed: 14 esound-common listen libesd0 libopenal-data libopenal1 libsvga1 unzip into mplayer150 upgraded, 9 newly installed, 0 to remove and 8 not authorized to get 3,567 kB of archives.17After this operation, 7, 772 kB of additional disk space will be used.18Do you want to continue [Y/n]? Y01root @ tecmint :~ # Apt-get update0203hit http://ppa.launchpad.net raring Release. gpg 04Hit http://ppa.launchpad.net raring Release. gpg 05Hit http://ppa.launchpad.net raring Release. gpg 06Hit http://ppa.launchpad.net raring Release. gpg 07Get: 1 http://security.ubuntu.com raring-security Release. gpg [933 B] 08Hit http://in.archive.ubuntu.com raring Release. gpg 09Hit http://ppa.launchpad.net raring Release. gpg 10Get: 2 Http://security.ubuntu.com raring-security Release [40.8 kB] 11Ign http://ppa.launchpad.net raring Release. gpg 12Get: 3 http://in.archive.ubuntu.com raring-updates Release. gpg [933 B] 13Hit http://ppa.launchpad.net raring Release. gpg 14Hit http://in.archive.ubuntu.com raring-backports Release. gpg Note: The above command will change the overall system, so the root password is required (check the prompt as "#" instead of "$ "). apt is more advanced and intelligent than yum commands. As you can see, apt-cache is used to search for whether the package contains the sub-package mplayer. apt-get is used to install and upgrade all installed packages to the latest version. 13. The tar command "tar" is a Tape Archive, which is useful for archiving and extracting some files. 1root @ tecmint :~ # Tar-zxvf abc.tar.gz ('z' represents .tar.gz) 1root @ tecmint :~ # Tar-jxvf abc.tar.bz2 ('j' represents .tar.bz2) 1root @ tecmint :~ # Tar-cvf archieve.tar.gz(.bz2)/path/to/folder/abc note: "tar.gz" indicates the use of gziparchive. When bar.bz2 is compressed with bzip, the compression is better but slower. 14. The cal command "cal" (Calender) is used to display the current month or the month in the future or any past year. 1root @ tecmint :~ # Cal2 3May 2013 4Su Mo Tu We Th Fr Sa 5 1 2 3 4 6 5 6 6 7 8 9 10 11 712 13 14 15 16 17 18 819 20 21 22 23 24 25 926 27 28 29 30 31 show the past month, february 1, 1835 root @ tecmint :~ # Cal 02 18352 3 February 1835 4Su Mo Tu We Th Fr Sa 5 1 2 3 4 5 6 7 6 8 9 10 12 13 14 715 16 17 19 20 21 822 23 24 25 26 27 28 show the months to come, may July 2145. 1root @ tecmint :~ # Cal 07 21452 3 July 2145 4Su Mo Tu We Th Fr Sa 5 1 2 3 6 4 5 6 7 8 9 10 711 12 13 14 15 16 17 818 19 20 21 22 23 24 925 26 27 28 29 30 31 Note: you do not need to adjust the calendar for 50 years. You do not need to calculate the date of birth or the date of your birthday. [because the minimum unit is month, instead of day]. 15. The date command "date" uses standard output to print the current date and time. You can also set it in depth. 1root @ tecmint :~ # Date2 3Fri May 17 14:13:29 IST 20131root @ tecmint :~ # Date -- set = '14 may 2013 13:57:00 '2 3Mon May 13 IST 2013 note: this command is very useful in scripts and time-and date-based scripts are more perfect. In addition, changing the date and time in the terminal makes you more professional !!! (Of course, you need the root permission to perform this operation, because it is an overall system change) 16. the cat command "cat" represents the Concatenation, connecting two or more text files, or printing the content of the file in the form of standard output. 1root @ tecmint :~ # Cat a.txt B .txt c.txt d.txt abcd.txt 1root @ tecmint :~ # Cat abcd.txt 2... 3 contents of file abcd4... note: ">>" and"> "Call the append symbol. They are used to append to files, rather than display on standard output. The ">" symbol deletes an existing file and creates a new file. For security reasons, we recommend that you use ">", which is written into the file rather than overwritten or deleted. Before in-depth exploration, I must let you know the wildcard (you should know the wildcard, which appears in most TV shows ). Wildcard is a special character of shell. It makes the command line more powerful than any GUI file manager! As you can see, in a graphics file manager, you usually have to use your mouse to select a large group of files. This may be simple, but in fact, this situation is frustrating! For example, if you have a directory with many types of files and subdirectories, then you decide to move the HTML files containing the "Linux" in all file names to another directory. How to simply complete this? If the directory contains a large number of HTML files with different names, your task is huge, not simple. In LInux CLI, this task is very simple. It is like moving only one HTML file, because it is so simple with shell wildcards. These are special characters that allow you to select a file name that matches a certain character pattern. It helps you to select, even if a large number of file names contain only a few characters, and in most cases, it is easier than selecting a file with the mouse. Here is the list of common Wildcard characters: 1 Wildcard Matches2 * zero or more characters 3? Exactly one character 4 [abcde] Exactly lists one character 5 [a-e] Exactly one character 6 in the given range [! Abcde] No character is listed. 7 [! A-e] No character is in the given range. 8 {debian, linux} is exactly the whole word in the given option! It is not, taobao '! 'Reverse string is true. For more information, see instance 13 of the Linux cat command instance 17. cp command "copy" in Linux. It copies a file from one place to another. 1root @ tecmint :~ # Cp/home/user/Downloads abc.tar.gz/home/user/Desktop (Return 0 when sucess) Note: cp is the most common command in shell scripts, in addition, it can use wildcards (described in the previous section) to customize the copy of the desired file. 18. The mv command "mv" is used to move files from one place to another. 1root @ tecmint :~ # Mv/home/user/Downloads abc.tar.gz/home/user/Desktop (Return 0 when sucess) Note: wildcards can be used for mv commands. Mv should be used with caution because mobile system or unauthorized files will not only cause security problems, but also may cause system crash. 19. The pwd command "pwd" (print working directory) shows the full path of the current working directory on the terminal. 1root @ tecmint :~ # Pwd2 3/home/user/Desktop Note: This command is not frequently used in scripts, but for beginners, the path is lost in the terminal after being connected to nux for a long time, this is definitely a lifeline. 20. At the end of the cd command, the frequently used "cd" command represents Directory change. It changes the working directory in the terminal to execute, copy, move, read, write, and so on. 1root @ tecmint :~ # Cd/home/user/login top1server @ localhost :~ $ Pwd2 3/home/user/Desktop Note: When you switch the directory on the terminal, cd will show up. "Cd ~" It will change the working directory to the user's home directory, and it is very useful when the user finds that he has lost the path in the terminal. "Cd .." is switched from the current working directory to the parent directory (the current working directory.