How To Remove A User From A Group In FreeBSD?

How To Remove A User From A Group In FreeBSD?

 

This post was last updated on August 1st, 2020 at 12:12 pm

I already discussed how to add a user to a group in FreeBSD. This article is about removing a user from a group. Before we get into the discussion to remove a user from a group I will briefly explain about users and groups in FreeBSD.

A group is a list of users. It makes it easier to define the permissions such as read, write, and execute for a system resource that is to be shared among the users of that group. You can set permission to ensure that files are accessible to users of a particular group like accounts, hr, marketing, etc.

Kernel identifies a user by its UID and group by its GID. The group name to GID mapping is given in /etc/group file. A superuser can modify it by using a text editor. Alternatively, pw can be used to add and modify a group in FreeBSD.

How to see the list of users having in a group

To display the list of users or the members of a group you will have to use the following command in your terminal –

pw groupshow group_name

For example –

pw groupshow management

As you can see in the image above currently there are two members in the management group.

How to remove a user from a group

To add or remove a group in FreeBSD we will use pw utility. The pw can be used to add, remove, modify, and display the users and groups. It has various command-line options that you can use in shell scripts.

Use the following command to remove a user from a group –

pw groupmod group_name -d user_name

For example –

pw groupmod management -d lalit

Now after executing the above command if you run –

pw groupshow management

you will see that user lalit is now removed from the management group.

Removing multiple users from a group in a single command

In a single command, you can remove the multiple users from a group in FreeBSD. Use the following command to remove the users from a group –

pw groupmod group_name -d user1,user2,user3

For example –

To remove both the user from the management group I will use the following command –

pw groupmod management -d lalit,vaibhav

This will remove the both the members from the management group.

Now If you want to know more about the uses of pw  then see its manual page by running following command in your terminal –

man pw

Ok, that’s all for now, If you have anything to say on this topic then you can write to us in the comments below.

Previous How To Add A User To A Group In FreeBSD?
Next A snap confined shell based on Mir: Mircade
 

About author

You might also like

How To 0 Comments

How To Extract A Zip File In Linux Using Terminal?

This post was last updated on August 1st, 2020 at 12:26 pmZip is an archive file format that supports lossless data compression. It is available for various platforms. Windows and

Linux OS 1Comments

[How to solve] Could not load host key: /etc/ssh/ssh_host_rsa_key issue in FreeBSD or Linux

This post was last updated on October 15th, 2020 at 01:55 amOnce I was strating the sshd service, I saw the error: Could not load host key: /etc/ssh/ssh_host_rsa_key issue. Sometimes

How To 0 Comments

How To Create A Zip File In Linux?

This post was last updated on August 1st, 2020 at 12:29 pmZip is an archive file format that supports lossless data compression. Zipping and unzipping tools are available for various

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply