Linux most commonly used commands

Source: Internet
Author: User

As a tester we do not need to be like operations engineers, database administrators, network engineers, such as the operating system, database, network and so deep understanding, but the common basic operations must be understood.    Here is the first summary of the common Linux operating system under the operation and commands. First, the common tools to connect the Linux operating system are: SecureCRT, mobaxterm, Xmanager, Common command 1, cd command This is a very basic, but also you often need to use the command, it is used to switch the current directory, its parameters are to switch to the directory path, can be an absolute path or a relative path. Such as: [Plain]View Plaincopy print?
    1. Cd/root/docements # Switch to directory/root/docements
    2. cd./path # Switch to the path directory in the current directory, "." Represents the current directory
    3. Cd.. /PATH # Switch to the path directory in the upper directory, "..." Represents a previous level of directory
2, ls command This is a very useful view of the file and directory commands, list of the meaning, it has a lot of parameters, the following list some of my usual parameters, as follows: [Plain]View Plaincopy print?
    1. -L: Lists Long data strings, including file attributes and permission data, etc.
    2. -A: Lists all the files, together with hidden files (files that begin with.) (common)
    3. -D: Lists only the directory itself, not the file data for the directory
    4. -H: List the file capacity in a more readable way (GB,KB, etc.)
    5. -R: Listed along with the contents of the subdirectory (recursively listed), equal to all files in that directory will be displayed
Note: These parameters can also be used in combination, the following two examples: [Plain]View Plaincopy print?
    1. Ls-l #以长数据串的形式列出当前目录下的数据文件和目录, can be shortened to LL
    2. LS-LR #以长数据串的形式列出当前目录下的所有文件
3. mkdir command to create a folder
    1. mkdir dir1 Create a directory called ' Dir1 '
    2. mkdir dir1 DIR2 Create two directories at a time
    3. Mkdir-p/tmp/dir1/dir2 Create a directory tree
4. VI command to edit an existing file or create a file
    1. VI 123.txt Create or edit an existing file
    2. After creation: ESC exits edit mode: q! does not save exit: Wq Save exit.
5, CP Command This command is used to copy files, copy of the meaning, it can also be a single copy of multiple files to a directory, its common parameters are as follows: [Plain]View Plaincopy print?
    1. -A: Copy the attributes of the file together
    2. -P: Copied along with the properties of the file, not by default, similar to-a, often used for backup
    3. -I: If the target file already exists, the action will be asked before overwriting
    4. -R: Recursive continuous Replication for directory replication behavior
    5. -U: The destination file is copied when it differs from the source file
For example: [Plain]View Plaincopy print?
    1. Cp-a file1 file2 #连同文件的所有特性把文件file1复制成文件file2
    2. CP file1 file2 file3 dir #把文件file1, file2, file3 copy to directory dir
    3. cp/home/kingddom/tmp/env/#把 all folders and files under/home/kingdom/are copied to/tmp/env.
6. MV Command This command is used to move files, directories, or rename, move the meaning, its common parameters are as follows: [Plain]View Plaincopy print?
    1. -f:force mandatory Meaning, if the target file already exists, will not ask and directly overwrite
    2. -I: If the target file already exists, you will be asked to overwrite
    3. -U: Updates if the target file already exists and is newer than the target file
Note: This command can move a file or multiple files one folder at a time, but the last target file must be "directory". For example: [Plain]View Plaincopy print?
    1. MV File1 file2 file3 dir # move the file file1, File2, file3 to the directory dir
    2. MV File1 file2 # Rename the file file1 to File2
7, RM command This command is used to delete files or directories, between remove, its common parameters are as follows: [Plain]View Plaincopy print?
    1. -F: Force means ignoring files that do not exist and warning messages are not present
    2. -I: Interactive mode, ask the user whether to operate before deleting
    3. -R: Recursive delete, most commonly used for directory deletion, it is a very dangerous parameter
For example: [Plain]View Plaincopy print?
    1. Rm-i File # To delete files, ask for the action before deleting
    2. Rm-f file to delete a document called ' Files '
    3. RmDir dir Delete a directory called ' dir '
    4. RM-RF Dir1 Delete a directory called ' Dir1 ' and delete all of the files at the same time
    5. RM-RF dir1 DIR2 Delete two directories and their contents at the same time
8. PS Command This command is used to select and output the process operation at a certain point in time, and its common parameters are as follows: [Plain]View Plaincopy print?
    1. -A: All processes are displayed
    2. -A: All processes not related to terminal
    3. -U: Related processes for effective users
    4. -X: Generally used in conjunction with a parameter to list more complete information
    5. -L: Longer, the PID information is listed in more detail
In fact, we just need to remember the general use of PS command parameter collocation can be, they are not many, as follows: [Plain]View Plaincopy print?
    1. PS aux # View all process data for the system
    2. PS Ax # View all processes not related to terminal
    3. Ps-la # View all process data for the system
    4. PS AXJF # View together with a subset of process tree states
9. Kill command This command is used to transmit a signal to a job (%jobnumber) or to a PID (number), which is usually used with the PS and jobs commands, with the following basic syntax: [Plain]View Plaincopy print?
    1. Kill-signal PID
The commonly used parameters of signal are as follows: Note: The first number is the signal code, the use of the code can be replaced by the corresponding signal. [Plain]View Plaincopy print?
    1. 1:sighup, start the terminated process
    2. 2:sigint, equivalent to input CTRL + C, interrupts the process of a program
    3. 9:sigkill, forcing the interruption of a process
    4. 15:sigterm to terminate the process with normal end-of-process mode
    5. 17:sigstop, which is equivalent to input CTRL + Z, pauses a process
