Information Technology Tips

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

How to Create and Manage Groups in Ubuntu Linux

Inno by Inno
July 27, 2023

In Ubuntu Linux, users and group accounts, as well as ownership and permissions, are used for security purposes. In particular, users and processes have to be limited when it comes to which files and other resources they can access on the system.

Example:

ps aux | less (shows all processes running)

By creating user and group accounts, we can make sure that access to specific resources is limited or controlled.

To check the user accounts on the system:

cat /etc/passwd

The line that starts with systemd-network, is a user account that is used by the system-network process. This account has its own home directory (/run/systemd) as well as a shell (/usr/sbin/nologin).

Permissions

To list the contents of a current directory, we can type the following:

 ls -l (lists the contents of the current directory)

ls -l /var  (lists contents of the /var directory)

We can see that on the far left there are characters for permissions – the first 3 characters (rwx) represent the permission for the user (owner of the file), the next 3 characters represent permissions for the group owner and the last 3 characters represent permissions for the rest of the world.

To add a group named sales we use the below command:

sudo groupadd sales

To check the group accounts on the system, use the below command:

cat /etc/group

grep sales /etc/group (use grep to filter contents of the file that lists all groups)

To add the user joe to the group sales:

 sudo usermod -aG sudo joe (adds joe to the group sales. Use -a option to avoid removing the user from other supplementary/second groups)

To check which groups a user belongs to use:

id joe or groups joe

Example (Caution!!):

sudo usermod -G sales joe (adds user joe to sales group but also removes user joe from all other groups including sudo group)

grep sales /etc/group (filter contents of group file and see members of the group sales)

Create a new file using the touch command:

touch testfile

To list the user and group owner of a given file, we use ls -l. The default user and group owner is the name of the file creator.

Changing File Ownership

To change the user owner of the file:

sudo chown joe testfile

change the group owner of the file testfile:

sudo chgrp joe testfile

To change both user and group owner in one line:

sudo chown inno:inno testfile

To delete a group:

sudo groupdel sales

Conclusion

In this article, we have looked at how to create and manage groups in Linux. We have explained the importance of having user and group accounts for security purposes. We have described, using examples, how to create and modify permissions for users and groups. Additionally, we have shown how to determine file permissions and where to locate user and group lists.

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.

Should I Upgrade to Windows 11: Weighing the Pros and Cons

July 29, 2023
List and Tuples in Python Programming – An Overview

List and Tuples in Python Programming – An Overview

July 27, 2023

Trending.

How To Connect Kali Linux to Wi-Fi on VirtualBox

October 9, 2023

How to Install and Enable Free VPN in Kali Linux

July 27, 2023

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

July 27, 2023

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

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

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.