0

User is the main part of any operating system. The users and permissions and Linux. We’re going to be learned about. how to add users. how to delete users. How to deal with permissions you know passwords etc.

The main thing to understand is I keep saying this little Linux track. It is all relatively easy as long as you just kind of focus. What’s going on adding users is easy etc. the one thing that that’s kind of weird with Linux. It has actually kept users permissions much more simpler.

Step – 1 : Introduction to User Administration

To access the Operating System we need to provide credentials.The credentials can be username and password or any code. User account is created in order for giving access to Operating System.

Every process on the system runs as a particular user. Every file is owned by a particular user. Access to files are restricted by user. The user associated with a running process determines the files accessible to that process.

[root@techbrown~]# id

The id command is used to find the names of user and group as well as the UID and GID of the current user or the other users also which available in server.

For ex. user root:-

[root@techbrown~]# id root

Using this command  the user finds  information about user root.

[root@techbrown~]# ls -l

Using this command we can long list all the files

Step -2 : Understanding Important Files

/etc/passwd

There is one entry (one line) for every user account in this file. Each entry has 7 fields separated by colon.

USER:PASSWORD:UID:GID:GECOS:HOME:SHELL

  • USER – Username with which the user Logs in
  • PASSWORD – Encrypted password of user. ‘x’ indicates that shadowing is enabled and that the password is stored in /etc/shadow file.
  • UID – UID of user
  • GID – GID of primary group of user
  • GECOS – Comment about user
  • HOME – Location of Home directory of user
  • SHELL – Default shell for user

/etc/shadow

There is one entry for every user account in this file. Each entry has 9 fields separated by colon.

USER:PASSWORD:LAST_PASS_CHG:MIN_AGE:MAX_AGE:WARN:INACTIVE:EXPIRY:RES

  • USER – Username with which the user Logs in
  • PASSWORD – Encrypted password of user. ‘!’ indicates that password is locked. Blank means password is deleted and that user can login without password.
  • LAST_PASS_CHG – Date of Last Password Change. Specified in number of days since Jan 1, 1970.
  • MIN_AGE – Minimum Password Age.
  • MAX_AGE – Maximum Password Age.
  • WARN – Number of days before password expiry that the user will get warning of password expiry.
  • INACTIVE – Number of days after password expiry that the password will be made inactive.
  • EXPIRY – Account expiry date of user Number of days since Jan 1, 1970.
  • RES – Reserved for future use

Step – 3 : Create new user accounts

Syntax – useradd [options] user

The options of useradd command used like this

[root@techbrown~]# useradd useraA

u – UID of user

[root@techbrown~]# useradd -u 5005 userB

g – Primary group of user

[root@techbrown~]# useradd -g tech userC

c – Comment for user

[root@techbrown~]# useradd -c "Primary User" userD

d – Home directory of user

[root@techbrown~]# useradd -d /home/techbrown -m userE

s – Default shell for user

[root@techbrown~]# useradd -s /sbin/nologin userF

e – Account expiry date

[root@techbrown~]# useradd -e "2019-12-08" userG

f – Account Inactivity Period

[root@techbrown~]# useradd -f 8 userH

r – System Account

[root@techbrown~]# useradd -r userI

G – Supplementary group of user

[root@techbrown~]# useradd -G users,techbrown,root userJ

m – Create Home directory of user. Used only if option d is used.

[root@techbrown~]# useradd -u 3004 -g techbrown -d /home/techbrown -m -s /sbin/nologin user11

Step – 4 : Modify user accounts

Syntax – usermod [options] user

l – Change login name of user

[root@techbrown~]# usermod -l userZ userA

u – Uid of user

[root@techbrown~]# usermod -u 6004 userB

g – Primary group of user

[root@techbrown~]# usermod -g techbrown userC

c – Comment for user

[root@techbrown~]# usermod -c "Reguler Users" userD

d – Home directory of user

[root@techbrown~]# usermod -d /home/userE -m userE

s – Default shell for user

[root@techbrown~]# usermod -s /bin/bash userF

e – Account expiry date

[root@techbrown~]# usermod -e "2020-12-08" userG

f – Account Inactivity Period

[root@techbrown~]# usermod -f 15 userH

G – Supplementary group of user

[root@techbrown~]# usermod -G wheel -a userI

m – Create Home directory of user. Used only if option d is used.

[root@techbrown~]# usermod -u 5011 -g wheel -d /home/userJ -m -s /bin/bash userJ

Most of the options of usermod command are same as useradd above. The options that are different are

a – Add group to existing supplementary groups of user. Used with option G only.

Step – 5 : Delete user accounts

Syntax – userdel [options] user

[root@techbrown~]# userdel newuser1

r – System Account

[root@techbrown~]# userdel -r user2

Deleting user account does not remove the home directory and mailbox file of user. To remove them as well use option r.

Step – 6 : Password Management and Ageing

Password is set with passwd command.

The various options used are

[root@techbrown~]# passwd userA

S – Status of password

[root@techbrown~]# passwd -S userA

l – Lock password

[root@techbrown~]# passwd -l userA

u – Unlock password

[root@techbrown~]# passwd -u userA

d – Delete password

[root@techbrown~]# passwd -d userA

Step – 7 : Password ageing information can be list or changed with chage command

[root@techbrown~]# chage -l userB
[root@techbrown~]# chage userB

That’s all for now.

How to Launch and Connect Linux Server on AWS Amazon Web Services

Previous article

Group Administration on CentOS / RHEL

Next article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

More in Linux