Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently created a username and a group called gamesForAdmin. Since then I deleted it and the folder I made for it is still there:

drwxr-xr-x  5 root     root       4096 Jul  4 11:28 .
drwxr-xr-x 23 root     root       4096 May 29 12:41 ..
drwxr-xr-x  2 sftpuser sftpaccess 4096 Jul  4 11:24 gamesForAdmin
drwxr-xr-x 27 ryan     ryan       4096 Jul  4 11:31 ryan
drwxr-xr-x  3 root     sftpaccess 4096 Jul  4 11:29 sftpuser

When I try to run a sudo rmdir gamesForAdmin, I get this error message:

rmdir: failed to remove ‘gamesForAdmin’: Directory not empty

But theres nothing in the directory! When I run an ls, there is nothing listed.

  • Why does this occur?
  • How I can successfully remove this directory?

Output of ls -la gamesForAdmin:

total 28
drwxr-xr-x 2 sftpuser sftpaccess 4096 Jul  4 11:24 .
drwxr-xr-x 5 root     root       4096 Jul  4 11:28 ..
-rw------- 1 sftpuser sftpaccess  471 Jun  9 19:49 .bash_history
-rw-r--r-- 1 sftpuser sftpaccess  220 Apr  8 21:03 .bash_logout
-rw-r--r-- 1 sftpuser sftpaccess 3637 Apr  8 21:03 .bashrc
-rw-r--r-- 1 sftpuser sftpaccess  675 Apr  8 21:03 .profile
-rw------- 1 sftpuser sftpaccess  644 Jun  9 17:48 .viminfo
share|improve this question
For the record, you can also use rmdir --ignore-fail-on-non-empty, but of course that's longer than rm -rf and no sane person would ever use it. ;) – nyuszika7h Jul 4 '14 at 18:50
up vote 3 down vote accepted

Based on the output you're showing in your question the directory gamesForAdmin is not empty, so rmdir cannot remove this directory. To remove it you'll need to use rm -fr instead. Try this:

sudo rm -rf gamesForAdmin

which should fix you right up.

share|improve this answer
Perfect! Thanks much! – ryekayo Jul 4 '14 at 15:44
you've very welcome – Deryck Jul 4 '14 at 15:44
probably don't need the f. – richard Jul 4 '14 at 17:24
better safe than trying again – Deryck Jul 4 '14 at 17:27

Your folder can have some hidden files (ls doesn't show dot files by default, i.e. files whose name begins with . are hidden).


ls -la gamesForAdmin

to check if there is any hidden files in it.


According to your result ls -la, your directory is not empty, so rmdir can not remove it, rmdir only work with empty directory.

To remove it, you can use:

rm -r gamesForAdmin
share|improve this answer
Good point :), I will put the results in my question – ryekayo Jul 4 '14 at 15:43

ls -al is great for checking to see if there are any hidden directories.

Barring that rm -rf removes recursively and forces the removal, keep in mind that rm -rf \ will delete everything. Depending on distro this may throw an error, or demo your entire file system.

Ubuntu normally doesn't let you do an rm to your root filesystem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.