1833807 Members
4016 Online
110063 Solutions
New Discussion

Default Permissions

 
SOLVED
Go to solution
Jayson Hurd_2
Advisor

Default Permissions

What governs the default permissions for a new file created under a given directory? I have a place where a group ftps files, however the permissions are 640. Others need to read the file. I'd rather not add any of the others to the group owner. Is there a way to make it so new files created in that directory are, say, 644?
Most things worth having don't come easily.
13 REPLIES 13
Manish Srivastava
Trusted Contributor
Solution

Re: Default Permissions

Hi,

You can set the umask to 122.

manish.
Jayson Hurd_2
Advisor

Re: Default Permissions

Is umask specific to a particular login or can you set a umask on a directory?
Most things worth having don't come easily.
Anupam Anshu_1
Valued Contributor

Re: Default Permissions

umask command is responsible for it. You can set umask as follows:

-----------------------------------------
$ umask # current umask value
00
$ umask 022 # this will make files to be created with 644 permission
$ umask # Check the new umask value.
022
-----------------------------------------

HTH,

Anshu
Anupam Anshu_1
Valued Contributor

Re: Default Permissions

You can set the umask even for the directories. umask value would determine with what permissions your files and directories would get created.

if you have umask value set to 000, then the directory would be created with permission 777 (ls -l output would show drwxrwxrwx for the directory created).

You can set different umask values and try the same.

Cheers,

Anshu
John Carr_2
Honored Contributor

Re: Default Permissions

Hi

set the umask in the login profile which ftp uses when transferring the files.

John
Abdul Rahiman
Esteemed Contributor

Re: Default Permissions

I think the umask is for a specific user.
So, if different users are trying to put files, the permissions may be different.
What you want to do is probably setup a script to change the permissions the way you wanted and run via cron frequently.
No unix, no fun
Jeff_Traigle
Honored Contributor

Re: Default Permissions

umask is per login session. If it's set in /etc/profile, it will be set the same for all users. It can be set on a per user basis by including it in $HOME/.profile.
--
Jeff Traigle
John Carr_2
Honored Contributor

Re: Default Permissions

Hi

umask 022 removes write permission for group and other (files normally created with mode 777 become mode 755; files created with mode 666 become mode 644).

umask is session specific not directory specific umask is recognized and executed by the shell.

John.
Abdul Rahiman
Esteemed Contributor

Re: Default Permissions

Jayson,

You can use the "site umask" subcommand on ftp to change the umask during a ftp session.

Try this in your ftp session before transferring files,
ftp> site umask 022

HTH,
Abdul.
No unix, no fun
Jayson Hurd_2
Advisor

Re: Default Permissions

The problem I'm having is that I'm using ftpaccess to govern the files that are written since users are ftp-ing the files up. The profile does not apply to ftp-ing...
Most things worth having don't come easily.
Bruno Ganino
Honored Contributor

Re: Default Permissions

For permission 644 you must set umask to 122 into profile.
Bruno
Torino (Turin) +2H
Jose Mosquera
Honored Contributor

Re: Default Permissions

Hi,

For can set up an a generic ftp mask. Configure this feature in your /etc/inetd.conf file:

ftp stream tcp nowait root /usr/lbin/ftpd ftpd -l -a -u

Where -u determine the file permission for any ftp incoming file.

For additional info: "man ftpd"

Rgds.
Jayson Hurd_2
Advisor

Re: Default Permissions

Your suggestions worked for shelled users. For it to work on guest ftp accessed accounts, I had to edit the 'upload' section of the /etc/ftpd/ftpaccess file. Thanks everyone!!
Most things worth having don't come easily.