Liunx 習題練習02
-
返回
initial-setup-ks.cfg
文件中包含字符串 ‘boot’ 的行數[root@localhost ~]# grep 'boot' /root/initial-setup-ks.cfg | wc -l [root@localhost ~]# grep -c 'boot' /root/initial-setup-ks.cfg
-
返回
initial-setup-ks.cfg
文件中包含字符串 ‘boot’ 的行與行號[root@localhost ~]# grep -n 'boot' /root/initial-setup-ks.cfg
-
執行
ps -aux
命令,將文件內容保存到 /root/ps.log 中,查找該文件中包含1774或1775字符串的行[root@localhost ~]# ps -aux > /root/ps.log [root@localhost ~]# grep '177[45]' ps.log
-
在上述文件中查找包含一串包含四位數的字符串,並且這個字符串最後一個數字爲2
[root@localhost ~]# grep '[0-9][0-9][0-9]2' /root/ps.log [root@localhost ~]# grep '[0-9][0-9][0-9]...2' /root/ps.log [root@localhost ~]# grep '[0-9][0-9][0-9]...[Ss]' /root/ps.log
-
在當前目錄下查找除目錄以外的所有類型的文件
[root@localhost ~]# find . ! -type d
-
找出所有用戶ruochen 擁有的文件,並且把它們拷貝到/root/finder怒罵中
[root@localhost yum.repos.d]# find / -user harry -type f -exec cp {} /root/finder \; 2> /dev/null
-
查找文件更改時間比文件a.txt 新但比b.txt 文件舊的文件
-
-newr
-
find / - newer a.txt ! -newer b.txt
[root@localhost ~]# find / -newer initial-setup-ks.cfg ! -newer ps.log -exec ls -lh {} \;
-
-
統計當前系統中一共有多少賬戶
-
/etc/passwd
-
wc -l /etc/passwd
[root@localhost ~]# wc -l /etc/passwd 39 /etc/passwd
-
-
配置本機yum 環境
[root@localhost Desktop]# mkdir /mnt/cdrom [root@localhost Desktop]# mount /dev/sr0 /mnt/cdrom [root@localhost yum]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls [root@localhost yum.repos.d]# rm -rf * [root@localhost yum.repos.d]# vim dvd.repo [dvd] name = dvd baseurl = file:///mnt/cdrom gpgcheck = 0 enabled = 1 [root@localhost yum.repos.d]# yum clean all [root@localhost yum.repos.d]# yum repolist all