Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Basic Tutorial: Linux novice should know 26 commands     - CentOS installation Docker series (Linux)

- Let Mac OS X dedicated high-speed mobile hard disk can also be read in Linux (Linux)

- Linux Command Tutorial: Ubuntu apt-get command (Linux)

- Oracle Database ORA-01555 snapshot too old (Database)

- How to use SVN to manage our source code (Server)

- Python2.7.7 source code analysis (Programming)

- Linux kernel panic (because glibc result) Repair (Linux)

- Fedora 20 Installation and Configuration (Linux)

- Use LKM change the default linux security level (Linux)

- The Linux-based security settings Ipchains Firewall (Linux)

- Ubuntu installed Komodo editor by PPA (Linux)

- Oracle TDE transparent data encryption (Database)

- Git Experience Sharing - Using a remote repository (Linux)

- Linux compiler of GCC (Linux)

- Additional SQL Server 5123 database reported error (Database)

- Transfer files and permissions from Windows to Linux system by Samba (Linux)

- Oracle 12C RAC optimizer_adaptive_features cause of data into overtime (Database)

- Differences Shell scripting languages and compiled languages (Programming)

- Virt Related Command Summary (Linux)

- Spark parquet merge metadata problem (Server)

  Basic Tutorial: Linux novice should know 26 commands
  Add Date : 2017-01-08      
  When you enter the world of Linux, download, install a Linux distribution, the Linux desktop experience and installed something you love and need software after Linux should get to know the real charm: the command line. Each Linux command is actually a program, with the help of these commands, we can do a lot of things. The following will tell you about a few commonly used commands.

How to get help?

Problems encountered in Linux, the most important thing is to seek help themselves, here are three methods to seek help.


Linux is a man with the help of the manual, that manual. Since most programs will bring their own manual, so you can get help through the man command. After the execution, the man page page press q to quit.

Get help for ls

$ Man ls
See how many (different aspects) of the same name has manual

$ Man -f ls
ls (1) - list directory contents
ls (1p) - list directory contents
See specific manual

$ Man 1p ls

The difference is that the man can jump like browsing web pages in each node.

Start browsing from Docs

$ Info
Get help on a specific program

$ Info program

In addition to the above two methods, there is a simple method to use, that is --help parameters, the general procedure will have this parameter, the output will be the simplest useful introduction.

$ Man --help ### for help of man
Get info $ info --help ### help
$ Ls --help ### to get help for ls
How simple?

Terminal (Terminal), the many operating skills, here are a few simple.


up (arrow keys) Enter the execution history can be retrieved quickly execute commands
down (down arrow keys) with up to select execution history
Home to move the cursor to the beginning of the line
End Move the cursor to the end of the Bank
PgUp Page Up
PaDN Down
ctrl + c to terminate the current program
Tab completion

Tab completion is a very useful function that can be used to automatically complete the command or file name, saving time and accurate.

Even without entering the state press Tab twice to list all available commands
Has entered part of the command name or file name, press the Tab automatic completion, you will surely be used more like a.
Common Commands

The following commands are arranged in accordance with the usual frequency of use.


cd command is to open a path, that is, open a folder, and jump to the premises.

$ Cd path ### path is the path you want to open.
Which path has the absolute and relative paths of the points, to emphasize the absolute path from /, has been host to the path. Relative paths are relative to the current path, it is assumed that the current home directory etc folder (absolute path would be / home / username / etc), if you enter the direct cd etc folder, but if it is cd / etc / is entered system etc, pondering what can be understood. Also in Linux, the representative of the current directory, .. on behalf of parent directory, so you can return to the parent directory cd ...


ls That list, list the files.

$ Ls ### list only visible files in the current directory
Current directory, see file details $ ls -l ### listed
$ Ls -hl ### lists detailed information in a readable size displays the file size
For more information $ ls -al ### lists all files (including hidden)
Note: Linux to the beginning of the file or folder are hidden files or hidden folders.


pwd used to return the name of the current working directory, an absolute path name.

$ Pwd
/ Home

mkdir to create a new folder.

$ Mkdir folder
$ Mkdir -p folder / subfolder ### -p parameter is ignored when the parent directory exists, if the presence is established, use this parameter to establish a multi-level folder

rm ie remove, delete files.

$ Rm filename ### Delete filename
$ Rm -i filename ### before deleting the filename prompt, prompt if more than one file every time
Under $ rm -rf folder / subfolder / ### subfolder recursively delete all files and folders, including the subfolder itself
$ Rm -d folder ### delete empty folders

