Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
chmod octal numbers
Is there an easy way to remember what the each of the 8 numbers, 0-7 represent for chmod and umask? That way I would not have to keep guessing until I get it right.
Is there an easy way to remember what the each of the 8 numbers, 0-7 represent for chmod and umask? That way I would not have to keep guessing until I get it right.
in short -
wrt chmod, simplest way to remember apart from doing all the binary stuff is
r=4
w=2
x=1
the stat command will give a helping hand here..... stat <file>
with umask an example is
000 = creation of folders with 777 perms (rwxrwxrwx)
creation of files 666 (rw-rw-rw)
777 = creation of folders 000 perms (---------)
and same with files
In fact you can use the symbolic notation ie rwx for chmod and umask; I always do. There is no difference for chmod, but for umask, you quote the protections you want instead of the reverse ie no subtraction involved. http://linux.die.net/man/1/umask
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Original Poster
Rep:
Quote:
Originally Posted by chrism01
In fact you can use the symbolic notation ie rwx for chmod and umask; I always do. There is no difference for chmod, but for umask, you quote the protections you want instead of the reverse ie no subtraction involved. http://linux.die.net/man/1/umask
I am aware, but I like using octal numbers, maybe because I'm a computer nerd plus it's shorter to write.
One thing I have to remember when using rwx for chmod is that 'o' does not stand for owner. It stands for other. I've often made that mistake. It's easy to do. Even the man page for chmod says this.
"A combination of the letters ugoa controls which users' access to the
file will be changed: the user who owns it (u)"
Code:
chris@ubuntu910:/tmp$ touch test{1,2}
chris@ubuntu910:/tmp$ chmod u+r,u-wx,g+w,g-rx,o+x,o-rw test1
chris@ubuntu910:/tmp$ ls -l test1
-r---w---x 1 chris chris 0 2010-03-27 02:50 test1
chris@ubuntu910:/tmp$ chmod 421 test2
chris@ubuntu910:/tmp$ ls -l test2
-r---w---x 1 chris chris 0 2010-03-27 02:50 test2
chris@ubuntu910:/tmp$
See how much shorter and simpler to write the command using octal numbers is? Now that I know that figuring out octal numbers for permissions can be found using simple addition rather than memorizing, I find it much easier.
Last edited by fakie_flip; 03-27-2010 at 03:05 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.