| Difficulty: π’ Beginner | Time: 10 minutes | Category: Linux Administration |
Create a user with non-interactive shell for your organization on a specific server. This is essential for service accounts and automated processes that donβt require interactive login capabilities.
First, login into the app server using SSH:
ssh user@app-server-ip
It will ask for user password, enter the correct password.
After login into server, run the following command to create user with non-interactive shell
sudo useradd -m -s /usr/sbin/nologin user-name
s: for shell, here we are giving nologin shell
m: for user home directory, It will create a directory with user-name under /home
Verify the result
cat /etc/passwd
It should give you a list of users where you will find your created user. It will look like this:
kareem:x:1003:1004::/home/kareem:/usr/sbin/nologin
Try to login using:
sudo su user-name
Output: This account is currently not available.
cat /etc/passwd | grep username/usr/sbin/nologin exists on your system# List all users with nologin shell
grep nologin /etc/passwd
# Check user details
id username
# Remove user if needed
sudo userdel -r username
/usr/sbin/nologin or /bin/false/bin/bash (interactive), /usr/sbin/nologin (non-interactive), /bin/false (deny access)/etc/passwd stores user information, /etc/shadow stores passwords-m: Create home directory-s: Specify shell-d: Custom home directory path-g: Primary group-G: Additional groups-e: Account expiry date/bin/bashNext Challenge: Day 002 - Temporary User Setup