What is umask?

umask? What?

What is umask command use for in linux/unix system?

umask is uses to set the default file or directory permission when a user create a new file or directory. By default, when a user created new file/directory, the default permission is 644/755 or umask 022, that is the default umask configure in the your unix/linux system.

umask calculation

How does the umask calculation works? Simple, subtract the default value of file value (666) and directory value (777) to the permission mode you wanted. In an example, I would like a new files/directory create with owner (Read/Write/Execute), group (read), others (read), the umask value would be umask 022.

If you want the permit an unix user created the file with default permission 600, set the umask to 066 in the default shell config file.

Test with umask

Setting the umask to 066 and see what will happen.


shell> umask 066
shell> mkdir foo
shell> ls -dl foo

drwx--x--x  2 takizo  takizo    68B May 21 08:57 foo

the directory is created with permission mod 711


shell> touch bar
shell> ls -l bar

-rw-------  1 takizo  takizo     0B May 21 09:00 bar

the file is create with permission mod 600

Related posts:

  1. installing postgresql 8.2 on Leopard with macports postgresql! one of my favorite high performance open source db,...
  2. MySQL 5 Server Cannot Start on Apple Mac Leopard There were some problem during configuring MySQL5 Server on Leopard...
  3. Configure Your Own screenrc file There are few shell scripts I need to run...
  4. TextMate: Creating New Project in Shell Instantly Been using TextMate recently, really loving it like hell. There...
  5. Microsoft Windows 2000 – Problem Starting Computer Management Console When are you having problem to start up Computer Management...
  6. How To Generate a Certificate Signing Request (CSR) for an SSL Certificate This short tutorial is for Apache2.x + OpenSSL It’s advice...
  7. PECL Manual Install on Linux Centos Just bought a VPS server hosting to play around from...
  8. Open file and Splitting String in Perl What I gonna do is to read a bunch of...
  9. MySQL Quick Installation on FreeBSD Quick installation of MySQL Database on FreeBSD Server. Make sure...

Leave a Reply