Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
[root@ test_project]$ touch test.txt
[root@ test_project]$ ll test.txt
-rw-rw-r-- 1 root root  0 2011-08-03 13:57 test.txt

Currently it seems to be 664,how can I change it to 700?

share|improve this question

You can use the umask command to change the file creation mask. This though only masks bits. If the application creating the file does not request a bit to be set then umask wont set it. With a umask 077 then files will generally be created 600 and directories 700

You can set your default umask in your $HOME/.profile

share|improve this answer

You want to use umask

sente@oslo: $ umask
sente@oslo: $ umask -S

sente@oslo: $ touch foo
sente@oslo: $ ls -l foo
-rw-r--r-- 1 sente pg2662512 0 2011-08-02 23:13 foo

sente@oslo: $ umask -S u=rwx,g=,o=

sente@oslo: $ touch bar
sente@oslo: $ ls -l bar
-rw------- 1 sente pg2662512 0 2011-08-02 23:13 bar

I think you'll need to chmod u+x still.

sente@oslo: $ help umask:

umask: umask [-p] [-S] [mode]
    The user file-creation mask is set to MODE.  If MODE is omitted, or if
    `-S' is supplied, the current value of the mask is printed.  The `-S'
    option makes the output symbolic; otherwise an octal number is output.
    If `-p' is supplied, and MODE is omitted, the output is in a form
    that may be used as input.  If MODE begins with a digit, it is
    interpreted as an octal number, otherwise it is a symbolic mode string
    like that accepted by chmod(1).
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.