Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between using "chmod a+x" and "chmod 755" [closed]

Tags:

linux

unix

chmod

This may sound silly, but I have a file/ script that need to run and in order to do it I must change it to become executable. I would want to use either chmod a+x or chmod 755. But is there a difference between using chmod a+x and chmod 755?

like image 651
user2579439 Avatar asked Sep 03 '13 16:09

user2579439


People also ask

What does chmod 755 do?

When you perform chmod 755 filename command you allow everyone to read and execute the file, the owner is allowed to write to the file as well. So, there should be no permission to everyone else other than the owner to write to the file, 755 permission is required.

What does chmod 775 mean?

The number defined after chmod represents the permissions. The chmod 775 is an essential command that assigns read, write, and execute permission to a specific user, group, or others.

What is chmod g x?

This added execute permission for group. $ chmod g=x test_file -rw---xr-- 1 eric users. The = operators set group's permissions to execute, and in doing so removed read and write permission. While + and - set or unset the permissions specified, = will set exactly the mode specified and remove any others.

How do I use chmod 755 a directory?

Use chmod -R 755 /opt/lampp/htdocs if you want to change permissions of all files and directories at once. Use find /opt/lampp/htdocs -type d -exec chmod 755 {} \; if the number of files you are using is very large.


2 Answers

chmod a+x modifies the argument's mode while chmod 755 sets it. Try both variants on something that has full or no permissions and you will notice the difference.

like image 129
filmor Avatar answered Sep 20 '22 06:09

filmor


Yes - different

chmod a+x will add the exec bits to the file but will not touch other bits. For example file might be still unreadable to others and group.

chmod 755 will always make the file with perms 755 no matter what initial permissions were.

This may or may not matter for your script.

like image 41
akostadinov Avatar answered Sep 20 '22 06:09

akostadinov