
1、复制、移动
语法: cp [选项] 源文件 目标文件
(1)在/test目录下创建一个子目录dir,将/etc/passwd复制到该目录
[root@xixi ~]# cp -a /etc/passwd /test/dir
(2)将/etc/ssh/sshd config文件复制到/test目录
[root@xixi ~]# cp -a /etc/ssh/ssh_config /test
cp: overwrite '/test/ssh_config'? y
(3)将/etc/yum.repos.d/目录复制到/test目录
[root@xixi ~]# cp -a /etc/yum.repos.d /test
2、文件查找
find [选项] [路径] [查找条件] [处理动作]
详细find教学:
(39条消息) RHCSA-A11.查找文件_白-胖-子的博客-CSDN博客
(1)在$HOME目录及其子目录中,查找2天前被更改过的文件
[root@xixi ~]# find -mtime +2 -type f -print
(2)在/etc/目录下寻找以host开头的文件
[root@xixi ~]# find /etc -name "host*" -print
(3)在/test/下面查找目录文件
[root@xixi ~]# find /etc -type d
3、打包压缩
(39条消息) RHCSA之基本命令_归档和压缩命令篇(gzip.bzip2.tar)_SLASH-YONG的博客-CSDN博客
(1)将/test目录下的所有文件和文件夹全部压缩成myfile.zip文件
[root@xixi test]# zip myfile.zip file
(2)把myfile.zip文件解压到/opt
[root@xixi test]# tar -zcvf test.tar.gz test
(3)将/opt目录下的文件全部打包并用gzip压缩成/test/newfile.tar.gz
[root@xixi test]# tar -zcvf /test/newfile.tar.gz /opt