CentOS common commands to create and delete cut links

1. Create a directory mkdir

The command mkdir is used to create directories such as

but does not support cascade creation

Add -p to create cascading directories

2. Delete the empty directory rmdir

1 The rmdir command can only delete empty directories, but not files. If there are files in the directory, they cannot be deleted. Generally, it is not used.

2. The command rm can delete files, but cannot delete directories

-r option for deleting directories, you can delete non-empty directories, but you need to ask whether to delete

And you can delete files in non-empty directories, but you need to ask whether to delete

-f Force delete, without asking whether to delete, delete directly.

-rf Combine the options -r and -f to delete the directory and the files in the directory. You cannot add / after -rf, otherwise all system files will be deleted.

 

3. Copy command cp[option ][source file or directory ][target directory ]

1. You can copy files, but you need to add the -r option to copy directories

2. Rename the copied file ( cp filename to be copied.cfg/directory /new filename.cfg )

   

3. Options

-r To copy a directory, the -r option must be added, otherwise it cannot be copied

-i is a security option, if an existing file is encountered, it will ask whether to overwrite

-p copy with file attributes

-d If the source file is a linked file, copy link attributes

-a is equivalent to -pdr

 

4. Cut or rename command: mv (move) mv [original file or directory ] [target directory ]

1. When the target directory does not exist, a new target directory will be created.

5. Link command: ln ( link)

1. Hard link: slightly

2. Soft link: There is an existing file a, and a soft link file b (very small) is generated, and b points to a. When b is read , b forwards the read operation to a, which reads a. When you want to delete a, the linked file b will not be deleted, but if you read b again, you will be prompted that the file cannot be opened. delete b, it will not affect a

3. Command ln-s[source file name ][link file name ]: generate a link file, -s creates a soft link, and no -s is a hard link.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324746927&siteId=291194637