RHCSA之路

第四天作业

1> 在当前目录及子目录中,查找大写字母开头的txt文件

[root@localhost ~]# touch A.txt
[root@localhost ~]# touch B.txt
[root@localhost ~]# find . -name "[A-Z]*" -a -name "*.txt"
./A.txt
./B.txt


2> 在/etc及其子目录中,查找host开头的文件

[root@localhost ~]# find /etc -name "host*"
/etc/host.conf
/etc/hosts
/etc/avahi/hosts
/etc/hostname
/etc/nvme/hostnqn
/etc/nvme/hostid


3> 在$HOME目录及其子目录中,查找所有文件

[root@localhost ~]# find $HOME -type f
/root/.bash_logout
/root/.bash_profile
/root/.bashrc
/root/.cshrc
/root/.tcshrc
/root/anaconda-ks.cfg
/root/.cache/dconf/user
/root/.cache/tracker/db-version.txt
/root/.cache/tracker/meta.db
/root/.cache/tracker/db-locale.txt
/root/.cache/tracker/meta.db-wal
/root/.cache/tracker/meta.db-shm
/root/.cache/tracker/ontologies.gvdb
/root/.cache/tracker/parser-version.txt
/root/.cache/tracker/locale-for-miner-apps.txt
/root/.cache/tracker/last-crawl.txt
/root/.cache/tracker/first-index.txt
/root/.cache/event-sound-cache.tdb.f13823a8fa3e43329b755c2269e19612.x86_64-redhat-linux-gnu
/root/.cache/gnome-software/appstream/components.xmlb
/root/.cache/gnome-software/shell-extensions/gnome.json
/root/.cache/gnome-software/shell-extensions/extensions-web.xmlb
/root/.cache/gnome-software/flatpak-system-default/components.xmlb
/root/.cache/gnome-software/flatpak-user-user/components.xmlb
/root/.cache/gnome-software/odrs/ratings.json
/root/.cache/gstreamer-1.0/registry.x86_64.bin
/root/.cache/yelp/WebKitCache/Version 16/salt
/root/.dbus/session-bus/f13823a8fa3e43329b755c2269e19612-9
/root/.config/ibus/bus/f13823a8fa3e43329b755c2269e19612-unix-0
/root/.config/dconf/user
/root/.config/evolution/sources/system-proxy.source
/root/.config/user-dirs.dirs
/root/.config/user-dirs.locale
/root/.config/pulse/f13823a8fa3e43329b755c2269e19612-device-volumes.tdb
/root/.config/pulse/f13823a8fa3e43329b755c2269e19612-stream-volumes.tdb
/root/.config/pulse/f13823a8fa3e43329b755c2269e19612-card-database.tdb
/root/.config/pulse/cookie
/root/.config/pulse/f13823a8fa3e43329b755c2269e19612-default-sink
/root/.config/pulse/f13823a8fa3e43329b755c2269e19612-default-source
/root/.config/gtk-3.0/bookmarks
/root/.config/gnome-initial-setup-done
/root/.config/yelp/yelp.cfg
/root/initial-setup-ks.cfg
/root/.ICEauthority
/root/.local/share/gnome-shell/gnome-overrides-migrated
/root/.local/share/evolution/addressbook/system/contacts.db
/root/.local/share/evolution/calendar/system/calendar.ics
/root/.local/share/gsettings-data-convert
/root/.local/share/flatpak/repo/config
/root/.local/share/flatpak/.changed
/root/.local/share/gvfs-metadata/home
/root/.local/share/gvfs-metadata/root
/root/.local/share/gvfs-metadata/root-12e73d4f.log
/root/.local/share/gvfs-metadata/trash:
/root/.local/share/gvfs-metadata/home-c1df1f82.log
/root/.local/share/gvfs-metadata/trash:-1cb324fc.log
/root/.local/share/gnome-settings-daemon/input-sources-converted
/root/.local/share/tracker/data/tracker-store.ontology.journal
/root/.local/share/tracker/data/tracker-store.journal
/root/.local/share/tracker/data/.meta.isrunning
/root/.local/share/keyrings/login.keyring
/root/.local/share/keyrings/user.keystore
/root/.esd_auth
/root/.bash_history
/root/.Xauthority
/root/file
/root/A.txt
/root/B.txt



