Linux User & Group

Linux User & Group

1. User

创建用户

sudo useradd username

设置用户密码

sudo passwd username

删除用户并删除相关目录

sudo userdel -r username

修改用户属性

sudo usermod <-option value> username

可用的选项包括:

  • -l:修改用户名。
  • -a:用于将用户追加到某些组中,必须与"-G"选项一起使用。
  • -c:修改用户账户的注释信息。
  • -G:将用户添加到附加组。多个组名之间用逗号分隔。
  • -g:修改用户的主组。
  • -s:修改用户的默认shell。

示例:

将用户名username_old修改为username_new

sudo usermod -l username_new username_old

2. Group

注意:修改完重连ssh刷新组

创建用户组

sudo groupadd groupname

删除用户组

sudo groupdel groupname

修改用户组属性

sudo groupmod -options groupname

切换组

newgrp groupname

管理组的密码和成员

设置用户组密码

sudo gpasswd groupname

添加当前用户进组

sudo gpasswd -a $USER group_name

从用户组中删除用户

sudo gpasswd -d username groupname

授予用户组管理权限

sudo gpasswd -A username groupname

撤销用户组的管理权限

sudo gpasswd -R username groupname

查看组成员

getent group groupname

查看当前组

gropus

3. 常用组问题

3.1. docker使用提示没有权限

创建docker

sudo groupadd docker

将当前用户添加到docker

sudo usermod -aG docker $USER

切换到docker

newgrp docker

4. 参考

  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Group Linux, also known as "Linux distributions," refers to the various operating system distributions built upon the Linux kernel, which is an open-source and free software project developed by Linus Torvalds in 1991. These distributions are created by different teams around the world and offer a user-friendly interface, pre-installed software packages, and customization options tailored to meet the needs of different users and use cases. Some popular examples of Linux distributions include: 1. Ubuntu: A widely-used distribution known for its simplicity and frequent updates. It's based on Debian and popular among both beginners and professionals. 2. Red Hat Enterprise Linux (RHEL): Primarily designed for enterprise environments, it's known for its stability and support. RHEL derivatives like CentOS and Fedora are also widely used. 3. Debian: One of the oldest and most stable distributions, Debian is the foundation for many other distributions like Ubuntu. 4. CentOS: A community-supported version of Red Hat Enterprise Linux, offering a long-term support cycle. 5. Arch Linux: A lightweight and highly customizable distribution that encourages users to manage their systems manually. 6. Android: Although not technically a traditional Linux distribution, it uses a Linux kernel for its mobile operating system. Each distribution has its own package manager, desktop environments (like GNOME, KDE, or XFCE), and community support. Users can choose based on their requirements, hardware compatibility, and familiarity with the software stack.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yimtcode

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值