1. Create a directory/data. [[email protected][1] oldboystudy]# mkdir data[[email protected][1] oldboystudy]# lltotal 4drwxr-xr-x. 2 root root 4096 apr 11 09:49 data2. Create a file oldboy.txt below/data. [[email protected][1] oldboystudy]# cd data/[[email protected][1] data]# touch oldboy.txt[[email protected][1] data]# lltotal 0-rw-r--r--. 1 Root root 0 apr 11 09:53 oldboy.txt[[email protected][1] data] #3. added content for Oldboy.txt to "I am studying linux." [[email protected][1] data]# vim oldboy.txt [[email protected][1] Data]# cat oldboy.txt i am studying linux. [[Email protected][1] data] #4 . Copy the Oldboy.txt file to/tmp. [[email protected][1] data]# cp oldboy.txt /tmp [[email&nbsP;protected][1] data]# ll /tmp/total 8-rw-r--r--. 1 root root  21 APR 11 09:55 OLDBOY.TXTDRWX------. 2 root root 4096 jan 13 16:31 pulse-gmmrjfd7hg5z[[email protected][1] data] #5 . to move the/data directory to/root. [[email protected][1] oldboystudy]# lltotal 4drwxr-xr-x. 2 root root 4096 apr 11 10:01 data[[email protected][1] oldboystudy]# mv Data/ /root[[email protected][1] oldboystudy]# lltotal 0[[email protected] [1] oldboystudy]# cd[[email protected][1] ~]# lltotal 108-rw-r--r--. 1  ROOT ROOT   143 MAR 16 14:39 !-RW-------. 1 root Root 1554 dec 22 12:21 anaconda-ks.cfgdrwxr-xr-x. 2 root root 4096 apr&nbSp;11 10:01 data[[email protected][1] ~]# ll data/total 4-rw-r--r--. 1 root root 21 apr 11 09:55 oldboy.txt[[email protected][1] ~]# 6. Enter the data directory under the/root directory to delete the Oldboy.txt file. [[email protected][1] ~]# ll data/total 4-rw-r--r--. 1 root root 21 Apr 11 09:55 oldboy.txt[[email protected][1] ~]# [[email protected][1] ~]# [[email protected][1] ~]# [[email protected][1] ~]# cd data/[[email protected][1] data]# rm -f oldboy.txt #- F means to forcibly delete the file [[Email protected][1] data]# lltotal 0[[email protected][1] data] #7. 6th, exit to the previous level directory, delete the data directory. [[email protected][1] data]# cd[[email protected][1] ~]# rm -f data/rm: cannot remove ' data/': is a directory #必须加上-R parameter for recursive deletion [[email protected][1] ~]# rm - rf data/ #递归强制删除目录 [[email protected][1] ~] #8 . A command that does not contain a Oldboy string when the contents of the output Test.txt file are known to be:testliyaooldboy 9. by the test.txt content of the file. [[email protected][1] oldboystudy]# cat test.txt testliyaooldboy[[email protected][1] oldboystudy]# tail -n 2 test.txt liyaooldboy[[email protected ][1] oldboystudy] #10 . Use a command to complete the creation of the directory/oldboy/test, which is to create/oldboy directory and/oldboy/test directory [[email protected][1] oldboystudy]# mkdir -p /oldboy/test[[email protected][1] Oldboystudy]# cd /oldboy/test/[[email protected][1] test] #Mkdir常用的参数介绍: -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask -p, --parents no error if existing, make parent directories as needed#- The P parameter indicates that the parent directory is created directly when the parent directory does not exist, as in the case where the/oldboy directory does not exist and the test directory is created by using the-p parameter to automatically create the parent directory of the test catalog. -v, --verbose print a message for each Created directory -z, --context=ctx set the selinux security context of each created directory to CTX --help display this help and exit --version output version information and exit11. Known that the Test.txt file already exists in/tmp, how to execute the command in order to/mnt/test.txt copy to/tmp to cover the/tmp/test.txt, and let the system not prompt for overwrite (root permission). [[email protected][1] ~]# cp -f -r /mnt/test.txt /tmp/test.txt cp: overwrite '/tmp/test.txt '? [[email protected][ 1] ~]# #理论上来说,-R for recursion,-F for coercion. Added the-R and-F parameters will not be prompted to overwrite the situation, but the actual situation will still prompt whether to overwrite, what reason? is the alias in mischief, see below: [[email protected][1] ~]# aliasalias cp= ' cp -i ' alias l.= ' ls -d .* --color=auto ' alias ll= ' ls -l --color=auto ' alias ls= ' Ls --color=auto ' alias mv= ' mv -i ' alias rm= ' rm -i ' This means that the Execute CP command actually executes the cp –i command. Then we want to overwrite with the CP command without prompting for overwrite, we need to modify alias. [[email protected][1] ~]# cat ~/.bashrc# .bashrc# user specific Aliases and functionsalias rm= ' rm -i ' #alias cp= ' cp -i ' # Comment out the CP-related alias alias mv= ' Mv -i ' # source global definitionsif [ -f /etc/ bashrc ]; then. /etc/bashrcfi[[email protected][1] ~]# #注释掉后重新登录即可. Attach the CP command related parameters:-r, -r, --recursive copy directories recursively -- reflink[=when] control clone/cow copies. See below. --remove-destination remove each existing destination file before attempting to open it (Contrast with --force) --sparse=WHEN control creation of sparse files. See below. --strip-trailing-slashes remove any trailing slashes from each source argument-f, -- force if an existing destination file cannot be opened, remove it and try again (redundant if the -n option is used) 12. only see the contents of lines 20th through 30th in the/etc/passwd file (total 100 lines) Head -n 30 /etc/passwd | tail -n +20
This article is from the "Mangguo" blog, make sure to keep this source http://mangguostudy.blog.51cto.com/5643869/1632185
"Linux Practice" basic job One