Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339
Rep:
Ohh the stuff used with chmod (sorry I use numbers not the letters and call them Ids not accsess code).
That kind of stuff is found in the filesystem not the file so it might be hard...
I don't know... There might be an option in chmod or file but otherwise I think it might be filesystem specific...
I'm sorry this is not my best area of knowledge
Edit: ln -l -v would make it verbose and spit out everything, try that (if -v ends up being version try --verbose)
There's nothing wrong with the math. You can make the change by EITHER using numbers OR by using letters NOT by mixing them. In the example posted earlier:
Quote:
chmod ug+rw <some_file> or chmod 660 <some_file> as result you get rw-rw----
the ug would be the user/group and the + would add the rw (read/write) permissions for the user/group. That can also be written as: chmod 660. Using numbers in place of letters is usually easier faster. Using either of these specific commands would show the output below with the ls -l command:
Quote:
rw-rw----
The post above by yoK0 explains what each option means. If you don't understand, there are numerous sites explaining it in excruciating detail or you could search the LQ forums.
chmod's permission settings written numerically make use of binary. What yok0 told you wasn't wrong, but your interpretation of it is incorrect. Here are a few guidelines to help:
Quote:
1. Binary is read from left to right.
2. There are only two numbers: 0 and 1, two numbers hence BInary, much like BIcycle because it only has two wheels, or BIpolar, etc. etc. you get the point.
3. The first number (far left) is is 2^0. If it's a 1, that 2^0 is used (and equals 1), otherwise if it is 0, it is 0 no matter what 2^x it is. The second number is (second from the left) is 2^1, third is 2^2, and so on and so forth.
Here's an example:
1110
2^0 is off, 2^1 is on, 2^2 is on and 2^3 is on. Therefore 0 + 2 + 4 + 8 = 14.
Now let's see how chmod looks at this:
rwx
111
Now we know that rwx = 7. Of course there's 3 parts to Unix permissions: owner, group and other. Let's do some more math (I really love math): We want chmod to set these settings:
rwx|r-x|rw-
111|101|110
The pipes are to help you identify the splits. Starting from the left:
Other:
Code:
2^0 is off, 2^1 is on, 2^2 is on.
0 + 2 + 4 = 6.
Group:
Code:
2^0 is on, 2^1 is off, 2^2 is on.
1 + 0 + 4 = 5.
Owner:
Code:
2^0 is on, 2^1 is on, 2^2 is on.
1 + 2 + 4 = 7.
So if I wanted the settings above I would use: chmod 756
If that doesn't help, refer to yancek's post.
Edit 1: Please also note, that the numerical method will completely reset the settings and use the ones you specify. The other adds or removes settings as they're currently set. So using yancek's post as an example:
chmod 660 sets rw-rw---- BUT chmod ug+rw ADDS read-write access to the user+group, so if I used:
chmod 110, the user and groups that have access to that file are only able to execute it (2^0 is on). If I use "chmod ug+rw" on that file, I get read-write access too so instead of being:
I don't understand how you've been with LQ.org for 7 years and didn't learn binary at least in that time, but I'll help. As previously stated in my post already, binary only consists of two numbers: 0 and 1. Bicycles only consist of two wheels. So bi means two. With those two numbers, 0 is off and 1 is on. So let me ask the question this way:
Do you want to set the "readable (by owner)" switch to on?
Do you want to set the "writable (by owner)" switch to on?
Do you want to set the "executable (by owner)" switch to on?
Do you want to set the "readable (by group)" switch to on?
Do you want to set the "writable (by group)" switch to on?
Do you want to set the "executable (by group)" switch to on?
Do you want to set the "readable (by others)" switch to on?
Do you want to set the "writable (by others)" switch to on?
Do you want to set the "executable (by others)" switch to on?
1 for yes, 0 for no. And as many people here have pointed out already -- these options are separated into 3 groups so instead of having to do chmod 128 or some other crazy power of two, you only need to type 7 for all permissions.
Notice that yak0's numbers for r=4, w=2 and x=1 can all be solutions to 2^n. If you need help finding out what n equals, just use logarithms.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.