Information Technology Tips

Innotechtips_logo_v4
Menu
  • Home
  • Linux
  • Programming
  • Other Tech Tips
    • Windows
    • Security
Youtube
Home Linux

How to Manage User Accounts in Ubuntu Linux

Inno by Inno
July 27, 2023
How to Manage User Accounts in Ubuntu Linux

This article is going to cover some basic commands that can be used to manage users and groups in Ubuntu Linux including adding users and giving admin permissions. The screenshots used in this article were taken on an Ubuntu machine but the commands should work in most of the different Linux distros.

When it comes to adding a new user in Linux, the below command can be used.

useradd joe (creates a user, joe, together with the primary group with the same name)

If you are not logged in as a root user but have admin permissions, you will need to use the sudo command. Assuming the user is already in the sudo group. Use the below command:

sudo useradd joe

To check whether user joe shows up in the user accounts file located in /etc/passwd:

grep joe /etc/passwd (use grep to filter the contents of the file that lists all user accounts)

To check whether a user has sudo/admin privileges:

sudo whoami (The output should say ‘root’ if the current user has admin privileges. Otherwise, it will say “user is not in the sudoers file”)

To give administrative permissions/privileges, add the user to the sudo group. The sudo command allows users to perform admin tasks such as installing software.

To list all the groups that a user belongs to, use the below commands:

groups joe (lists all groups that user joe is a member of) OR

id joe (lists user joe’s id, as well as group id and all the groups user joe is a member of)

To change a user’s password use:

sudo passwd joe

All users have a default primary group that is created whenever a user is added. All files created by the user will be placed in this group. A user can be added to a secondary group which usually gives the user certain privileges.

To add the user to the sudo group, run the below command either as a root user or as a regular user who has sudo permissions.

usermod -h (use this command to see what options are available with the usermod command)

sudo usermod -aG sudo joe (adds joe to the sudo group)

To switch user to user joe use the below command:

su joe (use su for switch users then enter joe’s password)

Then check whether the user has sudo permissions:

sudo whoami

To delete a user, use the below command:

deluser joe or sudo deluser joe (deletes user joe, but does not delete his home directory and files)

deluser –remove-home joe (deletes user joe plus his home directory)

To remove sudo privileges, edit the /etc/sudoers file using the below commands:

sudo visudo  (open the sudoers file)

Then delete the following line in the file:

joe ALL=(ALL:ALL) ALL (Delete this line from the file and then save the file)

Conclusion

In this article, we went over some of the aspects to do with managing users and groups in Linux. We saw how to use various commands to perform tasks such as adding users and giving permissions. We also highlighted the importance of the admin group or the sudo group that is used to give users administrative privileges.

Inno

Inno

Related Posts

Linux

Getting Started with Kali Linux: A Guide for Beginners

July 31, 2024
Linux

20 Linux Commands for Beginners

March 31, 2024
Linux

What is KVM Virtualization?

March 31, 2024
Linux

The Linux Booting Process in Linux

February 17, 2024

Category

  • Linux
  • Other Tech Tips
  • Programming
  • Windows

Recommended.

Vi/Vim Text Editor-Basic Operations

Vi/Vim Text Editor-Basic Operations

July 27, 2023

Getting Started with Kali Linux: A Guide for Beginners

July 31, 2024

Trending.

How to Install and Enable Free VPN in Kali Linux

July 27, 2023

How To Connect Kali Linux to Wi-Fi on VirtualBox

October 9, 2023

How to Connect Kali Linux on VMware Workstation to a Wi-Fi Network

July 27, 2023
How to Connect to Kali Linux from Window’s Command Prompt

How to Connect to Kali Linux from Window’s Command Prompt

July 27, 2023

How to Capture Network Traffic on a Wi-Fi Network using Kali Linux

July 27, 2023

About us

This site is dedicated towards highlighting various important aspects of information technology. The key areas includes programming, Linux, software, and security. The content will include articles as well as videos.

Quick Links

Menu
  • Home
  • Linux
  • Programming
  • Other Tech Tips
    • Windows
    • Security

Privacy Policy

Menu
  • Privacy Policy
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}
No Result
View All Result
  • Cookie Policy (EU)
  • Home 1
  • Home 2
  • Home 3
  • Mytest Page
  • Privacy Policy

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.