Link to home
Start Free TrialLog in
Avatar of cgray1223
cgray1223

asked on

unix permissions

Hello,

I copied over a directory (LATEST) into a directory that I created on a linux server.  I now want to delete the LATEST directory and all directories below it, but I'm getting a permission denied.  Is there any way to delete these directories or does my user id lack sufficient privileges to do so?

drwxrwxr-x  3 colgray eng 4096 Nov  1 16:00 LATEST
dr-xrwxr-x  4 colgray eng  4096 Nov  1 16:00 bin
dr-xrwxr-x  2 colgray eng 12288 Nov  1 16:00 doc
dr-xrwxr-x  2 colgray eng  4096 Nov  1 16:00 include
dr-xrwxr-x  2 colgray eng  4096 Nov  1 16:00 lib
dr-xrwxr-x  2 colgray eng  4096 Nov  1 16:00 mapi
dr-xrwxr-x  2 colgray eng  4096 Nov  1 16:00 ref_agent

Avatar of xterm
xterm

The command to do it would be:

rm -rf LATEST

The directory is owned by user colgray.  If that is not the user that you are logged in as, then you would need to be either:

1)  root

or

2)  Logged in as a user in the group "eng" (since the folder is also group writable)  You can type "id" to find out what groups you are in.
Avatar of cgray1223

ASKER

that is the user I'm logged in with.  When I try that command I get permission denied
Are you sure there's not stuff inside that directory that doesn't belong to colgray?

Try "ls -lRt LATEST" and see if you see files owned by other users.
Avatar of farzanj
It is not the permission of LATEST that matters.  It is the permission of the folder that holds LATEST.  What is the permission of the folder where LATEST is located?


ls -ld ..

@farzanj:
You are of course correct that permissions on the parent folder override, but the author says that "I copied over a directory (LATEST) into a directory that I created on a linux server."  If the author created the folder, and copied the folder LATEST into it, then the author should technically own that parent  directory.
You could try

$ rmdir LATEST

just to see what error message it produces (and tell us).
you must check the permission of parent directory

$ ls -ld .
$ ls -ld . returned drwxrwxr-x  3 userName eng 4096 Nov  1 16:00 dirname
$ rmdir LATEST returned rmdir: `LATEST': Directory not empty

The problem is pointed out by xterm, when I run $ ls -lRt LATEST I get a ton of files and directories, below are some examples

-r--rwxr--  1 colgray eng   7067 Nov  1 16:00 tree.html
dr-xrwxr-x  4 colgray eng  4096 Nov  1 16:00 bin
dr-xrwxr-x  2 colgray eng  4096 Nov  1 16:00 lib

I did a cp -R when copying over, so did it maintain the permissions from the location I copied it from?  Any ideas on how to remove all directories and files under the LATEST directory?



ASKER CERTIFIED SOLUTION
Avatar of Olivier Hupé
Olivier Hupé
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It sounds like the parent directory permissions may have changed after you copied the files?

>  $ ls -ld . returned drwxrwxr-x  3 userName eng 4096 Nov  1 16:00 dirname

So, did you purposely change what shows as "userName" and "dirname" above before posting this?
yes, the actual parent directory that contains the LATEST dir (one I'm trying to delete) is exactly below, ignore that first bullet.


$ ls -ld . yields - drwxrwxr-x  3 colgray eng 4096 Nov  1 16:00 .
Can you please do the commands below and paste the full output here?
pwd
rm -rf LATEST

Open in new window

$ pwd
/aut/ew/colgray
$ rm -rf LATEST
rm: cannot remove `LATEST/toolkit/bin/Linux/RefAgent.sh': Permission denied
rm: cannot remove `LATEST/toolkit/bin/Linux/RefAgent': Permission denied
rm: cannot remove `LATEST/toolkit/bin/Linux/MgmtApiTest.sh': Permission denied
rm: cannot remove `LATEST/toolkit/bin/Linux/MgmtApiTest': Permission denied
rm: cannot remove `LATEST/toolkit/bin/WinXP/RefAgent.exe': Permission denied
rm: cannot remove `LATEST/toolkit/bin/WinXP/MgmtApiTest.exe': Permission denied
rm: cannot remove `LATEST/toolkit/include/EnergyWiseApi.h': Permission denied
rm: cannot remove `LATEST/toolkit/include/EnergyWise.h': Permission denied
rm: cannot remove `LATEST/toolkit/include/EnergyWiseLog.h': Permission denied
rm: cannot remove `LATEST/toolkit/include/EnergyWiseSdk.h': Permission denied
rm: cannot remove `LATEST/toolkit/include/EnergyWiseUtil.h': Permission denied
rm: cannot remove `LATEST/toolkit/include/platform_types.h': Permission denied
rm: cannot remove `LATEST/toolkit/lib/CiscoEnergyWiseApi.dll': Permission denied
rm: cannot remove `LATEST/toolkit/lib/CiscoEnergyWiseSdk.dll': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseApi.so.1.3': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseApi.so.1': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseApi.so': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseSdk.so.1.3': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseSdk.so.1': Permission denied
rm: cannot remove `LATEST/toolkit/lib/libCiscoEnergyWiseSdk.so': Permission denied
the permissions on those files look like

-r-xrwxr-x  1 colgray eng    132 Nov  1 16:00 RefAgent.sh
OHUPE's suggestion worked:


-r-xrwxr-x  1 colgray eng    132 Nov  1 16:00 RefAgent.sh

sorry the suggestion was to:

Assuming you are the coldgray user :
First type : chmod -R u+rw LATEST
and then : rm -rf LATEST
Yep, that would do it.  I had a feeling something inside the directory was causing it, but couldn't see it until you pasted that output - and yes, OHUPE's suggestion should do what you need.
xterm, so what is chmod -R u+rw LATEST really doing, blowing away all the permissions that were previously there?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial