• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to remove user accounts with home directory in Linux

{{postValue.id}}

Remove user accounts with home directory in Linux

In this article we will discuss how to remove user accounts with home directory in Linux. You can create user account and assign passwd for user at home directory.

To creating user and assigning passwd for user at home directory

We are going to create two users for example

[root@linuxhelp~]# useradd user4
[root@linuxhelp~]# useradd user5

< ads>


Example

[root@linuxhelp~]# passwd user5
Changing password for user user5.
New password: 
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.

To delete user accounts

Syntax
deluser [In Ubuntu based systems]
userdel [In CentOS based systems]

Example

vi /etc/deluser.conf        [On Debian/Ubuntu and its derivatives]
vi /etc/login.defs             [On RedHat/CentOS based systems]

5userdel-conf-file

6userdelconf-file2

To lock user accounts

This command is used to protect the system from other users.

Example

[root@linuxhelp~]# passwd --lock user5
Locking password for user user5. 
passwd: Success 
[root@linuxhelp~]# passwd --unlock user5
unLocking password for user user5. 
passwd: Success 

To kill running process of user

It can be killed by finding out the PIDs.

To grep any running process

Example

[root@linuxhelp~]# pgrep -u user5
1947
1959
2091
2094
2095
2168
2175

[root@linuxhelp~]# ps aux | grep user5
user5     2508  0.0  0.1 150532  1944 ?        Sl   11:34   0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
user5     2517  0.0  0.3 252660  3424 ?        Ssl  11:34   0:00 gnome-session
user5     2525  0.0  0.0  20036   320 ?        S    11:34   0:00 dbus-launch --sh-syntax --exit-with-session
user5     2526  0.0  0.1  22064  1252 ?        Ss   11:34   0:00 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
user5     2599  0.0  0.4 133404  4544 ?        S    11:34   0:01 /usr/libexec/gconfd-2
user5     2607  0.0  0.4 505396  4240 ?        Ssl  11:34   0:02 /usr/libexec/gnome-settings-daemon
.
.
.
.
user5     8702  0.0  0.1 108336  1784 pts/3    Ss   15:09   0:00 /bin/bash
root     10539  0.0  0.0 103248   840 pts/3    S+   16:42   0:00 grep user5

To kill a process

Syntax
Kill -9 “ process ID”

To take backup of user data

Syntax
tar -jcvf mybackup/user5.tar.bz2 /home/user5

Example

[root@linuxhelp~]# tar  -jcvf mybackup/user5.tar.bz2 /home/user5
/home/user1/
/home/user1/.pulse/
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-default-source
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-device-volumes.tdb
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-default-sink
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-card-database.tdb
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-stream-volumes.tdb
/home/user1/.pulse/a440afd05cdb59bd3135a9d100000013-runtime
/home/user1/tar_linuxhelp.odt
/home/user1/.thumbnails/
/home/user1/.thumbnails/normal/
/home/user1/.thumbnails/normal/6a5d83a47302159097f5afb93347fd9b.png
/home/user1/.thumbnails/normal/202ad313ecb8799c0e78c3ff8b27f46b.png
/home/user1/.thumbnails/normal/cc046f2d93f68eabfa97c4d28c88cf13.png
.
.
.
/home/user1/.libreoffice/3/user/config/standard.soc
/home/user1/.libreoffice/3/user/config/standard.soh

To remove user account files

Syntax
deluser --remove-home username [On Debian/Ubuntu and its derivatives]

userdel --remove username [On RedHat/CentOS based systems]

Example:

[root@linuxhelp~]#userdel &ndash remove user5
[root@linuxhelp~]#ls -l /home 
drwx------.  4 c     c     4096 Jan 28 13:16 c
drwx------.  4 d     d     4096 Jan 28 13:20 d
drwxr-xr-x.  2 root  root  4096 Feb 25 18:26 Desktop
drwxr-xr-x.  2   501   502 4096 Jan 27 17:19 new
drwx------. 34 user1 user1 4096 Feb 29 17:25 user1
drwx------. 21 user2 user2 4096 Feb 28 09:43 user2
drwx------   4 user3 user3 4096 Feb 27 15:03 user3

Tags:
noah
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

how to manage "groups" and "group members" in linuxmint ?

A

You have to install Gnome2's "users and groups" utility to do that kind of advanced stuff. "sudo apt-get install gnome-system-tools"

Q

how to set password expiration for user?

A

you can use "CHAGE" command to set expiration date.

Q

how to change a login shell?

A

You can make use of "CHSH" command to change login shell of linux.

Q

where i can find the configuration file for password and group?

A

Following is the location
/etc/passwd and /etc/group are the configuration file of password and group. And also you can use vigr and vipw command to open a group and password configurati

Q

What are all the commands to get who are all taking ssh with particular user?

A

"w" or "who" are the commands to get who are all taking ssh with particular user.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.