DEV Community

Cover image for 4.Service User Creation without Home Directory
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

4.Service User Creation without Home Directory

Lab Information

In response to the latest tool implementation at xFusionCorp Industries, the system admins require the creation of a service user account. Here are the specifics:

Create a user named ammar in App Server 1 without a home directory.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines (Technical Execution)

πŸ”Ή Step 1: Log in to Jump Host
ssh thor@jump_host.stratos.xfusioncorp.com

Password:

mjolnir123

πŸ”Ή Step 2: SSH into App Server 1
ssh tony@stapp01.stratos.xfusioncorp.com

Password:

Ir0nM@n

πŸ”Ή Step 3: Switch to Root

sudo -i
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 4: Create user ammar without a home directory

useradd -M ammar
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 5: Verify the user exists

id ammar
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 6: Confirm no home directory was created

ls -ld /home/ammar
Enter fullscreen mode Exit fullscreen mode

Expected result:

No such file or directory

Also verify in passwd file:

grep ammar /etc/passwd
Enter fullscreen mode Exit fullscreen mode

You should see a home path listed (usually /home/ammar), but the directory itself should NOT exist.

βœ… Final Checklist

βœ” User ammar created
βœ” Created on App Server 1 only
βœ” No home directory exists
βœ” User verified successfully

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)
πŸ”Ή Why create a user without a home directory?

Service accounts often:

Run background tools

Do not log in interactively

Do not store personal files

Creating a home directory would be unnecessary and slightly less secure.

πŸ”Ή What does -M do?

-M tells Linux:

"Do NOT create a home directory."

If you omit -M, Linux automatically creates:

/home/ammar

πŸ”Ή Why verify after creation?

Labs are strict. Verification confirms:

The user exists (id ammar)

No directory was created (ls /home/ammar)

Requirement is fully satisfied

πŸ” Security Context

Service users:

Should have minimal privileges

Should not have unnecessary directories

Should only exist for process ownership

This keeps the attack surface smaller.


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)