Drop user in linux

Как удалять пользователей в Linux (команда userdel)

Linux — это многопользовательская система, что означает, что с одной и той же системой одновременно могут взаимодействовать несколько человек. Как системный администратор, вы несете ответственность за управление пользователями и группами системы, создавая новых пользователей и распределяя их по разным группам .

Иногда вам может потребоваться удалить учетную запись пользователя. Возможно, из-за того, что пользователь ушел из организации, или она была создана для определенной службы, которая больше не работает в системе.

В Linux вы можете удалить учетную запись пользователя и все связанные с ней файлы с помощью команды userdel .

В этом руководстве рассматривается команда userdel и ее параметры.

Синтаксис команды userdel

Синтаксис команды userdel следующий:

Чтобы удалить пользователей с помощью команды userdel , вам необходимо войти в систему как root или как пользователь с доступом sudo .

Как удалить пользователя в Linux

Чтобы удалить учетную запись username с именем username с помощью команды userdel вы должны выполнить:

При вызове команда считывает содержимое файла /etc/login.defs . Свойства, определенные в этом файле, переопределяют поведение userdel по умолчанию. Если для параметра USERGROUPS_ENAB в этом файле задано значение yes , userdel удаляет группу с тем же именем, что и пользователь, только если в этой группе нет других пользователей.

Команда удаляет записи пользователей из файлов /etc/passwd и /etc/shadow, .

В большинстве дистрибутивов Linux при удалении учетной записи пользователя с помощью userdel домашний каталог пользователя и каталог спула почты не удаляются.

Используйте параметр -r ( —remove ), чтобы заставить userdel удалить домашний каталог пользователя и почтовый ящик:

Приведенная выше команда не удаляет пользовательские файлы, расположенные в других файловых системах. Вам придется искать и удалять файлы вручную.

Если пользователь, которого вы хотите удалить, все еще находится в системе или если есть запущенные процессы , принадлежащие этому пользователю, команда userdel не позволяет удалить пользователя.

В этой ситуации рекомендуется выйти из системы и убить все запущенные процессы пользователя с помощью команды killall :

После этого вы можете удалить пользователя.

Другой вариант — использовать параметр -f ( —force ), который сообщает userdel принудительно удалить учетную запись пользователя, даже если пользователь все еще находится в системе или если есть запущенные процессы, принадлежащие пользователю.

Выводы

В этом руководстве вы узнали, как удалить учетные записи пользователей в Linux с помощью команды userdel . Тот же синтаксис применяется к любому дистрибутиву Linux, включая Ubuntu, CentOS, RHEL, Debian, Fedora и Arch Linux.

userdel — это утилита низкого уровня, пользователи Debian и Ubuntu, скорее всего, будут использовать более дружелюбную команду deluser .

Читайте также:  Mcedit linux как пользоваться

Не стесняйтесь оставлять комментарии, если у вас есть вопросы.

Источник

How to Delete User on Ubuntu

Ubuntu is a well liked and widely used Linux distribution which allows you to add and delete use. Ubuntu is an operating system that handles several people who can use the system at the same time. When you install the Ubuntu system you need to create the user and you can add users later after installation of the system. But if you want to remove any users then Ubuntu allows you to delete the user using sudo privileges. In this Article our main focus will be on how to remove a user from Ubuntu using two approaches: Deleting user using Graphical Interface and Deleting user using Command Line.

Follow any of the approaches you find easier.

Deleting User Using Graphical Interface

As a beginner of Ubuntu you will find this approach a way easier. Follow the steps below to remove user using GUI on Ubuntu System:

Step 1: Open setting
Firstly you need to open the Settings by opening “Activities” and typing setting in search bar and click on Settings icon:

Or you can left click on the desktop screen of Ubuntu a drop-down list will appear, click on Settings option.

Step 2: Open Users setting
After the setting window will appear click on “Users” from list on left side, then on “Unlock…”:

Step 3: Remove User Account
In the Users setting, the system users will be shown on the screen.Then, at the bottom of the page, click the “Remove User…” button next to the user you wish to delete. Below I am removing “linuxhint” user from my system:

Now a dialogue box will appear asking you to select an option. To remove all files of the user you want to delete then choose Delete Files option, but if you want to store the files of the user for later use then choose Keep Files option.

And user will be removed from list of users as shown below:

Deleting User using Command Line

If you are a Command Line user this method is for you. You can also remove the user by writing commands on the terminal.

Step 1: List users
First check all the users registered on your system, the users are recorded in /etc/passwd, with the user account name as the first column.To see a list of existing user accounts, use the cat command, as seen below:

