Oct 082009
 

Suppose we have umask 0002 for our user default permission.

    $ umask
    0002

Create new directory

    $ mkdir tmpdir

tmpdir directory created with its default permission 775

    $ ls -l
    ..........
    ..........
    drwxrwxr-x  2 harry harry      4096 Oct  8 06:59 tmp
    ..........
    ..........

Create new file

    $ touch tmpfile

tmpfile file created with its default permission 664

    $ ls -l
    -rw-rw-r--  1 harry harry 0 Oct  8 07:06 tmpfile

Now, let’s see how the file permission settings are calculated using boolean expressions with default umask 0002.

For e.g. consider the case where we have default umask value of 0002 – 0000 0000 0000 0010
1’s complement of 0002 – 1111 1111 1111 1101

For directories perform logical AND operation with 0777 (0000 0111 0111 0111). So

    1111 1111 1111 1101 (1’s complement of 0002)
    0000 0111 0111 0111 (0777, base permission of directory)
    —————-------------- AND
    0000 0111 0111 0101 = 0775

For files, perfom logical AND operation with 0666 (0000 0110 0110 0110), so

    1111 1111 1111 1101 (1’s complement of 0002)
    0000 0110 0110 0110 (0666, base permission of file)
    —————-------------- AND
    0000 0110 0110 0100 = 0664

we can try different combination of umask value, so we can get a clear picture on how umask is applied to determine default permission on newly created files or directories.

Jul 102008
 
find . -type f -size +10000 -exec ls -al {} \;
find . -atime +1 -type f -exec mv {} TMP \; # mv files older then 1 day to dir TMP
find . -name "-F" -exec rm {} \; # a script error created a file called -F
find . -exec grep -i "vds admin" {} \;
find . \! -name "*.Z" -exec compress -f {} \;
find . -type f \! -name "*.Z" \! -name ".comment" -print | tee -a /tmp/list
find . -name *.ini
find . -exec chmod 775 {} \;
find . -user xuser1 -exec chown -R user2 {} \;
find . -name ebtcom*
find . -name mkbook
find . -exec grep PW0 {} \;
find . -exec grep -i "pw0" {} \;
find . -atime +6
find . -atime +6 -exec ll | more
find . -atime +6 -exec ll | more \;
find . -atime +6 -exec ll \;
find . -atime +6 -exec ls \;
find . -atime +30 -exec ls \;
find . -atime +30 -exec ls \; | wc -l
find . -name auth*
find . -exec grep -i plotme10 {};
find . -exec grep -i plotme10 {} \;
find . -ls -exec grep 'PLOT_FORMAT 22' {} \;

Continue reading »