Linux User and Group Management
linux is a multi-user and multitasking OS. In Linux, you can create any number of user account and groups. A user is always connected to a particular group and there can be any number of groups as well.
The user home directory by default is created under “/home” directory with the user name. E.g. User techbie has home directory “/home/techbie”, the mail account is created under “/var/spool/mail/”.
Each user and group in the system is identified by a unique no called as ID.
/etc/passwd
The file whare system user account definition is done is /etc/passwd. This file has the following strucutre
#cat /etc/passwd
username:a:500:500:Some Comments:/home/username:/bin/sh
username :
The system account username. It should not start with a number or include uppercase letters
a
The password. As a points to /etc/shadow for the password. An * means the account is disabled. A random group of letters and numbers represents the encrypted password
500
the user ID(UID) for the user
500
the group ID (GID) associated with that user
Some comments
Any information can be used in this field
/home/username
By default, RHEL places new home directories in /home/username
/bin/sh
Default user shell
In order add/delete users to the system this file can be edited directly with vipw or using useradd/userdel commends a described in next sections
/etc/group
The file where system group account definition is done is /etc/group . This file has the following structure
#cat /etc/group groupname:x:500:user1,user2
groupname
The system account groupname user gets this own group. BY default when a user is crated is related to a group with groupname equal to username
x
The group password. An x points to /etc/gshadow for the password as user password on /etc/passwd random group of letters and numbers represents the encrypted password
500
The group ID (GID) associated with user
user1, user2
Lists of users that belong t the group If it’s blank means that there is a username that is identical to the groupname
In order to add/delete groups to the system this file can be edited directly with vigr or using useradd/userdel commands as described in net section
/etc/shadow
The /etc/shadow file is can be read for every user on the system so include the encrypted password there is not a good idea. For this reason the file /etc/shadow accessible to root only is used to store the encrypted password
#/etc/shadow
username: $1sdsew$ed%wqee@132ewSDADdsa :14860:0:99999:7:::
Username
Username shadow entry, it is related with username account on /etc/passwd
$1sdsew$ed%wqee@132ewSDADdsa
Encrypted password. An x in the second column of /etc/passwd means that the encrypted password is stored here
14860
Last password changed date. In Linux epoch number if days: number of days after January 1, 1970
0
The values of 0 here means that this user can keep this password forever
99999
The system will ask to user to change his password after 99999 days since account creation
::
The values means the number if days before password expiration when is made a warning is given in this case none
::
the sets the no of days after password expiration when an account is made inactive in this case none
::
the values means the number if days after password expiration when an account is disabled in this case none
Adding user account:
When a user account needs to be added to the system the commend useradd must be used:
# useradd -u 678 -c “Test add user” -d /home/techbie -s /bin/bash techbie
With this command we have created the user account techbie with UID=678 which home directory in /home/techbie and default shell bash. By default the user is assigned to a new created group silicon with GID=678. This values can be changed using the -g option
#cat /etc/passwd
techbie:x:678:678:Test add user:/home/techbie:/bin/bash
Deleting user Account:
When a user account needs to be removed in the system the commend userdel must be used:
# userdel r techbie
With this commend all information about techbie account in removed on the system, including all home directory and mail spool files.
Modifying user Account:
I order to change the parameters of an existing account the commends usermod and/or chage can be used
# usermod e 2016-07-30 techbie
Sets the expiration account day for user “techbie” to 2016-07-30
# usermod G sales techbie
Sets ‘techbie’ account group ownership to sales group
# chage E -1 techbie
Removes any account expiration date for user “techbie”
# usermod expiredate 2016-07-30 techbie
Sets the expiredate for a user account techbie
# passwd d techbie
Disable the user account techbie
# passwd u techbie
Unlock the user account techbie
Linux User and Group Management的更多相关文章
- Linux指令--/etc/group文件
Linux /etc/group文件与/etc/passwd和/etc/shadow文件都是有关于系统管理员对用户和用户组管理时相关的文件.linux /etc/group文件是有关于系统管理员对用户 ...
- 每天一个linux命令: /etc/group文件详解
Linux /etc/group文件与/etc/passwd和/etc/shadow文件都是有关于系统管理员对用户和用户组管理时相关的文件.linux /etc/group文件是有关于系统管理员对用户 ...
- (linux)idr(integer ID management)机制
最近研究进程间通信,遇到了idr相关的函数,为了扫清障碍,先研究了linux的idr机制. IDR(integer ID management)的要完成的任务是给要管理的对象分配一个唯一的ID,于 ...
- Linux LVM Logical Volume Management 逻辑卷的管理
博主是一个数据库DBA,但是一般来说,是不做linux服务器LVM 逻辑卷的创建.扩容和减容操作的,基本上有系统管理员操作,一是各司其职,专业的事专业的人做,二是做多了你的责任也多了,哈哈! 但是li ...
- linux 学习随笔-group和user管理
1:/etc/passwd 打开该文件,可以看到每一行内容被分割成了7个字段比如:root:x:0:0:root:/root:/bin/bash 第一个字段表示用户名为root用户 第二个字段存放了该 ...
- <<Linux kernel development>> Process Management
The Process On modern operating systems,processes provide two virtualizations:a virtualized processo ...
- Neutron 理解(14):Neutron ML2 + Linux bridge + VxLAN 组网
学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...
- linux根文件系统制作
在嵌入式中移植的内核下载到开发板上,是没有办法真正的启动Linux操作系统的,会出现无法加载文件系统的错误. 那么根文件系统在系统启动中到底是什么时候挂载的呢?先将/dev/ram0挂载,而后执行/l ...
- Linux就这个范儿 第16章 谁都可以从头再来--从头开始编译一套Linux系统 nsswitch.conf配置文件
Linux就这个范儿 第16章 谁都可以从头再来--从头开始编译一套Linux系统 nsswitch.conf配置文件 朋友们,今天我对你们说,在此时此刻,我们虽然遭受种种困难和挫折,我仍然有一个梦 ...
随机推荐
- <Django>socket简单实现django简化版
服务端(自己实现django) ''' django简化版:socket服务端 a.收发浏览器信息----wsgiref.py b.根据用户访问的不同路径执行不同函数 c.从html读取出内容,并完成 ...
- java空和非空判断
public static boolean isEmpty(String str){ if("".equals(str)||str==null){ return true; }el ...
- 通过ID获取元素 注:获取的元素是一个对象,如想对元素进行操作,我们要通过它的属性或方法。
通过ID获取元素 学过HTML/CSS样式,都知道,网页由标签将信息组织起来,而标签的id属性值是唯一的,就像是每人有一个身份证号一样,只要通过身份证号就可以找到相对应的人.那么在网页中,我们通过id ...
- MyEclipse如何使用debug模式
知道如何打断点,如何进入debug与debug模式的视图,还有工具栏的使用和快捷键的使用 https://blog.csdn.net/menglanyingfei/article/details/55 ...
- BZOJ 4765: 普通计算姬 (分块+树状数组)
传送门 解题思路 树上的分块题,,对于修改操作,每次修改只会对他父亲到根这条链上的元素有影响:对于查询操作,每次查询[l,r]内所有元素的子树,所以就考虑dfn序,进标记一次,出标记一次,然后子树就是 ...
- 菜鸟nginx源码剖析数据结构篇(三) 单向链表 ngx_list_t[转]
菜鸟nginx源码剖析数据结构篇(三) 单向链表 ngx_list_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...
- Java序列化接口的作用总结1
一个对象有对应的一些属性,把这个对象保存在硬盘上的过程叫做”持久化”. 把堆内存中的对象的生命周期延长,存入硬盘,做持久化操作.当下次再需要这个对象的时候,我们不用new了,直接从硬盘中读取就可以了. ...
- 左神算法进阶班6_1LFU缓存实现
[题目] LFU也是一个著名的缓存算法,自行了解之后实现LFU中的set 和 get 要求:两个方法的时间复杂度都为O(1) [题解] LFU算法与LRU算法很像 但LRU是最新使用的排在使用频率最前 ...
- jun引导1.04可以让N3050支持6.2
1.03引导用在3050可以安装 但是安装后找不到dsm 需要手动插拔电源才可以解决 偶尔还会死机 1.04可以引导3050安装6.2 23739 安装24922正常,但是moments传照片后会死机 ...
- 08_springmvc数据回显和@ModelAttribute注解详解
一.数据回显 提交后,如果出现错误,将刚才提交的数据回显到刚才的提交页面. 二.pojo数据回显方法 1.springmvc默认对pojo数据进行回显. pojo数据传入controller方法后,s ...