1、文件查找
(1)在当前目录及子目录中,查找大写字母开头的txt文件
[root@localhost ~]# find {^A-Z}.txt
(2)在/etc及其子目录中,查找host开头的文件
[root@localhost etc]# cd /etc
[root@localhost etc]# find host*
(3)在$HOME目录及其子目录中,查找所有文件
[root@localhost ~]# find /home
(4)忽略文件名大小写查找a.txt
[root@localhost ~]# find -iname "a.txt"
2、查找文件 /usr/share/rhel.xml 中包含字符串 re 的所有行。将所有这些行的副本按原始顺序放在文件/root/files 中
[root@localhost ~]# cat /usr/share/rhel.xml | grep re > /root/files
3、将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz
[root@localhost ~]# tar -cvf /back/etcback.tar.gz /etc
4、使当前用户永久生效的命令别名:写一个命令命为hello,实现的功能为每输入一次hello命令,就有hello,everyone写入文件/file.txt中。
[root@localhost ~]# vim .bashrc
alias hello=echo hello,everyone >> /file.txt
5、创建mygroup组群,再创建myuser用户,并且此用户属于mygroup组群,接着以myuser身份登录,创建ex和hv两个文件于/home/myuser目录,并使hv文件的同组用户是root。请依次写出相应执行的命令。
[root@localhost ~]# groupadd mygroup
[root@localhost ~]# useradd myuser
[root@localhost ~]# gpasswd -a myuser mygroup
[root@localhost ~]# su myuser
[myuser@localhost root]$ cd /home/myuser
[myuser@localhost ~]$ touch ex hv
6、设置权限,要求如下:创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[root@localhost ~]# groupadd g1
[root@localhost ~]# useradd redhat
[root@localhost ~]# su redhat
[redhat@localhost root]$ touch redhat.txt