root@xx:~# adduser echin info: Adding user `echin' ... info: Selecting UID/GID from range 1000 to 59999 ... info: Adding new group `echin' (1000) ... info: Adding new user `echin' (1000) with group `echin (1000)' ... info: Creating home directory `/home/echin' ... info: Copying files from `/etc/skel' ... New password: echin Retype new password: echin Sorry, passwords do not match. passwd: Authentication token manipulation error passwd: password unchanged Try again? [y/N] y New password: Retype new password: passwd: password updated successfully Changing the user information for echin Enter the new value, or press ENTER for the default Full Name []: echin Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y info: Adding new user `echin' to supplemental / extra groups `users' ... info: Adding user `echin' to group `users' ...
# 就是将 file1,file2,file3等文件打包成xxx.tar形式的档案 # 一个目录打包 tar -cvf example.tar example # 多个目录打包 tar -cvf xxx.tar file1 file2 file3
例子:
1 2 3 4 5 6 7 8 9 10
echin@ip:~$ tar -cvf xxx.tar hello world hello/ hello/example/ hello/example/example4/ hello/example/example4/tt.txt hello/example/tt.txt hello/tt.txt world/ echin@iZbp19bvr4g3vqr24ft07rZ:~$ ls hello world xxx.tar
# 解压到当前目录中 tar -xvf xxx.tar # 解压到指定目录下 注意这个`C`必须要为大写 tar -xvf xxx.tar -C outDir
例子1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
echin@ip:~$ ls hello world xxx.tar echin@iZbp19bvr4g3vqr24ft07rZ:~$ rm -rf hello echin@iZbp19bvr4g3vqr24ft07rZ:~$ rm -rf world echin@iZbp19bvr4g3vqr24ft07rZ:~$ ls xxx.tar echin@ip:~$ tar -xvf xxx.tar hello/ hello/example/ hello/example/example4/ hello/example/example4/tt.txt hello/example/tt.txt hello/tt.txt world/ echin@iZbp19bvr4g3vqr24ft07rZ:~$ ls hello world xxx.tar
例子2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
echin@ip:~$ tar -xvf xxx.tar -c world/ tar: You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option Try 'tar --help' or 'tar --usage'for more information. echin@ip:~$ tar -xvf xxx.tar -C world/ hello/ hello/example/ hello/example/example4/ hello/example/example4/tt.txt hello/example/tt.txt hello/tt.txt world/ echin@ip:~$ cd world/ echin@ip:~/world$ ls hello world
echin@i:~$ ls hello world xxx.tar echin@r:~$ tar -czvf aaa.tar.gz world world/ world/hello/ world/hello/example/ world/hello/example/example4/ world/hello/example/example4/tt.txt world/hello/example/tt.txt world/hello/tt.txt world/world/ echin@i:~$ ls aaa.tar.gz hello world xxx.tar echin@i:~$ rm -rf hello world echin@i:~$ ls aaa.tar.gz xxx.tar echin@i:~$ tar -xzvf aaa.tar.gz world/ world/hello/ world/hello/example/ world/hello/example/example4/ world/hello/example/example4/tt.txt world/hello/example/tt.txt world/hello/tt.txt world/world/ echin@i:~$ ls aaa.tar.gz world xxx.tar
echin@i:/root$ cd /home/echin echin@i:~$ ls aaa.tar.gz world xxx.tar echin@i:~$ ln -s world link echin@i:~$ ls aaa.tar.gz link world xxx.tar #在服务器的显示中link的颜色是与其他有区别的--蓝色 echin@iZbp19bvr4g3vqr24ft07rZ:~$ ls aaa.tar.gz link world xxx.tar echin@i:~$ cdlink echin@i:~/link$ ls hello world
echin@i:~$ ls -l total 20 -rw-rw-r-- 1 echin echin 264 May 30 13:09 aaa.tar.gz lrwxrwxrwx 1 echin echin 5 May 30 17:17 link -> world drwxrwxr-x 4 echin echin 4096 May 30 13:03 world -rw-rw-r-- 1 echin echin 10240 May 30 12:56 xxx.tar