当前位置: 首页 > news >正文

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 

相关文章:

  • Matlab实现RIME-CNN-LSTM-Multihead-Attention多变量多步时序预测
  • 作物移栽机器人的结构设计的介绍
  • 2025-03-13 学习记录--C/C++-PTA 练习2-12 输出华氏-摄氏温度转换表
  • 《算法笔记》8.2小节——搜索专题->广度优先搜索(BFS)问题 A: Jugs
  • 人工智能与人的智能,思维模型分享【3】直觉
  • 西方力推的5G O-RAN难以撼动传统通信设备商
  • c语言经典基础编程题
  • 【数据结构】6栈
  • Linux--gdb/cgdb
  • 【Go】Go MongoDB 快速入门
  • 使用 pytesseract 进行 OCR 识别:以固定区域经纬度提取为例
  • 过滤器(Filter)与拦截器(Interceptor)
  • Flutter 学习之旅 之 flutter 使用 shared_preferences 实现简单的数据本地化保存封装
  • MySQL 深度分页如何优化?
  • 【Unity6打包Android】游戏启动的隐私政策弹窗(报错处理)
  • 从硬件定时器原理学会多任务调度
  • 筛选法找质数(信息学奥赛一本通-2040)
  • 陶陶摘苹果(信息学奥赛一本通-1103)
  • 46. HarmonyOS NEXT 登录模块开发教程(一):模态窗口登录概述
  • 操作系统高频面试题
  • 藤井树与藤井树:岩井俊二式的爱情,情书的三重生命
  • 特朗普与泽连斯基通话
  • 中国田径巡回赛西安站完赛:男子跳远石雨豪夺冠,女子跳高刘肼毅折桂
  • 复旦建校120周年大型义诊举行,百余名专家服务市民超三千人次
  • 第十届曹禺剧本奖上海揭晓,首次开放个人申报渠道
  • 人民网三评“网络烂梗”:莫让低级趣味围猎青少年