Step 2: Remove user
The “deluser” command is used for deleting or removing a user account from Ubuntu. The deluser command should be given the user account name. We also need capabilities to delete user accounts, which we can get by logging in as root or executing the sudo command as a regular user.

Below mentioned is the command to delete “linuxhint” user from my system:

Step 3 : Check User
Now check whether the user is deleted by below mentioned command:

Читайте также:  Остановить процесс astra linux

From above shown results we can check that “linuxhint” user no longer exists.

Conclusion

Ubuntu is an open source multi-user Linux distribution which provides several functionalities.It lets you add and remove users at any moment. In this Article, two approaches to delete the user from Ubuntu system are discussed; first is by GUI method and second is by Command line method using “deluser” command. To successfully delete the user, you can use any of the methods outlined in this article.

About the author

Alishba Iftikhar

I am currently an undergraduate student in my 1st year. I am an internee author with Linuxhint and loved learning the art of technical content writing from senior authors. I am looking forward to opting my career as a full time Linux writer after I graduate.

Источник

Linux Delete User

Linux Delete User

Linux Delete user option is used to delete a user from Server. By deleting a user form Linux, we can remove SSH access also and delete user’s files and user ownership directories. We can delete users in Linux only if we have root permissions.

Web development, programming languages, Software testing & others

Basic Syntax:

Linux server is a server where multiple users can login at a time. This means that there will be a number of users created and interacted at the same time. To manage their accounts, the administration should take up the responsibility to manage the user’s account. There might be situations where we would need to delete a user from the Server because the user is no longer associated with the organization or the user is no longer running in the server. Here in this article, we will discuss how to delete a user from the server.

The following are the ways that are used to delete a user from Server. The syntax is below:

userdel user_name userdel [options] user_name userdel -r user_name

Here the below options are used with userdel command in Linux:

  • -f : Forcefully delete a user account and also with forceful removal of files.
  • -r : Deletes user account along with mail spool and user’s home directory
  • -z : Deletes SELinux users if they are mapped for the users while deleting user from Linux.

How to Delete a User from Linux?

Below are the options that we can use to perform the delete operation on a user in Server.

Options Description
-f Forcefully delete a user account and also with forceful removal of files.
-r Deletes user account along with mail spool and user’s home directory
-z Deletes SELinux users if they are mapped for the users while deleting user from Linux.

Follow the below process step by step to delete a user in Linux:

Step 1: The first step to delete a user in Linux Server is to lock the user’s account. We can do this by the below process.

Step 2: Then, we need to back up the files from the user’s home directory to a backup folder. We can use the tar option to compress the size of the files.

$ tar -zcvf /backup_folder.tar.gz /home/user_name/

Step 3: Remove cron jobs that are set by the user.

Читайте также:  Linux find command location

Step 4: Then delete the printed jobs available in the system.

Step 5: Display all the files that are owned by the user.

Step 6: At the end, we will delete the user account in Server. Userdel command is used to delete a user in Server. We can do it as shown below.

Examples to Delete User form Linux Server

The following are the examples of using userdel command in Server to delete a user form Server. Options are briefly described with examples for better understanding.

Example #1 – No Option

When no option is passed in userdel command in Linux, it will delete the user from the server.

Example: if we want to delete a user named ‘nikhil’, then we can delete his account from Linux by the below example.

Example #2 – Option -r

To delete the user’s home directory and mail spool, we can use option -r with userdel command to delete them.

Example: To delete the user’s home directory and his mail spool for a user named ‘nikhil’, we can do it in Linux by the below example.

Example #3 – Option -f

when there are any other files in other locations for the deleted user, we can delete them forcefully by using option -f even though it is not owned by the user.

Example: Forecfull deletion of files from other locations can be done as shown below.

Example #4 – Option -z

To delete any SELinux users mapped to the user, we can use -z option.

Example: we can delete any SELinux users mapped to the user named ‘nikhil’ by using -z option as shown below.

Conclusion

In this article, you have now learned how to delete a user form Linux Server using userdel command. We can delete the users in Ubuntu, RHEL, CentOS also in a similar way that we did in Linux. Userdel command is a very important command mostly used by the administration to monitor if the user accounts are deleted when they are not been used in the Server. Delete user option is used to delete a user from Server. By deleting a user form Linux, we can remove SSH access also and delete user’s files and user ownership directories. We can delete users only if we have root permissions.

Recommended Article

We hope that this EDUCBA information on “Linux Delete User” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

502+ Hours of HD Videos
54 Courses
4 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5

57+ Hours of HD Videos
15 Courses
9 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5

Источник

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