cat oldboy.txt inode和block ?
记录指纹信息
[root@oldboyedu59 ~]#
[root@oldboyedu59 ~]#
[root@oldboyedu59 ~]#
[root@oldboyedu59 ~]# md5sum oldboy.txt
af5a89bcc62e35fcd51819bb4031ab2e oldboy.txt
[root@oldboyedu59 ~]# md5sum oldboy.txt >/tmp/police.md5
[root@oldboyedu59 ~]#
与公安局的指纹信息进行对比
[root@oldboyedu59 ~]# md5sum --check /tmp/police.md5
oldboy.txt: OK
[root@oldboyedu59 ~]# >oldboy.txt
[root@oldboyedu59 ~]# md5sum --check /tmp/police.md5
oldboy.txt: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
[root@oldboyedu59 ~]# md5sum -c /tmp/police.md5
oldboy.txt: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
1.找出/oldboy目录下面 以.txt结尾的文件 制作md5 存放在/tmp/oldboy.md5
2.对比 md5sum -c
[root@oldboyedu59 ~]# find /oldboy/ -type f -name "*.txt" |xargs md5sum >/tmp/oldboy.md5
[root@oldboyedu59 ~]# head /tmp/oldboy.md5
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/oldboy01.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/oldboy02.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/oldboy03.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/oldboy04.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/oldboy05.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/alex01.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/alex02.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/alex03.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/alex04.txt
d41d8cd98f00b204e9800998ecf8427e /oldboy/lidao/alex05.txt
[root@oldboyedu59 ~]# md5sum -c /tmp/oldboy.md5
/oldboy/lidao/oldboy01.txt: OK
/oldboy/lidao/oldboy02.txt: OK
/oldboy/lidao/oldboy03.txt: OK
/oldboy/lidao/oldboy04.txt: OK
/oldboy/lidao/oldboy05.txt: OK
/oldboy/lidao/alex01.txt: OK
/oldboy/lidao/alex02.txt: OK
/oldboy/lidao/alex03.txt: OK
/oldboy/lidao/alex04.txt: OK
/oldboy/lidao/alex05.txt: OK
/oldboy/lidao/oldboy.txt: OK
/oldboy/oldboy01.txt: OK
/oldboy/oldboy02.txt: OK
/oldboy/oldboy03.txt: OK
/oldboy/oldboy04.txt: OK
/oldboy/oldboy05.txt: OK
/oldboy/id.txt: OK
/oldboy/lidao.txt: OK
/oldboy/oldboy.txt: OK
/oldboy/fs.txt: OK
/oldboy/passwd.txt: OK
/oldboy/lidao01.txt: OK
/oldboy/lidao02.txt: OK
/oldboy/lidao03.txt: OK
/oldboy/lidao04.txt: OK
/oldboy/lidao05.txt: OK
[root@oldboyedu59 ~]# chattr +i oldboy.txt
[root@oldboyedu59 ~]# lsattr oldboy.txt
----i----------- oldboy.txt
[root@oldboyedu59 ~]# echo oldboy >>oldboy.txt
-bash: oldboy.txt: Permission denied
[root@oldboyedu59 ~]# >oldboy.txt
-bash: oldboy.txt: Permission denied
[root@oldboyedu59 ~]# \rm -f oldboy.txt
rm: cannot remove ‘oldboy.txt’: Operation not permitted
常用的命令解释器
/bin/bash
/sbin/nologin #虚拟用户的命令解释器
/bin/dash #ubuntu
/bin/csh /bin/tcsh #unix
找出/etc/passwd中的虚拟用户,显示这个用户的名字和uid
[root@oldboyedu59 ~]# awk -F: '/nologin1,NF}' /etc/passwd |column -t
bin 1 /sbin/nologin
daemon 2 /sbin/nologin
adm 3 /sbin/nologin
lp 4 /sbin/nologin
mail 8 /sbin/nologin
operator 11 /sbin/nologin
games 12 /sbin/nologin
ftp 14 /sbin/nologin
nobody 99 /sbin/nologin
systemd-network 192 /sbin/nologin
dbus 81 /sbin/nologin
polkitd 999 /sbin/nologin
tss 59 /sbin/nologin
abrt 173 /sbin/nologin
sshd 74 /sbin/nologin
postfix 89 /sbin/nologin
#/etc/skel
[root@oldboyedu59 ~]# ll /etc/skel/
total 0
[root@oldboyedu59 ~]# ll -a /etc/skel/
total 24
drwxr-xr-x. 2 root root 62 Apr 11 2018 .
drwxr-xr-x. 79 root root 8192 Apr 24 11:16 ..
-rw-r--r--. 1 root root 18 Oct 31 01:07 .bash_logout
-rw-r--r--. 1 root root 193 Oct 31 01:07 .bash_profile
-rw-r--r--. 1 root root 231 Oct 31 01:07 .bashrc
.bash_profile /etc/profile PS1 LANG PATH
.bashrc /etc/bashrc
.bash_logout
【企业故障案例】:命令行提示符-bash-4.1
故障模拟:
1.修改/etc/profile PS1加上注释
[root@oldboyedu59 ~]# tail -1 /etc/profile
#export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
2.添加的用户
useradd alex
3.切换用户
[root@oldboyedu59 ~]# su - alex
[alex@oldboyedu59 ~]$
4.检查是否有suid
ls -l /bin/rm
5.删根
rm -fr /*
6.重新登录alex ,出现故障
[root@oldboyedu59 ~]# su - alex
Last login: Wed Apr 24 11:42:51 CST 2019 on pts/0
-bash-4.2$
-bash-4.2$
-bash-4.2$
-bash-4.2$
原因:
当前用户的环境变量的配置文件.bash_profile .bashrc 被删除
解决?
复制?
方法1 从别人家复制 oldboy (提示权限拒绝)
-bash-4.2$ whoami
alex
-bash-4.2$ cp /home/oldboy/.bash* ~
cp: cannot stat ‘/home/oldboy/.bash*’: Permission denied
-bash-4.2$ ll -d /home/oldboy/
drwx------ 2 oldboy oldboy 99 Apr 23 12:01 /home/oldboy/
-bash-4.2$ ls /home/oldboy/
ls: cannot open directory /home/oldboy/: Permission denied
方法2 从/etc/skel复制 (√)
-bash-4.2$ cp /etc/skel/.bash* ~
-bash-4.2$
-bash-4.2$ logout
[root@oldboyedu59 ~]# su - alex
Last login: Wed Apr 24 11:44:23 CST 2019 on pts/0
[alex@oldboyedu59 ~]$
[alex@oldboyedu59 ~]$
[alex@oldboyedu59 ~]$
[root@oldboyedu59 ~]# #添加用户oldboy888 指定uid为888 不可登录系统 不创建家目录
[root@oldboyedu59 ~]# useradd -u 888 -s /sbin/nologin -M oldboy888
[root@oldboyedu59 ~]# id oldboy888
uid=888(oldboy888) gid=1003(oldboy888) groups=1003(oldboy888)
[root@oldboyedu59 ~]# grep oldboy /etc/passwd
oldboy:x:1000:1000::/home/oldboy:/bin/bash
oldboy888:x:888:1003::/home/oldboy888:/sbin/nologin
[root@oldboyedu59 ~]# ls -l /home/oldboy888
ls: cannot access /home/oldboy888: No such file or directory
[root@oldboyedu59 ~]# su - oldboy
Last login: Wed Apr 24 12:28:18 CST 2019 on pts/0
[oldboy@oldboyedu59 ~]$ whoami
oldboy
[oldboy@oldboyedu59 ~]$ logout
[root@oldboyedu59 ~]# su - oldboy -c whoami
oldboy
网友评论