Can't delete user directory on CentOS

7.6k Views Asked by At

I'm stuck.

I did a simple useradd. I had user -> mark and assigned directory -> /home/mark. Here i've installed a software. Later I've deleted mark and now i can't delete /home/mark. With root account I tried to:

a) Change permission to 777 -> Permission denied

b) Delete directory with

rm -rf /home/mark

Permission denied

c) Nautilus

sudo nautilus 

Could not parse arguments: Can't open display (what??)

There's no way for me to remove this directory from my server. Here's my permissions list

ls -la /home/mark

drwx------ 5  502  502    4096 10 ago 13:32 .
drwxr-xr-x 5 root root    4096 10 ago 16:13 ..
-rwxrwxrwx 1  502  502     366 10 ago 13:46 .bash_history
-rwxrwxrwx 1  502  502      18 10 mag 20:45 .bash_logout
-rwxrwxrwx 1  502  502     176 10 mag 20:45 .bash_profile
-rwxrwxrwx 1  502  502     124 10 mag 20:45 .bashrc
drwxrwxrwx 2  502  502    4096 12 nov  2010 .gnome2
drwxrwxrwx 2  502  502    4096 10 ago 14:28 .mozilla
drwxrwxrwx 2  502  502    4096 10 ago 14:28 mypackage
-rwxrwxrwx 1  502  502 4131518 10 ago 05:06 mypackage.tar.gz

Any idea?

p.s. On GNOME when I right-click this folder (of course I can't open it) I see on Permissions tab that Owner and Group are still assigned to mark's ID. I can see Owner -> 502 - user #502 (it was mark) and Group -> 502. All forms are greyed-out and I can't edit them.

3

There are 3 best solutions below

5
On

To delete the user mark and his data (/hom/mark), as root type this:

#userdel -r mark

EDIT : try this

chattr -i mark
rm -rf mark

You said that you cannot chown this directory, if the command above does not work, i suggest fsck on the system:

#shutdown -r -F now

And try after checking the filesyetemn to remove the mark folder.

3
On

Log in as root

cd /home
chmod -R 0777 mark
rm -fr mark

should do the trick.

Then edit /etc/passwd /etc/shadow

2
On

Make sure no running process associated with that directory.

[root@ap0003 tmp]# fuser /home/spatel
/home/spatel:         1196c  1243c
[root@ap0003 tmp]# ps aux | grep 1196
spatel    1196  0.0  0.0  66120  1540 pts/0    Ss   09:41   0:00 -bash
root      1889  0.0  0.0  61228   764 pts/0    S+   11:38   0:00 grep 1196