基础运维
基础命令
- 查看开机时间
last reboot
top
- 删除账号
userdel -r test
-r会删除所有关联信息,包括/home/test
权限控制
r对应4,w对应2,x对应1
u:user(所有者) g:group(所属组) o:other(其他人) a:all(所有人) r:read(读) w:write(写) x:execute(执行)
ll
查看目录与权限- 更改所属用户与组
chown -R root:root xxxx
chmod 777 xxx
所有权限,用户,组,其他用户都有读写执行权限chmod u+x xxx
用户增加可执行权限chmod g-rwx xxx
组删除读写执行权限chmod o=rw xxx
其他用户设置成读写权限chmod o= xxx
其他用户设置成无访问权限chmod 770 xxx
(7=4+2+1)其他用户无访问权限,用户与用户组都具有读写执行权限
创建新账号部署tomcat
使用的jdk、tomcat等组件尽量使用最新稳定版本,避免版本过旧带来不必要的安全漏洞。
1 | 1. ssh root登录 |
其他
禁止su到root
- 去除
/etc/pam.d/su
文件中如下行的注释:#auth required pam_wheel.so use_uid
- 在
/etc/login.defs
文件中加入如下配置项:SU_WHEEL_ONLY yes
- 经过上述配置后,普通用户将被禁止su,如果希望指定普通用户su至root,可以执行如下命令将该用户添加至wheel组中,只用加入组中的用户才能互相su否则(报错su: incorrect password):
usermod -G wheel username
- 查看所属分组
id username
方法二:
在/etc/pam.d/su
文件前面加上auth sufficient pam_rootok.so debug
auth required pam_wheel.so group=wheel