Create and Delete commands for the linux--directory

Source: Internet
Author: User

Linux Create and DELETE commands for directories

mkdir Command

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 is required to create the directory has write permissions in the current directory (in the parent directory of Dir-name), and dirname cannot be a directory or file name that is already in the current directory.

The meanings of the options in the command are:

-m set access permissions on the new directory. You can also set it with the chmod command.

-P can be a path name. At this point, if some directories in the path do not already exist, and with this option, the system will automatically set up those directories that do not yet exist, that is, multiple directories can be established at one time.

rmdir Command

Function: Delete Empty directory.

Syntax: rmdir [Options] Dir-name

Description: Dir-name represents 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 replace RmDir, but is dangerous. When you delete a directory, you must also have write permissions to the parent directory.

The meanings of the options in the command are:

-p recursively deletes the directory dirname, which is also deleted when its parent directory is empty after the subdirectory is deleted. If the entire path is deleted or a partial path is reserved for some reason, the system displays the appropriate 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 directory. If no directory is specified, the user's home directory is returned. In order to change to the specified directory, the user must have execute and Read permissions on the specified directory.

The command can use wildcard characters (see chapter tenth for the meaning of wildcards).


PWD
Command

In the Linux hierarchy, users can use the mkdir command to create a new directory under any authorized directory, or you can use the CD command to convert from one directory to another. However, there is no prompt to tell the user which directory is currently in. To know the current directory, you can use the PWD command, which displays the entire path name.

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, and its function is to list the contents of the directory. This is one of the most commonly used commands for users, because users need to view the contents of a directory from time to times. This command is similar to the dir command under DOS.

Syntax: LS [options] [directory or file]

For each directory, the command lists all subdirectories and files in it. For each file, LS will output its file name along with the additional information requested. By default, the output entries are sorted alphabetically. When a directory name or file name is not given, the current directory information 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 do not list "." and ".".

-B The non-displayed characters in the file name are displayed with octal escape characters.

-C Sort by the modified time of the file.

-C is divided into multiple columns to display the items.

-D If the parameter is a directory, only its name is displayed and the files below it are not displayed. Often used with the L option to get the details of the directory.

-F is not sorted. This option invalidates the LTS option and makes the AU option valid.

-F Mark "/" After the directory name, "*" After the executable file, Mark "@" after the symbol link, after the pipe (or FIFO) tag "|", after the socket file "=".

-I display the I node number of the file in the first column of the output.

-l Display the file details in a long format. This option is most commonly used.

The information listed in each row is: File type and permission link number file is the main file the group file size established or the last modified time name

For symbolic link files, the file name that is displayed is followed by the "-〉" and the reference file path name.

For a device file, its File size field displays the primary and secondary device numbers instead of the file size.

The total number of blocks in the catalog appears at the beginning of the long format list, which contains the indirect blocks.

-L If the specified name is a symbolic link file, the file to which the link points is displayed.

-m output in character stream format, file spread across pages, separated by commas.

-N The output format is the same as the L option, except that in the output Chinese the owner and the group are represented by the corresponding UID number and GID number, not the actual name.

-O is the same as the L option, except that the owner information is not displayed.

-P Add a "/" to the back of the directory.

-Q use "?" for non-displayed characters in the file name. Replace.

-R Displays the output in alphabetical order or first precedence.

-R recursively displays the files in each subdirectory of the specified directory.

-S gives the number of blocks used for each directory entry, including the indirect block.

-T is displayed by the modified time (most recently preferred) instead of by name. If the file is modified at the same time, it is in dictionary order. The modification time depends on whether you use the C or U top selection. The default time stamp is the last modification time.

-You are displayed by the time the file was last accessed (last preferred) rather than by name. The time stamp for-T is modified to the time of the last access.

-X Displays the information for each sort item by row.

The information displayed with the LS-L command begins with a 10-character string, where the first character represents a file type, which can be one of the following types:

-Normal file

Catalog D

L Symbolic Link

B-Block device files

C-Character device files

The following 9 characters represent the access rights of the file, divided into 3 groups and 3 bits per group.

The first group represents the permissions of the file owner, the second group represents the permissions of the same group of users, and the third group represents the permissions of the other users. Each group of three characters represents the read, write, and execute permissions on the file, respectively.

The permissions are as follows:

R Read

W Write

X execution. For the directory, the access permission is indicated.

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 executing process.

T set the flag bit (left in memory, not swapped out). If the file is a directory, the files in that directory can only be deleted by the superuser, the directory owner, or the file owner. If it is an executable file, the pointer to its body segment remains in memory after the file is executed. This will enable the system to load the file more quickly when it is executed again.

Create and Delete commands for the linux--directory

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.