{"id":6710,"date":"2017-05-08T14:30:37","date_gmt":"2017-05-08T06:30:37","guid":{"rendered":"http:\/\/rmohan.com\/?p=6710"},"modified":"2017-05-08T14:30:37","modified_gmt":"2017-05-08T06:30:37","slug":"rhel-7-rhcsa-notes-create-and-manage-access-control-lists-acls","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6710","title":{"rendered":"RHEL 7 \u2013 RHCSA Notes \u2013 Create and manage Access Control Lists (ACLs)"},"content":{"rendered":"<p>The file access control lists (FACLs) or simply ACLs are the list of additional user\/groups and their permission to the file. Although the default file permissions does their jobs perfectly, it does not allow you to give permissions to more than one user or one group on the same file.<\/p>\n<p>How to know when a file has ACL attached to it<\/p>\n<p>ls -l command would produce a output as show below. Note the + sign at the end of the permissions. This confirms that the file has an ACL attached to it.<\/p>\n<p># ls -l<br \/>\n-rw-r&#8211;r-+ 1   root   root  0  Sep  19  14:41  file<br \/>\nViewing ACLs<\/p>\n<p>To display details ACL information of a file use the getfacl command. If you see carefully, the users sam and john have some extra permissions (shown highlighted). The default user\/group permissions are specified using \u201cuser::permission\u201d and \u201cgroup::<\/p>\n<p># getfacl \/tmp\/test<br \/>\n# file: test<br \/>\n# owner: root<br \/>\n# group: root<br \/>\nuser::rw-<br \/>\nuser:john:rw-<br \/>\nuser:sam:rwx<br \/>\ngroup::r&#8211;<br \/>\nmask::rwx<br \/>\nother:&#8212;<br \/>\nIn contrast, if you check the ACLs on a a file with \u201cno ACLs\u201d the additional \u201cuser:\u201d lines and \u201cmask\u201d line will not be shown and standard file permissions will be shown. :<\/p>\n<p># getfacl test<br \/>\n# file: test<br \/>\n# owner: root<br \/>\n# group: root<br \/>\nuser::rw-<br \/>\ngroup::r&#8211;<br \/>\nother::r&#8211;<br \/>\nCreating and Managing FACLs<\/p>\n<p>The setfacl command is used to set ACL on the given file. To give a rw access to user john on the file \/tmp\/test :<\/p>\n<p># setfacl -m u:john:rw \/tmp\/test<br \/>\nThe -m option tells setfacl to modify ACLs on the file(s) mentioned in command line. Instead of user john we can have a group to have a specific permission on the file :<\/p>\n<p># setfacl -m g:accounts:rw \/tmp\/test<br \/>\nFACLs for multiple user and groups can also be set with single command :<\/p>\n<p># setfacl -m u:john:rw,g:accounts:rwx \/tmp\/test<br \/>\nDefault ACLs<\/p>\n<p>By setting a default ACL, you\u2019ll determine the permissions that will be set for all new items that are created in the directory. But the permissions of existing files and subdirectories remains same.<\/p>\n<p>To create a default FACL on a directory :<\/p>\n<p># setfacl -m default:u:john:rw \/accounts<br \/>\nNotice the default permissions in the getfacl command :<\/p>\n<p># getfacl accounts\/<br \/>\n# file: accounts\/<br \/>\n# owner: root<br \/>\n# group: root<br \/>\nuser::rwx<br \/>\ngroup::r-x<br \/>\nother::r-x<br \/>\ndefault:user::rwx<br \/>\ndefault:user:john:rw-<br \/>\ndefault:group::r-x<br \/>\ndefault:mask::rwx<br \/>\ndefault:other::r-x<br \/>\nRemoving FACLs<\/p>\n<p>To remove ACLs, use the setfacl command with -x option :<\/p>\n<p># setfacl -x u:john \/tmp\/test<br \/>\nThe above command removes the ACL for the user john on the file \/tmp\/test. The ACLs for other user\/groups if any remains unaffected. To remove all ACLs associated to a file use the -b option with setfacl :<\/p>\n<p># setfacl -b \/tmp\/test<br \/>\nYou can also create a backup of ACLs using getfacl, and restore ACLs using setfacl command. To create the backup, use getfacl -R \/dir > file.acls. To restore the settings from the backup file, use setfacl \u2013restore=file.acl<\/p>\n<p>RHEL 7 \u2013 RHCSA Notes : Change passwords and adjust password aging for local user accounts<\/p>\n<p>Password configuration<\/p>\n<p>password aging requires users to change their password periodically. Use the chage to configure password expiration. The syntax is :<\/p>\n<p># chage [options] user_name<br \/>\n\u2013 When you fire the command chage, the currently set options are displayed as well.<\/p>\n<p># chage oracle<br \/>\nChanging the aging information for oracle<br \/>\nEnter the new value, or press ENTER for the default<\/p>\n<p>\tMinimum Password Age [14]:<br \/>\n\tMaximum Password Age [30]:<br \/>\n\tLast Password Change (YYYY-MM-DD) [2016-08-23]:<br \/>\n\tPassword Expiration Warning [7]:<br \/>\n\tPassword Inactive [-1]:<br \/>\n\tAccount Expiration Date (YYYY-MM-DD) [1969-12-31]:<br \/>\nPassword expiration information is stored in \/etc\/shadow file.<\/p>\n<p># grep oracle \/etc\/shadow<br \/>\noracle:$6$H28sLVDL$iNvp\/AvbMeqqrslH2bfmTxJpE6.mO8UNzlIXGB3sp87jZP9dW1DxeoLf2QXR7hkLkomuXbtgO1zPKUEYRY8YI1:15284:14:30:7:::<br \/>\nAs shown above the oracle user has minimum password age of 14 and maximum password age of 30 \u2013 It means that in 14 days the user will have 30 days to change the password. Also the user is warned to change the password 7 days prior to password expiry date.<\/p>\n<p>chage options<\/p>\n<p>Number of options are available in chage command. To list aging information :<\/p>\n<p># chage -l geek<br \/>\nLast password change\t\t\t\t\t: Sep 18, 2016<br \/>\nPassword expires\t\t\t\t\t: never<br \/>\nPassword inactive\t\t\t\t\t: never<br \/>\nAccount expires\t\t\t\t\t\t: never<br \/>\nMinimum number of days between password change\t\t: 0<br \/>\nMaximum number of days between password change\t\t: 99999<br \/>\nNumber of days of warning before password expires\t: 7<br \/>\nTo force a user to set a new password immediately (force immediate expiration), set the last password change value to 0 :<\/p>\n<p># chage \u2013d 0 geek<br \/>\nauthconfig<\/p>\n<p>The Linux user password hashing algorithm is also configurable. Use the authconfig command to determine the current algorithm being used, or to set it to something different. To determine the current algorithm:<\/p>\n<p># authconfig &#8211;test | grep hashing<br \/>\n password hashing algorithm is sha512<br \/>\nTo change the algorithm, use the \u2013passalgo option with one of the following as a parameter: descrypt, bigcrypt, md5, sha256, or sha512, followed by the \u2013update option.<\/p>\n<p># authconfig &#8211;passalgo=md5 &#8211;update<br \/>\n\/etc\/login.defs file<\/p>\n<p>\/etc\/login.defs file provides default user account settings. Default values include:<\/p>\n<p>Location of user mailboxes<br \/>\nPassword aging controls<br \/>\nValues for automatic UID selection<br \/>\nValues for automatic GID selection<br \/>\nUser home directory creation options<br \/>\numaskvalue<br \/>\nEncryption method used to encrypt passwords<br \/>\nSample \/etc\/login.defs file :<\/p>\n<p># cat \/etc\/login.defs<br \/>\n&#8230;..<br \/>\nPASS_MAX_DAYS\t99999<br \/>\nPASS_MIN_DAYS\t0<br \/>\nPASS_MIN_LEN\t5<br \/>\nPASS_WARN_AGE\t7<br \/>\n&#8230;&#8230;<br \/>\nGID_MIN                  1000<br \/>\nGID_MAX                 60000<br \/>\n&#8230;..<br \/>\nUID_MIN                  1000<br \/>\nUID_MAX                 60000<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The file access control lists (FACLs) or simply ACLs are the list of additional user\/groups and their permission to the file. Although the default file permissions does their jobs perfectly, it does not allow you to give permissions to more than one user or one group on the same file.<\/p>\n<p>How to know when a [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6710"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6710"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6710\/revisions"}],"predecessor-version":[{"id":6711,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6710\/revisions\/6711"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}