linux删除用户账户_如何在Linux中删除删除用户帐户?

linux删除用户账户

linux删除用户账户

How can I remove a Linux user account from Linux system. As you know user management in Linux requires root privileges. While removing user his home directory can be remove or preserved. As same with mail box. User mailbox can be preserved.

如何从Linux系统中删除Linux用户帐户。 如您所知,Linux中的用户管理需要root特权。 在删除用户时,可以删除或保留其主目录。 与邮箱相同。 用户邮箱可以保留。

列出现有帐户 (List Existing Accounts)

Before removing or deleting an user account checking the existing of account can be useful. We can check whether given account exist with different ways. In this example we will use chage command with -l list option for user ismail .

在删除或删除用户帐户之前,请先检查帐户的存在性。 我们可以检查给定的帐户是否以不同的方式存在。 在此示例中,我们将对用户ismail使用chage命令和-l list选项。

$ chage -l ismail 
chage: user 'ismail' does not exist in /etc/passwd
  • chage will give information about specified user

    chage将提供有关指定用户的信息

  • -l test will list users information

    -l测试将列出用户信息

  • As said before the user is removed so there is no information about the user.

    如前所述,在删除用户之前,没有关于该用户的信息。

Or we can print the /etc/passwd in a formatted manner which only list user account names by using cut command

或者我们可以以格式化的方式打印/etc/passwd ,仅使用cut命令列出用户帐户名

$ cat /etc/passwd | cut -d ':' -f 1
List Existing Accounts 
List Existing Accounts
列出现有帐户

使用userdel命令删除/删除用户帐户(Remove/Delete User Account with userdel Command)

We can remove given user account with userdel command like below. In this example we will remove user account named ismail . As this is an administrative task we need root privileges which can be get with sudo command.

我们可以使用下面的userdel命令删除给定的用户帐户。 在此示例中,我们将删除名为ismail用户帐户。 由于这是一项管理任务,因此我们需要可以使用sudo命令获得的root特权。

$ sudo userdel ismail
  • userdel will remove specified test user account

    userdel将删除指定的测试用户帐户

删除/删除用户帐户和主目录(Remove/Delete User Account and Home Directory)

The default behavior of the userdel command is removing user account from user data which resides /etc/passwd . This will not delete the user account home directory. If we want to remove the user account home directory while removing account with userdel we should provide the -r option. In this example we will delete the user account test and its home directory.

userdel命令的默认行为是从驻留在/etc/passwd用户数据中删除用户帐户。 这不会删除用户帐户主目录。 如果要在删除带有userdel帐户时删除用户帐户的主目录,则应提供-r选项。 在此示例中,我们将删除用户帐户test及其主目录。

$ sudo userdel -r test

使用主目录和用户拥有的文件删除/删除用户帐户 (Remove/Delete User Account with Home Directory and User Owned Files)

In previous example we have deleted user account with its home directory. If we want to delete also user owned files and folders while remove user account we can use userdel command with -f option. In this example we will remove user account ali and its home folder and owned files and folders those resides other than his home directory.

在前面的示例中,我们已删除用户帐户及其主目录。 如果要在删除用户帐户的同时删除用户拥有的文件和文件夹,则可以使用带-f选项的userdel命令。 在此示例中,我们将删除用户帐户ali及其主文件夹以及拥有的文件和文件夹,这些文件和文件夹位于其主目录之外。

$ sudo userdel -r -f ali

从passwd文件中删除/删除用户帐户行 (Remove/Delete User Account Line From passwd File)

We have an other less structured option to remove a user account. We can remove the line which user is defined from file /etc/passwd . As this file contains user details this will remove  user account. We can also remove password hash from /etc/shadow .

我们还有另一个结构较简单的选项来删除用户帐户。 我们可以从文件/etc/passwd删除用户定义的行。 由于此文件包含用户详细信息,因此将删除用户帐户。 我们还可以从/etc/shadow删除密码哈希。

LEARN MORE  Linux Cut Command With Examples
通过示例了解更多Linux Cut命令

如何在Linux中删除删除用户帐户? 信息移植 (How To Delete Remove User Accounts In Linux? Infografic)

How To Delete Remove User Accounts In Linux? Infografic
How To Delete Remove User Accounts In Linux? Infografic
如何在Linux中删除删除用户帐户? 信息移植

翻译自: https://www.poftut.com/delete-remove-user-accounts-linux/

linux删除用户账户

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值