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
最新文章
- [转]ThoughtWorks(中国)程序员读书雷达
- C# 模拟键盘操作--SendKey(),SendKeys()
- Android SDK在线更新镜像服务器大全
- Windows Server 2008 显示桌面图标
- 一款jQuery满屏自适应焦点图切换特效
- Python网页解析
- C# 语言规范_版本5.0 (第14章 枚举)
- mysql性能监控工具
- curl笔记
- [Codeforces]871D Paths
- mongoose一看就会的基本操作
- 百度地图api在Html中显示,在jsp页面中不显示解决方法
- [Linux]流媒体服务器概述
- linux:安装并使用mongo
- JUC(java.util.concurrent)
- 实现数组(java)
- 前端开发利器自定义Iconfont图标
- 【转】JS组件系列——Bootstrap组件福利篇:几款好用的组件推荐(二)
- 学习笔记_J2EE_SSM_01_spring+springMVC+Mybatis整合_XML配置示例
- 【转载】Spark学习 &; 机器学习