Skip to content
Beebom
  • News
  • Opinions
  • Reviews
  • Gaming
    • Pokemon Go
    • Helldivers 2
    • Dragon’s Dogma 2
    • Valorant
    • Palworld
    • Wuthering Waves
    • Roblox
    • Genshin Impact
    • Counter Strike 2
    • Honkai Star Rail
    • Lego Fortnite
    • Minecraft
    • Fortnite
    • Wordle
    • Stardew Valley
    • NYT Strands
    • NYT Connections
  • Tech
    • Apps
      • Instagram
      • WhatsApp
      • Facebook
      • Discord
      • X
      • Snapchat
      • Spotify
    • Apple
      • iOS
      • iPad
      • Mac
      • Apple Watch
      • AirPods
      • Vision Pro
    • Android
    • AI
    • Internet
    • Windows
    • Chromebook
    • Hardware
  • Entertainment
    • Streaming Apps
      • Netflix
      • Hulu
      • Disney+
      • Crunchyroll
      • Prime Video
    • DC
    • Marvel
    • Anime
      • One Piece
      • Naruto
      • Boruto
      • Jujutsu Kaisen
      • Demon Slayer
      • Chainsaw Man
      • Solo Leveling
  • Beebom Gadgets
Beebom Gadgets
Search Results
Load More
  • News
  • Opinions
  • Reviews
  • Gaming
    • Pokemon Go
    • Helldivers 2
    • Dragon’s Dogma 2
    • Valorant
    • Palworld
    • Wuthering Waves
    • Roblox
    • Genshin Impact
    • Counter Strike 2
    • Honkai Star Rail
    • Lego Fortnite
    • Minecraft
    • Fortnite
    • Wordle
    • Stardew Valley
    • NYT Strands
    • NYT Connections
  • Tech
    • Apps
      • Instagram
      • WhatsApp
      • Facebook
      • Discord
      • X
      • Snapchat
      • Spotify
    • Apple
      • iOS
      • iPad
      • Mac
      • Apple Watch
      • AirPods
      • Vision Pro
    • Android
    • AI
    • Internet
    • Windows
    • Chromebook
    • Hardware
  • Entertainment
    • Streaming Apps
      • Netflix
      • Hulu
      • Disney+
      • Crunchyroll
      • Prime Video
    • DC
    • Marvel
    • Anime
      • One Piece
      • Naruto
      • Boruto
      • Jujutsu Kaisen
      • Demon Slayer
      • Chainsaw Man
      • Solo Leveling
  • Beebom Gadgets
Home > PC > Linux > How to Create a Non-login User in Linux

How to Create a Non-login User in Linux

Beebom Staff
Updated: December 18, 2023
Comments 0
Share
Copied

If you are a system administrator and are looking for ways to make your Linux system more secure or want to automate certain processes, creating a non-login user is the solution. Non-login users can prove to be very useful for a variety of cases right from limiting access to your Linux system to running specific processes with restricted privileges. Here, we will guide you through the steps to create a non-login user in Linux and set the appropriate permissions for them.

Table of Contents
  • What Is a Non-login User in Linux?
  • How to Create a User Without Login in Linux
    • Using the adduser Command
    • Editing the “/etc/passwd” File

What Is a Non-login User in Linux?

A non-login user is a type of user account that has restricted access to the Linux system and can only perform specific tasks or run certain processes without logging into the system. Unlike regular users, non-login users do not have access to a regular shell or the home directory. Hence, they cannot log in to your Linux PC. Some common uses of creating a non-login user are to automate tasks, run specific processes or improve your system’s overall security by restricting access.

How to Create a User Without Login in Linux

There are two different methods to create a non-login user in Linux, which are straightforward and easy. But there are some prerequisites you need to take care of:

  • Any Linux-based operating system (preferably the latest version)
  • A user with root access or sudo privilege

Now that you have the prerequisites, we will now discuss using the adduser command and editing the passwd file to create non-login users in Linux.

1. Using the adduser Command

Thanks to its simplicity and easy-to-use syntax, we generally use the “adduser” command to create new users in Linux. The basic syntax to create a user using the adduser command is:

sudo adduser <username> --system --no-create-home

In the above syntax, the “–system” option creates a new user account without a password and without a shell. Furthermore, to prevent the command from creating a new home directory, we use the “–no-create-home” option here. Other common options you can pair with the command are:

