Sitemap
Ramkumar L

Ramkumar L

A professor, technology enthusiast.

Linux: Adding user and changing the shell is an old but evergreen concept.

3 min readNov 7, 2025

To use the operating system service, we use the shell in Linux. Some of the standard shells in Linux are bash and sh. We always want to change it to have more functions. I recently recalled the commands for creating a new user, for example, sur_oman.

sudo useradd sur_oman

Then, I checked the user’s presence in the /home directory using the command ls -l /home

vln@linux2021:~$ ls -l /home

total 12

drwxr-xr-x 5 ram ram 4096 Nov 6 17:18 ram

drwxr-xr-x 5 vardhini vardhini 4096 Nov 6 17:31 vardhini

drwxr-xr-x 60 vln vln 4096 Nov 6 09:45 vln

It is not listed in the home directory, so here I have two options: (1) include the /home directory with some steps, or (2) if it already exists, delete the account and create it with the -m option.

First option steps are as follows:

— — -

vln@linux2021:~$ sudo cp -r /etc/skel/. /home/sur_oman

vln@linux2021:~$ sudo chown -R sur_oman:sur_oman /home/sur_oman

vln@linux2021:~$ sudo chmod 750 /home/sur_oman

vln@linux2021:~$ sudo usermod -d /home/sur_oman sur_oman

— — -

After this, I used ls -l /home and the output is:

— — -

vln@linux2021:~$ ls -l /home

total 16

drwxr-xr-x 5 ram ram 4096 Nov 6 17:18 ram

drwxr-x — — 4 sur_oman sur_oman 4096 Nov 7 08:28 sur_oman

drwxr-xr-x 5 vardhini vardhini 4096 Nov 6 17:31 vardhini

drwxr-xr-x 60 vln vln 4096 Nov 6 09:45 vln

— — —

I verified whether the user account was created using the command:

cat /etc/passwd | grep sur_oman

Yes, it is listed there, and with the sh shell.

Get Ramkumar L’s stories in your inbox

Join Medium for free to get updates from this writer.

— — -

Now, let me show you what happened when I created the user with the -m option, which helps make the user’s home directory.

vln@linux2021:~$ sudo useradd -m jalan_oman

I tried the ls command again, as,

— — -

vln@linux2021:~$ ls -l /home

total 20

drwxr-xr-x 4 jalan_oman jalan_oman 4096 Nov 7 09:01 jalan_oman

drwxr-xr-x 5 ram ram 4096 Nov 6 17:18 ram

drwxr-x — — 4 sur_oman sur_oman 4096 Nov 7 08:28 sur_oman

drwxr-xr-x 5 vardhini vardhini 4096 Nov 6 17:31 vardhini

drwxr-xr-x 60 vln vln 4096 Nov 6 09:45 vln

— — -

To enumerate the passwd database where our user details are stored, we can use the command as follows:

— — -

vln@linux2021:~$ getent passwd sur_oman jalan_oman

sur_oman:x:1003:1003::/home/sur_oman:/bin/sh

jalan_oman:x:1004:1004::/home/jalan_oman:/bin/sh

— — -

Now, we can notice that both users are using the sh shell. We can infer from /etc/default/useradd, specifically the SHELL=/bin/sh line, that the default shell is sh.

Now I want to change the default shell from sh to the fish shell for this specific user, sur_oman

First, I checked the location of the fish shell in my system using the “command -v fish”. In my system, it is in /usr/bin/fish.

To change the shell, I used the command ‘chsh’ with the following parameters: ‘sudo chsh -s /usr/bin/fish sur_oman’. Then, if we check, we can notice that it has been changed.

— — -

vln@linux2021:~$ sudo cat /etc/passwd | grep sur_oman

sur_oman:x:1003:1003::/home/sur_oman:/usr/bin/fish

— — -

Finally, to delete the user, use the command sudo userdel sur_oman.

What I discussed above is nothing new, but we cannot avoid these steps when working on Linux-based systems. Happy Learning!!

--

--

Ramkumar L
Ramkumar L

Written by Ramkumar L

A professor, technology enthusiast.