Linux operating system have users to operate applications, services and other stuff. Multiple users can be interact with Linux and we call it multi-user. It may be ridiculous but long time ago operating systems was single user. Which means to work on a system other users should sign out. Now in our era we have no restrictions like that.
There is a default user named
root almost all Linux distributions. There are other users coming by default but these users are generally service users. Service user is used by the application those run on the system and generally do not used by real human users. Adding user can be done with different way but most used one is;
$ useradd poftut
Adding user means adding user name to the user database, creating home directory under /home and other configuration files like .bash. Keep in mind that to add user Admin privileges are required which practically means we need to be root user to add new user.
Now we have added our user but want to get users in the current user database.
$ id uid=0(root) gid=0(root) groups=0(root)
- uid user id which identifies current user in the system
- gid group id which identifies current users group in the system
- groups lists groups where current user is a member
But we want to get a specific user information.
$ id -u poftut 1002
Like adding user in to the system deleting user is a task for a system administrator too. Deleting user is simple as adding user.
$ userdel poftut
If we look into the user database we cannot see the user
# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
But wait a minute if we look into the
/home we can see that poftut’s home directory exist. To delete a user with his home directory use
$ userdel -r poftut