Back to Engineering Notes
100 Days of DevOpsEngineering Note

Linux User Setup with Non-Interactive Shell

A non-interactive shell is used to create a user account without login access.

πŸ” What is a Non-Interactive Shell?

A non-interactive shell is used to create a user account without login access.

This is commonly used for:

Service accounts
Application users
FTP-only users
Security hardening

Such users cannot log in via SSH or access the system shell.

🚫 Common Non-Interactive Shell Paths

Depending on the Linux distribution, you can use:

/sbin/nologin
/usr/sbin/nologin
/bin/false

These shells prevent interactive login.

πŸ–₯️ Entering the Server (SSH Access)

To connect to a Linux server:

ssh {user}@{ip-address}

Example:

ssh james@172.16.238.11

πŸ‘€ Creating a User with Non-Interactive Shell

To add a user without login access:

sudo useradd -s /sbin/nologin {username}

Example:

sudo useradd -s /sbin/nologin appuser

This will:

Create the user
Set shell to /sbin/nologin
Prevent SSH login

πŸ” Verify the User’s Shell

You can check the assigned shell using:

cat /etc/passwd | grep appuser

Output example:

appuser:x:1002:1002::/home/appuser:/sbin/nologin

🎯 Best Practice

Use non-interactive shells for service accounts
Do NOT allow unnecessary SSH access
Follow the principle of least privilege