LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2024, 02:55 PM   #1
LordOfSteel
LQ Newbie
 
Registered: Feb 2024
Posts: 5

Rep: Reputation: 0
Question 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
 
Old 02-08-2024, 03:43 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,663
Blog Entries: 4

Rep: Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944Reputation: 3944
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.
 
Old 02-08-2024, 04:39 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by sundialsvcs View Post
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.

Last edited by rknichols; 02-08-2024 at 04:48 PM. Reason: Added possibility #3
 
1 members found this post helpful.
Old 02-08-2024, 05:10 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,641

Rep: Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966Reputation: 7966
Quote:
Originally Posted by LordOfSteel View Post
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"
 
Old 02-08-2024, 11:29 PM   #5
lvm_
Member
 
Registered: Jul 2020
Posts: 935

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
It could be a mountpoint - what does mount say?
 
Old 02-09-2024, 12:34 AM   #6
LordOfSteel
LQ Newbie
 
Registered: Feb 2024
Posts: 5

Original Poster
Rep: Reputation: 0
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)
 
Old 02-09-2024, 02:44 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
I guess you need to go into that dir and check the content. sometimes rm cannot remove files, because of insufficient permissions.
 
Old 02-09-2024, 05:52 AM   #8
LordOfSteel
LQ Newbie
 
Registered: Feb 2024
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
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?
 
Old 02-09-2024, 05:53 AM   #9
LordOfSteel
LQ Newbie
 
Registered: Feb 2024
Posts: 5

Original Poster
Rep: Reputation: 0
se answer above!
trying to delete this post but cant find the button ^^ sorry

Last edited by LordOfSteel; 02-09-2024 at 05:55 AM.
 
Old 02-09-2024, 06:00 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
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>
 
Old 02-09-2024, 06:57 AM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,524

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
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
 
Old 02-09-2024, 11:22 AM   #12
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 365

Rep: Reputation: 171Reputation: 171
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".
 
Old 02-13-2024, 12:32 AM   #13
LordOfSteel
LQ Newbie
 
Registered: Feb 2024
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 02-13-2024, 06:54 AM   #14
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,524

Rep: Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495Reputation: 2495
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/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Empty a File, Delete N Lines From a File, Remove Matching String From a File, And Remove Empty/Blank Lines From a File In Linux LXer Syndicated Linux News 0 11-22-2017 12:30 PM
Scripting Help--Check empty string condition (not null, but empty!) sungchoiok Linux - Newbie 4 01-01-2012 03:46 PM
rm: cannot remove directory `ff': Directory not empty blancs Linux - General 17 08-29-2011 01:47 PM
Can't remove non-empty directory with rsync alkos333 Slackware 5 01-20-2009 06:31 PM
Gentoo VNC, empty dialog box !! "Question" window is empty ! TheHushedCaskeT Linux - Software 0 02-01-2005 10:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration