UNix System Adminitrator Page
 
GOOGLE ADD
 
How to change the group:owner of a symlink
chown -h owner:group www

Note : chown owner:group www will not change the owner:group
 
Sorting file size in a directory
du -ksl * | sort -nr
du -ks *|sort -nr|more

To make this as an alias, add the line in your .cshrc file
alias bigfiles 'du -ksl * | sort -nr
 
Read-only files that even root can't manipulate - Permission Handling
lsattr is a very useful command to add extra security to your important files in linux. See below examples:

# lsattr foo.bar
------------- foo.bar

# chattr +i foo.bar
# lsattr foo.bar
----i-------- immutable
No, we have a read-only file - first try to delete the whole directory:

# cd ..
# rm -rf test
rm: cannot remove 'test/foo.bar': Operation not permitted

# cd test
# rm foo.bar
rm: remove write-protected regular empty file 'foo.bar'? y
rm: cannot remove `foo.bar': Operation not permittedst

Let's try emptying the file instead of deleting it:

# cp /dev/null foo.bar
cp: cannot create regular file 'foo.bar': Permission denied

# > for.bar
-bash: foo.bar: Permission denied

# Try to create a hard link

# ln foo.bar link-foo.bar
ln: creating hard link 'link-foo.bar' to 'foo.bar': Operation not permitted

Clear the flag:

# chattr -i foo.bar
# rm foo.bar

This could be very useful for adding an extra security step on your files you know you'll never want to change. While little will help you on a box that has been rooted, immutable files probably aren't vulnerable to simple overwrite attacks from other processes, even if they are owned by root.
 
Untitled Document
Terms & Conditions | Copyright © 2004-2007