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

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?

This question is related to linux unix chmod

The answer is


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.


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.


Indeed there is.

chmod a+x is relative to the current state and just sets the x flag. So a 640 file becomes 751 (or 750?), a 644 file becomes 755.

chmod 755, however, sets the mask as written: rwxr-xr-x, no matter how it was before. It is equivalent to chmod u=rwx,go=rx.


Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to unix

Docker CE on RHEL - Requires: container-selinux >= 2.9 What does `set -x` do? How to find files modified in last x minutes (find -mmin does not work as expected) sudo: npm: command not found How to sort a file in-place How to read a .properties file which contains keys that have a period character using Shell script gpg decryption fails with no secret key error Loop through a comma-separated shell variable Best way to find os name and version in Unix/Linux platform Resource u'tokenizers/punkt/english.pickle' not found

Examples related to chmod

changing the owner of folder in linux find . -type f -exec chmod 644 {} ; Differences between CHMOD 755 vs 750 permissions set Change all files and folders permissions of a directory to 644/755 Difference between using "chmod a+x" and "chmod 755" Correct file permissions for WordPress Python module os.chmod(file, 664) does not change the permission to rw-rw-r-- but -w--wx---- Chmod recursively Chmod 777 to a folder and all contents File Permissions and CHMOD: How to set 777 in PHP upon file creation?