Weird rm behaviour


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu Weird rm behaviour
# 1  
Old 12-01-2011
Weird rm behaviour

I am little bit confused by the behaviour of rm in Ubuntu.

It seems that as a regular user I can delete files owned by another user even when the permissions are set to 644.

Here is an example:

Code:
cjohnson@carbon:~/test$ sudo touch testfile
cjohnson@carbon:~/test$ ls -al
total 8
drwxr-xr-x  2 cjohnson cjohnson 4096 2011-12-01 11:21 .
drwxr-xr-x 64 cjohnson cjohnson 4096 2011-12-01 11:21 ..
-rw-r--r--  1 root     root        0 2011-12-01 11:21 testfile
cjohnson@carbon:~/test$ rm testfile
rm: remove write-protected regular empty file `testfile'? y
cjohnson@carbon:~/test$ ls -al
total 8
drwxr-xr-x  2 cjohnson cjohnson 4096 2011-12-01 11:21 .
drwxr-xr-x 64 cjohnson cjohnson 4096 2011-12-01 11:21 ..
cjohnson@carbon:~/test$

Anybody have an explanation?

Should have added this:

Code:
uname -a
Linux carbon 2.6.32-24-server #43-Ubuntu SMP Thu Sep 16 16:05:42 UTC 2010 x86_64 GNU/Linux


Last edited by ccj4467; 12-01-2011 at 12:31 PM.. Reason: addedd OS info
# 2  
Old 12-01-2011
unlink (and create) permission is determined by the directory, not the file.
This User Gave Thanks to CarloM For This Post:
# 3  
Old 12-01-2011
Yeah, just figured that one out. I guess I learned that many years ago and just forgot.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Ps command different behaviour

Hi Experts, ps command behavior in Redhat is such that it outputs all the output(of long lengths). In Unix the ps command output was limited to only 80 chars. In that if you pipe its output to another command hen the 80 chars restriction wouldn't be there. This 80 char limitation will only be... (14 Replies)
Discussion started by: Albert_Pinto7
14 Replies

2. Shell Programming and Scripting

Weird redirection behaviour

Linux. Bash 4.2.10. Let's say that i want the stderr of a command redirected to one file (err), and both stdout and stderr redirected to another file (outanderr). Easy. Many ways to do it. But may times the file outanderr will be messed up (with the output and the error mixed toghether). ... (3 Replies)
Discussion started by: Lem
3 Replies

3. Programming

different behaviour in fg and bg

fg = foreground bg = background I have a cobol program that I start with a very simple script. The script is not at fault as it has not changed and the program worked in fg and bg before. I have altered the logging in the program and moved my cursor declare to working storage. The program runs... (6 Replies)
Discussion started by: Bruble
6 Replies

4. Shell Programming and Scripting

find: "weird" regex behaviour

I have these two files in current dir: oos.txt oos_(copy).txt I execute this find command:find . -regex './oos*.txt'And this outputs only the first file (oos.txt)! :confused: Only if I add another asterisk to the find find . -regex './oos*.*txt' do I also get the second file... (7 Replies)
Discussion started by: courteous
7 Replies

5. Shell Programming and Scripting

Weird script behaviour !

Hello, I am getting an infinite loop from a script in Linux. Here is the last version of the script in question. As you can see I tried to define everything properly: #!/bin/ksh # Script to loop over a series of dates set -ex typeset -i start_date=20090701 typeset -i... (2 Replies)
Discussion started by: stavros
2 Replies

6. Shell Programming and Scripting

cp -R behaviour

i 've noticed the following difference between freebsd cp and gnu cp from the freebsd cp man page: -R ... If the source_file ends in a /, the contents of the directory are copied rather than the directory itself. ... on gnu cp from the man pagewhile on gnu cp manpage: ‘-r'... (2 Replies)
Discussion started by: aegis
2 Replies

7. Shell Programming and Scripting

Weird sed behaviour in script

I've written a small script to replace certain words in all the the files in a directory. #!/bin/sh #Get list of files to be edited file_list=`ls -p` for i in $file_list do echo "Processing $i" alteredi=`echo "$i" | sed -e 's/\//d/'` if then if then #actual altering (2 Replies)
Discussion started by: Peetrus
2 Replies

8. Shell Programming and Scripting

Count behaviour when using su -

Gentlemen, OK, I have an odd issue here perhaps someone can shed some light for me. When running a script as its user/owner the below pause/wait works just fine. When a developer has used su - to assume the username the pause does not happen... This is a HPUX11.00 machine, I have copied the blurb... (1 Reply)
Discussion started by: Eronysis
1 Replies

9. UNIX for Advanced & Expert Users

Weird sudo behaviour

Hi gurus. I implemented sudo and have the following in my sudo config file *************** # User alias specification User_Alias VENDOR = user1 # User privilege specification VENDOR ALL = NOPASSWD: /bin/, /sbin/, /usr/local/bin/, \ !/bin/su,... (1 Reply)
Discussion started by: geomonap
1 Replies
Login or Register to Ask a Question