Linux VI command interpretation

  
First introduce a noun "console" (or console), which is the human interface that we usually see using the character interface, such as dos. We say console commands, which are commands that can be entered through the character interface, such as the console command. What we need to know now is the basic console command based on the Linux operating system
. The most common HTMLLinux directory creation and deletion commands basics:
Function: Create a directory (similar to the md command under MSDOS).
Syntax: mkdir [options] dir-name
Description: This command creates a directory named by dir-name. The user who requested the directory creation has write permission in the current directory (in the parent directory of dir-name), and dirname cannot be the directory or file name already in the current directory.
The meaning of each option in the command is:
- m Set access rights for the new directory. It can also be set with the chmod command.
- p can be a path name. At this point, if some directories in the path do not exist yet, with this option, the system will automatically create those directories that do not exist yet, that is, you can create multiple directories at a time.
rmdir Command
Function: Delete an empty directory.
Syntax: rmdir [options] dir-name
Description: dir-name indicates the directory name. This command removes one or more subdirectory entries from a directory. It is important to note that a directory must be empty before it is deleted. The rm -r dir command can be used instead of rmdir, but it is dangerous. You must also have write access to the parent directory when you delete a directory.
The meaning of each option in the command is:
- p Recursively deletes the directory dirname, and when the parent directory is empty after the subdirectory is deleted, it is also deleted. If the entire path is deleted or part of the path is reserved for some reason, the system displays the corresponding information on the standard output.
cd command
Function: Change the working directory.
Syntax: cd [directory]
Description: This command changes the current directory to the directory specified by the directory. If no directory is specified, it will be returned to the user's home directory. In order to change to the specified directory, the user must have execute and read permissions to the specified directory. (This command can use wildcards)
pwd command
In the Linux hierarchical directory structure, users can use the mkdir command to create a new directory in any authorized directory, or use the cd command to convert from one directory to another. table of Contents. However, there is no prompt to tell the user which directory it is currently in. To know which directory is currently in use, you can use the pwd command, which displays the entire pathname.
Syntax: pwd
Description: This command displays the absolute path of the current working directory.
ls command
ls is a shorthand for the English word list, its function is to list the contents of the directory. This is one of the most common commands for users because users need to view the contents of a directory from time to time. This command is similar to the dir command under DOS.
Syntax: ls [options] [directory or file]
For each directory, this command will list all subdirectories and files in it. For each file, ls will output its file name and other information requested. By default, output entries are sorted alphabetically. When the directory name or file name is not given, the information of the current directory is displayed.
The meanings of the options in the command are as follows:
- a Displays all subdirectories and files in the specified directory, including hidden files.
- A Displays all subdirectories and files in the specified directory, including hidden files. But not listed “.” and “..”.
- b Displays undisplayable characters in file names in octal escape characters.
- c Sort by the modification time of the file.
- C is divided into multiple columns to display items.
- d If the parameter is a directory, only its name is displayed instead of the files under it. It is often used with the l option to get the details of the catalog.
- f does not sort. This option will invalidate the lts option and make the aU option valid.
- F Mark “/” after the directory name, “*” after the executable file, mark the <quo;@” after the symbolic link, mark the pipe (or FIFO) “| ”, the socket file is marked with “=”.
- i displays the i-node number of the file in the first column of the output.
- l Display the details of the file in long format. This option is most commonly used.
The information listed in each line is: File type and permission link number File belongs to the main file belongs to the group file size established or recently modified time name
For the symbolic link file, the displayed file name is followed by “— 〉” and reference file pathname.
For device files, the "File Size" field displays the primary and secondary device numbers instead of the file size.
The total number of blocks in the catalog is displayed at the beginning of the long format list, which contains indirect blocks.
- L If the specified name is a symbolic link file, the file pointed to by the link is displayed.
- m Outputs in character stream format, files are displayed across pages, separated by commas.
- n The output format is the same as the l option, except that the file owner and group in the output are represented by the corresponding UID number and GID number instead of the actual name.
- o Same as the l option, except that the owner information is not displayed.
- p Add a “/” to the back of the directory.
- q Replace the undisplayable characters in the file name with “?”.
- r Display the output in alphabetical order or in the earliest order.
- R Recursively displays files in each subdirectory of the specified directory.
- s gives the number of blocks used for each directory entry, including indirect blocks.
- t When you display, press Modify Time (Recent Priority) instead of Sort by Name. If the file modification time is the same, it is in lexicographic order. The modification time depends on whether c or u is used. The default time stamp is the last modification time.
- u When displaying, the last time the file was accessed (last priority) instead of sorted by name. Change the time stamp of -t to the time of the last visit.
- x Displays information about each sort item in rows.
The information displayed by the ls - l command starts with a string of 10 characters, the first character of which represents the file type, which can be one of the following types:
- Ordinary file
d directory
l symbolic link
b block device file
c character device file
The next 9 characters represent the access rights of the file, divided into 3 groups of 3 bits each.
The first group represents the permissions of the owner of the file, the second group represents the permissions of the same group of users, and the third group represents the permissions of other users. The three characters of each group represent the read, write, and execute permissions to the file.
The permissions are as follows:
r Read
w Write
x Execute. For directories, indicates access rights.
s When the file is executed, the UID or GID of the file is assigned to the UID (User ID) or GID (Group ID) of the execution process.
t Set the flag bit (left in memory, not swapped out). If the file is a directory, files in that directory can only be deleted by the superuser, directory owner, or file owner. If it is an executable file, the pointer to its body segment remains in memory after the file is executed. When you execute it again, the system can load the file faster.

Copyright © Windows knowledge All Rights Reserved