not del a file not affecting other permissions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting not del a file not affecting other permissions
# 1  
Old 01-24-2012
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 Smilie


What command would you use to make sure that you cannot easily delete a file
called backup (which you own) without affecting other permissions?
# 2  
Old 01-24-2012
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.
# 3  
Old 01-24-2012
Quote:
Originally Posted by Corona688
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 ????
# 4  
Old 01-24-2012
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.

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

# 5  
Old 01-24-2012
so like chmod a-w backup? cuz backup being the file.

i tried this command he said no lol. dam
# 6  
Old 01-24-2012
I repeat:
Quote:
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.
# 7  
Old 01-24-2012
he gave me hint. using rm
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Oracle dump file (del format) import into db2

1. The problem statement, all variables and given/known data: are the oracle dump files compatible to direct import into db2? I already tried many times but it always truncated results. anyone can help/ advice or suggest? 2. Relevant commands, code, scripts, algorithms: exp... (3 Replies)
Discussion started by: Sonny_103024
3 Replies

2. Shell Programming and Scripting

Del: line 13: syntax error: unexpected end of file

1 echo -e "Enter a filename" 2 read filename 3 if 4 then 5 echo -e "do you want to delete?" 6 read answer 7 if 8 then rm myfirst 9 else 10 echo -e "file not deleted" 11 fi 12 exit0 (1 Reply)
Discussion started by: Speedy
1 Replies

3. UNIX for Advanced & Expert Users

Copy files without affecting the running process

Hi Experts, I would like to know in Linux any command which will replace a file without affecting the running process. I tried the mv command bug the running process is not taking the new file. Any rsync option is available like this for not affecting the current process. Thanks in... (7 Replies)
Discussion started by: ThobiasVakayil
7 Replies

4. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

5. Shell Programming and Scripting

Script that delete a File when a DEL File will be placed in same folder

Hi there, i have a question. I have a folder called /usr/test There is a file in it.... test.csv I need not a shell script that checks if there is a file called: test.del And if the file is in the same folder then the script should delete the test.csv and also the test.del. Hope... (9 Replies)
Discussion started by: Bjoern28
9 Replies

6. Shell Programming and Scripting

Shell versions affecting find?

Hi all, I just spent 30hours writing a script (my first) that makes extensive use of the find command on my mac os x terminal and which was meant to be run as a cron job on my server. The script is an automated backup system for a bunch of source control repositories. On the mac it works... (6 Replies)
Discussion started by: cpower
6 Replies

7. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies
Login or Register to Ask a Question