Closed Captioning Closed captioning available on our YouTube channel

How to use the chmod command: 2-Minute Linux Tips

Network World | Apr 19, 2019

Learn how to use the chmod command – the command for changing permissions on files. The only tricky part is understanding that there are two ways to represent file permissions.

Copyright © 2019 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this 2-minute Linux tip, we’re going to look at the chmod command – the command for changing permissions on files. The only tricky part is understanding that there are two ways to represent file permissions. One way is to use a command like this:
Two things to know: 1) First digit (7)=owner, 2nd (5)=group, 3rd (0)=everyone else
In addition, each digit is octal and should be thought about in its binary form. 7=111, 5=101, 0=000, etc. and each position in a binary number like 101 represents a different permission. 1st digit=read, 2nd=write, 3rd=execute and if a digit is 1, it sets that privilege and if 0, it turns it off.
In this example, owner gets read/write/execute (rwx), group read and execute (r-x) and everyone else no access (---).
Note also that, in this method, all file permissions are assigned at once. Any previous settings are overwritten.
The other form of chmod uses the symbolic way where you might use a command like this:
This command would give all users (a) execute permission (x).
This next command would give only the owner (user) read and execute permission. No other permissions would be affected.
You can add or remove permissions using this method.
Here’s a fairly complex example where we’re giving all permissions to the file owner and removing write permission for everyone else.
Which way of using chmod is better depends on what you want to do and how comfortable you are thinking in octal.
That’s your Linux tip for today.
If you have questions or would like to suggest a topic, please add a comment below.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Featured videos from IDG.tv