云原生高级课前置复习一
·
一.命令行使用技巧
1.什么是内核、什么是shell、什么是Linux、什么是开源
2.Linux中命令录入方式
3.命令行快捷键
4.命令行补齐<TAB>
5.命令行中如何获得帮助 --help man
二.Linux下文件管理
1.touch、mkdir、rm、cp、mv、cat、head、less、vim、file、wc、ls
2.二级目录的作用
3.文件寻址 相对路径、绝对路径
4.文件批处理
*、?、[[:alpha:]]、[[:aigit:]]、[[:lower:]]、[[:upper:]]、[[:alnum:]]、[[:punct:]]、[[:space:]]
[]、{}
#实验 #说明:建议开启两个shell,在一个shell中开启监控 [root@localhost mnt]# watch -n 1 ls -Rl #在另外一个shell中操作 [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr lee [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# [root@localhost mnt]# rm -fr * [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr ??? [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr ???? [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le*e [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee file [root@localhost mnt]# rm -fr le*e [root@localhost mnt]# rm -fr * [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:digit:]]e [root@localhost mnt]# touch le8e leAe le@e leae le\ e lee [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# touch le66e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:digit:]]e [root@localhost mnt]# rm -fr le[[:digit:]][[:digit:]]e [root@localhost mnt]# touch le66e leAe le@e leae le\ e lee [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:digit:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:punct:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:punct:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# [root@localhost mnt]# rm -fr le[[:punct:]]*e [root@localhost mnt]# rm -fr le[[:space:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:alpha:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:upper:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:lower:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:alnum:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[[:punct:][:space:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[![:punct:][:space:]]*e [root@localhost mnt]# touch le6e leAe le@e leae le\ e lee [root@localhost mnt]# rm -fr le[^[:punct:][:space:]]*e
复制指定目录中符合指定条件的文件到指定位置并加入特定后缀
#复制/etc/中以.conf 结尾的文件到/mnt/conf.bak/中并加入.bak后缀
[root@localhost mnt]# find /etc -type f -name "*.conf" -exec sh -c 'cp "$1" "/mnt/conf.bak/$(basename "$1").bak"' _ {} \;
[root@localhost mnt]# ls /etc | awk '/\.conf$/{system("cp -r /etc/"$0 " /mnt/conf.bak/"$0".bak")}'
三.Linux中的输入和输出
1.字符设备是啥?
2.输入和输出的基本原理
3.输出重定向
4.追加
5.输入重定向
6.多行录入
7.管道
8.错误输出通过管道
9.输出复制
#实验步骤 #1.建立实验环境 [root@localhost mnt]# chmod 777 /mnt/ [root@localhost mnt]# watch -n 1 cat * #2.在另外一个shell中 [root@localhost mnt]# useradd lee [root@localhost mnt]# [root@localhost mnt]# su - lee [lee@localhost ~]$ #3.实验过程 [lee@localhost ~]$ find /etc/ -name passwd 2> /mnt/lee /etc/pam.d/passwd /etc/passwd [lee@localhost ~]$ find /etc/ -name passwd &> /mnt/lee [lee@localhost ~]$ > /mnt/lee [lee@localhost ~]$ [lee@localhost ~]$ echo hello linux > lee [lee@localhost ~]$ echo hello linux > lee^C [lee@localhost ~]$ cd /mnt/ [lee@localhost mnt]$ echo hello linux > lee [lee@localhost mnt]$ echo hello linux > lee [lee@localhost mnt]$ find /etc/ -name passwd >> /mnt/lee find: ‘/etc/sudoers.d’: 权限不够 find: ‘/etc/pki/rsyslog’: 权限不够 find: ‘/etc/sssd’: 权限不够 find: ‘/etc/nftables’: 权限不够 find: ‘/etc/sos/cleaner’: 权限不够 find: ‘/etc/ssh/sshd_config.d’: 权限不够 find: ‘/etc/lvm/archive’: 权限不够 find: ‘/etc/lvm/backup’: 权限不够 find: ‘/etc/lvm/cache’: 权限不够 find: ‘/etc/lvm/devices’: 权限不够 find: ‘/etc/polkit-1/rules.d’: 权限不够 find: ‘/etc/polkit-1/localauthority’: 权限不够 find: ‘/etc/grub.d’: 权限不够 find: ‘/etc/audit’: 权限不够 find: ‘/etc/firewalld’: 权限不够 [lee@localhost mnt]$ find /etc/ -name passwd ^C /mnt/lee [lee@localhost mnt]$ [lee@localhost mnt]$ tr '' tr: “” 后缺少操作数 当进行替换操作时必须给定两组字符串。 请尝试执行 "tr --help" 来获取更多信息。 [lee@localhost mnt]$ cat lee | tr 'a-z' 'A-Z' HELLO LINUX /ETC/PAM.D/PASSWD /ETC/PASSWD [lee@localhost mnt]$ [lee@localhost mnt]$ tr 'a-z' 'A-Z' <lee HELLO LINUX /ETC/PAM.D/PASSWD /ETC/PASSWD [lee@localhost mnt]$ echo haha | tr 'a-z' 'A-Z' HAHA [lee@localhost mnt]$ echo -e "haha\nhehe" | tr 'a-z' 'A-Z' HAHA HEHE [lee@localhost mnt]$ tr 'a-z' 'A-Z' <<EOF > hehe > haha > xixi > EOF HEHE HAHA XIXI [lee@localhost mnt]$ [lee@localhost mnt]$ echo haha | tr 'a-z' 'A-Z' ^C [lee@localhost mnt]$ find /etc/ -name passwd | wc -l find: ‘/etc/sudoers.d’: 权限不够 find: ‘/etc/pki/rsyslog’: 权限不够 find: ‘/etc/sssd’: 权限不够 find: ‘/etc/nftables’: 权限不够 find: ‘/etc/sos/cleaner’: 权限不够 find: ‘/etc/ssh/sshd_config.d’: 权限不够 find: ‘/etc/lvm/archive’: 权限不够 find: ‘/etc/lvm/backup’: 权限不够 find: ‘/etc/lvm/cache’: 权限不够 find: ‘/etc/lvm/devices’: 权限不够 find: ‘/etc/polkit-1/rules.d’: 权限不够 find: ‘/etc/polkit-1/localauthority’: 权限不够 find: ‘/etc/grub.d’: 权限不够 find: ‘/etc/audit’: 权限不够 find: ‘/etc/firewalld’: 权限不够 2 [lee@localhost mnt]$ find /etc/ -name passwd 2>&1 | wc -l 17 [lee@localhost mnt]$ find /etc/ -name passwd 2>&1 | wc -l 17 [lee@localhost mnt]$ find /etc/ -name passwd 2>&1 | tee file | wc -l 17 [lee@localhost mnt]$ rm -fr /mnt/* [lee@localhost mnt]$ find /etc/ -name passwd 2>&1 | tee file | wc -l [lee@localhost mnt]$ find /etc/ -name passwd 2>&1 | tee file | wc -l 17
四.用户管理
1.用户存在的意义(3A机制)
2.用户涉及到的系统配置文件有哪些
/etc/passwd /etc/group /etc/shadow /etc/skel/.* #用户配置文件模板,建立用户时会把此目录中的所有文件复制到新建用户的家目录中 /var/spool/mail/username /home/username
3.用户管理
userdel -r useradd -u -g -G -M -s -c -d usermod -l -g -G -aG -c -d -md -s -U -L passwd -S -d -e -x -n -w --stdin chage -d -W -m -M -E -I
4.权力下放
/etc/sudoers #不建议直接编写,因为没有语法检测 visudo sudo command
五.Linux系统中的权限管理
1.权限读取
元数据?
文件属性种类?
元数据被记录在磁盘的什么位置
2.更改文件所有人所有组
chown chgrp
3.文件普通权限
文件权限的类型
- 0
r 4
w 2
x 1
chmod
4.默认权限
umask
5.特殊权限
suid sgid stickybit 针对目录,当目录开启了此权限,在目录中文件只能被文件的所有人删除 [root@localhost ~]# mkdir /mnt/pub [root@localhost ~]# chmod 777 /mnt/pub/ [root@localhost ~]# watch ls -Rl /mnt/ [root@localhost mnt]# su - lee [lee@localhost ~]$ touch /mnt/pub/leefile [lee@localhost ~]$ 注销 [root@localhost mnt]# su - timinglee [timinglee@localhost ~]$ touch /mnt/pub/tfile [timinglee@localhost ~]$ rm -fr /mnt/pub/tfile [timinglee@localhost ~]$ rm -fr /mnt/pub/leefile [timinglee@localhost ~]$ ^C [timinglee@localhost ~]$ 注销 [root@localhost mnt]# [root@localhost mnt]# chmod 1777 /mnt/pub/ [root@localhost mnt]# touch /mn^C [root@localhost mnt]# su - timinglee [timinglee@localhost ~]$ touch /mnt/pub/tfile [timinglee@localhost ~]$ 注销 [root@localhost mnt]# su - lee [lee@localhost ~]$ rm -fr /mnt/pub/tfile
6.权限列表acl
setfac -m -m d -x -b getfac
7.attr
-i [root@localhost mnt]# chattr +i /mnt/pub/ [root@localhost mnt]# touch /mnt/pub/file touch: 正在设置 '/mnt/pub/file' 的时间: 没有那个文件或目录 -a [root@localhost mnt]# chattr +a /mnt/pub/ [root@localhost mnt]# lsattr /mnt/pub/ -d -----a---------------- /mnt/pub/ [root@localhost mnt]# touch /mnt/pub/file [root@localhost mnt]# rm -fr /mnt/pub/file rm: 无法删除 '/mnt/pub/file': 不允许的操作
六.进程管理
1.什么时进程什么是线程
2.进程状态
3.进程查看命令
ps pidof [root@localhost mnt]# vim & [1] 27942 [root@localhost mnt]# pidof vim 27942 [1]+ 已停止 vim pgrep root@localhost mnt]# su - lee [lee@localhost ~]$ vim & [1] 28012 [lee@localhost ~]$ vim & [2] 28013 [1]+ 已停止 vim [lee@localhost ~]$ vim ^ [2]+ 已停止 vim [lee@localhost ~]$ vim & [3] 28015 [root@localhost ~]# pgrep -lu lee 27979 bash 28012 vim 28013 vim 28015 vim top
4.进程前后台调用
[root@localhost mnt]# ping www.baidu.com PING www.a.shifen.com (183.2.172.177) 56(84) 比特的数据。 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=1 ttl=128 时间=45.9 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=2 ttl=128 时间=53.5 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=3 ttl=128 时间=48.6 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=4 ttl=128 时间=51.4 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=5 ttl=128 时间=48.9 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=6 ttl=128 时间=41.6 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=7 ttl=128 时间=44.7 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=8 ttl=128 时间=46.6 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=9 ttl=128 时间=44.7 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=10 ttl=128 时间=46.2 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=11 ttl=128 时间=46.8 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=12 ttl=128 时间=43.8 毫秒 ^Z #ctrl+z 标识把占用终端的进程打入后台停止 [1]+ 已停止 ping www.baidu.com [root@localhost mnt]# ps PID TTY TIME CMD 1732 pts/0 00:00:00 bash 28027 pts/0 00:00:00 ping 28028 pts/0 00:00:00 ps [root@localhost mnt]# jobs [1]+ 已停止 ping www.baidu.com root@localhost mnt]# jobs [1]+ 已停止 ping www.baidu.com [root@localhost mnt]# fg 1 ping www.baidu.com 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=13 ttl=128 时间=45.2 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=14 ttl=128 时间=48.1 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=15 ttl=128 时间=61.4 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=16 ttl=128 时间=41.8 毫秒 ^Z [1]+ 已停止 ping www.baidu.com ost mnt]# [root@localhost mnt]# bg 1 [1]+ ping www.baidu.com & [root@localhost mnt]# 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=17 ttl=128 时间=38.6 毫秒 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=18 ttl=128 时间=38.2 毫秒 [root@localhost mnt]# 64 比特,来自 183.2.172.177 (183.2.172.177): icmp_seq=19 ttl=128 时间=37.3 毫秒 [root@localhost mnt]# [root@localhost mnt]# [root@localhost mnt]# [root@localhost mnt]# [root@localhost mnt]# [root@localhost mnt]# vim &
5.进程优先级
6.进程信号
7.守护进程
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)