First, we will introduce the term "console", which is a commonly seen man-machine interface using character operation interfaces, such as DOS. The console command is a command that can be run on the operating system through the character interface. For example, the doscommand is a console command. What we need to know now is the basic Console Commands based on the Linux operating system. Note that, unlike the doscommand, Linux commands (including file names and so on) are case sensitive. That is to say, if the command you entered is case insensitive, the system will not respond as expected.
Ls
This command is equivalent to the Dir command under DOS. It must be the first one I will introduce. It is also one of the most important commands in Linux console commands. The most common parameters of LS include-a-l-f.
Ls-
Linux Files. files starting with LS are regarded as hidden files and cannot be seen only by using ls commands. In addition to displaying common file names, LS-A can also display hidden files.
Ls-l (this parameter is the lowercase letter of L, not the number 1)
This command can display the file content in a long format. If you need to view more detailed file information, you need to use the LS-l command. For example, if I Type LS-l in a directory, the following information may be displayed (the top two rows are added by myself ):
Location 1 2 3 4 5 6 7
File Attribute file number the group file size to which the owner belongs file name creation date
Drwx ------ 2 guest users 1024 Nov 21 mail
-Rwx -- X 1 Root 89080 Nov 7 tar *
-Rwxr-XR-x 1 root bin 5013 Aug 15 9:32 uname *
Lrwxrwxrwx 1 Root 4 Nov 24 :30 zcat-> Gzip
-Rwxr-XR-x 1 root bin 308364 Nov 29 7:43 zsh *
-Rwsr-x --- 1 root bin 9853 Aug 15 Su *
Next, I will explain the meaning of the displayed content.
The first column indicates the attributes of the file. Linux Files are basically divided into three attributes: readable (R), writable (w), and executable (X ). However, there are ten grids that can be added here (10 bits are actually implemented in a specific program ). The first cell is a special cell, indicating a directory or a link file, etc. D indicates a directory, for example, drwx ------; L indicates a link file, for example, lrwxrwxrwx; if it is a horizontal, indicates that this is a file. The remaining grids are in the unit of 3. Because Linux is a multi-user multi-task system, a file may be used by many people at the same time, so we must set the permissions for each file, the permission positions of the files are arranged in the following order (-rwxr-XR-X is used as an example ):
Rwx (owner) r-X (Group) r-X (other)
In this example, the permissions are as follows: users are readable, writable, and executable; users in the same group are readable, writable, and executable; other users are readable, writable, and executable. In addition, the execution of some program properties is not X, but s, which indicates that the user who executes the program can temporarily execute the program with the same power as the owner. Generally, commands or programs such as System Management enable the user to have the root identity during execution.
The second column indicates the number of files. If it is a file, the number is naturally 1. If it is a directory, the number is the number of files in the directory.
The third field indicates the owner of the file or directory. If the user is currently in his/her home, this column is probably the name of his/her account.
The fourth column, indicating the group to which it belongs ). Each user can have more than one group, but most users should belong to only one group. Only when the system administrator wants to grant special permissions to a user, to another group.
The fifth column indicates the file size. The file size is represented by byte, while the empty directory is usually 1024 bytes. Of course, you can use other parameters to make the file display unit different, for example, if LS-K is used, the size unit of a file is displayed in KB. However, we generally use byte as the main unit.
The sixth column indicates the creation date. In the format of "month, day, and time", for example, Aug 15 indicates on January 1, August 15.
The seventh column indicates the file name. We can use LS-a to display hidden file names.
Ls-F (Note: F is in upper case)
This parameter is used to add symbols of the file type after a file. For example, * Indicates executable,/indicates directory, and @ indicates link file, this is because the-F parameter is used. But now, basically all Linux releases have built-in the-F parameter for LS. That is to say, we can see all kinds of resolution symbols without entering this parameter.
CD
This command is used to access the directory. It is used in the same way as in DOS, so I think there is nothing to say, but there are two points to add. First of all, unlike dos, Linux directories are case-sensitive. If case-insensitive, your CD operation will fail. Second, if you enter CD directly without adding anything to it, it will return to the user's home directory. If it is root, it is returned to/root. This function is the same as Cd ~ Is the same.
Mkdir, rmdir
The mkdir command is used to create a new directory. The rmdir command is used to delete the directory to be created. The functions of these two commands are no longer described. They are basically the same as those of the MD and RD commands in DOS.
CP
This command is equivalent to the Copy command below dos. The specific usage is: CP-r source file (source) target file (target)
The parameter R is used to copy data together with sub-directories in the Metafile. Readers familiar with DOS may find it easier to use this command. After all, they need to press the keyboard twice less than below dos.
Rm
This command is used to delete files. It is different from the RM (delete an empty directory) in DOS. Common Parameters of the RM command include-I,-R, and-f.
For example, I want to delete a text file Rm-I test.
The system will ask us: "RM: Remove 'test '? Y ". After you press enter, the file will be deleted. This is because Linux does not have undelete commands like DOS, or it can use tools such as pctool to save deleted files, files deleted in Linux cannot be recovered. Therefore, it is necessary to use this parameter before deletion.
Rm-r directory name: this operation can be deleted along with the subdirectories under this directory. The function is similar to rmdir.
Rm-F file name (directory name): this operation can be forcibly deleted.
MV
The function of this command is to move a directory or file. The extended function is to rename a directory or file. Its usage is basically the same as the move in DOS. When you use this command to move a directory, it will be removed along with the subdirectories under the directory. In addition, there is no RENAME Command in Linux, so if you want to rename a file or directory, you can use the following method: the original MV file (directory) Name new file (directory) Name.
Du, DF
The du command displays the disk space occupied by the current directory, and the DF command displays the remaining disk space of the current disk. If the du command does not add any parameters, the returned information is the usage of the entire disk. If a directory is added to it, this is the usage of the directory on the disk (this function is not available in DOS ). However, I generally do not like to use du because it provides too much information. I don't think so. I am the most commonly used DF command, because the amount of space left on the disk is very important to me.
Cat
This command is a very important command in Linux. Its function is to display or link common ASCII text files. Cat is short for concatenate, similar to the type command under DOS. Its usage is as follows:
Cat text displays the text file;
Cat file1 file2 displays file1 and file2 in sequence;
Cat file1 file2> file3 combines the content of file1 and file2, and then "Redirect (>)" to the file3 file.
">" Is a very interesting symbol. It means to redirect to the right, that is, to treat the result on the left as an input and then input it to the file file3. Note that file3 is a file that has not existed before redirection. If file3 is an existing file, its content is overwritten and changed to file1 + file2. If there is no file name on the left, and there is a file name on the right, for example:
Cat> file1: The result is a blank line. Wait for you to enter the text, and then press [CTRL] + [c] or [CTRL] + [D]. the editing is completed and the file file1 is generated. The content of file1 is the content you just entered. The result of this process is the same as that of copy con file1 in DOS.
In addition, if you use the following command:
Cat file1> file2: This will be used to "APPEND" the content of file1 to the end of file2, while the content of file2 still exists. This type of redirection character> is more common than>, it can be used more.
More, less
These are two commands for displaying common text files. If a text file is too long to display more than one screen, it is not ideal to use Cat, you can try the more and less commands. The more command can temporarily hold a file with more than one page on the screen. It will not be displayed until you press any key. In addition to more functions, less can also be used to scroll up or down the network by using the direction keys. Therefore, when you read articles, less is a good choice.
Clear
This command is used to clear the screen. It does not require any parameters. It has the same function as the CLR in DOS. If you think the screen is too messy, you can use it to clear information on the screen.
PWD
The purpose of this command is to display the current working path of the user. This command does not need to be said.
Ln
This is another very important command in Linux. Please be familiar with it. Its function is to create a non-same link for a file in another location. The most common parameter of this command is-S. The specific usage is the target file of the Ln-S source file.
When we need to use the same file in different directories, we do not need to put a file that must be the same under each required directory. We only need to put it in a fixed directory, put the file, and then use the ln command link in other directories to link it, without occupying disk space repeatedly. Example: ln-S/bin/less/usr/local/bin/less
-S indicates the symbol (symbolic.
There are two points to note: first, the ln command will keep the synchronization of each link file, that is, no matter which one you change, other files will change the same; second, there are two types of LN links: Soft link and hard link. The soft link is ln-s *****. It will only generate a file image at your selected location, it does not occupy disk space. The hard link ln *** has no parameter-S. It will generate a file of the same size as the source file at the selected position, both soft links and hard links are synchronized.
If you use ls to view a directory, you will find that some files are followed by a @ symbol, that is, a file generated using LN command, and you can use LS-l command to view it, the link path is displayed.
Man
If your English is good enough, no one can master Linux, as long as you use man. Man is actually the help of command usage. The most important thing to learn about any UNIX operating system is to learn to use man's Auxiliary Command. Man is the abbreviation of manual (manual). Its description is very detailed, but it seems a headache because it is both in English. It is recommended that you go to man again when you need it. Normally, remember some basic usage.
Logout
At first glance, we can see that this is the command to exit the system. I will not say much about it. It should be emphasized that Linux is a multi-user, multi-process operating system, so if you don't need it, you can quit the system. You don't have to worry about shutting down the system, that is the case for the system administrator. But remember that even if you use Linux on a single machine, logout will not