首页 > 系统相关 >Linux关于用户和组操作的命令

Linux关于用户和组操作的命令

时间:2023-02-06 14:11:41浏览次数:44  
标签:group 用户组 Enter 用户 命令 command user Linux

准备工具

本篇已Ubuntu Linux系统为例来讲解Linux关于用户和组操作的命令(只有root权限才可以执行下面讲解的命令!)。不用担心其他发行版系统不能使用这些命令,它们的基本操作都是一样的。(本文后面还有英文翻译文章)

创建用户

在终端输入:

useradd -m -g 用户组名 用户名
-m命令的意思为在创建新用户的同时创建这个用户的家目录
-g命令的意思是将新建的用户归属于哪个用户组
以上两个参数可以不加

查看用户

在终端输入:

cat /etc/passwd
如果用户创建成功,在以上命令执行后显示的结果的最后一行就用关于新建用户的信息

为用户设置密码

在终端输入:

passwd 用户名
按照系统提示执行即可为用户设置密码

删除用户

在终端输入:

userdel 用户名

创建用户组

在终端输入:

groupadd 用户组名
随后可以向查看用户信息一样来查看用户组信息,也就是输入命令:
cat /etc/group
如果用户组创建成功,在以上命令执行后显示的结果的最后一行就用关于新建用户组的信息

删除用户组

在终端输入命令:

gourpdel 用户组名

切换用户

输入命令:

su 用户名
还可以输入命令直接切换到用户的家目录,输入命令:
su - 用户名

退出当前用户

输入命令:

exit

The following is the English translation above:

means of preparation

This article uses the Ubuntu Linux system as an example to explain Linux commands about user and group operations (only root permissions can execute the commands explained below!). Don't worry that other distribution systems can't use these commands. Their basic operations are the same.

Create user

Enter at the terminal:

useradd - m - g usergroupname username

-The m command means to create the user's home directory while creating a new user

-The g command means which user group the new user belongs to

The above two parameters can be omitted

View users

Enter at the terminal:

cat /etc/passwd

If the user is created successfully, the last line of the result displayed after the above command is executed will use the information about the new user

Set password for user

Enter at the terminal:

passwd user name

Follow the system prompts to set the password for the user

delete user

Enter at the terminal:

gourpdel user group name

Create user group

Enter at the terminal:

groupadd user group name

Then you can view user group information as you can view user information, that is, enter the command:

cat /etc/group

If the user group is created successfully, the last line of the result displayed after the above command is executed will use the information about the new user group

Delete User Group

Enter the command at the terminal:

gourpdel user group name

Switch users

Enter command:

su user name

You can also enter the command to directly switch to the user's home directory, and enter the command:

su - User name

Exit the current user

Enter command:

exit

标签:group,用户组,Enter,用户,命令,command,user,Linux
From: https://www.cnblogs.com/sokemile/p/17095233.html

相关文章

  • LINUX系统下需要Enter password时密码不显示
    如题,可能会有人像我一样用惯了windows在输入密码时输入的字符用“********”来代替。所以第一次用Linux在enterpassword时会比较懵,输了之后屏幕上啥也不显示。其实linux......
  • 'powershell'/'netsh'不是内部或外部命令,也不是可运行的程序或批处理文件
    笔者win10系统;昨天在配置openssh的时候在cmd里遇到了这两个报错。上网查了一下,解决方法分别是:'powershell':在环境变量path后添加powershell的路径(C:\Windows\System......
  • Centos7 设置默认启动界面为命令行
    有时候我们安装了Centos7后如果安装了GNOME的话,启动后默认都是进入到GNOME的GUI图形化界面中去的,但是实际的情况是我们可能因为某种原因,比如想要更加轻便一点,以命令行界面......
  • web之命令执行常见函数------2023.2.6
     system()函数作用:将字符串作为OS命令执行,自带输出功能。格式:stringsystem(string$command[,int&$return_var])//$command为执行的命令,&return_var可选,用来......
  • linux内核源码解析01–启动代码分析之汇编部分
    首先是引导程序,即bootloader,简单说即bootloader会做如下事情:(1)初始化物理内存;(2)设置设备树;(3)解压缩内核映像,将其加载到内核运行地址(可选);(4)跳转到内核入口地址;......
  • Linux下NTP服务器配置
    (Linux下NTP服务器配置)一、环境配置1.NTP服务器NTP服务器版本:RedHatEnterpriseLinuxrelease8.0(Ootpa)NTP服务器IP:192.168.8.11/24NTP服务器hostname:node12.......
  • tcpdump 命令
    tcpdump:一个可以根据需求来抓取网络上传输的数据包的工具 一般操作系统不会安装有,需要手动安装:yum-yinstalltcpdump 参数/选项的说明-i  tcpdump-ieth......
  • 用户下单
    移动端用户将菜品或者套餐加入购物车后,可以点击购物车中的【去结算】按钮页面跳转到订单确认页面,点击【去支付】按钮则完成下单操作。用户下单业务对应的数据表为orde......
  • 五、python——用户输入和while循环
    #函数input()让程序暂停运行,等待用户输入一些文本。#获取用户输入后,Python将其存储在一个变量中,以方便你使用message=input("Tellmesomething,andIwillrepea......
  • 项目实战:Qt终端命令模拟工具 v1.0.0(实时获取命令行输出,执行指令,模拟ctrl+c中止操作)
    需求  在Qt软件中实现部分终端控制命令行功能,使软件内可以又好的模拟终端控制,提升软件整体契合度。<br>Demo演示      <br>功能描述v1.0.0  windows......