{"id":21674,"date":"2023-09-30T16:26:45","date_gmt":"2023-09-30T16:26:45","guid":{"rendered":"https:\/\/linuxways.net\/?p=21674"},"modified":"2023-09-30T16:26:45","modified_gmt":"2023-09-30T16:26:45","slug":"understanding-chmod-x-making-files-executable","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/linux-commands\/understanding-chmod-x-making-files-executable\/","title":{"rendered":"Understanding Chmod +X &#8211; Making Files Executable"},"content":{"rendered":"<p>The \u201cchmod\u201d command in Linux-based Distributions like Ubuntu is used to change the access permissions of files and folders for users. In Ubuntu, getting unauthorized access to other users may endanger the overall security of the system. To prevent those security risks, certain file and folder permissions have to be changed.<\/p>\n<p>This article briefly discusses the \u201cchmod\u201d command and its use in making files executable.<\/p>\n<h2><strong>Understanding Chmod +X &#8211; Making Files Executable<\/strong><\/h2>\n<p>With \u201cchmod +X\u201d, the permissions of files and folders can be changed and those files are also made executable. The \u201cX\u201d command specifies and sets the execute permission on the file. The \u201c+\u201d sign means adding permission. The syntax for using the \u201cchmod\u201d command is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> <span class=\"br0\">&#91;<\/span>options<span class=\"br0\">&#93;<\/span> <span class=\"br0\">&#91;<\/span>mode<span class=\"br0\">&#93;<\/span> <span class=\"br0\">&#91;<\/span>filename<span class=\"br0\">&#93;<\/span><\/div><\/div>\n<h3><strong>Types of Permissions<\/strong><\/h3>\n<p>The permissions are of 3 types:<\/p>\n<ul>\n<li><strong>Read (r)<\/strong>: Allowing Users to view the file.<\/li>\n<li><strong>Write (w)<\/strong>: Allowing Users to write to the file.<\/li>\n<li><strong>Execute (x)<\/strong>: Granting Execute Permission to a file.<\/li>\n<\/ul>\n<h3><strong>Types of Users<\/strong><\/h3>\n<p>These permissions can affect four types of users on Ubuntu. These types are:<\/p>\n<ul>\n<li><strong>Owners (u)<\/strong>: Permissions only apply to Owners.<\/li>\n<li><strong>Groups (g)<\/strong>: Permissions only apply to users in a specific group.<\/li>\n<li><strong>All Users (a)<\/strong>: Permissions apply to Every User.<\/li>\n<li><strong>Others (o)<\/strong>: Permissions only apply to other people outside of a specific group or a specific type of user.<\/li>\n<\/ul>\n<h3><strong>Permission Operators<\/strong><\/h3>\n<p>The Permission Operators are of 3 types:<\/p>\n<ul>\n<li>\u201c<strong>+<\/strong>\u201d: Add User Permission<\/li>\n<li>\u201c<strong>&#8211;<\/strong>\u201d: Remove User Permission<\/li>\n<li>\u201c<strong>=<\/strong>\u201d: Set Permission to Specific Users<\/li>\n<\/ul>\n<p>To manage file permission and make files executable for users, the \u201cchmod\u201d command is used in the Terminal of Ubuntu.<\/p>\n<h2><strong>Using the Command Line or Terminal to Make Files Executable<\/strong><\/h2>\n<p>The Command line can be used to make any file executable. To make an executable file in Ubuntu, first you need to make a script file with the \u201c.sh\u201d extension using the \u201cnano\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">nano<\/span> <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span>.sh<\/div><\/div>\n<p>In our case, use the following command to make a script file \u201cScriptFileA.sh\u201d with the nano command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> ScriptFileA.sh<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1095\" height=\"68\" class=\"wp-image-21675\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-1.png 1095w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-1-300x19.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-1-1024x64.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-1-768x48.png 768w\" sizes=\"auto, (max-width: 1095px) 100vw, 1095px\" \/><\/p>\n<p>Once you hit \u201center\u201d, the text editor will open:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1102\" height=\"483\" class=\"wp-image-21676\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-2.png 1102w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-2-300x131.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-2-1024x449.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-2-768x337.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/p>\n<p>In the text editor, add the script that is to be executed. In our case, the following script will be added:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co0\">#!\/bin\/bash<\/span><br \/>\n<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;Hello World!&quot;<\/span><\/div><\/div>\n<p>Once the script is added, \u201cwrite out\u201d the script using the \u201cctrl+o\u201d key:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1101\" height=\"485\" class=\"wp-image-21677\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-3.png 1101w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-3-300x132.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-3-1024x451.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-3-768x338.png 768w\" sizes=\"auto, (max-width: 1101px) 100vw, 1101px\" \/><\/p>\n<p>It will ask for confirmation, hit \u201center\u201d to save it and then close the Text Editor using the \u201cctrl+x\u201d shortcut key. The Script File will be created and can be ensured using the \u201cls\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span><\/div><\/div>\n<p>In our Documents Directory, the Script File \u201cScriptFileA.sh\u201d is created:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1098\" height=\"248\" class=\"wp-image-21678\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-4.png 1098w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-4-300x68.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-4-1024x231.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-4-768x173.png 768w\" sizes=\"auto, (max-width: 1098px) 100vw, 1098px\" \/><\/p>\n<p>Before executing the file, change the permission of the Script File using the \u201cchmod\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> +x ScriptFileA.sh<\/div><\/div>\n<p>The \u201c+x\u201d means the File can now be executed by any user. The cursor moves to the next line indicating the permission was added:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"110\" class=\"wp-image-21679\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-5.png 1100w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-5-300x30.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-5-1024x102.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-5-768x77.png 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>Now, to Execute the File, the \u201c.\/\u201d command can be used:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">.<span class=\"sy0\">\/&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span>.sh<\/div><\/div>\n<p>In our case, the file name is \u201cScriptFileA.sh\u201d:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">.<span class=\"sy0\">\/<\/span>ScriptFileA.sh<\/div><\/div>\n<p>This will return the executed output in the terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1095\" height=\"80\" class=\"wp-image-21680\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-6.png 1095w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-6-300x22.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-6-1024x75.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-6-768x56.png 768w\" sizes=\"auto, (max-width: 1095px) 100vw, 1095px\" \/><\/p>\n<h2><strong>Understanding File Permission<\/strong><\/h2>\n<p>The file permissions can be useful for ensuring which users can access the file. The \u201cls\u201d command followed by \u201c-l\u201d is used to list all the files with details including the permissions. In our case, the \u201cls -l\u201d command will be used to list the files with details in the Documents Directory:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ls<\/span> <span class=\"re5\">-l<\/span><\/div><\/div>\n<p>The command line displays all the files with details:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1090\" height=\"285\" class=\"wp-image-21681\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-7.png 1090w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-7-300x78.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-7-1024x268.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-7-768x201.png 768w\" sizes=\"auto, (max-width: 1090px) 100vw, 1090px\" \/><\/p>\n<p>The first column of the detailed file list provides information about the file permission. In our case, the Script File \u201cScriptFileA.sh\u201d has the \u201c<strong>-rwxr-xr-x<\/strong>\u201d permission meaning all users have the read, write, and execute permission:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"289\" class=\"wp-image-21682\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-8.png 1093w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-8-300x79.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-8-1024x271.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-8-768x203.png 768w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/p>\n<p>In our case, the permission string consists of three sets, i.e. \u201c-rwx\u201d, \u201cr-x\u201d, and \u201cr-x\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"268\" height=\"82\" class=\"wp-image-21683\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-9.png\" \/><\/p>\n<p>These three sets are referred to as the \u201cowner(o)\u201d, \u201cgroup(g)\u201d, and \u201cothers(o)\u201d. The first set informs about the \u201cowner\u201d permission, the second set informs the \u201cgroup of users\u201d permission, and the third set informs the \u201cother users\u201d permission. In our case, the \u201cowner\u201d has \u201crwx\u201d permission meaning the owner can read the file, edit the file, and can also run or execute the file. The group of owners has the read and execute permission, and the file has only the read and execute permission for other users.<\/p>\n<h2><strong>Making Files Executable for All Users<\/strong><\/h2>\n<p>Multiple files can be made executable as well using the \u201cchmod\u201d command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> +x <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>With \u201c+x\u201d every user can execute the file. In our case, we have a \u201cScriptA.sh\u201d file having the read and write permission for the current user:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1094\" height=\"243\" class=\"wp-image-21684\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-10.png 1094w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-10-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-10-1024x227.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-10-768x171.png 768w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/p>\n<p>To change the File Permission, the \u201cchmod\u201d command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> +x ScriptA.sh<\/div><\/div>\n<p>The \u201c+x\u201d will ensure that the file is executable for every user. To confirm, the \u201cls -l\u201d command can be used to display the permission.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1101\" height=\"295\" class=\"wp-image-21685\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-11.png 1101w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-11-300x80.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-11-1024x274.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-11-768x206.png 768w\" sizes=\"auto, (max-width: 1101px) 100vw, 1101px\" \/><\/p>\n<p>The permission changed allowing all users to execute the script file. To change the execute permission of the file only for the user, use the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> u+x <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>The \u201cu+x\u201d indicates the file is only executable for the user. In our case, the file \u201cabc.txt\u201d currently has the read and write permissions only:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1108\" height=\"238\" class=\"wp-image-21687\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-12.png 1108w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-12-300x64.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-12-1024x220.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-12-768x165.png 768w\" sizes=\"auto, (max-width: 1108px) 100vw, 1108px\" \/><\/p>\n<p>Now to change the permission and make the file \u201cabc.txt\u201d executable for the user only, the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> u+x abc.txt<\/div><\/div>\n<p>The \u201c-rwx\u201d in the first set indicates it is executable for the user:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1099\" height=\"277\" class=\"wp-image-21688\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-13.png 1099w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-13-300x76.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-13-1024x258.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-13-768x194.png 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<h2><strong>Making Directory Executable for All Users<\/strong><\/h2>\n<p>The permission for directories inside Ubuntu can also be changed using the \u201cchmod\u201d command. The \u201cchmod\u201d command to change directory permission is the same as it is used for changing the file permission:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> +x <span class=\"sy0\">&lt;<\/span>directoryName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the \u201cNewDir\u201d has no permissions for any user:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1092\" height=\"181\" class=\"wp-image-21689\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-14.png 1092w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-14-300x50.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-14-1024x170.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-14-768x127.png 768w\" sizes=\"auto, (max-width: 1092px) 100vw, 1092px\" \/><\/p>\n<p>To make the Directory executable for All users, the command used will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> +x NewDir<\/div><\/div>\n<p>This will make the Directory Executable for all users:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1097\" height=\"204\" class=\"wp-image-21690\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-15.png 1097w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-15-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-15-1024x190.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-15-768x143.png 768w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/p>\n<h2><strong>Making Multiple Files Executable<\/strong><\/h2>\n<p>Multiple Files can also be executed using the \u201cchmod\u201d command. The syntax to make multiple files executable is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> +x <span class=\"sy0\">&lt;<\/span>file1<span class=\"sy0\">&gt;<\/span> <span class=\"sy0\">&lt;<\/span>file2<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the files \u201cfileA.txt\u201d and \u201cfileB.txt\u201d has only the read and write permission currently:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1097\" height=\"271\" class=\"wp-image-21691\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-16.png 1097w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-16-300x74.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-16-1024x253.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-16-768x190.png 768w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/p>\n<p>To change the permission of both files and make them executable for all the users, the \u201cchmod\u201d command will be used as follows:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> +x fileA.txt fileB.txt<\/div><\/div>\n<p>This will make both files executable for all users:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"293\" class=\"wp-image-21692\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-17.png 1093w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-17-300x80.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-17-1024x275.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-17-768x206.png 768w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/p>\n<h2><strong>Restrict Execution Permission Using \u201cchmod\u201d<\/strong><\/h2>\n<p>Instead of only adding the execute permissions on files and folders, permissions can also be removed restricting users from certain access or management. To remove permission or restrict execution permission specifically, the \u201c-\u201d symbol is used with the execute \u201cx\u201d operation:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">chmod<\/span> <span class=\"re5\">-x<\/span> <span class=\"sy0\">&lt;<\/span>fileName<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, the Script file \u201cScriptFileA.sh\u201d has the execute permission for all users:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1093\" height=\"274\" class=\"wp-image-21693\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-18.png 1093w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-18-300x75.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-18-1024x257.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-18-768x193.png 768w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/p>\n<p>To remove the execution permission from all users, the command used is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">chmod<\/span> <span class=\"re5\">-x<\/span> ScriptFileA.sh<\/div><\/div>\n<p>This will remove the execution permission from ScriptFileA.sh File:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1092\" height=\"291\" class=\"wp-image-21694\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-19.png 1092w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-19-300x80.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-19-1024x273.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21674-19-768x205.png 768w\" sizes=\"auto, (max-width: 1092px) 100vw, 1092px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The \u201cchmod\u201d command is useful for managing the file permissions of files and folders in Ubuntu. The chmod command is used with permission operators and user permissions to specify certain user permissions for a file or folder. It can also be used to limit access or permissions of files from users. This article explained all the different permission restrictions and additional methods with the \u201cchmod\u201d command.<\/p>","protected":false},"excerpt":{"rendered":"<p>The chmod command is used with permission operators and user types to specify certain user permissions for a file and can also be used to restrict access. <\/p>","protected":false},"author":110,"featured_media":21686,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1049],"tags":[],"class_list":["post-21674","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21674"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21674\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21686"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}