1.1 pwd Command
The command is interpreted in English as print working directory (print working directory). Enter the PWD command, and Linux will output the current directory.
1.2 CD command
The CD command is used to change your directory.
CD/go to the root directory
CD ~ Go to the/home/user user directory
Cd/usr go to the USR directory in the root directory-------------absolute path
CD test goes to-------relative path in the test subdirectory under the current directory
1.3 ls Command
The LS command is used to view the contents of the directory.
1.4 Cat Command
The cat command can be used to merge files or to display the contents of the entire file on the screen.
Cat Snow.txt The command displays the contents of the file Snow.txt, Ctrl+d quits Cat.
1.5 grep command
The most important function of the grep command is to find a specific string in a heap of files.
grep Money Test.txt
The above command looks for the money string in Test.txt, and the grep lookup is case-sensitive.
Typically this section can be used with pipelines with PS |grep bash
Pipe: Give the output of a command as a file to the right command processing
1.6 Touch Command
The touch command is used to create a new file, and he can create a blank file where you can add text and data.
Touch newfile This command to create a blank file named NewFile.
1.7 cp Command
The CP command is used to copy files, to copy files, and to enter commands:
CP <source filename> <target filename>
CP t.txt document/t The command will copy the file T.txt to the document directory and be named T.
1.8 MV Command
The MV command is used to move files.
MV T.txt document moves the file T.txt to the directory document.
1.9 RM Command
The RM command is used to delete files.
RM t.txt the command to delete the file T.txt
1.10 rmdir Command
The rmdir command is used to delete a directory.
Add:
1.11 mkdir Command
MkDir used to create a directory
Two Commands about disk space
2.1 Mount Command
The mount command is mounted on a file system that can mount a hard disk, a CD-ROM, a floppy disk, or mount an NFS network file system. The standard usage of this command is as follows:
Mount–t Device Type Storage directory
Mount IP Address:/provided directory storage directory
Under directory/mnt, hang up the iso9660 file system. Enter the command:
Mount–t Iso9660/dev/hdb/cdrom
2.2 Umount Command
The function of the Umount command is to unload a file system that has been hung, and the file system on all mounts should be uninstalled before shutting down the system. This command is relative to the Mount command. Usage:
Umount a directory or device that is already hung
To uninstall the/cdrom directory that is already hung, enter the command:
Umount/cdrom
To unload a section that has been hung, enter the command:
Umount/dev/hdb1
2.3 DF Command
The DF command is used to check the disk space of the hard disk partition and the mounted file system, that is, to check the amount of hard disk usage. The standard usage is as follows:
DF [-option]
For example, to list disk usage for all file systems and partitions, enter the command:
Df–a
2.4 du command
The function of the du command is to display the file directory or size. Standard usage:
Du [-Options]
2.5 fsck Command
The function of the fsck command is to check and repair the Linux file system, which is best used when no one or no partition hangs up, in fact, each boot system will do a check to see if there is a bad track or data loss phenomenon. Usage:
fsck (-option) partition name
Three File backup and Compression commands
3.1 bzip2 Command
To compress a file using bzip2, enter the command at the shell prompt:
bzip2 filename
The file is compressed and saved as filename.bz2.
To extract a file, enter the command:
BUNZIP2 filename.bz2
FILENAME.BZ2 will be deleted and replaced with filename.
bzip2 filename.bz2 file1 file2 file3/usr/work/school
The above command compresses the contents of the File1, File2, File3, and/usr/work/school directories and puts them in filename.bz2.
3.2 gzip Command
To compress a file using gzip, enter the command:
gzip filename
The file is compressed and saved as filename.gz.
To extract a file, enter the command:
Gunzip filename.gz
Filename.gz will be deleted and replaced with filename.
Gzip-r filename.gz file1 file2 file3/usr/work/school
The above command compresses the contents of the File1, File2, File3, and/usr/work/school directories and puts them in filename.gz.
3.3 Zip command
The zip command is used in conjunction with GZIP.
3.4 Tar Command
The TAR command was originally used for tape backup, but because of the increasing capacity of the hard disk, the main use of this command now is to back up all the files. Tar this command packs a large number of files and directories into a file.
To create a tar file, enter the command:
TAR–CVF Filename.tar Directory/file/home/mine
The above command puts Directory/file,/home/mine into the archive.
To list the contents of a tar file, enter the command:
TAR–TVF Filename.tar
To extract the tar file command, enter the command:
TAR–XVF Filename.tar
This command does not delete the tar file, but it copies the contents of the archive to the current working directory and preserves any directory structure used by the archive file.
Keep in mind that tar does not compress files by default. To create a file that uses tar and bzip2 to archive compressed files, use the-J option:
TAR–CJVF filename.tbz File
If you use the BUNZIP2 command to extract the Filename.tbz file, the FILENAME.TBZ is deleted and replaced with Filename.tar.
To extend and de-archive the bZIP tar file, enter the command:
TAR–XJVF FILENAME.TBZ
To create a file that is archived and compressed in tar and gzip, use the-Z option:
TAR–CZVF filename.tgz File
If you use the Gunzip command to extract the Filename.tgz file, the filename.tgz is deleted and replaced with Filename.tar.
Tar command
Unpacking: Tar zxvf Filename.tar
Package: Tar czvf filename.tar DirName
GZ command
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName
. tar.gz and. tgz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz DirName
Compress multiple files: Tar zcvf FileName.tar.gz DirName1 DirName2 DirName3 ...
bz2 command
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName
. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 DirName
BZ command
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown
. tar.bz
Decompression: Tar jxvf FileName.tar.bz
Z Command
Decompression: uncompress filename.z
Compression: Compress FileName
. Tar. Z
Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z DirName
Zip command
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip DirName
Four Commands for shutting down and viewing system information
4.1 Shutdown command
To use this command, the root user must be guaranteed, otherwise the SU command will be used to change to the root user. The command format is as follows:
shutdown– (option)
Join to shut down within 2min, enter command:
Shutdown–t 2
If this is a reboot after shutdown, enter the command:
Shutdown–r
4.2 Reboot Command
This command is also a shutdown command, only input, without any parameters, the system will be the fastest speed shutdown, and do not write memory or buffer contents back to the hard disk.
4.3 PS command
The PS command is used to see what programs are in progress in the computer system and how they are executed. This is a fairly powerful command that can be used to find out all the process IDs and names. In addition, the PS command can be used to list all programs that use memory. Use the following:
PS – (option)
Detailed reference: http://blog.csdn.net/xiaoxiaopengbo/article/details/78097696
4.4 Top Command
The top command can view the current program's execution scenarios and memory usage. It is similar to PS, however, it updates the system state for a few seconds and is easy to track. To get out of this program, press CTRL + C key to do it.
4.5 Kill command
The KILL command is used to terminate a process that is executing. If a program fails during execution, you can terminate the program to avoid remaining in memory and consuming system resources. However, its practical significance is to send a signal to the executing program, calling it suicide. Can send a lot of signals to these programs, also can let them receive signal after doing a lot of things. Standard usage:
kill– (option) PID
Before the KILL command is executed. You can use the PS command to check the PID of a program that is down, and then remove a program by using kill. For example, to terminate a program with PID 90:
Kill 90
Cut down the stroke of the PID 323 (Kill):
Kill-9 323
To re-run the 456-PID Stroke (restart):
Kill-hup 456
4.6 Date Command
The date command is used to display, set, and modify the current time and date. Standard usage:
date– (option) Display time format (beginning with +, plus format)
Date set time format
If you enter a command:
Date "+%x,%r"
The system returns the following information:
March 26, 2010, 18:06 P.M. 49 seconds
4.7 cal Command
The CAL command has two functions: a monthly calendar and a calendar.
The direct Input CAL command displays a monthly calendar for the current month.
To display a year's annual calendar, you can add a 4-digit year of A.D. to the Cal command. For example, to display a 2008 year calendar, you must enter:
Cal 2008
If you enter Cal 08, the Year 8 calendar is most displayed.
To view only a January calendar for a given year, you can enter: Cal month AD year. For example, enter: "Cal 12 2004".
Five Manage users and commands for setting up permissions
5.1 chmod command
The chmod command is used to change license permissions. Read, write, and execute are the three main settings in the license permissions. Because users are programmed into a group when their account is created, they can also specify that the group can read, write, or execute a file. which
R-Files can be read
W-Files can be written
X-Files can be executed if the file is a program
You can use the LS command with-l to carefully view many details of a file.
The chmod command is used to set permissions on a file. Standard usage:
chmod (+,-, =) permission name (r,w,x) file for user (u,g,o,a) of the file
To delete all permissions for a file, enter a command:
chmod a-rwx Test.txt
To add permissions to the file owner, enter the command:
chmod u+rwx Test
You can also use numbers to indicate permissions: 4--read, 2--write, and execute. The following two commands are equivalent:
chmod 751 filename
chmod u+rwx,g=rx,0=x filename
5.2 su Command
The SU command is used to modify the user. This is a very important command that allows an ordinary user to have access to superuser or other users. However, this command must have a superuser or other user's password to become a superuser or other user. If you want to leave, you can enter exit. Standard usage:
SU user name (default to root if no user name is entered)
For example, assuming that the current user User01 and want to transition to USER02, enter the command:
Su User02
System returns:
Password
At this point, enter the USER02 instruction and it will become user02.
5.3 Useradd Command
The Useradd command is used to increase the user, only the root user can increase the user. If you are not logged in as the root user, enter Su, and then enter the root password.
To add a user, enter a command:
Useradd User Name
Then, follow the prompts to enter a password for the new user.
Six Commands for online queries
6.1 Man Command
The man command is used to query and interpret the use of a command and the considerations for this command. This query query is available on every Linux. Typically, the user simply enters the command man and the name of the command shell will list a complete description. Standard usage:
Name of the man command
To query the description page of the LS command, enter the command:
Mans LS
To flip through the manual page, you can use the page UP and PAGE DOWN keys, or use the spacebar to turn back one page and use B to flip forward. To exit the manual page, enter the command Q. To search for keywords in the manuals page, enter a command/and keyword or phrase to search for, and then press ENTER. All keywords appearing on the manuals page are highlighted, allowing you to quickly read the keywords in the context.
6.2 Locate Command
The main function of the Locate command is to locate files and directories. Sometimes, you can use locate to locate files and directories only if you know that a file or directory exists, but you don't know where it is. Using the Locate command, you will see each file and directory that includes the search field. For example, if you want to search for a file with the word test, enter the command:
Locate test
The locate command uses a database to locate a file or directory with the word test.
6.3 Whatis Command
The Whatis command is used to query the meaning of a command. The use of simple, and do not need any parameters, directly after the Whatis command to add the command to query can be, but it is very practical.
To query the meaning of the MV command, enter the command:
Whatis MV
Seven Commands for reading files
7.1 Head Command
The head command can be used to view the beginning of a file. The format of this command is:
Head file name
The default setting, which only looks at the first 10 lines of the file. However, you can change the number of rows to display by specifying a number option, with the following command:
HEAD–20 file name
This command will look at the first 20 lines of the file.
7.2 Tail Command
The tail command is the opposite of the head command. With the tail command, you can view 10 lines at the end of a file. This helps you view the last 10 lines of the log file to read important system information. You can also use tail to observe the process of log file updates. With the-f option, tail automatically displays new information from the open file to the screen in real time. For example, to actively observe/var/log/messages, enter the following command under the shell as root user:
Tail–f/var/log/messages
7.3 Less command
The less command is similar to the more command.
7.4 More commands
The main difference between the more and less is that less allows you to use arrows to move back and forth, while more uses the SPACEBAR and the B key to move forward and backward. Use LS and more to enumerate the contents of the/etc directory:
ls–al/etc | More
To use more to search for a keyword in a text file, press the/key and enter the command to search for the entry:
/foo
Use the SPACEBAR to scroll through the page numbers before. Press the Q key to exit.
The more command standard format is:
more [options] [FileNames]
For example:
More-s testfile Displays the file contents of the Testfile pages by page, if there are two consecutive lines or more blank lines are displayed in a row of blank lines.
More +20 testfile from line 20th to display the contents of the Testfile file.
Eight Network Operations Command
8.1 FTP command
FTP commands are very important for transferring files. If you see a very important file on the network, you can use this command to upload that file to your machine.
Standard usage:
FTP (-option) host name or IP address
For example, log in to the Ftp.dark.com host with FTP and enter the command:
FTP ftp.dark.com
Note: Users must have appropriate access rights, or they cannot obtain files from a remote system or transfer files to a remote system. In order to use FTP to transfer files, the user must know the valid user name and password on the remote computer.
8.2 Bye Command
In FTP mode, input bye can interrupt the current connection job, and end the execution of FTP, there is no option.
8.3 ping command
The ping command, which uses the ICMP transport protocol, sends out a request for a response and, if there is no problem with the remote host's network, responds to the message and learns that the host is functioning properly.
Standard usage:
Ping (-option) host name or IP address
For example, the detection of Des.bllod.net Host network function is normal, send out to go to the information needs to complete 5 responses, each interval of 10s, the size of the packet is 512B, input command:
Ping–c 5–i 10–s 504–t des.blood.net
8.4 Telnet command
The main function of the Telnet command is to log in remotely. This command allows users to communicate between remote computers that use the Telnet protocol, and the user can log on to the remote computer over the network as if they were logged on to the local machine to execute the command. In order to log on to the computer via Telnet, you must know the valid user name and password on the remote computer. Telnet only provides terminal emulation for normal terminals, and does not support graphical environments such as X window.
Standard usage:
Telnet host name or IP
For example, to log on to a computer with an IP address of 140.114.63.12, enter the command:
Telnet 140.114.63.12
Once Telnet is successfully connected to the remote system, the login information is displayed and the user is prompted to enter a user name and password. If the user name and password are correct, they can log on successfully and work on the remote system. After the user finishes the remote session, be sure to use the logout command to exit the remote system. Then Telnet reports that the remote session was shut down and returned to the user's local machine at the shell prompt.
8.5 rlogin Command
Rlogin is also used to log in remotely. Its meaning in English is remote login. This command is similar to the Telnet command, allowing the user to start an interactive command session on the remote system. Usage:
Rlogin (-option) host
For example, to log in to someone else's computer. Enter the command:
Rlogin–l Inin 140.114.125.24
8.6 netstat command
The main function of the netstat command is to understand the network situation of the Linux system. Assuming that no parameters are specified for the netstat command, the effect is the same as specifying the-f parameter.
Usage:
Netstat (-option)
Nine commands for locating and locating files
which
Grammar
which command
Description
The location of the command is found sequentially from the directory listed in the PATH environment variable, and the name of the full path is displayed. When the first qualifying program file is found, the search stops immediately, omitting the remaining directories that are not searched.
example, find the location of the program file for the LS command:
which LS
System output:
/usr/bin/ls
Whereis
Grammar
Whereis [option] Name
Description
Find out the executable files, source code files, and manpage paths for the specific program. The name you provide will be first removed from the predecessor path and any. ext extension.
whereis will only be searched in the standard Linux directory.
Common options
-B
Only the executable file is searched.
-M
Search Manpage only.
-S
Only source code files are searched.
-B Directory
Changes or limits the directory to search for executable files.
-M directory
Changes or limits the search Manpage directory.
-S Directory
Change or qualify the directory where the source code files are searched.
Find
Grammar
Find paths expression [www.yongshiyule178.com action]
Description
Use paths as the search starting point to find each file that matches the expression criteria and perform the action represented by action on the file. Expression is a search condition consisting of an option that represents the matching item and a parameter that represents the matching pattern.
An action is a processing action that has an option to represent "processing" and an action parameter composition. If you do not specify an action, the default action is to display the file name.
Common search criteria
-name www.yingka178.com Pattern
-path pattern
-lname pattern
Locate the file with the name, path name, or symbolic link target matching the pattern pattern. Pattern can contain the shell's file name wildcard character, which is relative to the search starting point.
Common handling actions
-print
Displays the relative path of the file relative to the start of the search.
-exec cmd/;
Executes the specified shell command. If CMD contains any shell special characters, they must precede them with a/sign, lest the shell execute them immediately. In cmd, you can use the "{}" symbol (including double quotation marks) to represent the file found by find.
Locate
Grammar
Locate www.078881.cn Patterns
Description
The first time the locate is executed, it creates an index database that, when executed again, quickly finds the location of the file from the index database. Locate is a great place to search repeatedly for infrequently changed directories, but for old files that have just been renamed and for newly created files, locate cannot be found unless the database is rebuilt.
UpdateDB
Grammar
updatedb [option]
Description
Update the index database for slocate.
Options
-E Directories
Skip the directories listed in directories.
Ten Other commands
9.1 echo Command
The echo command is used to output a piece of text on the display, and this command is used to output some hints, so the meaning of this command is to output some text. It is also very simple to use:
echo– (parameter) string (can be used "", or not, show slightly different)
The parameter n means that the output text does not wrap, and the line is wrapped if no argument is added.
Enter the command:
echo "Welcome to www.baidu620.com use Linux"
The output is:
Welcome to use Linux
If you do not add "", the output is:
Welcome to use Linux
The difference is that the latter output is separated by only one space per two outputs, because Echo sees these outputs as strings.
9.2 Clear Command
The main function of the clear command is to clear the display, this command is simple, just enter clear.
9.3 passwd Command
The passwd command is used to modify the user's password.
Under the shell, enter
passwd
Then, follow the prompts to enter the old password and the new password.
9.4 LPR Command
The function of the LPR command is to send the specified file to the print queue. For example, LPR foo.txt prints a foo.txt file.
Standard usage:
LPR filename
To view the jobs waiting in the print queue, enter the command lpq on the command line. The system returns the following information:
Active root 389 foo.txt
In this example, 389 is the job number. You can also cancel jobs in the print queue in the following format:
LPRM Job number
Enter the command:
LPRM 389
This will fix the foo.txt print job.
9.5 Exit Command
Exits the current shell and, if it is the last shell, exits the terminal
Eleven. VI Use
Reference: http://blog.csdn.net/xiaoxiaopengbo/article/details/50839658
Twelve. GCC use
http://blog.csdn.net/xiaoxiaopengbo/article/details/50339877
Linux Learning---linux commands encyclopedia