4> 在当前目录及子目录中,查找不是out开头的txt文件
 

[root@localhost ~]# find . ! -name "out*" -a -name "*.txt"
./.cache/tracker/db-version.txt
./.cache/tracker/db-locale.txt
./.cache/tracker/parser-version.txt
./.cache/tracker/locale-for-miner-apps.txt
./.cache/tracker/last-crawl.txt
./.cache/tracker/first-index.txt
./A.txt
./B.txt


5> 忽略文件名大小写查找a.txt

[root@localhost ~]# find . -name "A.txt" -o -name "a.txt"
./A.txt
./a.txt


6> 在当前目录除aa之外的子目录内搜索 txt文件

[root@localhost ~]# ll /aa
total 0
-rw-r--r--. 1 root root 0 Feb 14 07:17 g.txt
[root@localhost ~]# find . -path /aa -prune -o -name "*.txt"
./.cache/tracker/db-version.txt
./.cache/tracker/db-locale.txt
./.cache/tracker/parser-version.txt
./.cache/tracker/locale-for-miner-apps.txt
./.cache/tracker/last-crawl.txt
./.cache/tracker/first-index.txt
./A.txt
./B.txt
./a.txt



7> 在当前目录及子目录下,查找符号链接文件

[root@localhost ~]# ln -s A.txt linka.txt
[root@localhost ~]# ll
total 8
-rw-------. 1 root root 1036 Feb 10 14:33 anaconda-ks.cfg
-rw-r--r--. 2 root root    0 Feb 14 07:03 a.txt
-rw-r--r--. 1 root root    0 Feb 14 06:57 A.txt
-rw-r--r--. 1 root root    0 Feb 14 06:57 B.txt
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Desktop
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Documents
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Downloads
-rw-r--r--. 1 root root    0 Feb 14 06:56 file
-rw-r--r--. 1 root root 1308 Feb 10 14:39 initial-setup-ks.cfg
lrwxrwxrwx. 1 root root    5 Feb 14 07:24 linka.txt -> A.txt
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Music
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Pictures
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Public
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Templates
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Videos
-rw-r--r--. 2 root root    0 Feb 14 07:03 x.txt
[root@localhost ~]# find . -type l
./linka.txt



8> 查找2天内被更改过的文件

[root@localhost ~]# find . -mtime -2
.
./.cache/tracker
./.cache/tracker/meta.db
./.cache/tracker/meta.db-wal
./.cache/tracker/meta.db-shm
./.cache/tracker/locale-for-miner-apps.txt
./.cache/gnome-software/shell-extensions
./.cache/gnome-software/shell-extensions/gnome.json
./.cache/gnome-software/shell-extensions/extensions-web.xmlb
./.cache/gnome-software/odrs
./.cache/gnome-software/odrs/ratings.json
./.config/ibus/bus
./.config/ibus/bus/f13823a8fa3e43329b755c2269e19612-unix-0
./.config/dconf
./.config/dconf/user
./.config/pulse/f13823a8fa3e43329b755c2269e19612-default-sink
./.config/pulse/f13823a8fa3e43329b755c2269e19612-default-source
./.config/gtk-3.0
./.config/gtk-3.0/bookmarks
./.ICEauthority
./.local/share/evolution/addressbook/system
./.local/share/evolution/addressbook/system/contacts.db
./.local/share/tracker/data
./.local/share/tracker/data/tracker-store.journal
./.local/share/tracker/data/.meta.isrunning
./.local/share/keyrings
./.Xauthority
./file
./A.txt
./B.txt
./a.txt
./x.txt
./linka.txt



9> 查找2天前被更改过的文件

