Can I make "touch" create executable files by manipulating umask?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can I make "touch" create executable files by manipulating umask?
# 1  
Old 06-07-2006
Can I make "touch" create executable files by manipulating umask?

I'm getting to grips with this concept of the umask.

What I thought was, setting umask uga+rwx would result in creating files with all permissions for everyone. Seems not to be the case though. Read and write bits get set, but not the execute bit.

Is there some gap in my understanding, or is some other setting overwriting the usual behavior of umask?

Demonstration follows:

Code:
$umask uga-rwx; rm a-file; touch a-file; ls -l a-file
rm: remove write-protected regular empty file `a-file'? y
----------  1 hartmann users 0 2006-06-07 21:11 a-file
$umask uga+rwx; rm a-file; touch a-file; ls -l a-file
rm: remove write-protected regular empty file `a-file'? y
-rw-rw-rw-  1 hartmann users 0 2006-06-07 21:11 a-file


Last edited by tphyahoo; 06-07-2006 at 04:10 PM..
# 2  
Old 06-07-2006
Let's use numbers, because umask can be confusing. It works sort of backwards.
umask controls the process' default file protection mask, chmod works on single files.
umask affects every file you create, in other words.

umask 777 looks like it would set all the bits on, but umask works on the "complement",
ie, it does the opposite, so this creates a protection mask with all bits off.

chmod 777 filename plays fair - it sets the bits on.

umask 000 would turn on bits that it could turn on. It works backwards, sort of.
# 3  
Old 01-30-2009
also, all umask does is modify the default behavior of permissions
on directory and file creation.

by default, a directory is created with 777 and a file 666.

so, if you set your umask to 0, meaning, allow the permissions
to be at their highest settings possible during file creation
you still don't get files to be created as executables by default.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Permission error when "touch"ing file with different user

Hi, There are 2 users (T886072 & T864764) that need to be provided full (rwx) access to a directory. I made the changes to the directory permissions using chmod and setfacl : root@digidb2:# chmod 700 /u02/ftpfiles/MFRS16/discount_rates/ root@digidb2:# setfacl -s... (3 Replies)
Discussion started by: anaigini45
3 Replies

2. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

3. Programming

"make" fails on the first .f90 file it encounters: not creating .o files

i may be asking way too much here but i am not a programmer and not sure where to to turn. i have a program that i am trying to "make". but the compiler i am supposed to use gets nowhere. there are a bunch of .f90 files that are being processed as follows but it doesn't get past the first one: ... (1 Reply)
Discussion started by: crimso
1 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Make scipt except from "Y","y" and "yes" to take [Enter] as being "yes"

This is the script: #!/bin/sh if ; then rm -rf /usr/share/WallpaperChanger; fi if ; then rm -rf /usr/bin/wallch; fi; if ; then rm -rf /usr/share/applications/wallch.desktop; fi if ; then rm -rf /usr/share/doc/wallch; fi if ; then rm -rf /usr/share/man/man1/wallch.1.gz; fi echo "Delete... (4 Replies)
Discussion started by: hakermania
4 Replies

6. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

7. Shell Programming and Scripting

Manipulating input into the shell "read" command

Hi All I have a migration program that creates directories based on dates, e.g 20090714 20090812 etc.. Based on their requirements, the user will select the directory they want to perform an action on. Currently, this is a snippet of the code I use no_of_versions=`ls | wc -l` if... (2 Replies)
Discussion started by: kingpin2502
2 Replies

8. Programming

how could i make a program mixed with many "|", "<" and ">"

I have written following code to do: ls -l | wc -w, it works: but when there are not only a single "|", if there are more such as: ls -l | sort -r | sort | sort -r, This program does not work, i want to know how could i deal with it when there are more "|", another situation is that, if it mixes... (2 Replies)
Discussion started by: strugglingman
2 Replies

9. UNIX for Advanced & Expert Users

Changing default permissions -without "umask"-...

Hi! My question is this: Is it possible to change the default permissions in UNIX (666 for files and 777 for directories)?. I am not talking about using the command "umask". I mean, with the command "umask" you can modify permissions from a default permissions x. Is it possible to make... (4 Replies)
Discussion started by: chicoGuapo
4 Replies

10. UNIX for Dummies Questions & Answers

"./cofigure" and "make" turmoil

I am a Unix newbie and I downloaded some X11 programs. I have gcc, but I cannot compile the files. I NEED HELP!!!! :confused: (16 Replies)
Discussion started by: gnerd
16 Replies
Login or Register to Ask a Question