LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Canīt remove directory with rm -rf [Directory not empty] (https://www.linuxquestions.org/questions/linux-newbie-8/can%B4t-remove-directory-with-rm-rf-%5Bdirectory-not-empty%5D-4175733661/)

LordOfSteel 02-08-2024 02:55 PM

Canīt remove directory with rm -rf [Directory not empty]
 
Trying to delete folder 28.
But I can't delete it.
here is what i tried.

Code:

[core-ssh 01]$ ls -all
total 12
drwxrwxrwx    3 root    root          4096 Feb  8 21:35 .
drwxrwxrwx    4 root    root          4096 Feb  1 06:41 ..
drwxrwxrwx    2 root    root          4096 Feb  8 20:53 28
[core-ssh 01]$ ls -all 28/
total 0
[core-ssh 01]$ rm -rf 28/
rm: can't remove '28': Directory not empty
[core-ssh 01]$ rmdir 28/
rmdir: '28/': Directory not empty
[core-ssh 01]$ cd 28/
[core-ssh 28]$ ls -all
total 0


sundialsvcs 02-08-2024 03:43 PM

Use ls -a and you should find that there are some hidden files and/or directories in there.

Anything with a "." was the first character of the name is ordinarily hidden.

rknichols 02-08-2024 04:39 PM

Quote:

Originally Posted by sundialsvcs (Post 6482321)
Use ls -a and you should find that there are some hidden files and/or directories in there.

He used "ls -all", which is equivalent to "ls -a -l -l", or else he meant "ls --all", which is equivalent to "ls -a".

A few possibilities:
  1. "ls" is invoking something other that the standard "ls" utility. The command "type ls" might reveal something.
  2. This might be a situation in need of "fsck" on the filesystem.
  3. A virus has infected your system and is hiding things from you.

TB0ne 02-08-2024 05:10 PM

Quote:

Originally Posted by LordOfSteel (Post 6482302)
Trying to delete folder 28. But I can't delete it. here is what i tried.
Code:

[core-ssh 01]$ ls -all
total 12
drwxrwxrwx    3 root    root          4096 Feb  8 21:35 .
drwxrwxrwx    4 root    root          4096 Feb  1 06:41 ..
drwxrwxrwx    2 root    root          4096 Feb  8 20:53 28
[core-ssh 01]$ ls -all 28/
total 0
[core-ssh 01]$ rm -rf 28/
rm: can't remove '28': Directory not empty
[core-ssh 01]$ rmdir 28/
rmdir: '28/': Directory not empty
[core-ssh 01]$ cd 28/
[core-ssh 28]$ ls -all
total 0


Capitalize the "r" in the command: "rm -fR 28"

lvm_ 02-08-2024 11:29 PM

It could be a mountpoint - what does mount say?

LordOfSteel 02-09-2024 12:34 AM

Tried your suggestions, here is the result.


sundialsvcs
Quote:

Use ls -a and you should find that there are some hidden files and/or directories in there.
Code:

[core-ssh 28]$ ls -a
[core-ssh 28]$


rknichols
Quote:

1. "ls" is invoking something other that the standard "ls" utility. The command "type ls" might reveal something.
Code:

[core-ssh 28]$ type ls
ls is hashed (/bin/ls)


rknichols
Quote:

2. This might be a situation in need of "fsck" on the filesystem.
How do I use fsack?
Code:

[core-ssh 28]$ fsck
fsck (busybox 1.36.1)
[core-ssh 28]$ fsck --help
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.

Usage: fsck [-ANPRTV] [-t FSTYPE] [FS_OPTS] [BLOCKDEV]...

Check and repair filesystems

        -A      Walk /etc/fstab and check all filesystems
        -N      Don't execute, just show what would be done
        -P      With -A, check filesystems in parallel
        -R      With -A, skip the root filesystem
        -T      Don't show title on startup
        -V      Verbose
        -t TYPE List of filesystem types to check


TB0ne
Quote:

Capitalize the "r" in the command: "rm -fR 28"
Code:

[core-ssh 01]$ rm -fR 28
rm: can't remove '28': Directory not empty


lvm_
Quote:

It could be a mountpoint - what does mount say?
Code:

[core-ssh 01]$ mount
overlay on / type overlay (rw,relatime,lowerdir=/mnt/data/docker/overlay2/l/Z2OB6PEKK2YZBD4PMO4MVPGD65:/mnt/data/docker/overlay2/l/UQQAFIMQXTQSN6UDT76EVSGTF2:/mnt/data/docker/overlay2/l/CZ2WL4T4SEKON5YPCGIEDUYHDZ:/mnt/data/docker/overlay2/l/652IOPQEMPDHZMHDO73GTWPNR2:/mnt/data/docker/overlay2/l/ZKLAA3CMRMDOQ7RTVYQWZRDN5U:/mnt/data/docker/overlay2/l/XGHY4JRCADB2NAF2KYFTMHMAMY:/mnt/data/docker/overlay2/l/S77H54AJ74DY4C7IBKIT75DM2H:/mnt/data/docker/overlay2/l/BZSJMRGZF3M2NUIHGGB7WZHWLT:/mnt/data/docker/overlay2/l/4JADSAWCSQMXQXVIZB2TOGYMJE:/mnt/data/docker/overlay2/l/3MGXKMKIJI6635A4NKDZ4A76WA,upperdir=/mnt/data/docker/overlay2/c50cd23f38a30112ddce8248fb0aaf38596dc841c26e546f81255d0c0cd8bbec/diff,workdir=/mnt/data/docker/overlay2/c50cd23f38a30112ddce8248fb0aaf38596dc841c26e546f81255d0c0cd8bbec/work)proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)sysfs on /sys type sysfs (ro,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup type cgroup2 (ro,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
/dev/sda8 on /homeassistant type ext4 (rw,relatime,commit=30)
/dev/sda8 on /data type ext4 (rw,relatime,commit=30)
devtmpfs on /dev type devtmpfs (ro,relatime,size=3030572k,nr_inodes=757643,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
/dev/sda8 on /backup type ext4 (rw,relatime,commit=30)/dev/sda8 on /media type ext4 (rw,relatime,commit=30)/dev/sda8 on /addon_configs type ext4 (rw,relatime,commit=30)/dev/sda8 on /ssl type ext4 (rw,relatime,commit=30)/dev/sda8 on /share type ext4 (rw,relatime,commit=30)/dev/sda8 on /addons type ext4 (rw,relatime,commit=30)
/dev/sda8 on /run/audio type ext4 (ro,relatime,commit=30)
/dev/sda8 on /etc/asound.conf type ext4 (ro,relatime,commit=30)
tmpfs on /run/dbus type tmpfs (ro,size=1213056k,nr_inodes=819200,mode=755)
/dev/sda8 on /etc/resolv.conf type ext4 (rw,relatime,commit=30)
/dev/sda8 on /etc/hostname type ext4 (rw,relatime,commit=30)
/dev/sda8 on /etc/hosts type ext4 (rw,relatime,commit=30)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
/dev/sda8 on /etc/pulse/client.conf type ext4 (ro,relatime,commit=30)
proc on /proc/bus type proc (ro,nosuid,nodev,noexec,relatime)
proc on /proc/fs type proc (ro,nosuid,nodev,noexec,relatime)
proc on /proc/irq type proc (ro,nosuid,nodev,noexec,relatime)
proc on /proc/sys type proc (ro,nosuid,nodev,noexec,relatime)
proc on /proc/sysrq-trigger type proc (ro,nosuid,nodev,noexec,relatime)
tmpfs on /proc/asound type tmpfs (ro,relatime)
tmpfs on /proc/acpi type tmpfs (ro,relatime)
devtmpfs on /proc/kcore type devtmpfs (ro,relatime,size=3030572k,nr_inodes=757643,mode=755)
devtmpfs on /proc/keys type devtmpfs (ro,relatime,size=3030572k,nr_inodes=757643,mode=755)
devtmpfs on /proc/timer_list type devtmpfs (ro,relatime,size=3030572k,nr_inodes=757643,mode=755)
tmpfs on /proc/scsi type tmpfs (ro,relatime)
tmpfs on /sys/firmware type tmpfs (ro,relatime)


pan64 02-09-2024 02:44 AM

I guess you need to go into that dir and check the content. sometimes rm cannot remove files, because of insufficient permissions.

LordOfSteel 02-09-2024 05:52 AM

Quote:

Originally Posted by pan64 (Post 6482393)
I guess you need to go into that dir and check the content. sometimes rm cannot remove files, because of insufficient permissions.


How do I find those files? when
ls
ls -a
ls -all
can't find any files in that dir.
is there another command to find files that are hidden?

LordOfSteel 02-09-2024 05:53 AM

se answer above!
trying to delete this post but cant find the button ^^ sorry

pan64 02-09-2024 06:00 AM

in that case probably you have no right to remove that directory itself.
you might try:
Code:

strace -o /tmp/strace.txt rm -rf <dir>

yancek 02-09-2024 06:57 AM

Is this on a local computer? Which Linux distribution are you using? This is always useful information to post in a new thread as there are probably over 1,000 different Linux distributions.
Where in the directory tree is this directory located?
Do you get the same error message when you try to remove it when logged in as root?
I don't know why you get the error you do as I would expect a 'permission denied' since the directory owner:group are clearly root:root and you are logged in as a user.

I noticed 'overlay' in the output of your mount command so might I suggest that you take a look at the link below to familiarize yourself.

https://www.kernel.org/doc/html/v5.8...overlayfs.html

metaed 02-09-2024 11:22 AM

NOTE I am not familiar with this problem. But yancek may be on the right track. A Google search for the terms
"docker" "overlay" "directory not empty"
digs up a lot of dirt, including kernel driver issues. As such I am not so sure this is a "Linux - Newbie" question. You might get more traction over at "Linux - Containers".

LordOfSteel 02-13-2024 12:32 AM

thank you for your commitment.
the problem is solved!!
After a total shutdown of the server, the problem disappeared.
Previously tried just reboting, but that didn't help.


The Linux "distro" is -> Home Assistant Operating System.
runnin in VirtualBox.

yancek 02-13-2024 06:54 AM

I'm glad to see you got your problem solved and would suggest that in the future, posting here or any other forum you provide more information at the start to get help. In addition to answers to the questions I asked in my earlier post, it would have been quite helpful to indicate you were using virtualization software and particularly which 'Linux' you are using, particularly when it is something as obscure as your "home assisteant". Is the link below to the software you are using? If so, posting the link would have been helpful.

https://www.home-assistant.io/installation/linux/


All times are GMT -5. The time now is 10:10 AM.