Simple question on unix file permission


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Simple question on unix file permission
# 1  
Old 04-07-2011
Simple question on unix file permission

As I understand the file permissions in UNIX is basically

Owner, group, others

Lets assume scott user who's primary group is dev creates a file called test.dat and then grants some privileges on that file...
Code:
scott@unix-host> echo "this is a test" > test.dat
scott@unix-host> chmod 640 test.dat
scott@unix-host> ls -l test.dat

-rw-r-----   1 scott  dev   960 Apr  1  2011 test.dat

Now, let's assume user Tom who's primary group is also dev logs in and tries to delete the test.dat file created by scott..
Code:
tom@unix-host> rm test.dat
test.dat: 640  mode ? (y/n) y

surprisingly, Tom was able to delete the file. I thought only scott user would be able to delete test.dat file as only the "owner" (as in owner,group,others) has "rw" privilege..I'm a bit confused as to how Tom was able to delete the file even though "Group" has only Read access...Could you help me understand this?

Thanks for your time...


Thanks

Last edited by Scott; 04-07-2011 at 08:06 PM.. Reason: Added code tags
# 2  
Old 04-07-2011
as tom user, after answering yes to the remove command,
what output is given by the following command :
Code:
echo $?
ls -l test.dat
alias
ls -l $(type rm | awk '{print $NF}')
id

?
# 3  
Old 04-07-2011
As odd as it seems this is expected behavior. The person's right to delete the file comes from the containing folder, not the file.

To avoid that, you need to set the "sticky" bit on the folder. That should make it so only the owner can delete the file.
Code:
chmod +t /path/to/set

# 4  
Old 04-07-2011
May I suggest my tutorial on file permissions
This User Gave Thanks to Perderabo For This Post:
# 5  
Old 04-08-2011
Thanks to all for your time & input...Special thanks to Paberdo for the excellent tutorial material...

Thanks again
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File Permission question

Experts: i want to change this permission back to the way it was: Initial: drwxr-xr-x 8 oracle oinstall 4096 Jun 5 15:21 oracle Now: drwxr-xr-x 8 oracle oinstall 4096 Jun 5 15:21 oracle drwsr-sr-x 8 oracle oinstall 4096 Jun 5 15:21 oracle Now I want to switch it back to ... (2 Replies)
Discussion started by: sumang24
2 Replies

2. Shell Programming and Scripting

Simple Question about Reading file by Perl

Hi , I just write a simple function to read the file line by line. But when I run it it says out of memory. I am not sure about the root cause, Can someone help me out of this? :D #! /usr/bin/perl use strict; sub checkAPs{ my $NDPDir = "/home/eweiqqu/NCB/NDP_files/"; ... (1 Reply)
Discussion started by: Damon_Qu
1 Replies

3. UNIX for Advanced & Expert Users

UNIX file Permission

I am trying to FTP files from windows to UNIX (IBM AIX). After having sent the files to unix server. Permisssion of the files becomes 640 (rw-r-----). I have to manually login to unix and do chmod 644 on the folder to give it permission. Is it possible that the files automaically be set to 644 on... (2 Replies)
Discussion started by: puspendu.das.in
2 Replies

4. Shell Programming and Scripting

Simple Bash Read File question

Hello all, I am trying to write a simple script that will parse through a text/properties file and check a couple of if statements. Here is what I have so far: FILENAME=$1 while read line do echo $line done < $FILENAME When I call ./simple.sh testfile.txt I recieve a file or... (7 Replies)
Discussion started by: lamagra
7 Replies

5. UNIX for Dummies Questions & Answers

Some simple question abt Unix kernel

Dear all, I got some questions abt how does the Unix kernel work with the work with the other components. (step by step) Can any body tell me some info abt that? if can provide a example for each question that gonna be perfect! Thank you!!! 1. How file management system work together... (2 Replies)
Discussion started by: melbdavid
2 Replies

6. UNIX for Dummies Questions & Answers

Simple Windows-to-Unix SCP question

Hi, I am fairly new to Unix. My school computers have only UNIX installed on them, and I wish to use them to do some parallel computing. To do so, I need to transfer the files from my Windows computer to my Unix account on a different computer. I am using the SSH login with the Putty client.... (2 Replies)
Discussion started by: Duchesne
2 Replies

7. UNIX for Dummies Questions & Answers

I have a simple unix question

Hello all, I need to write a little unix script to do some work on multiple files. I need to enter the filenames from the command line (scriptname <filename> <filename>. I have written the code to do double spacing, and some line numbering but it does not take multiple files from the command... (1 Reply)
Discussion started by: smn2003
1 Replies

8. Shell Programming and Scripting

Simple Unix Question

Hi all, ok here is my problem, my program below is reading lines in from a file (one at a time) and printing them out. my problem is that i want it to only print out 3 lines at a time on the screen, but the "read value" command in my code isnt working. Whats wrong? & what can i do to get this... (1 Reply)
Discussion started by: djt0506
1 Replies

9. HP-UX

simple Unix Execute permission for "others"

netjk@rediffmail.com I have a Shell Script (wrapper) that gathers parameters and invoke a base script (lets say B1). I have set the permission for this script as 711 (execute for everyone, group). When a user from another group try to execute the script, permission is denied (Cannot open file..)... (1 Reply)
Discussion started by: jsudha
1 Replies

10. Filesystems, Disks and Memory

Tricky File Permission Question

I'm trying to answer the following question about file permissions in Unix. Consider a file with the following permissions: rwx---r-- I am not the owner of this file, but I am a member of the group of this file. My question is: do I have read access to this file? I thought... (3 Replies)
Discussion started by: Hook
3 Replies
Login or Register to Ask a Question