Linux基础模块--day8(用户管理2)

Linux运维(基础模块)--day8

Linux系统用户管理

组命令管理

*组账户信息保存在/etc/group

/etc/group被':'分割为4个部分

  1. 组名称
  2. 密码占位符 -->组密码
  3. 组管理员
  4. 组成员 -->只显示附加成员, 不会显示基本成员

修改组信息

使用groupmod

# 修改组名称
groupmod -n [NewGroupName] [OldGroupName]
# Option
-g <群组识别码>  设置欲使用的群组识别码。
-o 重复使用群组识别码。
-n <新群组名称>  设置欲使用的群组名称。

身份切换

shell分类

  1. 交互式shell 等在用户输入命令,exit退出

  2. 非交互式shell 执行shell脚本, 脚本执行结束后自动退出shell

  3. 登录shell 需要用户名密码 eg: su

  4. 非登录shell 不需要用户名密码 eg: sh /bash

个人配置文件: ~/.bash_profile, ~/.bashrc
全局配置文件: /etc/profile, /etc/profile.d/*, /etc/bashrc

  • profile类

    设置环境变量, 登录前运行的脚本和命令

  • bashec类

    设置本地变量,定义命令别名

配置文件执行顺序

登录式shell

  1. /etc/profile
  2. etc/profile.d/*.sh
  3. ~/.bash_profile
  4. ~/.bashrc
  5. /etc/bashrc

非登录式shell

  1. ~/.bashrc
  2. etc/bashrc
  3. /etc/profile.d/*.sh

su 用户切换

su - [user]
su  # 切换到root

sudo提升权限

Centos提权方法

usermod -G whell [UserName]
  • 日志审计
sudo tail -f /var/log/secure
# 使用vi编辑/etc/sudoers配置文件
posted @ 2021-09-15 21:36  Alice只敲代码不秃头  阅读(27)  评论(0编辑  收藏  举报