Issue/Question
I tried removing a file or folder and it doesn't work
Using rmdir on a folder fails
Removing a file or folder gives me an error message
Environment
Cause
rm: cannot remove ‘folder-without-write/file’: Permission denied
rmdir: failed to remove ‘folder-with-hidden/’: Directory not empty
Resolution
- Use long list to check the permissions
- Pass the long, -l, flag (and others if you wish) to ls to make it list the permissions
$ ls -lFah folder-without-write/
total 1.5K
dr-xr-sr-x 2 bill.conn@usd.local jennewein_lab@usd.local 3 Jun 16 10:41 ./
drwxr-sr-x 4 bill.conn@usd.local jennewein_lab@usd.local 4 Jun 16 10:41 ../
-rw-r--r-- 1 bill.conn@usd.local jennewein_lab@usd.local 0 Jun 16 10:41 file
- Use the chmod command to attempt to add write permissions to the folder
Note: if you get the error 'Operation not permitted', you need to ask the owner (or the Service Desk) to change the file
chmod +w folder-without-write/
- You may now remove the file and folder
rm -rf folder-without-write/
- Use long list to check for hidden files
- Pass the long, -l, flag (and others if you wish) to ls to make it list the permissions
Note: Files and folders that start with a period ',' are normally 'hidden' during a normal list command
$ ls -lFah folder-with-hidden/
total 1.5K
drwxr-sr-x 3 bill.conn@usd.local jennewein_lab@usd.local 3 Jun 16 10:41 ./
drwxr-sr-x 3 bill.conn@usd.local jennewein_lab@usd.local 3 Jun 16 10:50 ../
drwxr-sr-x 2 bill.conn@usd.local jennewein_lab@usd.local 2 Jun 16 10:41 .git/
- Remove the hidden files or hidden directories before removing the original directory
Note: You may need to remove several things before a directory becomes empty
rm -rf folder-with-hidden/.git
- Remove the original directory
rmdir folder-with-hidden
- Please contact the Service Desk with the following information:
- Machine with the issue
- Your username on the machine
- The file or folder you are having a problem with
ITS STAFF ONLY
- Log in to the machine with the issue
- Become a superuser
sudo su -
- Navigate to the problem files or folders
- Since you are root, you can force permissions changes with chmod
- Remove the files for the user