How the Linux shell commands work:
Linux is strictly speaking of an operating system, we call it "core (kernel)", but we generally users, cannot directly use kernel. Instead, it communicates with kernel through kernel's "shell" program, the so-called shell. The shell has the same effect on Linux, mainly parsing our instructions and parsing instructions to the Linux kernel. Feedback results are run through the kernel and parsed to the user through the shell.
ls command
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/82/5D/wKioL1dSxhfgXhKWAABBofc-B7M511.png-wh_500x0-wm_3 -wmp_4-s_1723736820.png "title=" ls instruction. png "alt=" wkiol1dsxhfgxhkwaabbofc-b7m511.png-wh_50 "/>
-a lists all files in the directory, including the implied files that begin with.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/82/5E/wKiom1dSxSry7SnyAAC8KvripY8303.png-wh_500x0-wm_3 -wmp_4-s_883388142.png "title=" Ls-a.png "alt=" Wkiom1dsxsry7snyaac8kvripy8303.png-wh_50 "/>
CD command
1. Name: CD
2. Objects used: All Users
3. Command format: CD [DirName] (CD and directory separated by spaces)
4. Function: Switch the current directory to dirname.
CD ~: Go to User Directory
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/82/5D/wKioL1dSxsCQzNoWAABOizAAAV0450.png-wh_500x0-wm_3 -wmp_4-s_4000519228.png "title=" Cd~.png "alt=" Wkiol1dsxscqznowaaboizaaav0450.png-wh_50 "/>
CD-: Return to the most recently accessed directory (analogy pushd and POPD)
Cd.. : Return to Parent directory
CD!$: Use the parameters of the previous command as the target parameter of the CD command (not commonly used)
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/5D/wKioL1dSxn7hcUWUAAAofc0Q3E8057.png-wh_500x0-wm_3 -wmp_4-s_1855119020.png "title=" Cp.png "alt=" Wkiol1dsxn7hcuwuaaaofc0q3e8057.png-wh_50 "/>
Date display:
Date specifies the format to display time: Date +%y_%m_%d,date +%y:%m:%d
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/5E/wKiom1dSxeCRe9IBAAAXM8T2qAk928.png-wh_500x0-wm_3 -wmp_4-s_1684091817.png "title=" Date.png "alt=" Wkiom1dsxecre9ibaaaxm8t2qak928.png-wh_50 "/>
The date command itself provides a convenient addition and subtraction of dates.
For example: Get yesterday's time
Date +%y%m%d--date= "-1 day"
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/82/5E/wKiom1dSxfqhSJGBAAASwSaaXLQ970.png-wh_500x0-wm_3 -wmp_4-s_3852334241.png "title=" Date-1.png "alt=" Wkiom1dsxfqhsjgbaaaswsaaxlq970.png-wh_50 "/>
Time stamp
Time, time stamp: Date +%s
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/5D/wKioL1dSxxLSY-VnAAAQCjgzmv0724.png-wh_500x0-wm_3 -wmp_4-s_281850132.png "title=" timestamp. png "alt=" wkiol1dsxxlsy-vnaaaqcjgzmv0724.png-wh_50 "/>
Time stamp, time: Date +%y:%m:%d-d @1425384141
The Unix timestamp (in English for Unix epoch, Unix time, POSIX time, or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (Midnight of Utc/gmt), regardless of the leap seconds.
Cal directives
The CAL command can be used to display a Gregorian calendar. The Gregorian calendar is now the International Universal Calendar, also known as Griel, the Gregorian calendar. "Solar" is also known as "solar Calendar", the earth around the sun for one year, for the western countries are universal, it is also known as "Western Calendar".
Command format:
Cal [parameters] [month] [year]
Command function:
Used to view time information such as a calendar, such as a single argument, that represents the year (1-9999), and if there are two parameters, the month and year are shown
Command parameters:
-1 shows the one month calendar
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/82/5E/wKiom1dSxnywI23-AAAdFrLztUE736.png-wh_500x0-wm_3 -wmp_4-s_1728403898.png "title=" Cal.png "alt=" Wkiom1dsxnywi23-aaadfrlztue736.png-wh_50 "/>
-3 Display system first one months, current month, next one month calendar
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/82/5D/wKioL1dSx5DSMOATAABAHM8bPA4715.png-wh_500x0-wm_3 -wmp_4-s_3383783834.png "title=" Cal-3.png "alt=" Wkiol1dsx5dsmoataabahm8bpa4715.png-wh_50 "/>
-S displays Sunday for the first day of one weeks, the default format
-M displays Monday for the first day of one weeks
Touch command:
Linux touch commands are not commonly used, and are generally used when using make, to modify file timestamps, or to create a new file that does not exist.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/82/5D/wKioL1dSx7fADa6DAAAeJmHuM7g128.png-wh_500x0-wm_3 -wmp_4-s_3936310895.png "title=" Touch.png "alt=" Wkiol1dsx7fada6daaaejmhum7g128.png-wh_50 "/>
mkdir directive (important):
The Linux mkdir command is used to create a directory of the specified name, requiring the user who created the directory to have write permissions in the current directory, and the specified directory name cannot be a directory that is already in the current directory.
1. Command format:
mkdir [Options] directory ...
2. Command function:
The mkdir command enables you to create a folder or directory that is named DirName (the specified file name) at the specified location. To create a folder or directory, you must have write access to the parent folder of the folder you are creating. Also, the folder (directory) You create cannot have the same name as the filename in its parent directory (that is, the parent folder), that is, the same directory cannot have the same name (case sensitive).
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/82/5D/wKioL1dSx9WACL52AACBMlylzxM050.png-wh_500x0-wm_3 -wmp_4-s_674731618.png "title=" Mkdir.png "alt=" Wkiol1dsx9wacl52aacbmlylzxm050.png-wh_50 "/>
RmDir Instructions && RM instructions (IMPORTANT)
The rmdir is a command that corresponds to the mkdir. MkDir is to create a directory, and RmDir is a delete command. RM command can delete files or directories at the same time
1. Name: rmdir
2. Applicable object: All users with the current directory operation permissions
3. Command format: rmdir [-p-v] [DirName]
4. Function: Delete Empty directory
5. Detailed Parameters:
-P When the subdirectory is deleted, if the parent directory becomes an empty directory, then the parent directory is deleted.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/82/5F/wKiom1dSx4Dxn-NoAACPZXMgQUU381.png-wh_500x0-wm_3 -wmp_4-s_960277446.png "title=" Rmdir.png "alt=" Wkiom1dsx4dxn-noaacpzxmgquu381.png-wh_50 "/>
1. Name: RM
2. Applicable to: All users
3. Command format: RM [-f-i-r-v] [Dirname/dir]
4. Role: Delete files or directories
5. Detailed Parameters:
-F Even if the file property is read-only (that is, write-protected), it is also deleted directly
-I ask for confirmation before deleting
-R Delete directory and all files below it
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/5D/wKioL1dSyHCTAPbkAAAdqhIcCGk197.png-wh_500x0-wm_3 -wmp_4-s_2944564104.png "title=" Rm.png "alt=" Wkiol1dsyhctapbkaaadqhiccgk197.png-wh_50 "/>
CP directive (IMPORTANT):
Features: Copying Files or directories
Note: The CP instruction is used to copy files or directories, such as specifying more than two files or directories at the same time, and the final destination is an existing directory, it will copy all the previously specified files or directories into this directory. If you specify multiple files or directories at the same time and the final destination is not an existing directory, an error message appears
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/5D/wKioL1dSyLqi8c-0AAAofc0Q3E8222.png-wh_500x0-wm_3 -wmp_4-s_4079066340.png "title=" Cp.png "alt=" Wkiol1dsylqi8c-0aaaofc0q3e8222.png-wh_50 "/>
MV Instruction (IMPORTANT):
The MV command is the abbreviation for move, which can be used to move files or rename files (rename), which is a common command under Linux, often used to back up files or directories.
basename directive: (important)
Returns the base file name for a string parameter.
Grammar
BaseName String [Suffix (suffix)]
Describe
The basename command reads the String parameter, removes the prefix ending with A/(slash), and any specified suffix parameter, and writes the remaining base file names to standard output. The basename command applies the following rules for creating a base file name: If the string argument is a//(double slash) or if the string argument contains a slash character, change the string to a single/(slash). (basename
Removes any trailing/characters from the specified string. If any/characters are left in the string parameter, the prefix of the string is dropped until the last/character is (included).
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/82/5F/wKiom1dSyAvSjCiKAAAOlmcJxm4389.png-wh_500x0-wm_3 -wmp_4-s_460043484.png "title=" Basename.png "alt=" Wkiom1dsyavsjcikaaaolmcjxm4389.png-wh_50 "/>
DIRNAME directive: (important)
The role of the dirname command is to process the path to get the parent directory of the path, and dirname does not check that the path is legitimate.
Usage: dirname [path |options]
Function: The output has removed the name of the "/" character part of the tail, and if the name does not contain "/", then "." is displayed. (represents the current directory).
More directives: (important)
Feature Brief: More commands, features like cat, the Cat command is the entire contents of the file displayed on the screen from top to bottom. More will be a page-by-page display to facilitate users to read pages, and the most basic instruction is to press the blank key (space) on the next page, press the B key will be back to a page, but also the function of the search string. The more command reads the file backwards from the front, so it loads the entire file at startup. [also content display command]
Command parameters:
+n starting from joys N rows
-N defines the screen size as n rows
Less directive: (important)
The less tool is also a tool for paging through files or other output, which is a very powerful tool for Linux to view the contents of a file. The usage of less is more resilient than more. At more times, we have no way to
The front turn, can only look back, but if use less, you can use [PageUp] [PageDown] and other key functions to go to look at the file,
Easier to view the contents of a file! In addition, in less you can have more search function, not only to search down, but also to search upward.
Head command: (important)
Head and tail are as simple as their name, which is used to display the beginning or end of a number of chunks of text, the head is used to display the beginning of the file to the standard output, and tail to see the end of the file.
1. Command format:
Head [parameters] ... [File] ...
2. Command function:
The head is used to display the beginning of the file to the standard output, and the default head command hits
Print its corresponding file at the beginning of 10 lines.
3. Command parameters:
-Q Hide file names
-V Show file name
-c< bytes > Display bytes
-n< rows > rows displayed
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/82/5F/wKiom1dSyUWxdb7GAAAhYQwuBHI655.png-wh_500x0-wm_3 -wmp_4-s_1109837164.png "title=" Head.png "alt=" Wkiom1dsyuwxdb7gaaahyqwubhi655.png-wh_50 "/>
Tail directive: (important)
The tail command writes the file to standard output starting at the specified point. Using the tail command
The-F option provides easy access to the log file that is being changed, tail-
f filename will display the top of the filename in the screen, and does not
But refresh so that you see the latest file content.
1. command format;
tail[necessary parameters [selection parameters] [file]
2. Command function:
Used to display the content at the end of the specified file, and is processed as input when the file is not specified. Common view log files.
GZIP Instructions:
Command: gzip
Syntax: gzip [option] File name for compression (decompression)
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/82/5E/wKioL1dSyoaQK3FZAAAkfvOMZDQ493.png-wh_500x0-wm_3 -wmp_4-s_2473831884.png "title=" Gzip.png "alt=" Wkiol1dsyoaqk3fzaaakfvomzdq493.png-wh_50 "/>
Gunzip
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/5F/wKiom1dSyaSjDENuAAA0nbW3ic0514.png-wh_500x0-wm_3 -wmp_4-s_181941870.png "title=" Gunzip.png "alt=" Wkiom1dsyasjdenuaaa0nbw3ic0514.png-wh_50 "/>
TAR directive (important):
tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter directive (the meaning of Create);
-x: Unlock the parameter instructions for a compressed file!
-T: View the files inside the Tarfile!
In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time! Because it is not possible to compress and decompress simultaneously.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/82/5E/wKioL1dSys7y6kTNAABPtz4vH5I396.png-wh_500x0-wm_3 -wmp_4-s_4022033400.png "title=" Tar.png "alt=" Wkiol1dsys7y6ktnaabptz4vh5i396.png-wh_50 "/>
PWD command:
In Linux, use the PWD command to view the full path to the current working directory. Simply put, you will have a current working directory every time you operate in a terminal. When unsure of the current location, PWD is used to determine the exact location of the current directory within the file system.
1. Command format:
PWD [Options]
2. Command function:
View the full path to the current working directory
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/82/5F/wKiom1dSygrw_q2oAAAOHTYmo4A962.png-wh_500x0-wm_3 -wmp_4-s_3904848502.png "title=" Pwd.png "alt=" Wkiom1dsygrw_q2oaaaohtymo4a962.png-wh_50 "/>
WHO directive:
Who command
Feature Description: Displays the user information currently logged into the system.
Syntax: Who [-himqsw][--help][--version][am
i][Record file]
Additional note: The implementation of this directive will be informed that there are currently users logged into the system, the individual implementation of the WHO command would list the login account, the terminal used, login time and from where to log in or use which x monitor.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/82/5E/wKioL1dSyzWSf7UaAAAYIfOTTik515.png-wh_500x0-wm_3 -wmp_4-s_2542019177.png "title=" Who.png "alt=" Wkiol1dsyzwsf7uaaaayifottik515.png-wh_50 "/>
Diff
Commands are a very important tool on Linux to compare the contents of a file, especially to compare two different versions of files to find the changes. Diff prints each line's changes on the command line. The latest version of diff also supports binary files. The output of the diff program is called Patch, because there is also a patch program in the Linux system that updates the contents of the A.C file to B.C based on the diff output. Diff is an integral part of version control tools like SVN, CVS, and Git.
Linux commands are very rich, only in the learning of continuous use to master.
This article is from the "Qin-wang" blog, make sure to keep this source http://10810196.blog.51cto.com/10800196/1786141
Linux Shell Instructions