linux操作系统实战

第一题

创建根目录结构中的所有的普通文件

 [root@localhost ~]# cd /
 [root@localhost /]# mkdir /text
 [root@localhost /]# cd /text
 [root@localhost text]# mkdir /text/boot /text/root /text/home /text/bin /text/sbin /text/lib /text/lib64 /text/usr /text/opt /text/etc /text/tmp /text/run /text/dev /text/mnt /text/media /text/var /text/srv /text/sys /text/proc
 ​
 [root@localhost var]# mkdir /text/var/log /text/var/spool
 [root@localhost var]# cd /text/var/log
 [root@localhost log]# mkdir /text/var/log/messages /text/var/log/secure /text/var/log/cron 
 ​
 [root@localhost log]# cd ..
 [root@localhost var]# cd /text/var/spool
 [root@localhost spool]# mkdir /text/var/spool/mail /text/var/spool/cron
 [root@localhost spool]# cd ..
 [root@localhost var]# cd ..
 [root@localhost text]# cd /text/etc
 [root@localhost etc]# mkdir  /text/etc/hostmane /text/etc/hosts /text/etc/fstab /text/etc/bashrc /text/etc/chrony.conf /text/etc/ssh /text/etc/passwd /text/etc/shadow /text/etc/sudoers /text/etc/group
 [root@localhost etc]# cd /text/etc/ssh
 [root@localhost ssh]# mkdir /text/etc/ssh/ssh_config /text/etc/ssh/sshd_config /text/etc/ssh/sshd_config.d
 [root@localhost ssh]# cd ..
 [root@localhost etc]# cd ..
 [root@localhost text]# tree

第二题

列出所有账号的账号名

 [root@jky ~]# cut -d ":" /etc/passwd  -f1 
 root
 bin
 daemon
 adm
 lp
 sync
 shutdown
 halt
 mail
 operator
 games
 ftp
 nobody
 tss
 systemd-coredump
 dbus
 polkitd
 avahi
 colord
 rtkit
 pipewire
 clevis
 sssd
 geoclue
 flatpak
 setroubleshoot
 libstoragemgmt
 systemd-oom
 gdm
 cockpit-ws
 cockpit-wsinstance
 gnome-initial-setup
 sshd
 chrony
 dnsmasq
 tcpdump
 redhat
 xiaohong
 xiaoming
 nginx

第三题

将/etc/passwd中内容按照冒号隔开的第三个字符从大到小排序后输出所有内容

 [root@jky ~]# cut -d ":" -f3 /etc/passwd | sort -nr
 65534
 2030
 2029
 2028
 2027
 2026
 2025
 2022
 1004
 1003
 1002
 1001
 1000
 999
 998
 997
 996
 995
 994
 993
 992
 991
 985
 984
 983
 982
 981
 980
 979
 978
 172
 81
 74
 72
 70
 59
 42
 14
 12
 11
 8
 7
 6
 5
 4
 3
 2
 1
 0

第四题

列出/etc/passwd中的第20行-25行内容

 [root@jky ~]# head -25 /etc/passwd | tail -6
 rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
 pipewire:x:996:992:PipeWire System Daemon:/var/run/pipewire:/sbin/nologin
 clevis:x:995:991:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin
 sssd:x:994:990:User for sssd:/:/sbin/nologin
 geoclue:x:993:989:User for geoclue:/var/lib/geoclue:/sbin/nologin
 flatpak:x:992:988:User for flatpak system helper:/:/sbin/nologin

第五题

切割出你的ip地址和mac地址

 # 切割出来IP地址
 [root@jky ~]# ip a | grep ens160 
 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
     inet 192.168.247.128/24 brd 192.168.247.255 scope global dynamic noprefixroute ens160
 [root@jky ~]# ip a | grep ens160 | grep inet | cut -d "/" -f1 
     inet 192.168.247.128
 ​
 # 切割出来MAC地址
 (1)环回的MAC地址
 [root@jky ~]# ip a | grep lo 
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet 127.0.0.1/8 scope host lo
     inet 192.168.247.128/24 brd 192.168.247.255 scope global dynamic noprefixroute ens160
 [root@jky ~]# ip a | grep lo | grep link
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 [root@jky ~]# ip a | grep lo | grep link | cut -d " " -f6
 00:00:00:00:00:00
 ​
 (2)以太网接口 ens160 的 MAC 地址
 [root@jky ~]# ip a | grep link/ether
     link/ether 00:0c:29:f5:84:74 brd ff:ff:ff:ff:ff:ff
 [root@jky ~]# ip a | grep link/ether | cut -d " " -f6
 00:0c:29:f5:84:74

第六题

切割出/etc/passwd中的最后一个字段并进行重复内容的重复次数统计

 [root@jky ~]# cut -d ":" -f7 /etc/passwd | sort
 [root@jky ~]# cut -d ":" -f7 /etc/passwd | sort | uniq -c
      13 /bin/bash
       1 /bin/sync
       1 /sbin/halt
      28 /sbin/nologin
       1 /sbin/shutdown
       5 /usr/sbin/nologin
 [root@jky ~]# cut -d ":" -f7 /etc/passwd | sort | uniq -c 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值