Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How do I know if I can delete a file/folder?

by mitd (Curate)
on Jul 26, 2002 at 05:36 UTC ( [id://185432]=note: print w/replies, xml ) Need Help??


in reply to How do I know if I can delete a file/folder?

This simple answer is you, that is you the owner of the process which is attempting to delete the file, must have 'write permissions' on/for that file.

The definition of 'write permissions' is one of the following:

  1. you are the file owner and the file has owner write permission set.
  2. you are a member of the file's group and the file has group write permissions set
  3. The file has other write permissions.

The same rule apply to directories with addtional condition that the directory must be empty.

UPDATE

Holy Dumbus Old Fartus! why an old fart should not be
allowed to touch the keyboard past midnight.

After a well deserved 'slap upside the head' from grep and others.

Please ignore the above the only excuse I can offer is 1969 bad drugs.

Repeat after me: File deletion operations are Directory operations and therefore depend on directory ownership and mode settings

mitd-Made in the Dark
'Interactive! Paper tape is interactive!
If you don't believe me I can show you my paper cut scars!'

  • Comment on Re: How do I know if I can delete a file/folder?

Replies are listed 'Best First'.
Re: Re: How do I know if I can delete a file/folder?
by grep (Monsignor) on Jul 26, 2002 at 15:17 UTC

    THIS IS WRONG FOR UNIX

    As I tried to politely explain in a /msg to mitd a file delete is a directory operation. The file permissions are not a factor. You need directory write permissions to delete a file in *nix

    If you are still unsure please check these links

  • Permissions - By Rutgers Univ.
  • An Introduction to Unix Permissions - By ONLAMP.com
  • File and Directory Permissions
  • CHMOD on perlfect.com
  • To quote from the perlfect.com site:

    Directories

    Another interesting thing to note is that lib/ which is a directory has permissions, too. Permissions take a different meaning for directories. Here's what they mean:

    • read determines if a user can view the directory's contents, i.e. do ls in it.
    • write determines if a user can create new files or delete file in the directory. (Note here that this essentially means that a user with write access to a directory can delete files in the directory even if he/she doesn't have write permissions for the file! So be careful with this.)
    • execute determines if the user can cd into the directory.


    grep
    Just me, the boy and these two monks, no questions asked.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://185432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found