给Linux添加新用户,新建用户,新建帐号

添加用户组

sudo groupadd groupname

添加用户

sudo useradd username -m -s /sbin/nologin -d /home/username -g groupname
-s /sbin/nologin 设置不能登陆 -s /bin/false(老方法) 也行
-d 设置用户主目录
-g 用户组
-m 创建用户目录

useradd的具体参数为

[root@317304 ~]# useradd --help
Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping

更改用户登录权限

在增加了-s /sbin/nologin 参数后,那么这个帐号就不能登陆了,如果想要恢复登陆使用

sudo usermod -s /bin/bash username

禁用用户登录权限

sudo usermod -s /sbin/nologin username

设置密码

给用户设置密码,这样帐号就能使用了。

sudo passwd username

删除用户

删除用户

sudo userdel username

原文  https://www.chenyudong.com/archives/linux-add-new-userer.html

linux下查看所有用户及所有用户组
    原文 https://blog.csdn.net/zdwzzu2006/article/details/7944434
groups 查看当前登录用户的组内成员
groups gliethttp 查看gliethttp用户所在的组,以及组内成员
whoami 查看当前登录用户名

/etc/group文件包含所有组
/etc/shadow和/etc/passwd系统存在的所有用户名

#修改passwd文件禁止mysql登陆

vi /etc/passwd

将/bin/bash改为/sbin/nologin

给Linux添加新用户,新建用户,新建帐号的更多相关文章

  1. linux添加新LUN,无需重启

    linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似a ...

  2. Linux添加新硬盘自动挂载硬盘

    Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...

  3. Linux 添加新用户账号并赋予root权限

    除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1.  添加新用户账号 useradd  mary.lee 2.  为新用户账号设置密码 passwd ...

  4. LINUX添加新的用户账号并赋予root权限

    一:添加新的用户账号使用 useradd 命令 语法:     useradd  选项  用户名 示例:      # 添加用户,设定登录目录:useradd -d  /home/admin -m a ...

  5. linux 添加新硬盘的方法

    在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...

  6. Virtualbox中Linux添加新磁盘并创建分区

    原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ----------------------------------------------- ...

  7. linux添加新硬盘

    1.添加新磁盘 2.fdisk -l查看磁盘被识别的名称 3.如果输入fdisk -l命令没有找到新的磁盘,按下面步骤操作 1)进入到cd /sys/class/scsi_host/ 2)echo & ...

  8. linux添加新硬盘不需要重启识盘,及查看uuid

     添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态     查看主机总线号,命令:ls /sys/class/scsi_ ...

  9. 在SQL Server中添加供应用程序使用的帐号

        在之前客户咨询案例中,很多客户应用程序连接SQL Server直接用的就是SA帐号.如果对数据库管理稍微严格一点的话,就不应该给应用程序这种权限,通常应用程序只需要进行增删改查,而很少有DDL ...

随机推荐

  1. AngularJs轻松入门(一)创建第一个应用

    AngularJs是Google工程师研发的一款JS框架,官方文档中对它的描述是,它是完全使用JavaScript编写的客户端技术,同其他历史悠久的Web技术(HTML,CSS等)配合使用,使得Web ...

  2. 12 条实用的 zypper 命令范例 (转载)

    12 条实用的 zypper 命令范例 作者: Kerneltalks 译者: LCTT cycoe | 2018-12-12 13:29 zypper 是 Suse Linux 系统的包和补丁管理器 ...

  3. core组件进阶

    访问图像像素 存储方式 BGR连续存储有助于提升图像扫描速度. isContinuous()判断是否是连续存储. 颜色空间缩减 仅用这些颜色中具有代表性的很小的部分,就足以达到同样的效果. 将现有颜色 ...

  4. yii2.0缓存篇之页面缓存

    页面缓存: 如果整个页面都不会发生改变,就可以使用页面缓存缓存整个页面. public function behaviors(){            //此方法[也叫行为]会提前控制器内其他方法执 ...

  5. ELK安装笔记

    1.jdk安装 2.logstash安装使用 #命令方式[root@ELK ELK]# tar xf logstash-5.3.2.tar.gz [root@ELK logstash-5.3.2]# ...

  6. es6 学习2 模板字符

    es6模板字符简直是开发者的福音啊,解决了ES5在字符串功能上的痛点. 1.第一个用途,基本的字符串格式化.将表达式嵌入字符串中进行拼接.用${}来界定 //es5 var name = 'lux' ...

  7. bzoj1935 [Shoi2007]园丁的烦恼

    bzoj1935 [Shoi2007]园丁的烦恼 有N个点坐标为(xi,yi),M次询问,询问(a,b)-(c,d)的矩形内有多少点. 0≤n≤500000,1≤m≤500000,0≤xi,yi≤10 ...

  8. numpy基础篇-简单入门教程3

    np import numpy as np np.__version__ print(np.__version__) # 1.15.2 numpy.arange(start, stop, step, ...

  9. [NOI2015]品酒大会(SA数组)

    [NOI2015]品酒大会 题目描述 一年一度的"幻影阁夏日品酒大会"隆重开幕了.大会包含品尝和趣味挑战 两个环节,分别向优胜者颁发"首席品酒家"和" ...

  10. ubuntu中开启、关闭防火墙

    1.关闭ubuntu的防火墙        ufw disable 开启防火墙 ufw enable 2.卸载了iptables        apt-get remove iptables 3.关闭 ...