cp That copy, copy files.

$ Cp source dest ### to copy source to dest
$ Cp folder / * dest ### to all the files under the folder (without subfolders in the folder) is copied to dest
$ Cp -r folder dest ### folder and all the files (including sub-folders all files) copied to dest

mv That move, move files.

$ Mv source folder ### will move to the next source folder, was completed folder / source
$ Mv -i source folder ### while moving, if the file already exists you are prompted whether to overwrite ** **
$ Mv source dest ### at dest directory is not the premise, to rename the source dest

cat used to output the file contents to the Terminal.

Content $ cat /etc/locale.gen ### of output locale.gen
Output $ cat -n /etc/locale.gen ### locale.gen and display line numbers

and more similar to cat, you can view the contents of the file, the difference is that when a document is too long, cat only show the last full contents of the screen, in front of the content is not visible. This time can be used more progressive display.

$ More /etc/locale.gen
$ More + 100 / etc / locale.gen ### from 100 lines began to show

less and more similar, but less support to scroll content, and more only support progressive display.

$ Less /etc/locale.gen
$ Less + 100 / etc / locale.gen


nano is a simple and practical text editor, simple to use.

$ Nano filename ### edit filename file, if the file does not exist, a new open file, save if the exit, the file is created
After editing, ctrl + X prompted to save, press y OK to save.

Note: Available ctrl + G to get help during use.


reboot command to restart.

# Reboot ### '$' and '#' difference is that the '$' ordinary users can perform
### And '#' before execution for the root user, or ordinary users to use 'sudo'

poweroff for the shutdown command.

# Poweroff ### immediately shut down


ping is mainly used to test network connectivity by sending a packet to the target machine to test whether the two hosts communicating, and delay the case.

