Differences between CentOS commands usermod, chown, and chmod
For Linux beginners, I often confuse the differences between chown and chmod. This blog is for reference.
Usermod is used to modify the UID, GID, and groups of a user. Usage:
Usermod-u 9999 testuser // change the UID of testuser to 9999 usermod-g 9999 testuser // change the GID of testuser to 9999 usermod-G 9999 testuser // change the additional group of testuser change to 9999
Chown is used to modify the user and group of a file. Usage:
Chown-R root: root/tmp/tmp1 // The-R parameter simultaneously modifies the user and group of the subdirectory.
Chmod is used to modify the access permissions of files or directories.-Rwxrwxrwx
Column. Usage:
Chmod [-Rf] u + w file name // Add write permission to the user owner chmod [-Rf] 777 file name // grant 777 permission to the file
Operation object
Operation object meaning "user" in the utable, that is, the owner g of a file or directory represents "same group users ", that is, all users with the same group ID as the file owner o Represents "other users" a represents "all users ". It is the default value of the system.
Operation symbol
Operation symbol meaning + Add a permission-cancel a permission = grant a given permission and cancel all other permissions (if any)
Permission
Permission symbol meaning r readable w writable x executable