[root@localhost ~]# find . -mtime +2
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./anaconda-ks.cfg
./.cache
./.cache/dconf
./.cache/dconf/user
./.cache/libgweather
./.cache/evolution
./.cache/evolution/addressbook
./.cache/evolution/addressbook/trash
./.cache/evolution/calendar
./.cache/evolution/calendar/trash
./.cache/evolution/mail
./.cache/evolution/mail/trash
./.cache/evolution/memos
./.cache/evolution/memos/trash
./.cache/evolution/sources
./.cache/evolution/sources/trash
./.cache/evolution/tasks
./.cache/evolution/tasks/trash
./.cache/tracker/db-version.txt
./.cache/tracker/db-locale.txt
./.cache/tracker/ontologies.gvdb
./.cache/tracker/parser-version.txt
./.cache/tracker/last-crawl.txt
./.cache/tracker/first-index.txt
./.cache/event-sound-cache.tdb.f13823a8fa3e43329b755c2269e19612.x86_64-redhat-linux-gnu
./.cache/gnome-software
./.cache/gnome-software/appstream
./.cache/gnome-software/appstream/components.xmlb
./.cache/gnome-software/flatpak-system-default
./.cache/gnome-software/flatpak-system-default/components.xmlb
./.cache/gnome-software/flatpak-user-user
./.cache/gnome-software/flatpak-user-user/components.xmlb
./.cache/gstreamer-1.0
./.cache/gstreamer-1.0/registry.x86_64.bin
./.cache/yelp
./.cache/yelp/WebKitCache
./.cache/yelp/WebKitCache/Version 16
./.cache/yelp/WebKitCache/Version 16/salt
./.cache/yelp/WebKitCache/Version 16/Blobs
./.dbus
./.dbus/session-bus
./.dbus/session-bus/f13823a8fa3e43329b755c2269e19612-9
./.config
./.config/ibus
./.config/gnome-session
./.config/gnome-session/saved-session
./.config/evolution
./.config/evolution/sources
./.config/evolution/sources/system-proxy.source
./.config/goa-1.0



10> 查找超过1M的文件

[root@localhost ~]# find -size +1000
./.cache/tracker/meta.db
./.cache/tracker/meta.db-wal
./.cache/gnome-software/appstream/components.xmlb
./.cache/gnome-software/shell-extensions/gnome.json
./.cache/gnome-software/shell-extensions/extensions-web.xmlb
./.cache/gnome-software/odrs/ratings.json
./.cache/gstreamer-1.0/registry.x86_64.bin



6、查找文件 /etc/yum.repos.d/redhat.repo中包含字符串 re 的所有行。将所有这些行的副本按原始顺序放在文件/root/files 中。

[root@localhost ~]# find /etc/yum.repos.d/redhat.repo | xargs grep "re"
# *** This file is auto-generated.  Changes made here will be over-written. ***
# *** Use "subscription-manager repo-override --help" if you wish to make changes. ***
# a "yum repolist" to refresh available repos
[root@localhost ~]# find /etc/yum.repos.d/redhat.repo | xargs grep "re" | xargs > /root/files
[root@localhost ~]# cat /root/files
# *** This file is auto-generated. Changes made here will be over-written. *** # *** Use subscription-manager repo-override --help if you wish to make changes. *** # a yum repolist to refresh available repos


所有用户生效的命令别名:
写一个所有用户都生效的命令别名为hh,每一个用户输入这个命令之后可以在该用户家目录下创建一个file1文件。

[root@localhost ~]# vim /etc/passwd

[root@localhost ~]# hh
[root@localhost ~]# ll
total 12
-rw-------. 1 root root 1036 Feb 10 14:33 anaconda-ks.cfg
-rw-r--r--. 2 root root    0 Feb 14 07:03 a.txt
-rw-r--r--. 1 root root    0 Feb 14 06:57 A.txt
-rw-r--r--. 1 root root    0 Feb 14 06:57 B.txt
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Desktop
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Documents
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Downloads
-rw-r--r--. 1 root root    0 Feb 14 06:56 file
-rw-r--r--. 1 root root    0 Feb 14 07:41 file1
-rw-r--r--. 1 root root  208 Feb 14 07:34 files
-rw-r--r--. 1 root root 1308 Feb 10 14:39 initial-setup-ks.cfg
lrwxrwxrwx. 1 root root    5 Feb 14 07:24 linka.txt -> A.txt
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Music
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Pictures
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Public
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Templates
drwxr-xr-x. 2 root root    6 Feb 10 07:42 Videos
-rw-r--r--. 2 root root    0 Feb 14 07:03 x.txt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值