OptionsDescription
--disabled-loginIf used, the user won’t be able to use the account until the password is set.
--gid IDWhen creating a user, this option will put the user in that group.
--home <directory_name>Use <directory_name> as the user’s home directory, rather than the default location.
--shell <shell_path>Use <shell_path> as the user’s login shell, rather than the default shell.
--debugShows informational messages on every operation taking place.

For example, to create a non-login user with the username “test_user” in Linux, use this command:

sudo adduser test_user --system --no-create-home
adding new non-login user with the adduser command

Once the new user is created, you can now set permissions for various processes and tasks. You can learn how Linux file permissions work using the linked article.

2. Editing the “/etc/passwd” File

The “/etc/passwd” file is a system file that stores information about all user accounts on a Linux system. This file has read permissions for all user types and only the superuser holds write permissions. We saw the contents of the “passwd” file in our recent article on how to list users in Linux. To create a non-login user in Linux, you can manually edit the /etc/passwd file to add a new entry for the new account with the following steps:

  • Open the Terminal in your Linux system.
  • Then, use the nano command in Linux to open the “/etc/passwd” file. You can use any other Linux text editor you like, but if you’re following along, then paste the following command in the Command Line:
sudo nano /etc/passwd
  • Next, scroll down to the bottom of the list and add a new non-login user with this command:
<username>:x:<UID>:<GID>:<user_description>:/dev/null:/bin/false

For example, we use the command below to create a non-login user named “new_user” on our Linux system:

new_user:x:1001:1001:New Non-Login User:/dev/null:/bin/false
  • Finally, save and exit the nano editor for the changes to take place. If you are using the Vim editor, follow our guide to learn how to exit the Vim editor in Linux.
  • Once the new user is created, you can now adjust the permissions for it for various processes and tasks.

Note:

Always keep a backup of the “/etc/passwd” file as modifying this file is risky, and in the worst case, it can render your system useless.

What are the different types of users in Linux?

There are three types of users in Linux:
1. Super User: It is a type of user with the highest level of permissions in the system; also known as the “root user”
2. Normal User: These types of users have restricted access to the commands and files along with a shell and a home directory.
3. System User: Also known as the “Non-login” user; they neither have access to a shell nor to a home directory. All they have access to is some specific commands they are allowed to run.

How to view all users present in the system?

To view all users present in the Linux system, use this command: cat /etc/passwd

Beebom Staff

Bringing the latest in technology, gaming, and entertainment is our superhero team of staff writers. They have a keen eye for latest stories, happenings, and even memes for tech enthusiasts.

Comments 0
Leave a Reply Cancel reply

Loading comments...

    Recommended Articles
    How to Change Owner of a Directory in Linux
    Abubakar Mohammed
    How to Delete a Directory in Linux
    Abubakar Mohammed
    Linux Kernel 6.5 Released: Supports WiFi 7, USB 4 v2, And More
    Satyam Kumar
    5 Useful Bash For Loop Examples
    Beebom Staff
    How to Extract or Untar a File on Linux
    Abubakar Mohammed
    What Is Bash Function in Linux & How to Use It?
    Beebom Staff
    Bash If, Elif, and If Else Explained with Examples
    Beebom Staff

    Trending Stories in
    #Linux Terminal

    01

    Google Reveals the Real Purpose of Android’s New Terminal App
    Abubakar Mohammed

    02

    How to Change Directory in Linux Terminal
    Beebom Staff

    03

    8 Best Examples of cp Command in Linux
    Beebom Staff

    04

    How to Create a User in Linux
    Beebom Staff

    05

    How to Copy Files in Linux (2 Ways)
    Beebom Staff
    Beebom is one of the leading consumer technology websites aimed at helping people understand and use technology in a better way.
    • About Us
    • Careers
    • Get in touch
    • Advertise
    • Privacy Policy
    • Editorial Guidelines
    Beebom is one of the leading consumer technology websites aimed at helping people understand and use technology in a better way.
    • About Us
    • Careers
    • Get in touch
    • Advertise
    • Privacy Policy
    • Editorial Guidelines

    Do not sell or share my personal information
    Privacy Settings
    © Beebom Media Private Limited
    %%footer%%