3

I use Ubuntu and someone advised me to change permissions to a file with sudo chmod " +x ".

It is not clear to me if +x means to change permissions to something very general as 777 or 775, or something totally different.

I've tried to Google +x unix and +x linux, but I couldn't find data regarding it in a fast search.

Here are the orders I have done (thus I'm stuck in stage 4):

  1. install wget
  2. run wget http://files.drush.org/drush.phar
  3. run sudo mv drash.phar /usr/local/bin/drush
  4. run sudo chmod +x /usr/local/bin/drush
  5. test drush
  • See man chmod. Yes, chmod +x filename is an actual command; no, you don't need to specify numeric permissions. – Wildcard Jun 21 '16 at 19:38

3 Answers3

2

x is a symbolic presentation of the executable mode (it can be in numeric format as well) that chmod command uses to set the executable permission of a file (in case of directories it sets their searchable mode). + sets executable mode and - unsets it.

From man page of chmod:

The format of a symbolic mode is [ugoa...][[+-=][perms...]...], where perms is either zero or more letters from the set rwxXst, or a single letter from the set ugo. Multiple symbolic modes can be given, separated by commas.

See this link for more information: chmod

L. Levrel
  • 1,503
Vombat
  • 12,884
  • 1
    What is the numeric value of the symbolic command +x ? (Or there are more than one and it depends external factors)... –  Jun 21 '16 at 20:49
  • A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Omitted digits are assumed to be leading zeros. The first digit selects the set user ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values. – Vombat Jun 21 '16 at 20:51
  • @Benia sorry a bit tired to explain so just copied the related part from man page. – Vombat Jun 21 '16 at 20:52
2

The "+x" to which you refer is the symbolic mode argument to chmod. As given, and assuming that your chmod comes from Gnu Coreutils, that argument directs chmod to set the executable bits for user, group, and other, except for those executable bits set in your shell's umask. So, if your umask is 0077 (as is common) that command will only set the executable bit for the user who owns the file. If your umask is 0007 (as is also common), the user and group which owns the file will be able to execute it.

It is likely that the intended effect is for all users to be able to execute the file. You can achieve that using symbolic modes by specifying that all execute bits are to be set:

chmod a+x filename

or by explicitly stating the desired permissions:

chmod 0755 filename

Symbolic modes are a wonderfully useful shortcut, but much of their behavior is left as "implementation defined" by POSIX. Therefore it is also useful to remember the numeric modes and their meanings for portable scripts and instructions.

wyrm
  • 543
1

chmod can give rights by two ways:
1) with numbers (eg chmod 744 file will make file wrx to you and r to group and others)
2) with specific right to specific category
(eg chmod +x will give all the execute right)
on your case i suppose tha your user and his group(maybe)need the execute right not everyone some more examples:

 chmod u=rx file        (Give the owner rx permissions, not w)
 chmod go-rwx file      (Deny rwx permission for group, others)
 chmod g+w file         (Give write permission to the group)
 chmod a+x file1 file2  (Give execute permission to everybody)
 chmod g+rx,o+x file    (OK to combine like this with a comma)
igiannak
  • 750