LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-19-2006, 11:59 AM   #1
XaViaR
Member
 
Registered: Dec 2004
Distribution: RHEL, CentOS, SuSE
Posts: 170

Rep: Reputation: 31
Permission - Folder vs. File


Hello,

I was wondering if it is possible to create folders with default permissions of 0755. And, file permissions with 0744. Is this possible?

I know that I can use UMASK 007. However, this will create ALL files/folders with the permission of 0770.

Thanks for your help!

P.S.
I am not using Samba. Just SSH.
 
Old 01-19-2006, 01:28 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
I know that I can use UMASK 007. However, this will create ALL files/folders with the permission of 0770
The above is incorrect. The umask setting is applied as a MASK to default permissions, not as an OVERRIDE of these permissions.
Example:
Code:
$ umask 022
$ >testfile
$ mkdir testdir
$ ls -l | grep test
drwxr-xr-x  2 haertig haertig   1024 2006-01-19 12:22 testdir
-rw-r--r--  1 haertig haertig      0 2006-01-19 12:22 testfile
$
By default, files are not created as executable, and that's why the file permission above came out as 644 rather than 755.
 
Old 01-19-2006, 01:31 PM   #3
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Also umask is a genefral mask, whereas dmask and fmask are masks for directories and files respectively.
 
Old 01-19-2006, 01:59 PM   #4
XaViaR
Member
 
Registered: Dec 2004
Distribution: RHEL, CentOS, SuSE
Posts: 170

Original Poster
Rep: Reputation: 31
Thanks for your help!
 
Old 01-19-2006, 02:29 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by linmix
Also umask is a genefral mask, whereas dmask and fmask are masks for directories and files respectively.
Gack! I've been writing programs on Unix systems since about, well, when time(2) used to return zero! And I've never heard of fmask or dmask. You never quit learning...
 
Old 01-19-2006, 02:45 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by haertig
Gack! I've been writing programs on Unix systems since about, well, when time(2) used to return zero! And I've never heard of fmask or dmask. You never quit learning...
Neither has any of the Linux installations I can lay
my hands on at the moment, or Solaris? Where do
you find dmask/fmask? :)


Cheers,
Tink
 
Old 01-21-2006, 08:35 AM   #7
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
I read up on mount (man page) and found info on dmask and fmask for inclusion in fstab. Maybe it's a builtin command? Haven't looked if it exists as seperate binary and am not at my linux box right now.
 
Old 01-21-2006, 01:29 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by linmix
I read up on mount (man page) and found info on dmask and fmask for inclusion in fstab. Maybe it's a builtin command? Haven't looked if it exists as seperate binary and am not at my linux box right now.
I see... well, those are mount options for FAT file-sytems,
have *nothing* to do with linux file-system creation masks.


Cheers,
Tink
 
Old 01-21-2006, 04:13 PM   #9
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Sorry. I guess that's the risk of answering a post when you have no access to a linux box. I expected that since it works for mount options there would be a binary as well, but it appears I was wrong: umask is a bash builtin command, dmask and fmask only apply to mount options.

Anyway, to get back to the topic at hand, I guess default file and directory permissions are set in a config file somewhere, so if you locate that the question would be answred, right? Does anyone know?
 
Old 01-21-2006, 04:58 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
The common place (for the system default umask) is
/etc/profile - may (of course) vary with distribution,
and no, it's a script, not a config-file.


Cheers,
Tink
 
Old 01-21-2006, 05:23 PM   #11
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Code:
]$ cat /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}

# Path manipulation
if [ $EUID = 0 ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after


# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

unset i
unset pathmunge
Where's the bit about standard file and directory permission settings?
Probably different in Fedora then..
 
Old 01-21-2006, 05:37 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
As I said - it can vary;

Mine is here:
Code:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems using 'eval tset' instead of 'TERM=', but you might want to 
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
 eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
 eval `dircolors -s`
else
 eval `dircolors -b`
fi

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y
fi

# Append any additional sh scripts found in /etc/profile.d/:
for file in /etc/profile.d/*.sh ; do
  if [ -x $file ]; then
    . $file
  fi
done

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
 ulimit -u 512
fi



Cheers,
Tink
 
Old 01-21-2006, 05:50 PM   #13
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
This is one of the few things that occasionally makes want to scream. I know each distro developer blieves he/she has a very good reason for doing things diferently, but the disparity in config files and scripts between distros - not in content, but in location - can be quite annoying at times.

I suppose I could just include those lines in my /etc/profiles script, but I doubt whether it'll do any good as either my distro won't look into that script for the permissions, or it will override it with the settings indicated somewhere else. Where? Who knows! Annoying!! Mainly becasue it makes learning 'linux' so much harder.
 
Old 01-21-2006, 05:55 PM   #14
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Well, FCs coders may have stuck it somewhere in /etc/profile.d
for instance...
Just do a
grep -r umask /etc/*
to find where ...


Cheers,
Tink
 
Old 01-22-2006, 09:54 AM   #15
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
Strange as it may sound I'd never used grep in this way! I either use it to serch for a file by name (as a complement to slocate) or to look inside 1 file, but I do remember reading this...

Anyway, grep -r umask /etc/* gives a ling list of hits, but no profiles. The most promising entry (as far as I can tell) is /etc/bshrc (what's rc an abbreviarion of anyway?)
Code:
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 022
fi
although it doesn't look a bit like the entry in your /etc/profiles
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how create a folder/permission rusmi Linux - Newbie 7 02-11-2005 10:04 AM
Permission to write to folder Garoth Linux - Software 1 10-09-2004 11:41 PM
Folder permission javamdk Slackware 9 07-07-2004 11:26 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM
File, Folder permission and SAMBA Steve1445 Linux - Newbie 2 01-15-2004 02:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration