Write (save time) Permission set


 
Thread Tools Search this Thread
# 1  
Tools Write (save time) Permission set

When am saving a file using my username in Linux environment, the file permission granted is rw-r--r--

I have to manually change the permissions using chmod command.

How do i write it to the disk as rw-rw-r while saving my file.

Last edited by Avishek_rc1; 09-07-2013 at 10:28 PM.. Reason: typo
# 2  
You need to change your umask.

Code:
$ umask  # show the current umask
0022
$ touch z
$ ll z
-rw-r--r--  1 scott  staff  0 Sep  8 03:21 z
$
$ rm z
$
$ umask 0002  # set a new umask
$ touch z   
$ ll z
-rw-rw-r--  1 scott  staff  0 Sep  8 03:21 z

You can save the command (umask 0002) in your ~/.profile, or in your shell's rc file in your home directory.

Note that this only affects new files - it does not update the permissions of existing files - for that you still need to chmod the file.
This User Gave Thanks to Scott For This Post:
# 3  
Thanks Scott, that was helpful.

I tried it and it worked. The same user account is used by my application too which creates the file.

Now when the application is using the file, it creates the file as rw-r-----

Can you please suggest why the application, when using the same login creates a file with different permission sets.

Appreciate your help on this.
# 4  
You may need to restart the application to get it to use the new mask.
# 5  
Thank You.

I have added the script and have restarted the server itself but no luck

This is how my /etc/bashrc looks like (plus additional data..)
Code:
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 011
fi


Last edited by Scott; 09-08-2013 at 12:36 AM.. Reason: please use code tags
# 6  
Can you confirm that the umask is properly set before you start the application?

Otherwise it may be that the application is not using the value of umask when it creates files, in which case you may need to find an alternative solution, such as using a cronjob.
# 7  
The umask sets the default permissions for new files. Applications (processes) can set further restricted permissions in the open() kernel call. Or it can call chmod() afterwards.
If this is the case, you can maybe set the desired permissions in an application preference ...
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #88
Difficulty: Easy
PowerShell makes use of pipes.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Setting write permission for particular user

Hi All, We have a scenario in production where we want only one user from a group to modify the file. The file is not set to write permission for application manager. -r--r--r-- 1 amgr u00 15661716 Aug 30 00:06 DCI.dat So here amgr will have permission to edit the file. We want a... (10 Replies)
Discussion started by: arunkumar_mca
10 Replies

2. Red Hat

SE Linux write permission denied

Hi, In my server I am getting below errors in "/var/log/messages": Oct 8 14:45:44 LKOGOMEEMM01 kernel: type=1400 audit(1444295744.792:15818): avc: denied { write } for pid=53421 comm="ip" path="/var/VRTSvcs/log/tmp/IPMultiNIC-8" dev=dm-0 ino=2754879 scontext=system_u:system_r:ifconfig_t:s0... (4 Replies)
Discussion started by: rochitsharma
4 Replies

3. UNIX for Dummies Questions & Answers

Save cron job get permission denied

After I edit the cron job by using crontab -e and using :wq! to save, i got following error message: "/tmp/crontabxvaarX" 1 line, 60 characters crontab: /tmp/crontabxvaarX: Permission denied Could anyone please help? (1 Reply)
Discussion started by: Alex Li
1 Replies

4. Red Hat

useradd w/o write permission on /etc/passwd

Hi root user creates a user using the useradd command. This command creates an entry in the /etc/passwd file. /etc/passwd file has rw permission for the root user. Now, if I happen to remove the w permission for the root user, useradd command still is successfully creating entry in the... (3 Replies)
Discussion started by: guruprasadpr
3 Replies

5. Debian

Write permission for USB device

Hello, I need to run an application in wine that requires write permission to a USB device. Wine users must not have root privileges. On FreeBSD this could be accomplished by adding the user to the wheel group but I am using Debian 6.0. From looking at the passwd file it is not obvious what... (6 Replies)
Discussion started by: snorkack59
6 Replies

6. UNIX for Dummies Questions & Answers

Need to remove Group write permission .

How would i write a command that can find all the objects under the etc directory that have group write permission enabled and have not been accessed in the last X days. This is what i got from internet souce but i m not able to modify it according to my distribution. find /etc -perm... (1 Reply)
Discussion started by: pinga123
1 Replies

7. UNIX for Dummies Questions & Answers

How can I set save daylight time

Hi everybody... I am using IBM unix server . Server take time options from satellite but server is not include true setting . What can I do? (2 Replies)
Discussion started by: deox
2 Replies

8. UNIX for Dummies Questions & Answers

Vi, write something then try to save & quit.

If I'm in Vi, write something then try to save & quit. :wq I get: "myvifile" "myvifile" E212: Can't open file for writing Press ENTER or type command to continue It won't let me save... Is it because other users on the network have access to the file also? Or I don't have permission to save? Thanks... (5 Replies)
Discussion started by: JudoMan
5 Replies

9. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

10. Debian

Turning on write-permission in Debian?

How can i do that? Is it safe? Why is it disabled by default? Thanks /Richard ++ ie: the program to write to other users on my computer. -- (3 Replies)
Discussion started by: riwa
3 Replies

Featured Tech Videos