Linux del user group

Linux del user group

NAME

deluser, delgroup - remove a user or group from the system

SYNOPSIS

deluser [options] [--force] [--remove-home] [--remove-all-files] [--backup] [--backup-to DIR] user deluser --group [options] group delgroup [options] [--only-if-empty] group deluser [options] user group COMMON OPTIONS [--quiet] [--system] [--help] [--version] [--conf FILE]

DESCRIPTION

deluser and delgroup remove users and groups from the system according to command line options and configuration information in /etc/deluser.conf and /etc/adduser.conf. They are friendlier front ends to the userdel and groupdel programs, removing the home directory as option or even all files on the system owned by the user to be removed, running a custom script, and other features. deluser and delgroup can be run in one of three modes: Remove a normal user If called with one non-option argument and without the --group option, deluser will remove a normal user. By default, deluser will remove the user without removing the home directory, the mail spool or any other files on the system owned by the user. Removing the home directory and mail spool can be achieved using the --remove-home option. The --remove-all-files option removes all files on the system owned by the user. Note that if you activate both options --remove-home will have no effect because all files including the home directory and mail spool are already covered by the --remove-all-files option. If you want to backup all files before deleting them you can activate the --backup option which will create a file username.tar(.gz|.bz2) in the directory specified by the --backup-to option (defaulting to the current working directory). Both the remove and backup options can also be activated for default in the configuration file /etc/deluser.conf. See deluser.conf(5) for details. If you want to remove the root account (uid 0), then use the --force parameter; this may prevent to remove the root user by accident. If the file /usr/local/sbin/deluser.local exists, it will be executed after the user account has been removed in order to do any local cleanup. The arguments passed to deluser.local are: username uid gid home-directory Remove a group If deluser is called with the --group option, or delgroup is called, a group will be removed. Warning: The primary group of an existing user cannot be removed. If the option --only-if-empty is given, the group won't be removed if it has any members left. Remove a user from a specific group If called with two non-option arguments, deluser will remove a user from a specific group.

OPTIONS

--conf FILE Use FILE instead of the default files /etc/deluser.conf and /etc/adduser.conf --group Remove a group. This is the default action if the program is invoked as delgroup. --help Display brief instructions. --quiet Suppress progress messages. --system Only delete if user/group is a system user/group. This avoids accidentally deleting non-system users/groups. Additionally, if the user does not exist, no error value is returned. This option is mainly for use in Debian package maintainer scripts. --backup Backup all files contained in the userhome and the mailspool-file to a file named /$user.tar.bz2 or /$user.tar.gz. --backup-to Place the backup files not in / but in the directory specified by this parameter. This implicitly sets --backup also. --remove-home Remove the home directory of the user and its mailspool. If --backup is specified, the files are deleted after having performed the backup. --remove-all-files Remove all files from the system owned by this user. Note: --remove-home does not have an effect any more. If --backup is specified, the files are deleted after having performed the backup. --version Display version and copyright information.

RETURN VALUE

0 The action was successfully executed. 1 The user to delete was not a system account. No action was performed. 2 There is no such user. No action was performed. 3 There is no such group. No action was performed. 4 Internal error. No action was performed. 5 The group to delete is not empty. No action was performed. 6 The user does not belong to the specified group. No action was performed. 7 You cannot remove a user from its primary group. No action was performed. 8 The required perl-package 'perl modules' is not installed. This package is required to perform the requested actions. No action was performed. 9 For removing the root account the parameter "--force" is required. No action was performed.

FILES

SEE ALSO

deluser.conf(5), adduser(8), userdel(8), groupdel(8)
Copyright (C) 2000 Roland Bauerschmidt. Modifications (C) 2004 Marc Haber and Joerg Hoh. This manpage and the deluser program are based on adduser which is: Copyright (C) 1997, 1998, 1999 Guy Maor. Copyright (C) 1995 Ted Hajek, with a great deal borrowed from the original Debian adduser Copyright (C) 1994 Ian Murdock. deluser is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is no warranty.

© 2019 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.

Читайте также:  Изменение разрешения экрана linux через терминал

Источник

Linux deluser and delgroup commands

Computer Hope

On Linux operating systems, the deluser and delgroup commands remove a user or group from the system.

Description

deluser and delgroup remove users and groups from the system according to command line options and configuration information in /etc/deluser.conf and /etc/adduser.conf. They are friendlier front ends to the userdel and groupdel programs, removing the home directory as option or even all files on the system owned by the user to be removed, running a custom script, and other features. deluser and delgroup can run in one of three modes:

To remove a normal user

If called with one non-option argument and without the —group option, deluser removes a normal user.

By default, deluser removes the user without removing the home directory, the mail spool or any other files on the system owned by the user. Removing the home directory and mail spool can be achieved using the —remove-home option.

The —remove-all-files option removes all files on the system owned by the user. Note that if you activate both options —remove-home has no effect because all files including the home directory and mail spool are already covered by the —remove-all-files option.