For example: [Plain]View Plaincopy print?
    1. # at the end of the normal process to finally the first background work, you can use the Jobs command to view the background of the first worker process
    2. Kill-sigterm%1
    3. # re-change process ID to PID process, PID can be filtered using the PS command with the command of the command plus grep
    4. Kill-sighup PID
10. Tar command This command is used to package the file, the default is not compressed, and if the corresponding parameters are specified, it will also call the appropriate compression programs (such as Gzip and bzip) for compression and decompression. Its common parameters are as follows: [Plain]View Plaincopy print?
    1. -C: New package file
    2. -T: See what file names are included in the contents of the packaged files
    3. -X: Unpacking or decompression function, can be used with-C (uppercase) to specify the extracted directory, note-c,-t,-x cannot appear in the same command
    4. -J: Compression/decompression via BZIP2 support
    5. -Z: Compression/decompression with GZIP support
    6. -V: Displays the file name being processed during the compression/decompression process
    7. -F filename:filename for files to be processed
    8. -C dir: Specify a directory for compression/decompression dir
The above explanation may have knocked you out, but usually we just need to remember the following commands: [Plain]View Plaincopy print?
    1. Tar cvfz archive.tar.gz dir1 Create a zipped package in gzip format
    2. Tar XVFZ archive.tar.gz unzip a compressed package in gzip format
    3. Compression: Tar-jcv-f filename.tar.bz2 The name of the file or directory to be processed
    4. Enquiry: Tar-jtv-f filename.tar.bz2
    5. Unzip: Tar-jxv-f filename.tar.bz2-c to extract the directory
Note: The file name is not set to the end of the suffix tar.bz2, here is mainly to illustrate the use of the compression program for bzip211, chmod command the command to change the permissions of the file, the general usage is as follows: [Plain]View Plaincopy print?
    1. chmod [-r] XYZ file or directory
    2. -R: Continuous change of recursion, that is, all files under subdirectories are changed
At the same time, chmod can also use the U (user), G (group), O (Other), a (all) and + (join),-(delete), = (set) with the rwx to make changes to the permissions of the file. [Plain]View Plaincopy print?
    1. For example
    2. chmod 0755 File # Changes files permissions to-rxwr-xr-x
    3. chmod g+w File # Adds a user group writable permission to files ' permissions
12, grep command This command is often used to analyze a row of information, if there is information we need, the line is displayed, the command is usually used with the pipeline command, for the output of some commands to filter processing, etc., its simple syntax for [Plain]View Plaincopy print?
    1. grep [-ACINV] [--color=auto] ' Find string ' filename
Its common parameters are as follows: [Plain]View Plaincopy print?
    1. -A: Find data in a binary file as a text file
    2. -C: Calculate the number of times to find ' find string '
    3. -I: Ignore case differences, that is, case is considered the same
    4. -V: Reverse selection, which shows the line without the ' Find string ' content
    5. For example
    6. # Remove the line containing Manpath in the file/etc/man.config and add color to the Found keyword
    7. grep--color=auto ' MANPATH '/etc/man.config
    8. # put the output of ls-l with the letter file (case-insensitive) content output
    9. Ls-l | Grep-i file
13, yum Command This command for installation, update system files and software operations. The ability to automatically download the RPM package from the specified server and install it, can automatically handle dependency relationships, and install all dependent software packages at once, without the hassle of downloading and installing them over and over again. Yum provides commands to find, install, and delete one, a group, or even all of the packages, and the commands are concise and well-remembered.
    1. Yum [options] [command] [package ...]
its common parameters are as follows:
    1. -H: #帮助
    2. -Y: #当安装过程提示选择全部为 "yes"
    3. -Q: #不显示安装的过程
The general usage is as follows:
    1. Yum-y Install SVN #安装svn
    2. YUM Package Upgrade-(Fedora, Redhat and similar systems)
    3. Yum install package_name download and install a RPM package
    4. Yum Localinstall package_name.rpm will install a RPM package that uses your own software warehouse
    5. The library solves all dependencies for you
    6. Yum Update package_name.rpm updates all installed RPM packages in the current system
    7. Yum Update package_name updates a RPM package
    8. Yum Remove package_name Delete an RPM package
    9. Yum list lists all packages installed in the current system
    10. Yum search package_name searching for packages in RPM repositories
    11. Yum Clean Packages cleanup rpm cache to delete downloaded packages
    12. Yum Clean headers Delete all header files
    13. Yum Clean all deletes all cached packages and header files
14. SFTP command This command is used to transfer files (unable to transfer folders) and to transfer a file from one Linux machine to another Linux machine. Common usage:
    1. SFTP root/192.168.12.36 #从本机连接到192.168.12.36 up.
    2. put/home/123.txt/tmp/#从本机将123. txt transfer to the tmp/path of the 12.36 machine down
    3. get/tmp/123.txt/home/#将目标机12.36 under 123.txt download to native home/folder
    4. in addition pwd LS RM rmdir mkdir These commands are available. Call this machine is plus l, that is, Lls LRM. To leave SFTP, use Exit or quit, bye. The man sftp can be consulted in detail.
15. Turn the firewall on and off
Service mode

Open: Service iptables start
Close: Service iptables stop
Iptables Way
To view the firewall status:
/etc/init.d/iptables status
To temporarily turn off the firewall:
/etc/init.d/iptables stop
Restart Iptables:
/etc/init.d/iptables restart

16, port this thing only firewall tube, other words, you want to telnet port, then this port must program in listening, then can telnet pass

17. Modify the system time   To be continued ...

Linux most commonly used commands

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.