Execute permission for files; search permission for directories. X: Execute permission for files if the current (unmodified) mode bits have at least one of the user, group, or other execute bits set. The X flag is ignored if the File parameter is specified and none of the execute bits are set in the current mode bits. Search permission for directories.
I have been following this iptables guide online and came across a problem where I tried to give myself execute permissions to a file that is owned by root and stored in root's home folder. The author made a number of mistakes.
The script should be created, chmod'd and executed as root. The script is missing the shebang to tell it what interpreter to use.This is what you should be doing:As root (sudo -s) create the file /root/fw.stop: $ sudo -sEnter foo's password:# nano -w /root/fw.stopThen enter the following script (note the change in the first line): #!/bin/shecho 'Stopping firewall and allowing everyone.' Iptables -Fiptables -Xiptables -t nat -Fiptables -t nat -Xiptables -t mangle -Fiptables -t mangle -Xiptables -P INPUT ACCEPTiptables -P FORWARD ACCEPTiptables -P OUTPUT ACCEPTThen you can chmod it (still as root): # chmod +x /root/fw.stopThen you can run it (yes, still as root): # /root/fw.stopIf you want to run it as anyone other than root then you should use sudo ( sudo /root/fw.stop). The setuid bit is possible but a serious security hole as it would allow anyone to run the script.
NAMEchmod - To change access permissions, change mode. SYNOPSISchmod Options. Mode ,Mode.
File.chmod Options. NumericMode file.chmod Options.reference=RFile file.DESCRIPTIONchmod changes the permissions of each given file according to mode, where mode describes the permissions to modify.
Mode can be specified with octal numbers or with letters. OPTIONS TagDescription-f, -silent, -quietsuppress most error messages-v, -verboseoutput a diagnostic for every file processed-c, -changeslike verbose but report only when a change is made-c, -reference=RFileuse RFile's mode instead of MODE values-R, -recursivechange files and directories recursively-helpdisplay help and exit-versionoutput version information and exitNumeric modeThe format of a numberic mode is 'augo'A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Any omitted digits are assumed to be leading zeros. The first digit selects the set user ID (4) and set group ID (2) and sticky (1) attributes.
![Chmod a file Chmod a file](/uploads/1/2/5/5/125500546/616428109.gif)
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. EXAMPLESRead by owner only$ chmod 400 sample.txtRead by group only$ chmod 040 sample.txtRead by anyone$ chmod 004 sample.txtWrite by owner only$ chmod 200 sample.txtWrite by group only$ chmod 020 sample.txtWrite by anyone$ chmod 002 sample.txtExecute by owner only$ chmod 100 sample.txtExecute by group only$ chmod 010 sample.txtExecute by anyone$ chmod 001 sample.txtAllow read permission to owner and group and anyone.$ chmod 444 sample.txtAllow everyone to read, write, and execute file.$ chmod 777 sample.txtSymbolic modeThe format of a symbolic mode is 'ugoa.+-=rwxXstugo.' .
Multiple symbolic operations can be given, separated by commas. A combination of the letters 'ugoa' controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a).