欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux下完全刪除用戶的兩種方法

 更新時(shí)間:2018年10月08日 15:41:13   投稿:mrr  
這篇文章主要介紹了Linux下完全刪除用戶的兩種方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

Linux操作

實(shí)驗(yàn)環(huán)境:Centos7虛擬機(jī)

首先創(chuàng)建一個(gè)普通用戶 gubeiqing 。

[root@localhost ~]# useradd gubeiqing
[root@localhost ~]# passwd gubeiqing
Changing password for user gubeiqing.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

這樣就成功創(chuàng)建了一個(gè)普通用戶,然后來刪除這個(gè)用戶。

[root@localhost ~]# userdel gubeiqing
[root@localhost ~]#

使用 useradd 命令就刪除了,但是,,,問題來了,當(dāng)我們?cè)俅蝿?chuàng)建 gubeiqing 這個(gè)用戶時(shí):

[root@localhost ~]# useradd gubeiqing
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists

文件已存在,無法創(chuàng)建,這是為什么?因?yàn)樵趧?chuàng)建用戶時(shí)會(huì)默認(rèn)生成用戶的 家目錄 , 密碼文件 , 用戶組 (不指定用戶組的情況下),以及 郵箱文件 ,而使用 userdel 命令刪除時(shí)僅僅是刪除了這個(gè)用戶,而這個(gè)用戶的文件還在,那么就需要完全刪除這些文件。我看了一下大概有四個(gè)地方需要處理。

/home
/etc/passwd
/etc/group
/var/spool/mail

下面依次來刪除這些文件。

1.刪除 /home 目錄下的文件

[root@localhost ~]# cd /home
[root@localhost home]# ls
gubeiqing
[root@localhost home]# rm -rf gubeiqing
[root@localhost home]# ls
[root@localhost home]#

2.刪除 /etc/passwd 下的用戶

我們可以查看一下這個(gè)文件。

[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:997:User for polkitd:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
dockerroot:x:997:994:Docker User:/var/lib/docker:/sbin/nologin
gubeiqing:x:1000:1000::/home/gubeiqing:/bin/bash

在這里可以看到這個(gè)系統(tǒng)中的所有用戶,可以看到最后一行就是剛剛創(chuàng)建的用戶,那么使用 vi 編輯器刪除最后一行的用戶。

3.刪除 /etc/group 下的用戶組文件

先查看一下這個(gè)文件:

[root@localhost ~]# cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:30:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
ssh_keys:x:999:
input:x:998:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
polkitd:x:997:
postdrop:x:90:
postfix:x:89:
sshd:x:74:
chrony:x:996:
cgred:x:995:
dockerroot:x:994:
gubeiqing:x:1000:

然后使用 vi 編輯器刪除這個(gè)用戶組。

4.刪除 /var/spool/mail 下的郵箱文件

[root@localhost ~]# cd /var/spool/mail
[root@localhost mail]# ls
gubeiqing
[root@localhost mail]# rm -rf gubeiqing
[root@localhost mail]# ls
[root@localhost mail]#

刪除完成,再來創(chuàng)建 gubeiqing 用戶。

[root@localhost mail]# useradd gubeiqing
[root@localhost mail]# passwd gubeiqing
Changing password for user gubeiqing.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

搞定!

除了這種方法還有一種完全刪除的方法。

[root@localhost mail]# userdel -rf gubeiqing
[root@localhost mail]# useradd gubeiqing
[root@localhost mail]# passwd gubeiqing
Changing password for user gubeiqing.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

使用這兩種方法就可以完全刪除用戶。

總結(jié)

以上所述是小編給大家介紹的Linux下完全刪除用戶的兩種方法 ,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • linux下修改文件權(quán)限chmod命令詳細(xì)解析

    linux下修改文件權(quán)限chmod命令詳細(xì)解析

    大家好,本篇文章主要講的是linux下修改文件權(quán)限chmod命令詳細(xì)解析,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • CentOS 7 安裝 MySQL 5.6遇到的各種問題小結(jié)

    CentOS 7 安裝 MySQL 5.6遇到的各種問題小結(jié)

    在一測試服務(wù)器(CentOS Linux release 7.2.1511)上安裝MySQL 5.6(5.6.19 MySQL Community Server)時(shí)遇到了很多奇葩問題,今天小編給大家總結(jié)了關(guān)于entOS 7 安裝 MySQL 5.6遇到的各種問題,需要的朋友一起看看吧
    2016-11-11
  • Centos7 mysql數(shù)據(jù)庫安裝及配置實(shí)現(xiàn)教程

    Centos7 mysql數(shù)據(jù)庫安裝及配置實(shí)現(xiàn)教程

    這篇文章主要介紹了Centos7 mysql數(shù)據(jù)庫安裝及配置實(shí)現(xiàn)教程,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-08-08
  • xshell上傳下載文件(Windows、Linux)

    xshell上傳下載文件(Windows、Linux)

    Windows下載的軟件包,如何上傳到遠(yuǎn)程Linux主機(jī)上?如何從Linux主機(jī)下載軟件包到Windows下,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 在CentOS 7上給一個(gè)網(wǎng)卡分配多個(gè)IP地址的方法

    在CentOS 7上給一個(gè)網(wǎng)卡分配多個(gè)IP地址的方法

    本篇文章主要介紹了在CentOS 7上給一個(gè)網(wǎng)卡分配多個(gè)IP地址的方法,具有一定的參考價(jià)值,有需要的可以了解一下。
    2017-03-03
  • linux安裝部署ftp圖片服務(wù)器的實(shí)現(xiàn)方法

    linux安裝部署ftp圖片服務(wù)器的實(shí)現(xiàn)方法

    這篇文章主要介紹了linux安裝部署ftp圖片服務(wù)器的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-06-06
  • 解決Centos7安裝nginx后提示“Welcome to nginx on Fedora!”,conf.d目錄下無default.conf文件

    解決Centos7安裝nginx后提示“Welcome to nginx on Fedora!”,conf.d目錄下無d

    這篇文章主要介紹了Centos7安裝nginx后提示“Welcome to nginx on Fedora!”,conf.d目錄下無default.conf文件 ,本文給出了問題原因解析及解決方法,需要的朋友可以參考下
    2019-07-07
  • 網(wǎng)站加速VPS篇 memcache和memcached安裝方法

    網(wǎng)站加速VPS篇 memcache和memcached安裝方法

    Memcache是一個(gè)自由和開放源代碼、高性能、分配的內(nèi)存對(duì)象緩存系統(tǒng)。用于加速動(dòng)態(tài)web應(yīng)用程序,減輕數(shù)據(jù)庫負(fù)載。
    2010-12-12
  • 詳解Linux中關(guān)于引號(hào)的那些事

    詳解Linux中關(guān)于引號(hào)的那些事

    這篇文章主要給大家介紹了關(guān)于Linux中關(guān)于引號(hào)的那些事,文中詳細(xì)介紹了關(guān)于引號(hào)、單引號(hào)和雙引號(hào)、引用單個(gè)字符以及反斜杠的其他使用技巧等的相關(guān)內(nèi)容,介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • Linux如何運(yùn)行Jar包命令

    Linux如何運(yùn)行Jar包命令

    這篇文章主要介紹了Linux如何運(yùn)行Jar包命令問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05

最新評(píng)論