Users in GNU Linux
Table of Contents
User management in GNU/Linux
List all the existing users
$ cat /etc/passwd
Add new user
Add username first
$ sudo useradd username
Add password
$ sudo passwd username
This will not create home directory “/home/username” to do that
Create user with home directory
$ sudo useradd -m username
Followed with passwd creation as above mentioned.
Adding home/directory after creating user
/home/Android/Sdk
$ mkhomedir_helper username
```
Changing the shell of user
$ grep username /etc/passwd
--> username:x:1003:1003::/home/username:/bin/sh
Here the user has “/bin/sh” as shell.
Changing it to Bash.
$ usermod --shell /bin/bash username
Login with new user
$ su - username
Enter the user password and login.
Removing the user
$ sudo deluser --remove-home eric
Error:
While logging into new account ls, cat, clear the basic commands were not working. On Root it was working but not in new user.
Solution:
- Have a root access.
$ su
$ root@host$
- Update the .bashrc file on other user (newuser)
cd into
root$ cd /home/newuser
Open .bashrc file of newuser
root$ nano .bashrc
Add this
export PATH="$PATH:/bin"
export PATH="$PATH:/usr/bin"
- Login to newuser
root$ su - newuser
## Enter password
- Update the source file
newuser# source ~/.bashrc
- Wolaah! commands should work now.