Thursday, April 7, 2022

[SOLVED] How to add a new user with its own directory and shell Debian

Issue

Hello i am doing a small project with debian, and i want to do this:

Add a third user “test” and set its password to “Test4321”, its home directory to /home/test_home (owner set accordingly for this directory), and its shell to /bin/sh.

I tried starting first with

mkdir test_home
sudo useradd -d /home/test_home
cat /etc/passwd | grep Test4321

Then i make this command again

cat /etc/passwd

I see that the user i added but when i try to login it says wrong password. What is the problem here? Thank you in advance


Solution

So i tried this and worked for me

sudo useradd test

//enter password and other info

then login with

su-

//enter su password

and make this command to change its directory

usermod -m -d /home/test_home test

cat /etc/passwd   

//to check it



Answered By - Kostandin Vllahu
Answer Checked By - Robin (WPSolving Admin)