目录
(1)在/test目录下创建一个子目录dir,将/etc/passwd复制到该目录
(2)将/etc/ssh/sshd_config文件复制到/test目录
(3)将/etc/yum.repos.d/目录复制到/test目录
(1)在$HOME目录及其子目录中,查找2天前被更改过的文件
(1)将/test目录下的所有文件和文件夹全部压缩成myfile.zip文件
(3)将/opt目录下的文件全部打包并用gzip压缩成/test/newfile.tar.gz
一、第5章思维导图
二、第6章思维导图
三、文件操作
1、复制、移动
(1)在/test目录下创建一个子目录dir,将/etc/passwd复制到该目录
[root@xixi ~]# cd /test
[root@xixi test]# mkdir dir
[root@xixi test]# ls
bashrc file motd.hard passwd sshd.conf
dir group motd.soft profile sshd_config
[root@xixi test]# cp /etc/passwd /test/dir
[root@xixi test]# ls /test/dir
passwd
(2)将/etc/ssh/sshd_config文件复制到/test目录
[root@xixi test]# cp /etc/ssh/sshd_config /test
(3)将/etc/yum.repos.d/目录复制到/test目录
[root@xixi test]# cp -r /etc/yum.repos.d/ /test
[root@xixi test]# ls /test
bashrc file motd.hard passwd sshd.conf yum.repos.d
dir group motd.soft profile sshd_config
2、文件查找
(1)在$HOME目录及其子目录中,查找2天前被更改过的文件
[root@xixi ~]# find /home -mtime +1
(2)在/etc/目录下寻找以host开头的文件
[root@xixi ~]# find /etc/ -name host*
/etc/host.conf
/etc/hosts
/etc/avahi/hosts
/etc/hostname
/etc/nvme/hostnqn
/etc/nvme/hostid
(3)在/test/下面查找目录文件
[root@xixi ~]# find /test -type d
/test
/test/dir
/test/yum.repos.d
3、打包压缩
(1)将/test目录下的所有文件和文件夹全部压缩成myfile.zip文件
[root@xixi test]# zip -r myfile.zip /test
adding: test/ (stored 0%)
adding: test/profile (deflated 10%)
adding: test/motd.soft (deflated 3%)
adding: test/motd.hard (deflated 3%)
adding: test/file (deflated 21%)
adding: test/sshd.conf (deflated 54%)
adding: test/passwd (deflated 38%)
adding: test/bashrc (deflated 33%)
adding: test/sshd_config (deflated 55%)
adding: test/group (stored 0%)
adding: test/dir/ (stored 0%)
adding: test/dir/passwd (deflated 61%)
adding: test/yum.repos.d/ (stored 0%)
adding: test/yum.repos.d/redhat.repo (deflated 37%)
(2)把myfile.zip文件解压到 /opt
[root@xixi test]# unzip myfile.zip -d /opt
Archive: myfile.zip
creating: /opt/test/
inflating: /opt/test/profile
inflating: /opt/test/motd.soft
inflating: /opt/test/motd.hard
inflating: /opt/test/file
inflating: /opt/test/sshd.conf
inflating: /opt/test/passwd
inflating: /opt/test/bashrc
inflating: /opt/test/sshd_config
extracting: /opt/test/group
creating: /opt/test/dir/
inflating: /opt/test/dir/passwd
creating: /opt/test/yum.repos.d/
inflating: /opt/test/yum.repos.d/redhat.repo
(3)将/opt目录下的文件全部打包并用gzip压缩成/test/newfile.tar.gz
[root@xixi opt]# tar -czvf /test/newfile.tar.gz /opt
tar: Removing leading `/' from member names
/opt/
/opt/test/
/opt/test/profile
/opt/test/motd.soft
/opt/test/motd.hard
/opt/test/file
/opt/test/sshd.conf
/opt/test/passwd
/opt/test/bashrc
/opt/test/sshd_config
/opt/test/group
/opt/test/dir/
/opt/test/dir/passwd
/opt/test/yum.repos.d/
/opt/test/yum.repos.d/redhat.repo