LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   umask for files (https://www.linuxquestions.org/questions/linux-newbie-8/umask-for-files-4175435990/)

thiyagusham 11-06-2012 09:16 PM

umask for files
 
Hai to all;

>> am i right ? >>

Directories, base permissions are 0777 (rwxrwxrwx)
Files , base are are 0666 (rw-rw-rw).

>> To calculate file permissions for a umask >>

[oracle@localhost ~]$ umask 077
[oracle@localhost ~]$ touch filey.txt
[oracle@localhost ~]$ mkdir touchdir1
[oracle@localhost ~]$
[oracle@localhost ~]$ ls -ld filey.txt touchdir1

-rw------- 1 oracle oinstall 0 Nov 7 08:33 filey.txt
drwx------ 2 oracle oinstall 4096 Nov 7 08:33 touchdir1

>> My question >>

IF file default permission is 666 , i got only 600 i.e.
owner only read & write . what abt group and others here ?

Thanks & Regards
Thiyagusham.G

thiyagusham 11-06-2012 10:22 PM

1 Attachment(s)
Hello to all ;

Please review attached screen shot ... I create single directory only
but why linux shows twice while listing .....
regards
Thiaygusham G

chrism01 11-07-2012 01:44 AM

Re qn 1;
Default umask (& therefore perms) is usually set in /etc/profile. You subtract the umask values from 7 for each position.
If you use umask with symbolic notation (rwx), then it is set as those values.
http://www.cyberciti.biz/tips/unders...lue-usage.html

chrism01 11-07-2012 01:51 AM

Re qn2 : when you ls a dir, it shows the content. If you cd into scriptdir, you'll see more clearly.
Every dir in *nix has 2 entries:

1 '.' current dir
2 '..' parent dir

http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

thiyagusham 11-07-2012 03:02 PM

Hi chrism01

Thanks ..

Ya, Given link was very useful ... but having only one question

>> i need example 077 for files only >>

[rose@localhost ~]$ umask 077
[rose@localhost ~]$ touch oo.txt
[rose@localhost ~]$ mkdir oo
[rose@localhost ~]$ ls -al oo oo.txt
-rw------- 1 rose rose 0 Nov 8 02:15 oo.txt

oo:
total 8
drwx------ 2 rose rose 4096 Nov 8 02:15 .
drwx------ 7 rose rose 4096 Nov 8 02:15 ..

if i set 077 means linux subtracts 777-077 (directories) = 700 ok i am very clear ..

till hee no problem ..

i need explanation only for following command
-rw------- 1 rose rose 0 Nov 8 02:15 oo.txt

Quote:

Default permissions: 777 / 666
Subtract umask value: 077 (-)
Resulting permissions: 700 / 600

https://wiki.archlinux.org/index.php/Umask

chrism01 11-07-2012 05:38 PM

There's a default convention that newly created files (at the bash level) never automatically set execute perm on... If you think about it, there's a good reason (hint; security).
Its fine for dirs.
Have a good read of those links


All times are GMT -5. The time now is 01:32 AM.