Ubuntu - Using the Command Line

|

Although it can be done, it’s usually not a good idea to directly edit the /etc/passwd or
/etc/group files. Bad things can happen, and you wouldn’t want them to happen while you’re in the middle of editing one of those two files! Instead, the safer way to manage user and group accounts from the command line is to use the two commands explained in this section.


The User Commands
When working on the command line, you should use the adduser command to create a new user or add a user to an existing group. To add a user with the adduser command, use this format:
sudo adduser --home /home/rich rich

This command creates the new user account, rich, and creates a home folder at /home/ rich for the account.

You can also use the adduser command to add an existing user account to a group:
sudo adduser rich users

This command adds the username rich to the users group.
The deluser command deletes a user account from the system:
sudo deluser rich

By default, the deluser command doesn’t remove the home folder of the user. To do that, you need to add the --remove-home parameter:
sudo deluser --remove-home rich

Similar to the adduser command, you can use the deluser command to remove a username from a group:
sudo deluser rich users

These two commands give you complete control over user accounts from the command line, but there are more commands for controlling groups, discussed next.


The Group Commands
As you might have guessed by now, you can use the addgroup command to add a new group to the Ubuntu system:
sudo addgroup sales

This command creates the new group, sales, and automatically assigns the next available group ID value to it. To add users to the group, use the adduser command, shown in the previous section.
Finally, to remove a group, there’s the delgroup command:
sudo delgroup sales

This command removes the group from the system, but any files or folders that you assign group privileges to will retain the group ID value.


If a group is set as the primary group for an existing user account, Ubuntu will prevent you from deleting it. If you want to ensure that you delete empty groups only, you can add the --only-if-empty parameter to the delgroup command. If any users belong to the group, Ubuntu will prevent you from deleting the group.

Source of Information : Wiley Ubuntu Linux Secrets

0 comments:

Subscribe to Computing Tech

Enter your email address:

Delivered by FeedBurner

Add to Technorati Favorites Top Blogs