Linux account and privilege Management
Linux/Centos7 account and rights management user account, group account query account information settings file and directory permissions settings file and directory attribution I. Preface Overview as a multi-user, multi-task (Multi-Users,Multi-tasks) server operating system, Linux provides a strict rights management mechanism, mainly from the user identity, file permissions two aspects to limit resources. Linux controls access to resources based on the user's identity. User account category: superuser-root, most privileged ordinary user-Custom user Anonymous user (nobody) is similar to Guest program user in Windows-controlling programs and services Unable to log in to a group account-- a collection of users (in fact, it can be thought of as a collection of user permissions)-- basic groups (private groups)-- created with the same name as the user (or you can set it yourself), but when you create a user, there must be an additional group (public group)-- create an empty group directly, you can add existing users and set permissions for the group. All users in this group have this permission UID and GIDUID (User IDentity)-- user identification number (by default 0 means root 1: 999 means (system) program user 1000: 60000 means (login) ordinary user) GID (Group IDentity)-- group identification number 2, user account file / etc/passwd-- saves user name, host directory, Log in to shell and other basic information [root@lokott ~] # head-2 / etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologin
Root:x:0:0:root:/root:/bin/bash-- is explained one by one below separated by colons
Root-- user account name xmai-password encrypted using encryption algorithm. Here is the full name of the UIDroot-- user of the basic group account to which the user UID number 0Mel is not displayed. You can fill in the user details / root-- host directory / the login Shell/etc/shadow-- of the bin/bash-- specified user to save the user's password, account validity, etc. [root@lokott ~] # head-2 / etc/shadow / / View the first two lines of information root:$6 $P0mVYDgJo8HZnWlyogoYlITJyv.h.6wS sign OCuAdc61QoWTkYJONdy9aAjRW4Cpmc5Mor40xn RiZ9Hi1PzhVoX5Chur4Vf8JmKO1JmKO1purpur0pur99999JmKO1JMJJJJJJJJJJJO1PzhVoX5Chur4Vf8JmKO1JMKO1V014999JJJJJJJJJJJJJJJJJJO1PzhVoX5Chur4Vf8JmKO1
Root:$6 $P0mVYDgJo8HZnZWlyogoYlITJyv.hP.6wSAccording to OCuAdc61QoWTkYJMcONdy9aAjRW4Cpmc5Mor40xn RiZ9Hi1PzhVoX5Chur4VfFB8JmKO1PzhVoX5Chur4VfFB8JmKO1 is separated by a colon, which is explained one by one below
Root-- user account name
Bold-indicates the password encrypted by the encryption algorithm. The password entered by login is invalid.
::-- the content between is the last modified time
0mi-the minimum valid days of the password (0 means it can be changed at any time)
99999muri-the longest valid days of the password
7mi-7 days in advance to remind the user that the password will expire
::-- indicates the operation processing after the expiration of the password and account (basically negligible)
Second, manage user accounts 1. Add user account-- useradd command
Option
-u-- specifies the UID number of the user, and the UID number is not used by other users-d-- specifies the location of the user's host directory (does not take effect when used with-M! )-emure-account expiration time (expiration time)-gmure-basic group-Gmure-additional group-Mmuri-no-home directory-s-specify the login shell of the user
Example: useradd-d / opt/mike (- g mike)-G caiwu-s / sbin/nologin mike
[root@lokott] # useradd-d / opt/mike-G caiwu-s / sbin/nolgin mike / / Note you need to have a caiwu group first-- groupadd caiwu [root@lokott ~] # tail-2 / etc/passwd / / View the last two lines of information in the passwd file lokott:x:1000:1000:lokott:/home/lokott:/bin/bashmike:x:1001:1001::/opt/mike:/sbin/nolgin [root@lokott ~] # tail-2 / etc/groupcaiwu:x : 1002:mikemike:x:1001: [root@lokott ~] # tail-2 / etc/shadowlokott:$6 $aq3AU9oDZf pick ERE2DruOl.zBTLNqbsPDdsJYE0yU3Wa7EUU1SonR3rUQ616PsgA2u.DtQ99ecTUbdw2y2RhmlaL75WlcqMsfEUNretgb0RmlaL99999MsfEUNretgb0Rm18192 0RV 018 192RV 0RV 99999MsfEUNretgb018192 0RV: [root@lokott ~] # id mike / / View mike's id information uid=1001 (mike) gid=1001 (mike) group = 1001 (mike) 1002 (caiwu) [root@lokott ~] # ls / home/ because-d specifies the user's host directory So the home directory is created in the specified / opt/mike directory demo lokott [root@lokott ~] # ls / opt/demo01.txt mike rh test [root@lokott ~] # 2. Set / change user password (password) passwd
Passwd option. User name
-d clear password-l Lock-S to see if it is locked or unlocked (uppercase! )-u unlock [root@lokott ~] # useradd-d / opt/lisi-s / sbin/nologin lisi [root@lokott ~] # tail-2 / etc/passwdlokott:x:1000:1000:lokott:/home/lokott:/bin/bashlisi:x:1001:1001::/opt/lisi:/sbin/nologin / / where / sbin/nologin means that the user cannot log in to [root@lokott ~] # passwd lisi to change the password of the user lisi. New password: / / requires you to enter an invalid password: the password is less than 8 characters / / because you have entered a simple password, you can continue to enter it once, of course, if you have a complex password, you can re-enter the new password: passwd: all authentication tokens have been successfully updated. [root@lokott ~] # su-lisi Last failed login: April 31 18:49:45 CST 2019 from: 1:1 the most successful login followed by a failed login attempt. This account is currently not available. / / unable to log in Because the login shell is / sbin/nologin [root@lokott ~] # pwd/root [root@lokott ~] # vim / etc/passwd / / enter the passwd file to change the user's / sbin/nologin to / bin/bash [root@lokott ~] # su-lisi / / root when you switch users, you do not need to enter a password for the last login: October 31, October 31, 18:52:42 CST 2019pts/2 Log in to lisi user / opt/lisi [lisi@lokott ~] $su / / on [lisi@lokott ~] $pwd / / equivalent to su-root. The results below show that ordinary users need a password when switching root. The password entered does not display the password: [root@lokott lisi] # pwd/opt/lisi [root@lokott lisi] # cd [root@lokott ~] # pwd/ / indicates that the password that switches to the root user / root [root@lokott ~] # passwd-l lisi / / locks the password of user lisi. Passwd: operation succeeded [root@lokott ~] # passwd-S lisi / / View the password status of lisi users lisi LK 2019-10-31 0 99999 7-1 (password is locked.) [root@lokott ~] # su-lisi Last login: [lisi@lokott ~] $pwd / / on CST 2019pts/2 at 19:01:10 on October 31 on Thursday, you can see that although root is locked, root can switch login without the need for a password / opt/lisi [lisi@lokott ~] $[root@lokott ~] # passwd-u lisi to unlock the password of user lisi. Passwd: operation succeeded [root@lokott ~] # passwd-S lisilisi PS 2019-10-31 0 99999 7-1 (password has been set, use SHA512 algorithm.)
The example can be summarized as follows:
Among them, the / sbin/nologin user cannot log in directly and is switched to login after the passwd-l lisi is executed. The user cannot log in in the graphical user interface, but the login can be switched from the root user (and the root switch does not require a password) 3. Modify the attributes of the user account usermod-u modify the user's UID number-d modify the user's host directory location-e modify the user account expiration time-s specify the user's login shell-l change the user login account name-L lock-equivalent to passwd-lcomeU unlock-equivalent to passwd-u
Among them, 1-4 is similar to useradd and demonstrates the following operation of-l
[root@lokott ~] # usermod-l zhangsan lisiusermod: user lisi is currently used by process 71736 [root@lokott ~] # ps-ef | grep lisiroot 71735 71117 0 19:01 pts/2 00:00:00 su-lisilisi 71736 71735 0 19:01 pts/2 00:00:00-bashroot 72433 71829 0 19:11 pts/2 00:00:00 su-lisilisi 72435 72433 0 19:11 pts/2 00:00:00-bashroot 73325 72935 0 19:24 Pts/2 00:00:00 grep-- color=auto lisi [root@lokott ~] # kill 71735 / / can also be restarted Automatically ends the process [root@lokott ~] # Session terminated, killing shell... ... Has been killed. [root@lokott ~] # exit [root@lokott ~] # usermod-l zhangsan lisi [root@lokott ~] # tail-2 / etc/passwdmike:x:1001:1001::/opt/mike:/sbin/nolginzhangsan:x:1002:1003::/opt/lisi:/bin/bash / / only changed the lisi user name, but the name of the home directory is still lisi [root@lokott ~] # ls / optdemo01.txt lisi mike rh test [root@lokott ~] # 4. Delete user account userdel
-r delete the host directory together, and the following demonstration follows the above operation
[root@lokott ~] # tail-2 / etc/passwd / / shows two users mike:x:1001:1001::/opt/mike:/sbin/nolginzhangsan:x:1002:1003::/opt/lisi:/bin/bash [root@lokott ~] # userdel-r mike / / Delete mike users and "copy home" [root@lokott ~] # tail-3 / etc/passwd tcpdump:x:72:72::/:/sbin/nologinlokott : x:1000:1000:lokott:/home/lokott:/bin/bashzhangsan:x:1002:1003::/opt/lisi:/bin/bash [root@lokott ~] # ls-l / opt/mike / / indicates that-r removes the specified home directory ls: unable to access / opt/mike: there is no file or directory [root@lokott ~] # ls / opt/ / currently in / opt has lisi home directory (the name has been changed to zhangsan above) demo01.txt lisi rh test [root@lokott ~] # userdel-r zhangsan / / Delete zhangsan users At the same time, the lisi directory will be deleted [root@lokott ~] # tail-3 / etc/passwdpostfix:x:89:89::/var/spool/postfix:/sbin/nologintcpdump:x:72:72::/:/sbin/nologinlokott:x:1000:1000:lokott:/home/lokott:/bin/bash [root@lokott ~] # ls-l / opt / / because the zhangsan user is deleted and-r delete the home directory If you do not add-r, the total amount will not be deleted. 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 root root 32 October 31 18:33 test [root@lokott ~] # useradd wang / / create a new user [root@lokott ~] # usermod-l sung wang / / change to user name [root@lokott ~] # tail-2 / etc/passwd / / View passwd information lokott:x:1000:1000:lokott:/home/lokott:/bin/bashsung:x:1001:1003::/home/wang:/bin/bash [root@lokott ~] # userdel sung / / Delete sung users but do not delete wang [root@lokott ~] # ls / home/demo lokott wang5. The initial configuration file of the user account
File source-the new user account is copied from the / etc/skel directory (use ls-an in the cd to home directory)
~ / .bash_profile means to be loaded after entering bash ~ / .bashrc users are loaded when logging in ~ / .Execution is executed when bash_logout logs out. 3. Manage group account group account files-similar to user account files / etc/group: save group account basic information / etc/shadow: save group account password information (usually not set) 1. Add group account groupadd command
Groupadd option group name
-g-- specify GID
[root@lokott ~] # groupadd lisi / / add lisi group [root@lokott ~] # tail / etc/group / / View group information postdrop:x:90:postfix:x:89:stapusr:x:156:stapsys:x:157:stapdev:x:158:tcpdump:x:72:lokott:x:1000:printadmin:x:985:caiwu:x:1002:lisi:x:1003: [root@lokott ~] # groupadd- G 1005 wangwu / / add wangwu group and configure it with GID of 1005 [root@lokott ~] # tail-2 / etc/grouplisi:x:1003:wangwu:x:1005: [root@lokott ~] # 2. Add group members and delete group members add-gpasswd-an adding a user to the group does not overwrite-d removes a user-M comma-separated set group membership list from the group, overwriting group members Kick out the original [root@lokott ~] # tail-2 / etc/group / / View group information lisi:x:1003:wangwu:x:1005: [root@lokott ~] # tail-2 / etc/passwd / / View user information tcpdump:x:72:72::/:/sbin/nologinlokott:x:1000:1000:lokott:/home/lokott:/bin/bash [root @ lokott ~] # useradd lisi / / add lisi user will fail Because the above shows that the lisi group already exists-if you want to add this user to the group, use the-g parameter. [root@lokott ~] # useradd-g lisi lisi / / add lisi users to the lisi group [root@lokott ~] # useradd zhangsan / / add another zhangsan user [root@lokott ~] # tail-2 / etc/passwd / / View user information lisi:x:1001:1003::/home/lisi:/bin/bashzhangsan:x : 1002:1006::/home/zhangsan:/bin/bash [root@lokott ~] # gpasswd-a lisi wangwu / / add lisi to wangwu group (first wangwu group) adding user "lisi" to "wangwu" group [root@lokott ~] # id lisi / / View UIDuid=1001 (lisi) gid=1003 (lisi) group of lisi = 1003 (lisi) 1005 (wangwu) [root@lokott ~] # gpasswd-d lisi wangwu / / removing lisi from the wangwu group is removing the user "lisi" from the "wangwu" group [root@lokott ~] # id lisi / / View lisi's UID No longer belong to wnagwu group uid=1001 (lisi) gid=1003 (lisi) group = 1003 (lisi) [root@lokott ~] # tail-5 / etc/passwd / / display user information postfix:x:89:89::/var/spool/postfix:/sbin/nologintcpdump:x:72:72::/:/sbin/nologinlokott:x:1000:1000:lokott:/home/lokott:/bin/bashlisi:x:1001:1003::/home/lisi:/bin/bashzhangsan : x:1002:1006::/home/zhangsan:/bin/bash [root@lokott ~] # tail-5 / etc/group / / display group information printadmin:x:985:caiwu:x:1002:lisi:x:1003:wangwu:x:1005:zhangsan:x:1006: [root@lokott ~] # gpasswd-M lisi Zhangsan wangwu / / add two users to the wangwu group in batch [root@lokott ~] # tail-5 / etc/groupprintadmin:x:985:caiwu:x:1002:lisi:x:1003:wangwu:x:1005:lisi,zhangsan / / check the information zhangsan:x:1006: [root@lokott ~] # useradd hh / / add two new users To verify the coverage function of-M [root@lokott ~] # useradd ww [root@lokott ~] # gpasswd-M hh,ww wangwu [root@lokott ~] # tail-5 / etc/grouplisi:x:1003:wangwu:x:1005:hh,ww / / the original lisi and zhangsan are kicked out zhangsan:x:1006:hh:x:1007:ww:x:1004: delete-- groupdel group account
Attention! You cannot delete a group at will using the groupdel command. This command applies only to groups that are "not any user's initial group (primary group)". In other words, if a group is still a user's initial group (primary group), it cannot be deleted successfully using the groupdel command. For example:
[root@lokott] # tail-10 / etc/group stapdev:x:158:tcpdump:x:72:lokott:x:1000:printadmin:x:985:caiwu:x:1002:lisi:x:1003:wangwu:x:1005:hh Wwzhangsan:x:1006:hh:x:1007:ww:x:1004: [root@lokott ~] # groupdel caiwu [root@lokott ~] # groupdel lisigroupdel: the primary group of user "lisi" cannot be removed [root@lokott ~] # groupdel wangwu [root@lokott ~] # groupdel zhangsan groupdel: the primary group of user "zhangsan" [root@lokott ~] # groupdel hhgroupdel: the primary group of user "hh" [root@lokott ~] # groupdel wwgroupdel: the primary group of user "ww" [root@lokott ~] #
If you really want to delete, you can delete the initial member who created the group and then delete it.
[root@lokott note] # tail-1 / etc/passwdww:x:10000:10000::/home/ww:/bin/bash [root@lokott note] # groupdel wwgroupdel: cannot remove the primary group of user "ww" [root@lokott note] # userdel ww [root@lokott note] # tail-1 / etc/groupzhangsan:x:1006: [root@lokott note] # command lastb is used to view recently logged in information [root@lokott ~] # lastblisi: 1 1 Thu Oct 31 18:49-18:49 (00:00) root pts/1 Thu Oct 31 17:07-17:07 (00:00) root: 0:0 Thu Oct 24 14 root 43-14 root 43 (00) root: 0 Thu Oct 24 14:43-14:43 (00:00) root: 0:0 Thu Oct 24 14:43-14:43 (00:00) btmp begins Thu Oct 24 14:43:01 2019 [root@lokott] # IV. Permissions and attribution of files / directories 1. Access permission
Read r: allows you to view file contents and display directory lists
Write w: allows file contents to be modified, new files or subdirectories to be created, moved, or deleted in the directory
Executable x: allows you to run programs and change directories
two。 Ownership (ownership)
Owner: the user account used for this file or directory
Group: the group account used for this file or directory
3. Combined with an example, this paper introduces the total amount of authority [root@lokott] # ls-l. 1 root root 1785 October 23 12:21 anaconda-ks.cfg-rw-r--r--. 1 root root 1833 October 23 12:24 initial-setup-ks.cfgdrwxr-xr-x. 4 root root 73 October 30 22:03 note / / take this as an example
The following is about drwxr-xr-x. 4 root root 73 October 30 22:03 note to explain
D-file type (d for directory, l for linked file, c for character device (input / output) file, b block device (storage) file-ordinary file) rwx, rmurx, rmae x represent sovereign limits (here, readable, writable and executable), group permissions (here, readable and executable), Other permissions (in this case, readable and executable) 4-number of subdirectories first root-- owner
5. The second root-- belonging to group 73-- 22:03 on October 30-- creation time note-- directory name (file) 4. Set permissions for files and directories chmod command (- R recursion) chmod [ugoa] [+-=] [rwx] chmod nnn files or directories (preferred) / / the following is the permission operation for files [root@lokott note] # touch 2.sh [root@lokott note] # ls-l 2.sh / / 2.sh permission is 644Murray. 1 root root 0 October 31 21:41 2.sh [root@lokott note] # chmod uplix 2.sh [root@lokott note] # ls-l 2.sh-rwxr--r--. 1 root root 0 October 31 21:41 2.sh [root@lokott note] # chmod ugo+w 2.sh [root@lokott note] # ls-l 2.sh-rwxrw-rw-. 1 root root October 31 21:41 2.sh [root@lokott note] # chmod 655 2.sh [root@lokott note] # ls-l 2.sh-rw-r-xr-x. 1 root root October 31 21:41 2.sh// below is the permission operation on the directory [root@lokott note] # ll / / ll is the total amount of aliases for ls-l-color 8-rwxrwxrwx. 1 root root 0 October 31 21:40 1.txt-rw-r-xr-x. 1 root root 0 October 31 21:41 2.sh-rwxrwxrwx. 1 root root 286 October 30 22:03 ifcfg-ens33drwxrwxrwx. 2 root root 26 October 23 13:20 linux-cmd-rwxr-xr-x. 1 root root 30 October 30 22:02 readme.txtdrwxrwxrwx. 2 root root 173.Oct 30 21:56 shelldrwxr-xr-x. 2 root root 6 October 31 21:38 test [root@lokott note] # which ll alias ll='ls-l-color=auto' / usr/bin/ls [root@lokott note] # chmod 777 test/ change permission to 777 [root@lokott note] # ll total usage 8-rwxrwxrwx. 1 root root 0 October 31 21:40 1.txt-rw-r-xr-x. 1 root root 0 October 31 21:41 2.sh-rwxrwxrwx. 1 root root 286 October 30 22:03 ifcfg-ens33drwxrwxrwx. 2 root root 26 October 23 13:20 linux-cmd-rwxr-xr-x. 1 root root 30 October 30 22:02 readme.txtdrwxrwxrwx. 2 root root 173.Oct 30 21:56 shelldrwxrwxrwx. 2 root root 6 October 31 21:38 test [root@lokott note] # touch test/1.sh [root@lokott note] # ls-l test/1.sh-rw-r--r--. 1 root root October 31 21:50 the permissions of the test/1.sh / / directory have nothing to do with its subdirectories and file permissions unless recursively-R [root@lokott note] # chmod 777-R test/ recursively change permissions that is, all file permissions of test and its subdirectories are 777 [root@lokott note] # ls-l test/1.sh-rwxrwxrwx. 1 root root 0 October 31 21:50 test/1.sh
If you give subordinate groups and other users only write permission (622), you can force writes, but the original content will be overwritten!
[root@lokott test] # pwd / / the absolute path of the current directory / opt/test [root@lokott test] # ll / / displays the details of the total amount of 8 Murray Rafael. 1 root root 13 October 31 16:33 1.txt / / all user rights except root are read-only-rw--w--w-. 1 root root 18 October 31 18:33 2.txt / / the rest of the user rights except root are write-only [root@lokott test] # cat 1.txt tehsdahello [root@lokott test] # cat 2.txt / / the contents of the original 2.txt here are as follows: 2313542222244878 [root@lokott lisi] # su-lisi / / switch to lisi user's last login October 31 22:36:45 on CST 2019pts/1 [lisi@lokott ~] $cd / opt/test/ [lisi@lokott test] $ll / / No permission for ls ls: unable to open directory.: insufficient permissions [lisi@lokott test] $cat 1.txt / / indicates that you can view 1.txt content tehsdahello [lisi@lokott test] ] $vim 1.txt / / attempt to write data [lisi@lokott test] $cat 1.txt / / can wq! Forced save and exit, resulting in tehsdahellodadaasdaadas [lisi@lokott test] $cat 2.txtcat: 2.txt: insufficient permissions [lisi@lokott test] $vim 2.txt [lisi@lokott test] $cat 2.txt / / seems to be available after forced data writing, because the owner is lisi But if / / the owner is a root user, the lisi user cannot view ssdad dsawdad [lisi@lokott test] $ls-l 2.txtMurray RWM when the lisi user logs in. 1 lisi lisi 14 October 31 22:45 2.txt// uses the echo command to redirect and append data to the text [lisi@lokott test] $echo "123123" > 2.txt [lisi@lokott test] $cat 2.txt123123 [lisi@lokott test] $echo "123456" > > 2.txt [lisi@lokott test] $cat 2.txt123123123456 [lisi@lokott test] $su password: [root@lokott test] # ls-l Total usage 8Murray. 1 lisi lisi 27 October 31 22:43 1.txtMui RW Muhami. 1 lisi lisi 14 October 31 22:47 2.txt [root@lokott test] # cat 2.txt 123123123456 [root@lokott test] # 5. Set the attribution of files and directories to chownchown master chown: generic group chown master: generic group [root@lokott opt] # ls-l total dosage 0 Murray Rafael. 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 root root 32 October 31 22:45 test [root@lokott opt] # chown lisi test [root@lokott opt] # ls-l total dosage 0Mel RW, RK, R, M, V, C, C, B, C, B. 2, root root 32, test [root@lokott opt] # chown lisi test [root@lokott opt] # ls-l 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 lisi root 32 October 31 22:45 the owner of the test / / test directory itself becomes lisi, but the group has not changed [root@lokott opt] # chown root:lisi test [root@lokott opt] # ls-l total dosage 0Murray. 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 root lisi 32 October 31 22:45 the owner of the test / / test directory itself becomes root and the group becomes chown [root @ root] # chown: root test [root@lokott opt] # ls-l the total amount is 0murr, Murray, Murray. 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 root root 32 October 31 22:45 test / / test directory itself becomes root6. Permission mask umask
Function: control the permissions of newly created files or directories-note that they are only valid for newly created files or directories
The default permission to remove umask is
[root@lokott opt] # mkdir umasktest [root@lokott opt] # umask 000000 umasktest/ [root@lokott opt] # ll total consumption 0Murray RWM. 1 root root 0 October 31 16:19 demo01.txtdrwxr-xr-x. 2 root root 6 March 26 2015 rhdrwx-wx-wx. 2 root lisi 32 October 31 22:45 testdrwxrwxrwx. 2 root root 6 October 31 23:26 umasktest [root@lokott opt] # cd umasktest/ [root@lokott umasktest] # mkdir 2019 [root@lokott umasktest] # touch 1.txt [root@lokott umasktest] # ll total usage 0kyu RWFLY. 1 root root October 31 23:26 1.txt / / File permission is 666drwxrwxrwx. 2 root root 6 October 31 23:26 2019 / / the directory permissions are 777 [root@lokott umasktest] # cd. [root@lokott opt] # umask 111umasktest/ the original 1.txt and 2019 permissions have not changed! [root@lokott opt] # cd umasktest/ [root@lokott umasktest] # mkdir 2018 [root@lokott umasktest] # touch 2.txt [root@lokott umasktest] # ll total dosage 0 Murray RWMI. 1 root root 0Oct 31 23:26 1.txtdrwmuri rwwmuri. 2 root root 6 October 31 23:28 2018 / / the directory permission is 666drwxrwxrwx. 2 root root 6 October 31 23:26 2019 RW Murray RW Murray. 1 root root October 31 23:28 2.txt / / 2.txt permission is 666 [root@lokott umasktest] # cd.. [root@lokott opt] # umask 666 umasktest/ [root@lokott opt] # cd umasktest/ [root@lokott umasktest] # mkdir 2017 [root@lokott umasktest] # touch 3.txt [root@lokott umasktest] # ll total usage 0Murray RWMuir. 1 root root 0 October 31 23:26 1.txtd--x--x--x. 2 root root 6 October 31 23:29 2017 / / the directory permission is 111drwMurrwMurrwMel. 2 root root 6 October 31 23:28 2018drwxrwxrwx. 2 root root 6 October 31 23:26 2019 RW Murray RW Murray. 1 root root 0Oct 31 23:28 2.txtmuri. 1 root root 0 October 31 23:29 3.txt / / File 3.txt permissions are all 0 [root@lokott umasktest] # umask / / View umask value 0666