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.
What Is a Non-login User in Linux?
A non-login user is a type of user account that hasrestricted access to the Linux systemand 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.
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:
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.
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:
For example, to create a non-login user with the username “test_user” in Linux, use this command:
Once the new user is created, you can now set permissions for various processes and tasks. You can learn howLinux file permissions workusing the linked article.
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 onhow 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:
For example, we use the command below to create a non-login user named “new_user” on our Linux system:
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.
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.
To view all users present in the Linux system, use this command:cat /etc/passwd
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.