How To Add A User To A Group In FreeBSD?
This post was last updated on August 1st, 2020 at 12:12 pm
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.
Contents
How to list the groups in a terminal
The list of the groups with their group id is given in the /etc/group
file. To display the list of groups in your terminal use the following command –
less /etc/group
How to add a group in FreeBSD
To add 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.
Now to add a group use the following command –
pw groupadd group_name
For example –
pw groupadd management
A group with the name management will be added to the system.
You can check the newly added group by using –
pw groupshow management
How to add a user to a group
By using pw
we can add a user to a group. Now if you use pw groupshow
command you will find that there are no members are added in the newly created group. Use the following command to add a user to a group –
pw groupmod group_name -M user_name
For example –
pw groupmod management -M lalit
The option -M
will add a user to an empty group or it will replace the existing user of a group.
Use the following command to see the members of a group –
pw groupshow management
As you can see in the image above user lalit is now a member of the management group.
How to add multiple users in a group
To add multiple users to a group you will have to use the option -m
with the given command. Now to add another user named vaibhav to the management group run the following command in your terminal-
pw groupmod management -m vaibhav
If you run the following command you will see that the multiple users are added to the group-
pw groupshow management
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, I discussed removing a user from a group in FreeBSD in another article. If you have anything to say on this topic then you can write to us in the comments below.
About author
You might also like
How To Run A Docker Container In Linux?
This post was last updated on August 1st, 2020 at 07:52 amContainerization is a process that encapsulates an application in a container with its own operating environment. It is a
Serial Console in Linux
This post was last updated on May 26th, 2020 at 10:21 pmUse a Null Modem Cable or Laplink Cable Connect the cable between the serial ports of 2 systems. Run
[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
0 Comments
No Comments Yet!
You can be first to comment this post!