给Linux添加新用户,新建用户,新建帐号
给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下查看所有用户及所有用户组
whoami 查看当前登录用户名
/etc/group文件包含所有组
/etc/shadow和/etc/passwd系统存在的所有用户名
#修改passwd文件禁止mysql登陆
vi /etc/passwd
将/bin/bash改为/sbin/nologin
给Linux添加新用户,新建用户,新建帐号的更多相关文章
- linux添加新LUN,无需重启
linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似a ...
- Linux添加新硬盘自动挂载硬盘
Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...
- Linux 添加新用户账号并赋予root权限
除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1. 添加新用户账号 useradd mary.lee 2. 为新用户账号设置密码 passwd ...
- LINUX添加新的用户账号并赋予root权限
一:添加新的用户账号使用 useradd 命令 语法: useradd 选项 用户名 示例: # 添加用户,设定登录目录:useradd -d /home/admin -m a ...
- linux 添加新硬盘的方法
在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...
- Virtualbox中Linux添加新磁盘并创建分区
原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ----------------------------------------------- ...
- linux添加新硬盘
1.添加新磁盘 2.fdisk -l查看磁盘被识别的名称 3.如果输入fdisk -l命令没有找到新的磁盘,按下面步骤操作 1)进入到cd /sys/class/scsi_host/ 2)echo & ...
- linux添加新硬盘不需要重启识盘,及查看uuid
添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态 查看主机总线号,命令:ls /sys/class/scsi_ ...
- 在SQL Server中添加供应用程序使用的帐号
在之前客户咨询案例中,很多客户应用程序连接SQL Server直接用的就是SA帐号.如果对数据库管理稍微严格一点的话,就不应该给应用程序这种权限,通常应用程序只需要进行增删改查,而很少有DDL ...
随机推荐
- Git-如何将已存在的项目提交到git
1.首先在码云或者github上创建一个不带README.md的项目,然后复制远程库的地址(下面以码云为例): 2.进入本地已存在的项目目录:house touch README.md //新建说明 ...
- PostgreSQL Replication之第七章 理解Linux高可用(5)
7.5 高可用性是所有冗余 让我们从一个不同的角度看一下前面的混合超市的例子.为了处理大量顾客无需长排队,无需关闭超市,混合超市雇用更多的出纳员以及安装许多(甚至更多)的收银机. 这样,如果一个收银机 ...
- <Three.js>(第一节)环境搭建
Three.js顾名思义3D的js库.是运行在浏览器的基于webgl的3D引擎.该引擎是github上的一个开源项目,下载地址:https://github.com/mrdoob/three.js/ ...
- BAPC 2014 Preliminary(第一场)
D:Lift Problems On the ground floor (floor zero) of a large university building a number of students ...
- 用 while 循环做个小游戏
import random #可输入次数 flag = 0 #生成一个1到10之间的随机整数 res = random.randint(1,10) #判读三次输入机会 while(flag<3) ...
- centos通过yum安装jdk
安装之前先检查一下系统有没有自带open-jdk 命令: rpm -qa |grep java rpm -qa |grep jdk rpm -qa |grep gcj 如果没有输入信息表示没有安装. ...
- 单调队列&单调栈归纳
单调队列 求长度为M的区间内的最大(小)值 单调队列的基本操作,也就是经典的滑动窗口问题. 求长度为M的区间内最大值和最小值的最大差值 两个单调队列,求出长度为M的区间最大最小值的数组,分别求最大最小 ...
- Android 查看CPU及内存
借助getprop.dumpsys来了解一些系统相关信息. 一.getprop adb shell cat /system/build.prop 文件中存放的是用于启动系统时需要的配置文件,通常可以通 ...
- 修改cloudera manager的端口号
最近想在测试机装一个hadoop测试集群debug玩玩,然后就用cloudera manager装吧 这回使用rpm安装失败了,在网上搜到Cloudera Manager 5和CDH5离线安装说需要用 ...
- Nginx 性能调优
原文地址:http://nginx.com/blog/tuning-nginx/ Tuning NGINX for Performance Nginx 性能调优 NGINX is well known ...