How to Add a User in Linux and Configure Permissions:
Managing users and their permissions is a fundamental task for Linux administrators. This ensures that users have the right access level to perform their tasks without compromising system security. In this article, we’ll guide you through the process of adding a user in Linux and configuring their permissions.
Add a New User in Linux
However, many administrators prefer the adduser
command (where available) because it’s more interactive and user-friendly:
ubuntu@Rushi-Infotech:/$ sudo adduser rushi
![](https://rushiinfotech.in/wp-content/uploads/2023/09/05-copy-5-1024x138.png)
This command will prompt you to set a password(for the privacy issues Linux will hide the password) and may also ask for other details like the user’s full name, room number, etc.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/07-copy-2-1024x271.png)
Confirm with ” y ” to create user.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/07-copy-3-1024x271.png)
Once the user is created for confirmation use below command:
ubuntu@Rushi-Infotech:/$ sudo cat /etc/passwd
![](https://rushiinfotech.in/wp-content/uploads/2023/09/N-2-copy-1024x339.png)
Here, we can see the user details.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/N-3-copy-1024x109.png)
Giving Permission for User to Connect Server with Password
- Will try to connect to server with the username and password
![](https://rushiinfotech.in/wp-content/uploads/2023/09/10-copy-1-1024x596.png)
- We got an Error that “we cannot connect the server with the username and password other than public key”
![](https://rushiinfotech.in/wp-content/uploads/2023/09/17-1024x186.png)
- So we need to give permission to connect with password
Giving permission for the user to connect the server with username and password:
- Description: we need to edit the sshd_config file to give permission.
ubuntu@Rushi-Infotech:/$ sudo vi /etc/ssh/sshd_config
![](https://rushiinfotech.in/wp-content/uploads/2023/09/11-copy-3-1024x97.png)
- In this file “password authentication” will have in the “no”. We need to convert it into “Yes”
![](https://rushiinfotech.in/wp-content/uploads/2023/09/13-copy-2-1024x124.png)
- Now, to save and exit from the file we need to enter, “Esc , :wq” and press “Enter”.
Esc :wq and Enter
![](https://rushiinfotech.in/wp-content/uploads/2023/09/14-1024x240.png)
- To work the ssh services we need to restart the ssh services.
ubuntu@Rushi-Infotech:/$ sudo service ssh restart
![](https://rushiinfotech.in/wp-content/uploads/2023/09/16-copy-2-1024x99.png)
- Now, you can connect with the username and password to the server.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/18-1024x94.png)
Successfully you have connected to the Server.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/19-1-1024x614.png)
Configuring User Permissions with sudo
For a user to execute commands with superuser privileges, they must be added to the sudo
group or specified in the sudoers file.
- Will try to create a file as a user:
ubuntu@Rushi-Infotech:~/$ sudo touch test1
![](https://rushiinfotech.in/wp-content/uploads/2023/09/20-copy-2-1024x135.png)
We got an Error that user is not in the sudoers file.
- Edit the sudoers file:
First, open the sudoers file using the visudo command for safe editing:
ubuntu@Rushi-Infotech:/$ sudo visudo
![](https://rushiinfotech.in/wp-content/uploads/2023/09/21-copy-1024x126.png)
Then, to give rushi full sudo privileges, add the following line:
rushi ALL=(ALL:ALL) ALL
![](https://rushiinfotech.in/wp-content/uploads/2023/09/23-copy-1024x194.png)
- Now we will try to create a file as a user again.
![](https://rushiinfotech.in/wp-content/uploads/2023/09/25-copy-1024x181.png)
Successfully we have created a file as a user.
How to Remove User
- We need to remove unnecessary users by following command:
ubuntu@Rushi-Infotech:/$ sudo deluser rushi
![](https://rushiinfotech.in/wp-content/uploads/2023/09/26-copy-1024x134.png)
Conclusion:
Managing users and their permissions is a routine but crucial task in Linux. By adding users and configuring their permissions correctly, you ensure that individuals can perform their tasks on the system while maintaining a high level of security. Always remember to periodically review user permissions and make adjustments as roles and responsibilities evolve.
To Know more about Linux visit official website.
Any queries pls contact us
https://rushiinfotech.in/contact/