1、将 整 个 /etc 目 录 下 的 文 件 全 部 打 包 并 用 gzip 压 缩 成/back/etcback.tar.gz
[root@localhost /]# tar -czvf /back/etcback.tar.gz etc
etc/
etc/mtab
etc/fstab
etc/crypttab
etc/dnf/
tar (child): /back/etcback.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
etc/dnf/modules.d/
etc/dnf/modules.d/container-tools.module
etc/dnf/modules.d/llvm-toolset.module
etc/dnf/modules.d/perl-DBD-SQLite.module
etc/dnf/modules.d/perl-DBI.module
etc/dnf/modules.d/python36.module
etc/dnf/modules.d/satellite-5-client.module
2、查看 /back/etcback.tar.gz 文件中有哪些文件?
[root@localhost ~]# tar -tvf etcback.tar.gz
drwxr-xr-x root/root 0 2022-10-23 21:24 etc/
lrwxrwxrwx root/root 0 2022-10-23 21:17 etc/mtab -> ../proc/self/mounts
-rw-r--r-- root/root 579 2022-10-23 21:15 etc/fstab
-rw------- root/root 0 2022-10-23 21:15 etc/crypttab
drwxr-xr-x root/root 0 2022-10-23 21:15 etc/dnf/
drwxr-xr-x root/root 0 2019-09-03 15:41 etc/dnf/modules.d/
-rw-r--r-- root/root 76 2022-10-23 21:15 etc/dnf/modules.d/container-tools.module
-rw-r--r-- root/root 70 2022-10-23 21:15 etc/dnf/modules.d/llvm-toolset.module
-rw-r--r-- root/root 75 2022-10-23 21:15 etc/dnf/modules.d/perl-DBD-SQLite.module
-rw-r--r-- root/root 62 2022-10-23 21:15 etc/dnf/modules.d/perl-DBI.module
3、将/back/etcback.tar.gz 解压到 /tmp 目录。
tar tvf etcback.tar.gz
4、当前用户永久生效的命令别名 ~/.bashrc
1)写一个命令命为hello,实现的功能为每输入一次hello命令,就有hello,everyone写入文件/file.txt中。
2)写一个命令别名为shuaxin,实现的功能为每输入一次该命令,file.txt文件的所有时间就更新为当前时间。
[root@localhost ~]# alias hello="echo hello,everyone > /file.txt"
[root@localhost ~]# alias shuaxin="touch -a file.txt"
[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias hello='echo hello,everyone > /file.txt'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias shuaxin='touch -a file.txt'
alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
alias xzegrep='xzegrep --color=auto'
alias xzfgrep='xzfgrep --color=auto'
alias xzgrep='xzgrep --color=auto'
alias zegrep='zegrep --color=auto'
alias zfgrep='zfgrep --color=auto'
alias zgrep='zgrep --color=auto'
5、统计显示用户配置文件nologin 出现的次数
[root@localhost ~]# grep -c nologin /etc/passwd
39
6、 查找2天内被更改过的文件
[root@localhost ~]# find -type f -mtime -2
./.cache/tracker/meta.db
./.cache/tracker/meta.db-wal
./.cache/tracker/meta.db-shm
./.cache/tracker/locale-for-miner-apps.txt
./.config/ibus/bus/9aff53ff776d425c8149251317c6dce2-unix-0
./.config/pulse/9aff53ff776d425c8149251317c6dce2-default-sink
./.config/pulse/9aff53ff776d425c8149251317c6dce2-default-source
./.config/dconf/user
./.config/gtk-3.0/bookmarks
./.ICEauthority
./.local/share/evolution/addressbook/system/contacts.db
./.local/share/tracker/data/tracker-store.journal
./.local/share/tracker/data/.meta.isrunning
./.bash_history
./etcback.tar.gz