Linux file directory base notes

4418040-03dfa6315644def4

1, enter the directory name: cd

mainly cd command instruction to switch to a different user directories.

For example: cd # cd command to execute only the default root directory into the root

cd / home # to enter the home directory, if the directory has testdir home directory, you can execute cd testdir enter testdir directory.

2. Create a directory command: mkdir

Format: mkdir dirname #dirname refers to the name of the directory created.

For example: mkdir testdir # testdir directory will be created in the current directory operation

mkdir -p testdir/testdir2

 # -P parameter create multiple directories, the command will create testdir then creates a directory under testdir2 testdir

mkdir -p /home/testdir/testdir1/testdir3 

# Create a multi-layer structure by way of absolute directory path

3, delete the directory command: rmdir and rm

rmdir: to remove a directory, provided that the directory must be empty directory, otherwise the system will prompt can not be deleted.

For example: rmdir testdir # testdir delete the current directory in the directory, you need to ensure that testdir is empty.

rm: This command can be used to delete a file, you can also delete the need to add a -r parameter when deleting directory directory.

For example: rm -r testdir # delete all files and directories and directory testdir inside. Execute the command to delete a file or directory each time you need to confirm Y will execute successfully, if testdir which contains hundreds of files, you need to confirm hundreds of times

This is very tedious, which is the Linux system to fully consider the safety of the system, every time you delete a file to remind confirm. If you do not think you can confirm the -r replaced -rf. The system will not go to confirm the reminder.

But the command is executed must pay attention, because after deleting basically impossible to recover.

4, file and directory replication directory: CP

File Copy

Format: cp filename dir / filenamenew # The first argument filename: to copy the source file, the second parameter indicates the name of the file to be copied to the directory or copy.

For example: cp hello.txt /home/hellonew.txt

Directory Replication

Format cp -r dir dirnew # need to add -r command

For example: cp -r testdir testdirnew

Reproduced in: https: //www.jianshu.com/p/5448b5f7efdc

Guess you like

Origin blog.csdn.net/weixin_34247032/article/details/91333383