1.在/home目录及其子目录中,查找2天前被更改过的文件
[root@localhost ~]# find /home/ -mtime +2
/home/redhat/.mozilla
/home/redhat/.mozilla/extensions
/home/redhat/.mozilla/plugins
/home/redhat/.bash_logout
/home/redhat/.bash_profile
/home/redhat/.bashrc
/home/redhat/.bash_history
/home/redhat/.cache
/home/user1/.mozilla
/home/user1/.mozilla/extensions
/home/user1/.mozilla/plugins
/home/user1/.bash_logout
/home/user1/.bash_profile
/home/user1/.bashrc
/home/user2/.mozilla
/home/user2/.mozilla/extensions
/home/user2/.mozilla/plugins
/home/user2/.bash_logout
/home/user2/.bash_profile
/home/user2/.bashrc
[root@localhost ~]#
2.在/etc目录下寻找以host开头的文件
[root@localhost ~]# find /etc -name "host*"
/etc/host.conf
/etc/hosts
/etc/avahi/hosts
/etc/hostname
[root@localhost ~]#
3.在/test下查找目录文件
[root@localhost ~]# find /test -type d
/test
4.在/test目录及其子目录,查找超过2k的文件打包压缩
[root@localhost ~]# find /test -size +2k |xargs zip
5.将/test下所有文件和文件夹全部压缩为myfile.zip文件
[root@localhost ~]# zip -r /myfile.zip /test/
6.把myfile.zip文件解压缩到/opt
[root@localhost ~]# unzip /myfile.zip -d /opt
7.将/opt下文件全部打包并用gzip压缩成/test/newfile.tar.zp
[root@localhost test]# tar -czPf newfile.tar.gz /opt
8.查看文件/test/newfile.tar.gz文件中有哪些文件
[root@localhost test]# tar -tf newfile.tar.gz
tar: Removing leading `/' from member names
/opt/
/opt/test/
/opt/test/file.lnk
/opt/test/aa
/opt/test/file.zip
9.在/test目录内,备份/etc下的所有文件并保留其权限
[root@localhost ~]# cp -rp /test /etc/test.
10.写一个命令为hello,实现的功能为每输入一次hello命令,就有hello,everyone写入文件/file.txt中(当前用户)
11.写一个命令别名为shuaxin,实现的功能为每输入一次该命令,file.txt文件的所有时间都更新为当前时间。(当前用户)
[root@localhost ~]# vim ~/.bashrc 进入~/.bashrc文件
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias hello='echo hello,everyone >> /file.txt' 添加别名
alias shuaxin='touch /file.txt'
# Source global definitions
[root@localhost ~]# source ~/.bashrc
11.写一个所有用户都生效的命令别名hh,每一个用户输入这个命令之后可以在该用户家目录下创建一个file1文件
(1)进入/etc/bashrc文件
[root@localhost ~]# vim /etc/bashrc
(2)添加别名
(3)
[root@localhost ~]# source /etc/bashrc
12.新建一个用户sarah,不属于adminuser组,并将其shell设置为不可登录的shell
[root@localhost ~]# useradd -M -s /sbin/nologin sarah
[root@localhost ~]# tail -1 /etc/passwd
sarah:x:1089:1089::/home/sarah:/sbin/nologin
13.创建alex用户,使alex用户满足:用户id为3456,描述名为alian,密码为glegunge
[root@localhost ~]# useradd -c alian -u 3456 -p glegunge alex
[root@localhost ~]# tail -1 /etc/passwd
alex:x:3456:3456:alian:/home/alex:/bin/bash