$ Ping locez.com ### ping the domain name, if DNS is not set up, you may not ping
$ Ping linux.cn
PING linux.cn ( 56 (84) bytes of data.
64 bytes from211.157.2.94.static.in-addr.arpa ( icmp_seq = 1 ttl = 53 time = 41.5 ms
64 bytes from211.157.2.94.static.in-addr.arpa ( icmp_seq = 2 ttl = 53 time = 40.4 ms
64 bytes from211.157.2.94.static.in-addr.arpa ( icmp_seq = 3 ttl = 53 time = 41.9 ms
^ C
--- Linux.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min / avg / max / mdev = 40.406 / 41.287 / 41.931 / 0.644 ms
$ Ping ### through the IP address ping, if you can not ping may be network connectivity issues

grep is mainly used for matching item is returned, it supports regular expressions.

$ Grep PATTERN filename ### returns all rows containing PATTERN
$ Grep zh_CN /etc/locale.gen ### returns all rows containing zh_CN

mount is used to mount a file system, you need root user to perform. A disk can be divided into several partitions, you can create a file system on top of the partition, and a mount point is to provide access to the entrance, a partition file system is mounted to a directory, the directory is called the mount point and you can access the content through the file system mount point.

For example, a hard disk expressed in Linux as / dev / sda then the partition above it should be expressed as / dev / sda1, / dev / sda2.

# Mount ### outputs the current system mount information
# Mount / dev / sda1 / mnt ### will sda1 on / mnt in
# Cd / mnt ### directly through the / mnt to access the content
# Mount -o remount, rw / mnt ### remounted sda1 to / mnt and set to read-write
# Mount -a ### configured to mount the file system fstab file

umount and moung the contrary, it is to uninstall a mount point, that the abolition of the entrance.

# Umount / mnt ### uninstall / mnt mount point of the file system
# Umount -a ### unmount all mounted file systems

tar is mainly used to create the archive file, and unzip the archive, which itself is no compression, but you can call gzip, bzip2 compressed.
Parameter explanation:

-c to create an archive
-x-extracting archive
-v display processing procedure
-f target file, the target file must be subsequently followed
-j call bzip2 to decompress
-z call gzip to decompress
-t lists the files in the archive
$ Tar -cvf filename.tar. ### The current directory of all filing, but does not compress, watch behind a '.', It can not be omitted, on behalf of the meaning of the current directory
$ Tar -xvf filename.tar ### unzip filename.tar to the current folder
$ Tar -cvjf filename.tar.bz2. ### Compressed with bzip2
$ Tar -xvjf filename.tar.bz2 ### unzip filename.tar.bz2 to the current folder
$ Tar -cvzf filename.tar.gz ### compressed with gzip
$ Tar -xvzf filename.tar.gz ### unzip filename.tar.gz to the current folder
$ Tar -tf filename ### to see only the filename files in the archive without extracting

ln primarily used to create a link in two files, the link is divided into Hard Links (hard link) and Symbolic Links (symbolic link or soft link), which defaults to create a hard link, use the -s parameter to specify create a soft link.

Hard link is to increase the number of links to a file, as long as the number of links to the file is not 0, the file will not be physically removed, so delete more than one file with hard links, you must remove all of its hard links only be deleted.
Simple soft link is created for the file something like a shortcut, you can access files, modify the file through the link, but will not increase the number of links to the file, delete a soft link does not delete the source files, even if the source files are deleted, soft links also exist when re-creating the source file of the same name, the soft link points to the newly created file.
Hard link can only link two files can not link directories, soft links can link directory, so soft link is very flexible.
$ Ln source dest ### to create a hard link named dest to source
$ Ln -s source dest ### to create a soft link named dest to source

chown for changing a file's owner and the group is located.

# Chown user filename ### for the user to change the filename of the owner
# Chown user: group filename ### to change the filename of the owner of user, group, group
# Chown -R root folder ### to change the owner of folders and subfolders folder is root

chmod never changes the permissions of a file, there are read, write, execute, three permission, which the owner, the user group, the other three each, thus ls -l can see the following information

-rwxr - r - 1 locez users 154Aug3018: 09 filename
Where r = read, w = write, x = execute

# Chmod + x filename ### add execute permissions for user, group, others
# Chmod -x filename ### canceled execute permissions user, group, others of
# Chmod + w filename ### add write permissions for the user
# Chmod ugo = rwx filename ### set user, group, others have read, write, execute permissions
# Chmod ug = rw filename ### set user, group add read, write permissions
# Chmod ugo = --- filename ### cancel all privileges

useradd is used to add a normal user.

# Useradd -m -g users -G audio -s / usr / bin / bash newuser
### -m Create home directories, main group belongs -g, -G specified additional user group which, -s set the default shell, newuser new username

passwd is used to change the user password.

$ Passwd ### without parameters, change the current user password
User password # passwd newuser ### to change the above-mentioned new newuser

whereis for finding documents, manuals, etc.

$ Whereis bash
bash: / usr / bin / bash /etc/bash.bashrc /etc/bash.bash_logout /usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz
$ Whereis -b bash ### only to find binary
bash: / usr / bin / bash /etc/bash.bashrc /etc/bash.bash_logout
$ Whereis -m bash ### only to find manual
bash: /usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz

find also used to find files, but more powerful, support for regular, and search results can be passed to other commands.

$ Find.-Name PATTERN ### PATTERN find qualified file from the current directory
$ Find / home -name PATTERN -exec ls -l {} \; # Find / home file PATTERN all matching files and output by the ls details

wget is a download tool, simple and powerful.

$ Wget -O newname.md https://github.com/LCTT/TranslateProject/blob/master/README.md ### download README file and rename it to newname.md
$ Wget -c url ### url download and open HTTP
- Emacs install clojure development environment (Linux)
- Linux operation and maintenance of the actual file system, file links (Linux)
- Yii PHP Framework Getting Started tutorial (Linux)
- Install VLC player on Ubuntu 14.10 (Linux)
- Linux operating system Study Notes (Linux)
- MySQL performance view and configure finishing Daquan (Database)
- Sturdy build secure Linux server (Linux)
- After Ubuntu Password Forgot your way back (Linux)
- Depth understanding of Python character set encoding (Programming)
- Linux shell in back quotes (`) Application (Linux)
- To install Docker under Ubuntu 15.04 (Linux)
- Linux Command - ps: a snapshot of the current process (Linux)
- Oracle user lock how to know what causes (Database)
- Modify MySQL character encoding under Linux (Database)
- Win7 + Ubuntu Kylin + CentOS 6.5 installed three systems (Linux)
- Linux RAID Set RAID 10 or 0 + 1 (Linux)
- Talking about the shortcomings and deficiencies of the firewall (Linux)
- Ubuntu UFW firewall settings Introduction (Linux)
- Linux prohibit non-WHEEL user su command Detail (Linux)
- About redis in Replication (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.