-3

Just a question after I was surprised by this:

I wanted to extend RWX permission for all groups for a folder so I wrote "chmod 777 FOLDER" command

After I listed the folder it was defined as 777 but with drwxr-xr-x symbols only (not write symbols for last groups)

I made a second command sudo chmod 777 FOLDER and the it was ok with the symbols also drwxrwxrwx

I also noticed that the folder are underlined in green.

Could you please explain what happened (just to understand).

Thanks

Vico la patate
  • 209
  • 2
  • 4
  • 12
  • 1
    Not a programming question, this is basic linux usage, belongs to **Super User** or **Unix & Linux**. – tink Feb 25 '16 at 19:46

2 Answers2

1

Executable files are highlighted as green in ubuntu (type ls /usr/bin for example). Folders have read and execute (6) permissions by default. Setting it to 7 tells the terminal to display it as an executable. There are some great answers to colors for files and folders at https://askubuntu.com/questions/17299/what-do-the-different-colors-mean-in-the-terminal and https://unix.stackexchange.com/questions/94498/what-causes-this-green-background-in-ls-output

EDIT

As pointed out by @Carpetsmoker, 777 file permissions are dangerous because they allow anyone to change and run any code in the file with 777 permissions. Beyond running malicious code for the one file, they can write malicious code granting them access to the entire computer.

Notice that any set of permissions has three numbers. The first number refers to permissions for the owner of the file. The second number refers to permissions for the group the file is assigned to. The last number refers to permissions for everyone else. The number can be an integer 0-7. The reasoning for this is that each number in turn represents three binary numbers, i.e.

rwx = number
000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7

These binary numbers have meaning, as shown by the rwx. The r column stands for read permissions (view contents of the file), the w column stands for write permissions (change contents of the file), and the x column stands for execute permissions (let the user have the *nix kernel run the code). 1 means "yes, it has this permission", 0 means "no, it does not have this permission".

So giving 777 file permissions is like saying

Owner: Can view, can change contents of, and can run code in this file.

rwx
111

Group: Can view, can change contents of, and can run code in this file.

rwx
111

Anyone else: Can view, can change contents of, and can run code in this file.

rwx
111

And as pointed out at Who can access a file with octal permissions "000" on Linux/UNIX? , the Root user will always have rwx permissions for all files and folders.

Community
  • 1
  • 1
neallred
  • 740
  • 1
  • 8
  • 24
0

in simple terms, sudo gives you root/admin capabilities and that is why it worked for all the groups whereas when you ran it without sudo it worked only for the local user.

I am adding the following information because it is important to point out the downside of using chmod 777, as pointed out by @Carpetsmoker.

Basically there are three groups of permissions - User, Group, and Other. Using chmod 777 gives read-write-execute privileges to Other, which is indeed pretty bad for security and you are allowing anybody to manipulate the files and folders. In fact you should not use chmod 666 either because it also provides privileges to Other although only read-write, still it entails only bad you.

When you see chmod 777, you want to use chmod 755, when you see chmod 666, use chmod 664. If it doesn't work after that, then set the user or group of the file with chown.

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
Jay T.
  • 307
  • 1
  • 6