Bo's Oracle Station

查看: 1639|回复: 0

课程第12次

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2019-5-7 20:38:51 | 显示全部楼层 |阅读模式
2019-05-07
tar -k/-C选项和文件路径:
  1. bash-4.2# ls
  2. 1.txt
  3. bash-4.2# tar zcvf ../labs.tgz  ./
  4. ./
  5. ./1.txt
  6. bash-4.2# ls
  7. 1.txt
  8. bash-4.2# cd ..
  9. bash-4.2# ls
  10. ca-agent.p12  Desktop         Downloads  labs.tgz  Pictures        Templates
  11. cacert.p12    Documents  labs            Music     Public        Videos
  12. bash-4.2# rm -rf labs
  13. bash-4.2# ls
  14. ca-agent.p12  Desktop         Downloads  Music     Public         Videos
  15. cacert.p12    Documents  labs.tgz   Pictures  Templates
  16. bash-4.2# mkdir labs
  17. bash-4.2# cd labs
  18. bash-4.2# ls
  19. bash-4.2# tar zxvf ../labs.tgz
  20. ./
  21. ./1.txt
  22. bash-4.2# ls
  23. 1.txt
  24. bash-4.2# tar ztvf ../labs.tgz
  25. drwxr-xr-x root/root         0 2019-05-07 08:31 ./
  26. -rw-r--r-- root/root        20 2019-04-04 09:59 ./1.txt
  27. bash-4.2# ls
  28. 1.txt
  29. bash-4.2# cd /
  30. bash-4.2# ls
  31. bin   botang  etc   lib    lost+found  mnt  proc   root  sbin  sys  usr
  32. boot  dev     home  lib64  media       opt  rhost  run         srv   tmp  var
  33. bash-4.2# tar zcvf labsnew.tgz  /root/labs
  34. tar: Removing leading `/' from member names
  35. /root/labs/
  36. /root/labs/1.txt
  37. bash-4.2# cd /root/
  38. bash-4.2# ls
  39. ca-agent.p12  Desktop         Downloads  labs.tgz  Pictures        Templates
  40. cacert.p12    Documents  labs            Music     Public        Videos
  41. bash-4.2# rm -rf labs
  42. bash-4.2# cd /
  43. bash-4.2# ls
  44. bin        dev   labsnew.tgz  lost+found  opt    root  srv  usr
  45. boot        etc   lib           media       proc   run   sys  var
  46. botang        home  lib64           mnt               rhost  sbin  tmp
  47. bash-4.2# mv labsnew.tgz   /tmp/
  48. bash-4.2# cd /tmp/
  49. bash-4.2# ls
  50. hsperfdata_pkiuser
  51. labsnew.tgz
  52. ssh-IixMSBI7647L
  53. systemd-private-4c44fb5523354b269e132965198e945f-bolt.service-NG8bbB
  54. systemd-private-4c44fb5523354b269e132965198e945f-colord.service-2eUe8T
  55. systemd-private-4c44fb5523354b269e132965198e945f-cups.service-uQgvN4
  56. systemd-private-4c44fb5523354b269e132965198e945f-fwupd.service-sC8t5T
  57. systemd-private-4c44fb5523354b269e132965198e945f-httpd.service-SwlNKq
  58. systemd-private-4c44fb5523354b269e132965198e945f-ipa-custodia.service-8ITicw
  59. systemd-private-4c44fb5523354b269e132965198e945f-ntpd.service-W79cGM
  60. systemd-private-4c44fb5523354b269e132965198e945f-rtkit-daemon.service-5mobth
  61. systemd-private-4c44fb5523354b269e132965198e945f-systemd-machined.service-bmllan
  62. tracker-extract-files.0
  63. vmware-root_6905-4156336045
  64. bash-4.2# tar -C / -zxvf labsnew.tgz
  65. root/labs/
  66. root/labs/1.txt
  67. bash-4.2# cd /root/
  68. bash-4.2# cd labs
  69. bash-4.2# ls
  70. 1.txt
  71. bash-4.2#
复制代码
  1. [root@station60 labs]# cd ..
  2. [root@station60 ~]# rm -rf labs
  3. [root@station60 ~]# cd /
  4. [root@station60 /]# tar ztvf labsa.tgz
  5. drwxrwxr-x root/root         0 2019-04-29 09:45 root/labs/
  6. -rwxr-xr-x root/root         8 2019-04-29 08:44 root/labs/1.sh
  7. -rwxr-xr-x root/root        12 2019-04-29 08:46 root/labs/2.sh
  8. -rwxr-xr-x root/root        24 2019-04-29 09:37 root/labs/3.sh
  9. -rwxr-xr-x root/root         8 2019-04-29 09:41 root/labs/5.sh
  10. -rwxr-xr-x root/root        21 2019-04-29 09:42 root/labs/4.sh
  11. [root@station60 /]# tar -zxvf labsa.tgz  -k root/labs/3.sh   
  12. root/labs/3.sh
  13. [root@station60 /]# cd /root/labs
  14. [root@station60 labs]# ls
  15. 3.sh
复制代码
diff/rsync
  1. root@station60 ~]# ls
  2. anaconda-ks.cfg  Downloads             labs2      Pictures  Templates
  3. Desktop          initial-setup-ks.cfg  Music      Public    Videos
  4. Documents        labs                  nohup.out  swap.gz
  5. [root@station60 ~]# cd labs
  6. [root@station60 labs]# ls
  7. 3.sh
  8. [root@station60 labs]# touch 6.sh
  9. [root@station60 labs]# ls
  10. 3.sh  6.sh
  11. [root@station60 labs]# cd ..
  12. [root@station60 ~]# ls
  13. anaconda-ks.cfg  Downloads             labs2      Pictures  Templates
  14. Desktop          initial-setup-ks.cfg  Music      Public    Videos
  15. Documents        labs                  nohup.out  swap.gz
  16. [root@station60 ~]# diff -r labs labs2
  17. Only in labs: 6.sh
  18. [root@station60 ~]# rsync -avH --delete -n   labs labs2  
  19. sending incremental file list
  20. labs/
  21. labs/3.sh
  22. labs/6.sh

  23. sent 109 bytes  received 22 bytes  262.00 bytes/sec
  24. total size is 24  speedup is 0.18 (DRY RUN)
  25. [root@station60 ~]# ls
  26. anaconda-ks.cfg  Downloads             labs2      Pictures  Templates
  27. Desktop          initial-setup-ks.cfg  Music      Public    Videos
  28. Documents        labs                  nohup.out  swap.gz
  29. [root@station60 ~]# cd labs
  30. [root@station60 labs]# ls -l
  31. total 4
  32. -rwxr-xr-x. 1 root root 24 Apr 29 09:37 3.sh
  33. -rw-r--r--. 1 root root  0 May  7 09:25 6.sh
  34. [root@station60 labs]# stat 3.sh
  35.   File: ‘3.sh’
  36.   Size: 24                Blocks: 8          IO Block: 4096   regular file
  37. Device: fd00h/64768d        Inode: 18286293    Links: 1
  38. Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
  39. Context: unconfined_u:object_r:admin_home_t:s0
  40. Access: 2019-05-07 09:24:46.328498088 -0400
  41. Modify: 2019-04-29 09:37:00.685457467 -0400
  42. Change: 2019-05-07 09:21:11.620563195 -0400
  43. Birth: -
  44. [root@station60 labs]# stat  /root/labs2/3.sh
  45.   File: ‘/root/labs2/3.sh’
  46.   Size: 24                Blocks: 8          IO Block: 4096   regular file
  47. Device: fd00h/64768d        Inode: 33575664    Links: 1
  48. Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
  49. Context: unconfined_u:object_r:admin_home_t:s0
  50. Access: 2019-05-07 09:25:31.672695525 -0400
  51. Modify: 2019-04-29 09:37:00.685457467 -0400
  52. Change: 2019-05-07 09:24:46.328498088 -0400
  53. Birth: -
  54. [root@station60 labs]#
复制代码
  1. [root@station60 labs]# rsync -aAXvH --delete  192.168.0.61:/root/labs/  ./
  2. Password:
  3. Password:
  4. receiving incremental file list

  5. sent 25 bytes  received 238 bytes  19.48 bytes/sec
  6. total size is 73  speedup is 0.28
  7. [root@station60 labs]# ls -Z
  8. -rwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 1.sh
  9. -rwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 2.sh
  10. -rwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 3.sh
  11. -rwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 4.sh
  12. -rwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 5.sh
  13. [root@station60 labs]# lsattr
  14. ---------------- ./3.sh
  15. ---------------- ./1.sh
  16. ---------------- ./2.sh
  17. ---------------- ./4.sh
  18. ---------------- ./5.sh
  19. [root@station60 labs]# lsattr
复制代码
rysnc  标准/   要同步的目录/

不写/的后果:
  1. [root@station60 labs]# rsync -avH --delete  192.168.0.61:/root/labs  ./
  2. Password:
  3. receiving incremental file list
  4. labs/
  5. labs/1.sh
  6. labs/2.sh
  7. labs/3.sh
  8. labs/4.sh
  9. labs/5.sh

  10. sent 123 bytes  received 415 bytes  97.82 bytes/sec
  11. total size is 73  speedup is 0.14
  12. [root@station60 labs]# ls
  13. 1.sh  2.sh  3.sh  4.sh  5.sh  labs
  14. [root@station60 labs]#
复制代码





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-19 17:43 , Processed in 0.036365 second(s), 24 queries .

快速回复 返回顶部 返回列表