Is there something that can turn file permissions display into numeric?
OK, when I use ls -l I get the list of files and folders but also a list of permissions, unless I have a printed out table of what they mean when choosing a chmod value, I have absolutely no idea what they are, is there a command that I can use that will show the permissions in numeric form?
For Example this bash file in my user directory -rwxr--r-- 1 usalabs usalabs 237 Aug 24 06:20 start-irc.sh I would like it to show a number instead of all that xyz crap, that is not understandable. |
https://www.linuxquestions.org/quest...etters-811890/
https://askubuntu.com/questions/5509...ers-to-numbers https://askubuntu.com/questions/1520...m-command-line by the way, it is not crap and it is definitely understandable, probably better to learn it. |
r=read
w=write x=execute Pretty easy to understand to me. 1st space on the left is designated if it's a directory (d) or not...the rest are in groups of 3 for: owner, group, and everyone else. So what you listed is just a file (no d for directory was indicated), -usalabs is the owner who can read,write, and execute the file -Next, anyone in the usalabs group can read it' -Finally, everyone else can read it. |
Quote:
Code:
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \ https://askubuntu.com/questions/2954...ormat-i-e-0755 https://www.google.com/search?ei=hto...4dUDCAs&uact=5 Gives you a result like this when used. Code:
seeder1@haswell:~$ ls -l |
This tutorial explains how both sets of permissions (numeric and alpha) work. https://www.linux.com/tutorials/unde...e-permissions/
Here's an excerpt: Quote:
|
The answer is in post #2, last link therein.
I hope OP can muster the energy to click it, read it, and reply here. |
Quote:
The permission word represents both the (12) bits of the actual file mode (chmod can modify those) and the (4) bits of what type of entry it is: like "normal file", "directory", "symbolic link", "device special file" etc. The 0 in your example means: there are no setuid, setgid or sticky bits and thus has nothing to do with this Quote:
For instance -rwsr-s--- means 6750 as an octal value. |
Personally I prefer symbolic anyway - it's more intuitive as to what perms are set.
Also, you can use symbolic representations in cmds eg chmod etc, so the numeric format is superfluous for humans, although I expect the underlying C code uses the numeric form. |
It took me a week or two of trying to focus it out, now all I see are octals when I look at permissions. I had a real hard time with it at first I admit. It will come. I have no clue how that is implemented but I'd guess changing it to numbers is not a simple task.
|
Quote:
instead of chmod a+r,go-w,a-x <some file(s)> (which for normal users will clear set?id and sticky bits too, for the superuser you would need ,a-s,-t to be added to the mode string too); just use chmod 644 <those files> to do all of those at once (or i.e. 755 for directories and/or executables). |
Quote:
As mentioned by Basslord1124 in post #3 above: Quote:
User: Read, Write and Execute or in Binary 111. Translated to Octal gives 7 Group: Read, no Write, no Execute. Binary 100. Translated to Octal gives 4 World: Read, no Write, no Execute. Binary 100. Translated to Octal gives 4 So, the number you want to show the permissions of your file is 744! Ta Da! :D Play Bonny! :hattip: |
Quote:
Code:
The new file mode is specified in mode, which is a bit mask created by So on the programming level you specify a single value (int) of which the lower 12 bits are significant. The chmod command translates symbolic changes into the right 12-bits mask (see man 1 chmod). And as far as I know ls -l always shows the 9-character mode string. |
All times are GMT -5. The time now is 02:21 PM. |