DEV Community

Cover image for 3.Linux User Setup with Non-Interactive Shell
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

3.Linux User Setup with Non-Interactive Shell

Lab Information

To accommodate the backup agent tool's specifications, the system admin team at xFusionCorp Industries requires the creation of a user with a non-interactive shell. Here's your task:

Create a user named javed with a non-interactive shell on App Server 1.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines
Target Server

App Server 1

Hostname: stapp01.stratos.xfusioncorp.com

User: tony

Step 1: Log in to the Jump Host

ssh thor@jump_host.stratos.xfusioncorp.com


Password:

mjolnir123
Enter fullscreen mode Exit fullscreen mode

Step 2: SSH into App Server 1

ssh tony@stapp01.stratos.xfusioncorp.com

Password:
Ir0nM@n
Enter fullscreen mode Exit fullscreen mode

Step 3: Switch to root

sudo -i
Enter fullscreen mode Exit fullscreen mode

Step 4: Create user javed with a non-interactive shell

useradd -s /sbin/nologin javed
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify the user

id javed
Enter fullscreen mode Exit fullscreen mode

Step 6: Verify the assigned shell

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

Expected output should include:

javed❌xxxx:xxxx::/home/javed:/sbin/nologin

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)

Why a non-interactive shell?
Backup agents and service accounts should not allow login access.
This improves system security.

What is /sbin/nologin?
It is a special shell that prevents users from logging in, even if they have a password.

Why not /bin/bash?
/bin/bash allows interactive logins, which is unnecessary and unsafe for service users.

What does useradd -s do?

-s specifies the login shell

Setting it to /sbin/nologin disables interactive access

Why check /etc/passwd?
It confirms:

User exists

Correct shell is assigned


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)