not del a file not affecting other permissions

i was faced by a question from a friend. i found it very tricky. all my months of learning unix i never can figure it out still. heres the question he faced me with. wondering if you all can help me figure a solution.

ill let him know the forums helped me out :smiley:

What command would you use to make sure that you cannot easily delete a file
called backup (which you own) without affecting other permissions?

Delete permissions aren't controlled by the file's own permissions at all, to delete a file you need write permissions on the directory it's in. Set the directory -w and you won't be able to delete it -- or create other files, for that matter.

Depending on the system and filesystem there may be other ways to control it. ext2/3/4 on linux have extended flags like immutable that can be set on files for instance.

so the command would be? chmod ????

Which command to use depends on what you want, and this does't sound like what you want since it would affect the ability to delete or create other files in the same folder. That's simply how delete permissions work, is the problem, so he's asking for something which might not exist.

You've also given no context for this question. He may be hunting for something in particular without giving enough information to guess what.

chmod u-w /path/to/folder
chmod g-w /path/to/folder
chmod o-w /path/to/folder

so like chmod a-w backup? cuz backup being the file.

i tried this command he said no lol. dam

I repeat:

he gave me hint. using rm

rm deletes files.

If you open the file then delete it, it will stay on disk until whatever holds it open closes. However, there won't be any way for anything else to open it -- it won't be in the current directory anymore.

Again, this isn't what he asked for and you've given absolutely no context at all. Far too many 'tricky' questions are more opaque than tricky...

whats rm -ir. is that a command. or rm -i

See man rm.

rm deletes files. -r deletes entire folders and everything in them. Don't let him play some horrible joke on you with it.

true he prob jking. what a guy