To backup all files before deleting them, you can activate the —backup option to create a file username.tar(.gz|.bz2) in the directory specified by the —backup-to option (defaulting to the current working directory). Both the remove and backup options can also be activated for default in the configuration file /etc/deluser.conf. See deluser.conf for details.

To remove the root account (uid 0), then use the —force parameter; this prevents removing the root user by accident.

Читайте также:  Execute files in linux terminal

If the file /usr/local/sbin/deluser.local exists, it will be executed after the user account is removed to do any local cleanup. The arguments passed to deluser.local are: «username uid gid home-directory«.

To remove a group

If deluser is called with the —group option, or delgroup is called, a group will be removed.

Warning: The primary group of an existing user cannot be removed.

If the option —only-if-empty is given, the group won’t be removed if it has any members left.

To remove a user from a specific group

If called with two non-option arguments, deluser removes a user from a specific group.

Syntax

deluser [--quiet] [--system] [--help] [--version] [--conf FILE] [--force] [--remove-home] [--remove-all-files] [--backup] [--backup-to DIR] user 
deluser --group [--quiet] [--system] [--help] [--version] [--conf FILE] group 
delgroup [options] [--quiet] [--system] [--help] [--version] [--conf FILE] group 
deluser [options] user group 

Options

—conf FILE Use FILE instead of the default files /etc/deluser.conf and /etc/adduser.conf
—group Remove a group. This is the default action if the program is invoked as delgroup.
—help Display a help message, and exit.
—quiet Suppress progress messages.
—system Only delete if user/group is a system user/group. This avoids accidentally deleting non-system users/groups. Additionally, if the user does not exist, no error value is returned.
—backup Backup all files contained in the userhome and the mailspool file to a file named /$user.tar.bz2 or /$user.tar.gz.
—backup-to Place the backup files not in / but in the directory specified by this parameter. This implicitly sets —backup also.
—remove-home Remove the home directory of the user and its mailspool. If —backup is specified, the files are deleted after having performed the backup.
—remove-all-files Remove all files from the system owned by this user. Note: —remove-home does not have an effect any more. If —backup is specified, the files are deleted after having performed the backup.
—version Display version and Copyright information.

Configuration

The file /etc/deluser.conf contains defaults for the programs deluser and delgroup. Each option takes the form «option = value«. Double or single quotes are allowed around the value. Comment lines must have a hash sign («#«) at the beginning of the line.

deluser and delgroup also read /etc/adduser.conf, see adduser.conf; settings in deluser.conf may overwrite settings made in adduser.conf.

The valid configuration options are:

Return values

0 The action was successfully executed.
1 The user to delete was not a system account. No action was performed.
2 There is no such user. No action was performed.
3 There is no such group. No action was performed.
4 Internal error. No action was performed.
5 The group to delete is not empty. No action was performed.
6 The user does not belong to the specified group. No action was performed.
7 You cannot remove a user from its primary group. No action was performed.
8 The required perl package ‘perl modules’ is not installed. This package is required to perform the requested actions. No action was performed.
9 For removing the root account the parameter «—force» is required. No action was performed.
Читайте также:  Freeing ports in linux

Files

Examples

Deletes the user account myuser.

deluser --remove-home myuser

Deletes the user account myuser, and removes that user’s home directory as well.

Deletes the user account myuser even if that user is currently logged in.

deluser --backup-to /directory myuser

Deletes the user account myuser and backs up their files in a tar archive called myuser.tar, which is created in the directory /directory.

Deletes the group mygroup.

adduser — Add a user to the system.
addgroup — Add a group to the system.
groupadd — Add a group to the system.
useradd — Add a user to the system.

Источник

How to Add or Remove Linux User From Group

Linux is by default a multi-user system (meaning many users can connect to it simultaneously and work), thus Linux user management is one of the fundamental tasks of a system administrator, which includes everything from creating, updating, and deleting user accounts or user groups on a Linux system.

In this short quick article, you will learn how to add or remove a user from a group in a Linux system.

Check a User Group in Linux

To find out what group a user is in, just run the following groups command and provide the username (tecmint in this example) as an argument.

# groups tecmint tecmint : tecmint wheel 

To find out the group of root user in Linux, just run the groups command without any argument.

# group root 

Check a User Group in Linux

Add a User to a Group in Linux

Before trying to add a user to a group, ensure that the user exists on the system. To add a user to a certain group, use the usermod command with the -a flag which tells the usermod to add a user to the supplementary group(s), and the -G option specifies the actual groups in the following format.

In this example, tecmint is the username and postgres is the group name:

# usermod -aG postgres tecmint # groups tecmint

Add User to Group in Linux

Remove a User from a Group in Linux

To remove a user from a group, use the gpasswd command with the -d option as follows.

# gpasswd -d tecmint postgres # groups tecmint

Remove User from Group in Linux

Additionally, on Ubuntu and its derivatives, you can remove a user from a specific group using the deluser command as follows (where tecmint is the username and postgres is the group name).

$ sudo deluser tecmint postgres

For more information, see the man pages for each of the different commands we have used in this article.

$ man groups $ man usermod $ man gpasswd $ man deluser

You will also find the following user management guides very useful:

Источник

Оцените статью
Adblock
detector