The Linux operating directory (create, move, rename, delete, copy)

1. Create

mkdir [dirname] // create a single directory

mkdir -p newdir1 / newdir2 / newdir3 // recursively create multi-level directory

mkdir dir1 / dir2 / newdir3 // Create a directory in the existing directory

mkdir -p dir1 / newdir2 / newdir3 // recursively create multi-level directory in the existing directory

Create a directory mkdir / home / zhangsan / movie // use the 'absolute path' relative to the root directory of the way

Summary: When a new directory level is greater than 1, it is necessary -p parameter
2. Move

mv dir1 dir2 // dir1 dir2 moved to the directory of result: dir2 / dir1

mv dir1 / dir2 dir3 // dir2 moved to the directory dir3 results: dir3 / dir2

mv dir1 / dir2 dir3 / dir4 // dir2 moved to the directory dir4 results: dir3 / dir4 / dir2

mv / home / zhangsan / movie / home / lisi / video // movie moves to the next video catalog, the result: / home / lisi / video / movie

3. renamed

mv dir1 newdir // dir1 move to the current directory, and changed his name to newdir

mv dir1 / dir2 dir3 // dir2 dir3 move to the directory, and renamed formerly results: dir3 / dir2

mv dir1 / dir2 dir3 / newdir // dir2 dir3 move to the directory, and renamed newdir The, results: dir3 / newdir

4. Copy

cp -R dir1 dir2 // dir1 dir2 copied to the directory, Results: dir2 / dir1

cp -R dir1 / dir2 dir3 / newdir // copied to the next dir3 dir2 directory, and renamed newdir The, results: dir3 / newdir

cp -R dir1 / dir2 newdir // dir2 copied to the current directory, and renamed newdir

cp dir1 / file1 dir2 // file1 dir2 directory copied to the result: dir2 / file1

cp dir1 / file1 dir2 / dir3 / // copy file2 file1 to the next dir3 directory and renamed file2, result: dir2 / dir3 / file2

5. Delete

rm [filename] // delete files

rm -r [dirname] // delete directory

rm -rf [filename] // forced to delete files

rm -rf [dirname] // force delete directory recursively

rm -rf / // recursive forced to delete "/ slash" root directory (Once deleted, the system crashes, caution !!!)
---------------------
quote from article: https: //blog.csdn.net/liu537192/article/details/51490863

Guess you like

Origin www.cnblogs.com/guo-shuai/p/11280536.html