day004-习题
文章目录
- 01.说说常见的Linux系统.
- 02. Linux系统最高权限用户是谁?他的名字是大写还是小写?
- 03. 如何查询红帽系统ip地址?
- 04. 说两个你熟悉的Linux命令及他们的作用?
- 05. 什么是Shell?
- 06. [root@oldboy-c7 /etc/sysconfig/ ]# 说说每一部分含义?
- 07. 说一个错误提示及含义?
- 08. 说说Linux命令格式,什么是选项和参数?
- 09. 根据要求执行相应的命令(进行操作并做记录,操作,操作,操作)
- 01) 显示/etc/目录下面内容的详细信息
- 02) 进入到 /etc/sysconfig/network-scripts/目录然后显示当前所在目录.
- 03) 返回当前用户家目录,复制/etc/hosts 到当前用户家目录下面.
- 04) 显示/etc/passwd 文件的内容
- 05) **在根下创建目录oldboy-83,然后在oldboy-83下面创建 lidao.txt,然后追加 oldboy83 linux 到lidao.txt中,然后显示lidao.txt文件内容.**
- 06) **复制 lidao.txt 到/oldboy-83/并改名oldboy.txt**
- 07) 一键创建多层目录/oldboy/lidao/old01/old02/old03/old0011**
- 08) 假设在 /etc/sysconfig/network-scripts/下面 然后你进入了 /tmp/目录,请问如何快速回到/etc/sysconfig/network-scripts目录下面.**
- 10. Linux无法远程连接排查流程及使用的命令.
- 11. 备份目录/oldboy-83 到 /backup下 并改名叫 oldboy-83-backup
- 12.检查www.baidu.com的80端口是否开启
- 13.检查www.jd.com的22端口是否开启
- 14.检查到223.5.5.5ip的连通性
- 01)显示/root目录下所有文件(含隐藏)
- 02) 复制网卡配置文件到/oldboy-83/目录下.
- 03) **修改/oldboy-83目录名字为/oldboy-83-lnb**
- 04) 创建/backup/20210308 目录,然后把/oldboy-83或者/oldboy-83-lnb 复制到 /backup/20210308/下.
- 15.如何检查Linux 是否能上网?
- 实战操作题:
- 1. 实战练习题:网站部署
- **背景**
- **任务分解**
- 2. 实战练习题:服务器初始化配置与日志收集
- **背景**
- **任务分解**
01.说说常见的Linux系统.
redhat centos kylin Debian rocky kali Ubuntu 欧拉 统信UOS
02. Linux系统最高权限用户是谁?他的名字是大写还是小写?
root。小写
03. 如何查询红帽系统ip地址?
ip a
ifconfig
04. 说两个你熟悉的Linux命令及他们的作用?
ls:显示当前目录下的文件
cd:切换工作目录
05. 什么是Shell?
是命令解释器,将外围软件的命令解释成Linux内核可以执行的命令。
06. [root@oldboy-c7 /etc/sysconfig/ ]# 说说每一部分含义?
用户名@主机名 当前工作目录 用户标识
# 表示root用户
$ 表示普通用户
07. 说一个错误提示及含义?
could not connection
连接失败
08. 说说Linux命令格式,什么是选项和参数?
命令 选项 参数
选型是命令的其他功能
参数是命令执行的目标或需要的信息
09. 根据要求执行相应的命令(进行操作并做记录,操作,操作,操作)
01) 显示/etc/目录下面内容的详细信息
[root@oldboy99 ~]# ll /etc/
总用量 1340
drwxr-xr-x 3 root root 101 4月 23 18:46 abrt
-rw-r--r-- 1 root root 44 4月 27 11:55 adjtime
-rw-r--r-- 1 root root 1529 6月 23 2020 aliases
drwxr-xr-x 2 root root 4096 4月 27 07:39 alternatives
drwxr-xr-x 4 root root 58 12月 13 2023 anaconda
-rw-r--r-- 1 root root 541 3月 22 2022 anacrontab
drwxr-xr-x 5 root root 4096 4月 23 18:46 asciidoc
-rw-r--r-- 1 root root 32 1月 10 2020 asound.conf
-rw------- 1 root root 0 4月 23 18:50 at.allow
drwxr-x--- 4 root root 100 7月 3 2023 audit
drwxr-xr-x 3 root root 20 4月 27 07:38 authselect
drwxr-xr-x 3 root root 165 4月 27 07:38 bash_completion.d
-rw-r--r-- 1 root root 3019 6月 23 2020 bashrc
-rw-r--r-- 1 root root 447 4月 7 2020 bindresvport.blacklist
drwxr-xr-x 2 root root 6 1月 22 09:51 binfmt.d
drwxr-xr-x 2 root root 45 4月 23 18:46 bluetooth
drwxr-xr-x 2 root root 6 3月 6 2021 chkconfig.d
-rw-r--r-- 1 root root 10 12月 4 2023 chkuid_state
-rw-r--r-- 1 root root 1169 4月 8 2021 chrony.conf
-rw-r----- 1 root chrony 540 5月 10 2019 chrony.keys
drwxr-xr-x 2 root root 26 5月 28 2024 cifs-utils
drwxr-xr-x 3 root root 19 4月 23 18:46 cni
drwxr-xr-x 4 root root 42 4月 23 18:46 cockpit
drwxr-xr-x 3 root root 68 4月 23 18:46 containers
-rw------- 1 root root 0 4月 23 18:50 cron.allow
drwx------ 2 root root 74 4月 27 07:38 cron.d
drwxr-xr-x 2 root root 76 10月 16 2023 cron.daily
drwx------ 2 root root 22 4月 23 18:44 cron.hourly
drwx------ 2 root root 6 3月 14 2020 cron.monthly
-rw------- 1 root root 451 3月 14 2020 crontab
drwx------ 2 root root 6 3月 14 2020 cron.weekly
drwxr-xr-x 6 root root 81 4月 23 18:44 crypto-policies
-rw------- 1 root root 0 4月 23 18:43 crypttab
-rw-r--r-- 1 root root 1657 6月 23 2020 csh.cshrc
-rw-r--r-- 1 root root 1128 4月 23 18:50 csh.login
-rw-r--r-- 1 root root 1294 4月 29 2022 csh.precmd
drwxr-xr-x 4 root root 78 10月 28 2023 dbus-1
drwxr-xr-x 4 root root 31 4月 23 18:45 dconf
drwxr-xr-x 2 root root 44 4月 27 07:38 default
drwxr-xr-x 2 root root 23 4月 27 07:36 depmod.d
drwxr-x--- 3 root root 61 4月 27 13:23 dhcp
-rw-r--r-- 1 root root 4351 11月 24 2023 DIR_COLORS
-rw-r--r-- 1 root root 4351 11月 24 2023 DIR_COLORS.256color
-rw-r--r-- 1 root root 4351 11月 24 2023 DIR_COLORS.lightbgcolor
drwxr-xr-x 8 root root 154 4月 27 07:38 dnf
-rw-r--r-- 1 root root 117 6月 30 2024 dracut.conf
drwxr-xr-x 2 root root 84 4月 27 07:37 dracut.conf.d
-rw-r--r-- 1 root root 685 1月 16 2024 e2scrub.conf
drwxr-xr-x 3 root root 37 4月 23 18:44 egl
-rw-r--r-- 1 root root 67 4月 4 2024 environment
-rw-r--r-- 1 root root 1362 6月 23 2020 ethertypes
-rw-r--r-- 1 root root 0 6月 23 2020 exports
drwxr-xr-x 2 root root 6 11月 8 17:46 exports.d
-rw-r--r-- 1 root root 70 4月 4 2024 filesystems
drwxr-x--- 7 root root 164 12月 7 2023 firewalld
drwxr-xr-x 3 root root 38 4月 23 18:44 fonts
-rw-r--r-- 1 root root 655 4月 23 18:43 fstab
-rw-r--r-- 1 root root 694 11月 2 2021 fuse.conf
drwxr-xr-x 2 root root 46 4月 23 18:44 gamin
drwxr-xr-x 7 root root 107 4月 27 07:37 gconf
drwxr-xr-x 2 root root 25 9月 1 2023 gcrypt
-rw-r--r-- 1 root root 265 3月 22 2024 gdbinit
drwxr-xr-x 2 root root 6 3月 22 2024 gdbinit.d
drwxr-xr-x 3 root root 26 4月 23 18:44 glvnd
drwxr-xr-x 2 root root 6 9月 22 2023 gnupg
-rw-r--r-- 1 root root 839 4月 27 07:37 group
-rw-r--r-- 1 root root 826 4月 27 07:37 group-
lrwxrwxrwx 1 root root 22 3月 21 14:41 grub2.cfg -> ../boot/grub2/grub.cfg
drwx------ 2 root root 301 4月 27 07:37 grub.d
---------- 1 root root 674 4月 27 07:37 gshadow
---------- 1 root root 664 4月 27 07:37 gshadow-
drwxr-xr-x 3 root root 20 3月 13 14:54 gss
drwxr-xr-x 2 root root 79 4月 23 18:45 gssproxy
drwxr-xr-x 3 root root 24 4月 23 18:46 ha.d
-rw-r--r-- 1 root root 9 6月 23 2020 host.conf
-rw-r--r-- 1 root root 9 4月 23 18:54 hostname
-rw-r--r-- 1 root root 158 6月 23 2020 hosts
drwxr-xr-x 5 root root 105 4月 27 07:37 httpd
-rw-r--r-- 1 root root 5799 11月 8 17:46 idmapd.conf
drwxr-xr-x 2 root root 25 4月 23 18:46 init
lrwxrwxrwx 1 root root 11 6月 20 2023 init.d -> rc.d/init.d
drwxr-xr-x 3 root root 20 4月 23 18:46 initial-setup
-rw-r--r-- 1 root root 490 1月 22 09:51 inittab
-rw-r--r-- 1 root root 943 6月 23 2020 inputrc
drwxr-xr-x 2 root root 159 4月 23 18:46 iproute2
-rw-r--r-- 1 root root 1738 2月 19 11:17 ipsec.conf
drwx------ 3 root root 22 2月 19 11:17 ipsec.d
-rw------- 1 root root 31 2月 19 11:17 ipsec.secrets
drwxr-xr-x 2 root root 6 10月 23 2023 ipset
-rw-r--r-- 1 root root 70 4月 23 18:50 issue
drwxr-xr-x 2 root root 27 4月 23 18:46 issue.d
-rw-r--r-- 1 root root 70 4月 23 18:50 issue.net
-rw-r--r-- 1 root root 7925 4月 23 18:46 kdump.conf
drwxr-xr-x 4 root root 41 1月 22 09:51 kernel
drwxr-xr-x 2 root root 6 3月 6 2021 keyutils
-rw-r--r-- 1 root root 587 2月 11 22:40 krb5.conf
drwxr-xr-x 2 root root 55 3月 13 14:54 krb5.conf.d
-rw-r--r-- 1 root root 48 12月 11 2023 kylin-release
drwx------ 2 root root 68 4月 23 18:50 kylin_security
drwxr-xr-x 3 root root 41 4月 23 18:46 latrace.d
-rw-r--r-- 1 root root 79823 4月 27 13:25 ld.so.cache
-rw-r--r-- 1 root root 28 11月 13 15:03 ld.so.conf
drwxr-xr-x 2 root root 4096 4月 27 07:38 ld.so.conf.d
-rw-r----- 1 root root 191 12月 17 2020 libaudit.conf
drwxr-xr-x 3 root root 20 4月 23 18:46 libblockdev
drwxr-xr-x 2 root root 35 4月 23 18:44 libnl
drwxr-xr-x 2 root root 6 3月 6 2021 libpaper.d
drwxr-xr-x 6 root root 171 4月 23 18:44 libreport
-rw-r--r-- 1 root root 2391 7月 24 2015 libuser.conf
-r--r--r-- 1 root root 441 3月 31 2023 LICENSE
-rw-r--r-- 1 root root 19 4月 23 18:54 locale.conf
lrwxrwxrwx 1 root root 35 4月 23 18:54 localtime -> ../usr/share/zoneinfo/Asia/Shanghai
-rw------- 1 root root 9 4月 27 17:15 localtime_tmp
-rw-r--r-- 1 root root 1515 4月 23 18:50 login.defs
-rw-r--r-- 1 root root 434 10月 14 2019 logrotate.conf
drwxr-xr-x 2 root root 227 4月 27 07:38 logrotate.d
drwxr-xr-x 3 root root 43 4月 23 18:44 lsm
drwxr-xr-x 6 root root 100 9月 19 2024 lvm
-r--r--r-- 1 root root 33 4月 23 18:44 machine-id
-rw-r--r-- 1 root root 111 2月 21 2022 magic
-rw-r--r-- 1 root root 272 4月 22 2020 mailcap
-rw-r--r-- 1 root root 5122 3月 30 2022 makedumpfile.conf.sample
-rw-r--r-- 1 root root 5176 2月 21 2022 man_db.conf
-rw-r--r-- 1 root root 67454 4月 22 2020 mime.types
-rw-r--r-- 1 root root 812 1月 16 2024 mke2fs.conf
drwxr-xr-x 2 root root 320 4月 27 07:38 modprobe.d
drwxr-xr-x 2 root root 6 1月 22 09:51 modules-load.d
-rw-r--r-- 1 root root 70 4月 23 18:50 motd
drwxr-xr-x 2 root root 21 4月 4 2024 motd.d
lrwxrwxrwx 1 root root 19 4月 23 18:44 mtab -> ../proc/self/mounts
drwxr-xr-x 2 root root 6 11月 6 13:40 multipath
drwxr-xr-x 2 root root 6 11月 9 2022 my.cnf.d
drwxr-x--- 2 root named 6 9月 9 2024 named
-rw-r----- 1 root named 1705 9月 9 2024 named.conf
-rw-r----- 1 root named 1029 9月 9 2024 named.rfc1912.zones
-rw-r--r-- 1 root named 1070 9月 9 2024 named.root.key
-rw-r--r-- 1 root root 11620 8月 29 2024 nanorc
drwxr-xr-x 3 root root 38 4月 23 18:44 ndctl
-rw-r--r-- 1 root root 767 4月 7 2020 netconfig
drwxr-xr-x 7 root root 134 4月 27 07:38 NetworkManager
-rw-r--r-- 1 root root 58 6月 23 2020 networks
-rw-r--r-- 1 root root 1159 11月 8 17:46 nfs.conf
-rw-r--r-- 1 root root 3606 11月 8 17:46 nfsmount.conf
drwxr-xr-x 3 root root 327 4月 23 18:46 nftables
drwxr-xr-x 2 root root 32 4月 23 18:44 nginx
-rw-r--r-- 1 root root 1516 4月 23 18:44 nsswitch.conf
-rw-r--r-- 1 root root 1498 7月 27 2022 nsswitch.conf.bak
drwxr-xr-x 3 root root 21 4月 23 18:46 OpenCL
drwxr-xr-x 4 root root 50 4月 23 18:46 openldap
drwxr-xr-x 2 root root 6 3月 6 2021 opt
-rw-r--r-- 1 root root 158 12月 11 2023 os-release
drwxr-xr-x 3 root root 23 4月 23 18:45 ostree
drwxr-xr-x 2 root root 48 4月 23 18:46 PackageKit
drwxr-xr-x 2 root root 4096 4月 27 07:37 pam.d
-rw-r--r-- 1 root root 68 3月 6 2021 papersize
-rw-r--r-- 1 root root 1927 4月 27 07:37 passwd
-rw-r--r-- 1 root root 1857 4月 27 07:37 passwd-
drwxr-xr-x 2 root root 33 4月 23 18:46 pesign
-rw-r--r-- 1 root root 2872 3月 15 2020 pinforc
drwxr-xr-x 3 root root 21 4月 23 18:44 pkcs11
drwxr-xr-x 8 root root 88 4月 23 18:46 pki
drwxr-xr-x 2 root root 28 8月 30 2023 plymouth
drwxr-xr-x 5 root root 52 4月 23 18:43 pm
drwxr-xr-x 5 root root 72 12月 24 11:47 polkit-1
drwxr-xr-x 2 root root 25 4月 27 07:38 popt.d
drwxr-xr-x 2 root root 24 4月 27 07:36 prelink.conf.d
-rw-r--r-- 1 root root 233 6月 23 2020 printcap
-rw-r--r-- 1 root root 1891 4月 27 11:49 profile
drwxr-xr-x 2 root root 186 4月 27 07:36 profile.d
-rw-r--r-- 1 root root 6568 6月 23 2020 protocols
drwxr-xr-x 2 root root 79 4月 27 07:37 pulse
-rw-r--r-- 1 root root 220 3月 27 2013 quotagrpadmins
-rw-r--r-- 1 root root 261 3月 27 2013 quotatab
lrwxrwxrwx 1 root root 10 6月 20 2023 rc0.d -> rc.d/rc0.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc1.d -> rc.d/rc1.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc2.d -> rc.d/rc2.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc3.d -> rc.d/rc3.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc4.d -> rc.d/rc4.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc5.d -> rc.d/rc5.d
lrwxrwxrwx 1 root root 10 6月 20 2023 rc6.d -> rc.d/rc6.d
drwxr-xr-x 10 root root 127 1月 22 09:51 rc.d
lrwxrwxrwx 1 root root 13 1月 22 09:51 rc.local -> rc.d/rc.local
-rw-r--r-- 1 root root 1787 3月 6 2021 request-key.conf
drwxr-xr-x 2 root root 77 4月 23 18:46 request-key.d
-rw-r--r-- 1 root root 72 4月 27 12:34 resolv.conf
-rw-r--r-- 1 root root 1634 8月 1 2018 rpc
drwxr-xr-x 2 root root 25 5月 24 2023 rpm
-rw-r--r-- 1 root root 458 1月 20 19:02 rsyncd.conf
-rw-r--r-- 1 root root 2163 9月 6 2023 rsyslog.conf
drwxr-xr-x 2 root root 6 9月 7 2023 rsyslog.d
drwxr-xr-x 2 root root 31 5月 28 2024 rwtab.d
drwxr-xr-x 2 root root 61 4月 27 07:36 samba
drwxr-xr-x 2 root root 6 11月 13 2023 sasl2
drwxr-xr-x 6 root root 301 1月 3 15:52 security
drwxr-xr-x 3 root root 132 1月 24 2024 selinux
-rw-r--r-- 1 root root 10593 3月 6 2021 sensors3.conf
drwxr-xr-x 2 root root 6 3月 6 2021 sensors.d
-rw-r--r-- 1 root root 692252 6月 23 2020 services
-rw-r--r-- 1 root root 216 12月 7 2023 sestatus.conf
drwxr-xr-x 2 root root 33 12月 7 2023 setroubleshoot
drwxr-xr-x 3 root root 4096 4月 23 18:44 sgml
---------- 1 root root 982 4月 27 07:37 shadow
---------- 1 root root 962 4月 27 07:37 shadow-
-rw-r--r-- 1 root root 77 4月 23 18:46 shells
drwxr-xr-x 2 root root 76 4月 23 18:46 skel
-rw-r--r-- 1 root root 2030 3月 15 2020 slsh.rc
drwxr-xr-x 3 root root 74 4月 23 18:46 smartmontools
-rw-r--r-- 1 root root 138 7月 9 2020 sos.conf
drwxr-xr-x 3 root root 323 4月 27 15:11 ssh
drwxr-xr-x 2 root root 19 4月 23 18:44 ssl
drwx------ 4 root root 48 5月 28 2024 sssd
drwxr-xr-x 2 root root 6 3月 6 2021 statetab.d
-rw-r--r-- 1 root root 0 6月 23 2020 subgid
-rw-r--r-- 1 root root 0 6月 23 2020 subuid
drwxr-xr-x 2 root root 6 3月 3 16:58 subversion
-rw-r----- 1 root root 3985 1月 10 2024 sudo.conf
-r--r----- 1 root root 4359 1月 8 2024 sudoers
drwxr-x--- 2 root root 6 1月 10 2024 sudoers.d
drwxr-xr-x 5 root root 4096 4月 27 09:34 sysconfig
-rw-r--r-- 1 root root 1076 4月 23 18:50 sysctl.conf
drwxr-xr-x 2 root root 53 1月 22 09:51 sysctl.d
drwxr-xr-x 5 root root 267 1月 22 09:51 systemd
lrwxrwxrwx 1 root root 13 12月 11 2023 system-release -> kylin-release
-rw-r--r-- 1 root root 32 12月 11 2023 system-release-cpe
drwxr-xr-x 4 root root 50 4月 23 18:46 systemtap
-rw-r----- 1 root tss 7046 3月 22 2022 tcsd.conf
drwxr-xr-x 2 root root 6 4月 29 2024 terminfo
drwxr-xr-x 2 root root 6 1月 22 09:51 tmpfiles.d
-rw-r--r-- 1 root root 750 9月 9 2024 trusted-key.key
drwxr-xr-x 3 root root 224 4月 27 07:38 tuned
drwxr-xr-x 4 root root 68 4月 27 07:40 udev
-rw-r--r-- 1 root root 106 4月 23 18:44 uid_list
drwxr-xr-x 2 root root 45 4月 27 07:36 unbound
-rw-r--r-- 1 root root 587 10月 29 2019 updatedb.conf
-rw-r--r-- 1 root root 28 4月 23 18:54 vconsole.conf
-rw-r--r-- 1 root root 351 4月 2 09:07 vimrc
-rw-r--r-- 1 root root 351 4月 2 09:07 virc
drwxr-xr-x 5 root root 67 4月 27 07:36 vulkan
-rw-r--r-- 1 root root 3360 12月 17 2015 warnquota.conf
-rw-r--r-- 1 root root 4945 8月 17 2018 wgetrc
drwxr-xr-x 2 root root 33 10月 14 2024 wpa_supplicant
drwxr-xr-x 6 root root 70 4月 23 18:44 X11
-rw-r--r-- 1 root root 643 2月 21 2022 xattr.conf
drwxr-xr-x 4 root root 38 4月 23 18:44 xdg
drwxr-xr-x 2 root root 18 4月 27 13:25 xinetd.d
drwxr-xr-x 2 root root 21 4月 23 18:44 xml
drwxr-xr-x 2 root root 57 4月 27 07:38 yum
lrwxrwxrwx 1 root root 12 4月 17 13:56 yum.conf -> dnf/dnf.conf
drwxr-xr-x 2 root root 48 4月 27 09:33 yum.repos.d
-rw-r--r-- 1 root root 120 3月 22 2022 zlogin
-rw-r--r-- 1 root root 58 3月 22 2022 zlogout
-rw-r--r-- 1 root root 159 3月 22 2022 zprofile
-rw-r--r-- 1 root root 303 3月 22 2022 zshenv
-rw-r--r-- 1 root root 590 3月 22 2022 zshrc
02) 进入到 /etc/sysconfig/network-scripts/目录然后显示当前所在目录.
[root@oldboy99 ~]# cd /etc/sysconfig/network-scripts/
[root@oldboy99 /etc/sysconfig/network-scripts]# pwd
/etc/sysconfig/network-scripts
03) 返回当前用户家目录,复制/etc/hosts 到当前用户家目录下面.
[root@oldboy99 /etc/sysconfig/network-scripts]# cd
[root@oldboy99 ~]# cp /etc/hosts ./
[root@oldboy99 ~]# ls
anaconda-ks.cfg hosts initial-setup-ks.cfg Kylin-Server-V10-SP3-General-Release-2303-X86_64.iso
04) 显示/etc/passwd 文件的内容
[root@oldboy99 ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
systemd-timesync:x:998:996:systemd Time Synchronization:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
libstoragemgmt:x:997:994:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
dbus:x:81:81:D-Bus:/var/run/dbus:/sbin/nologin
polkitd:x:996:993:User for polkitd:/:/sbin/nologin
unbound:x:995:992:Unbound DNS resolver:/etc/unbound:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
setroubleshoot:x:994:991::/var/lib/setroubleshoot:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
cockpit-ws:x:993:990:User for cockpit-ws:/nonexisting:/sbin/nologin
chrony:x:992:989::/var/lib/chrony:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
dhcpd:x:177:177:DHCP server:/:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
pesign:x:991:987:Group for the pesign signing daemon:/var/run/pesign:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
05) 在根下创建目录oldboy-83,然后在oldboy-83下面创建 lidao.txt,然后追加 oldboy83 linux 到lidao.txt中,然后显示lidao.txt文件内容.
[root@oldboy99 ~]# mkdir /oldboy-83
[root@oldboy99 ~]# touch /oldboy-83/lidao.txt
[root@oldboy99 ~]# echo oldboy83 linux > /oldboy-83/lidao.txt
[root@oldboy99 ~]# cat /oldboy-83/lidao.txt
oldboy83 linux
06) 复制 lidao.txt 到/oldboy-83/并改名oldboy.txt
[root@oldboy99 ~]# cp /oldboy-83/lidao.txt /oldboy-83/oldboy.txt
07) 一键创建多层目录/oldboy/lidao/old01/old02/old03/old0011**
[root@oldboy99 ~]# mkdir -p /oldboy/lidao/old01/old02/old03/old11
[root@oldboy99 ~]# tree /oldboy
/oldboy
└── lidao└── old01└── old02└── old03└── old115 directories, 0 files
08) 假设在 /etc/sysconfig/network-scripts/下面 然后你进入了 /tmp/目录,请问如何快速回到/etc/sysconfig/network-scripts目录下面.**
cd -
10. Linux无法远程连接排查流程及使用的命令.
1.检查网络是否畅通:ping ip
2.查看目标主机的防火墙是否关闭,或禁用了22端口:systemctl disable firewalld
3.查看目标主机22端口是否开启:telnet ip 22
11. 备份目录/oldboy-83 到 /backup下 并改名叫 oldboy-83-backup
[root@oldboy99 ~]# cp /oldboy-83/ /backup/oldboy-83-backup -r
[root@oldboy99 ~]# ls /backup/
oldboy-83-backup
12.检查www.baidu.com的80端口是否开启
[root@oldboy99 ~]# telnet baidu.com 80
Trying 39.156.66.10...
Connected to baidu.com. #已开启
Escape character is '^]'.
Connection closed by foreign host.
13.检查www.jd.com的22端口是否开启
[root@oldboy99 ~]# telnet jd.com 22
Trying 211.144.24.218...
telnet: connect to address 211.144.24.218: Connection refused
# 未开启
14.检查到223.5.5.5ip的连通性
[root@oldboy99 ~]# ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=6.49 ms
64 bytes from 223.5.5.5: icmp_seq=2 ttl=128 time=6.86 ms
^C
--- 223.5.5.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.485/6.674/6.864/0.189 ms
01)显示/root目录下所有文件(含隐藏)
[root@oldboy99 ~]# ll -a
总用量 4471644
dr-xr-x--- 3 root root 282 4月 27 17:25 .
dr-xr-xr-x. 21 root root 283 4月 27 17:30 ..
-rw------- 1 root root 2743 4月 23 18:49 anaconda-ks.cfg
-rw------- 1 root root 3801 4月 27 15:11 .bash_history
-rw-r--r-- 1 root root 18 3月 13 2020 .bash_logout
-rw-r--r-- 1 root root 176 3月 13 2020 .bash_profile
-rw-r--r-- 1 root root 176 3月 13 2020 .bashrc
-rw-r--r-- 1 root root 100 3月 13 2020 .cshrc
drwx------ 3 root root 108 4月 27 12:34 .gnupg
-rw-r--r-- 1 root root 158 4月 27 17:25 hosts
-rw-r--r-- 1 root root 3188 4月 23 18:54 initial-setup-ks.cfg
-rw-r--r-- 1 root root 4578914304 4月 27 13:46 Kylin-Server-V10-SP3-General-Release-2303-X86_64.iso
-rw------- 1 root root 51 4月 27 15:11 .lesshst
-rw-r--r-- 1 root root 129 3月 13 2020 .tcshrc
-rw------- 1 root root 6852 4月 27 15:11 .viminfo
02) 复制网卡配置文件到/oldboy-83/目录下.
[root@oldboy99 ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /oldboy-83/
[root@oldboy99 ~]# ls /oldboy-83/
ifcfg-ens33 lidao.txt oldboy.txt
03) 修改/oldboy-83目录名字为/oldboy-83-lnb
[root@oldboy99 ~]# mv /oldboy-83/ /oldboy-83-lnb
04) 创建/backup/20210308 目录,然后把/oldboy-83或者/oldboy-83-lnb 复制到 /backup/20210308/下.
[root@oldboy99 ~]# cp -r /oldboy-83-lnb/ /backup/20210308/
[root@oldboy99 ~]# cd /backup/20210308/
[root@oldboy99 /backup/20210308]# ls
oldboy-83-lnb
15.如何检查Linux 是否能上网?
1.查看本地网卡配置,注意ip、dns、网关
2.查看vm的网络编辑器:vmnet8:子网地址、网关
3.查看主机是否能上网
实战操作题:
1. 实战练习题:网站部署
背景
你刚刚加入"老男孩教育99期"担任初级云计算运维工程师。部门主管给你布置了第一个任务:
"公司新项目需要快速部署一套测试用的Nginx Web服务环境,具体要求如下:
- 在
/opt/project
目录下建立规范的网站目录结构- 创建测试页面并配置虚拟主机
- 保证服务开机自启
- 最后清理临时文件
这是检验你基础运维能力的重要任务!"
任务分解
1. 构建标准目录结构
# 创建项目根目录及子目录(使用mkdir)
/opt/project
├── html # 网站主目录
├── config # 配置文件目录
├── logs # 日志目录
└── backup # 备份目录
根据上面目录结构进程创建,创建对应的目录# 生成测试页面(使用{}生成序列文件)
在html目录下创建:
- index.html
- product{1..3}.html在backup目录下创建oldboy-backup{01..10}.bak 10个文件
################################################
[root@oldboy99 ~]# mkdir -p /opt/project
[root@oldboy99 ~]# cd /opt/p
-bash: cd: /opt/p: 没有那个文件或目录
[root@oldboy99 ~]# cd /opt/p
patch_workspace/ project/
[root@oldboy99 ~]# cd /opt/p
patch_workspace/ project/
[root@oldboy99 ~]# cd /opt/project/
[root@oldboy99 /opt/project]# mkdir html config logs backup
[root@oldboy99 /opt/project]# touch html/index.html
[root@oldboy99 /opt/project]# touch html/product{1..3}.html
[root@oldboy99 /opt/project]# ls ./html/
index.html product1.html product2.html product3.html
[root@oldboy99 /opt/project]# touch ./backup/oldboy-backup{01..10}.bak
[root@oldboy99 /opt/project]# ls ./backup/
oldboy-backup01.bak oldboy-backup03.bak oldboy-backup05.bak oldboy-backup07.bak oldboy-backup09.bak
oldboy-backup02.bak oldboy-backup04.bak oldboy-backup06.bak oldboy-backup08.bak oldboy-backup10.bak
2. 配置虚拟主机
在config目录下创建oldboy_project.conf文件并写入如下内容:
server {listen 80;server_name project.test;root /opt/project/html;access_log /opt/project/logs/access.log;
}
#####################################################
[root@oldboy99 /opt/project]# vim ./config/oldboy_project.conf
[root@oldboy99 /opt/project]# cat ./config/oldboy_project.conf
server{listen 80;server_name project.test;root /opt/project/html;access_log /opt/project/logs/access.log;
}
3. 服务管理
这步骤先略过.
4. 清理工作
删除/backup/目录下所有内容.#############################
[root@oldboy99 /opt/project]# rm -rf ./backup/*
[root@oldboy99 /opt/project]# ls ./backup/
[root@oldboy99 /opt/project]#
2. 实战练习题:服务器初始化配置与日志收集
背景
你作为"星云科技"新入职的运维工程师,接手了部门新采购的10台服务器。技术主管给出紧急任务:
"所有服务器需在今日完成基础环境初始化,具体要求:
- 建立运维专用目录结构
- 批量创建测试文件
- 备份关键系统配置
- 配置服务监控检查
- 生成初始化报告
这是生产环境服务器,操作必须规范!
任务分解
1. 创建运维目录体系
⚠️注意项目所有操作都相对于 /opt/cloud_ops目录.
# 使用mkdir创建多级目录(注意使用-p参数)
/opt/cloud_ops
├── backups # 备份目录
├── scripts # 脚本目录
├── reports # 报告目录
└── temp # 临时目录
#######################################################
[root@oldboy99 ~]# mkdir -p /opt/cloud_ops/
[root@oldboy99 ~]# cd /opt/cloud_ops/
[root@oldboy99 /opt/cloud_ops]# mkdir backups scripts reports temp
[root@oldboy99 /opt/cloud_ops]# ls
backups reports scripts temp
2. 生成测试数据集
# 使用{}批量创建日志模拟文件(注意文件命名规范)
在/opt/cloud_ops/temp下创建:
- web_access_{1..5}.log
- db_query_{a..c}.log# 使用echo生成系统信息文件
echo "Kernel: $(uname -r)" 运行左边的命令把结果写入到文件:/opt/cloud_ops/reports/system_info.txt中(思考下重定向符号)
############################################[root@oldboy99 /opt/cloud_ops]# touch ./temp/web_access_{1..5}.log
[root@oldboy99 /opt/cloud_ops]# touch ./temp/db_query_{a..c}.log
[root@oldboy99 /opt/cloud_ops]# echo "Kernel:$(uname -r)" > ./reports/system_info.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/system_info.txt
Kernel:4.19.90-52.46.v2207.ky10.x86_64
3. 系统配置备份
# 使用cp备份关键配置文件(注意保留原属性)
把/etc/hosts /etc/hostname /etc/passwd /etc/resolv.conf复制到/ /opt/cloud_ops/backups/# 使用>>追加备份记录
echo "$(date) 完成系统配置备份" 追加到/opt/cloud_ops/reports/operation.log
##########################################################
[root@oldboy99 /opt/cloud_ops]# cp -a /etc/hosts ./backups/
[root@oldboy99 /opt/cloud_ops]# cp -a /etc/hostname ./backups/
[root@oldboy99 /opt/cloud_ops]# cp -a /etc/passwd ./backups/
[root@oldboy99 /opt/cloud_ops]# cp -a /etc/resolv.conf ./backups/
[root@oldboy99 /opt/cloud_ops]# ls ./backups/
hostname hosts passwd resolv.conf
[root@oldboy99 /opt/cloud_ops]# echo "$(date)" >> ./reports/operation.log
[root@oldboy99 /opt/cloud_ops]# cat ./reports/operation.log
2025年 04月 27日 星期日 17:54:45 CST
4. 服务状态检查
# 使用systemctl检查关键服务(结果输出到报告)
systemctl status sshd 写入到文件中 /opt/cloud_ops/reports/service_status.txt
systemctl is-active firewalld 追加到文件中. /opt/cloud_ops/reports/service_status.txt# 使用cat合并报告
把/opt/cloud_ops/reports/system_info.txt和/opt/cloud_ops/reports/service_status.txt 2个文件内容合并到 final_report.txt文件中.
##############################################
[root@oldboy99 /opt/cloud_ops]# systemctl status sshd >> ./reports/service_status.txt
[root@oldboy99 /opt/cloud_ops]# systemctl is-active firewalld >> ./reports/service_status.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/
operation.log service_status.txt system_info.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/
operation.log service_status.txt system_info.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/service_status.txt
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2025-04-27 15:11:20 CST; 2h 45min ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 4591 (sshd) Tasks: 1 Memory: 2.5M CGroup: /system.slice/sshd.service └─4591 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups 4月 27 15:11:20 oldboy99 sshd[4591]: Server listening on :: port 12345. 4月 27 15:11:20 oldboy99 systemd[1]: Started OpenSSH server daemon. 4月 27 15:11:58 oldboy99 sshd[4614]: rexec line 147: Deprecated option RSAAuthentication 4月 27 15:11:58 oldboy99 sshd[4614]: rexec line 149: Deprecated option RhostsRSAAuthentication 4月 27 15:11:58 oldboy99 sshd[4614]: Connection from 10.0.0.1 port 3384 on 10.0.0.203 port 12345 rdomain "" 4月 27 15:11:59 oldboy99 sshd[4614]: reprocess config line 147: Deprecated option RSAAuthentication 4月 27 15:11:59 oldboy99 sshd[4614]: reprocess config line 149: Deprecated option RhostsRSAAuthentication 4月 27 15:11:59 oldboy99 sshd[4614]: Accepted password for root from 10.0.0.1 port 3384 ssh2 4月 27 15:11:59 oldboy99 sshd[4614]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0) 4月 27 15:11:59 oldboy99 sshd[4614]: User child is on pid 4639
inactive
[root@oldboy99 /opt/cloud_ops]# cat ./reports/system_info.txt ./reports/service_status.txt >> ./reports/
operation.log service_status.txt system_info.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/system_info.txt ./reports/service_status.txt >> ./reports/final_report.txt
[root@oldboy99 /opt/cloud_ops]# cat ./reports/final_report.txt
Kernel:4.19.90-52.46.v2207.ky10.x86_64
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2025-04-27 15:11:20 CST; 2h 45min ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 4591 (sshd) Tasks: 1 Memory: 2.5M CGroup: /system.slice/sshd.service └─4591 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups 4月 27 15:11:20 oldboy99 sshd[4591]: Server listening on :: port 12345. 4月 27 15:11:20 oldboy99 systemd[1]: Started OpenSSH server daemon. 4月 27 15:11:58 oldboy99 sshd[4614]: rexec line 147: Deprecated option RSAAuthentication 4月 27 15:11:58 oldboy99 sshd[4614]: rexec line 149: Deprecated option RhostsRSAAuthentication 4月 27 15:11:58 oldboy99 sshd[4614]: Connection from 10.0.0.1 port 3384 on 10.0.0.203 port 12345 rdomain "" 4月 27 15:11:59 oldboy99 sshd[4614]: reprocess config line 147: Deprecated option RSAAuthentication 4月 27 15:11:59 oldboy99 sshd[4614]: reprocess config line 149: Deprecated option RhostsRSAAuthentication 4月 27 15:11:59 oldboy99 sshd[4614]: Accepted password for root from 10.0.0.1 port 3384 ssh2 4月 27 15:11:59 oldboy99 sshd[4614]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0) 4月 27 15:11:59 oldboy99 sshd[4614]: User child is on pid 4639
inactive
5. 环境清理
# 使用rm安全清理临时文件(先确认文件列表)
删除temp下所有内容.
##########################
[root@oldboy99 /opt/cloud_ops]# tree ./temp/
./temp/
├── db_query_a.log
├── db_query_b.log
├── db_query_c.log
├── web_access_1.log
├── web_access_2.log
├── web_access_3.log
├── web_access_4.log
└── web_access_5.log0 directories, 8 files
[root@oldboy99 /opt/cloud_ops]# rm -f ./temp/*
[root@oldboy99 /opt/cloud_ops]# tree ./temp/
./temp/0 directories, 0 files