Use the chown command of linux to change file or directory users and user groups
Editor to share with you the use of linux chown command to change the file or directory users and user groups, I hope you will learn a lot after reading this article, let's discuss it!
Linux/Unix is a multi-user and multi-tasking operating system, and all files have owners. Use the chown command to change the owner of the specified file to the specified user or group, the user can be a user name or user ID, the group can be a group name or group ID, the file is a list of files to change permissions separated by spaces, and wildcards are supported. Generally speaking, this directive is only used by system administrators (root), and ordinary users do not have the right to change the files and groups to which they belong.
Syntax format: chown [parameters]
Common parameters:
-R makes the same owner change to all files and subdirectories in the current directory-c shows the change action only if the file owner has indeed changed-f if the file owner cannot be changed, do not display an error message-h only make changes to the link, not the file that the link actually points to-v shows the details of the owner's change-help display auxiliary instructions-version display version
Reference example
Change the test.txt file user group and users to bin:
[root@linuxcool] # ll test.txt.bz2-rw-r--r-- 1 root root 56 Jul 22 20:17 test.txt.bz2 [root@linuxcool] # chown bin:bin test.txt.bz2 [root@linuxcool] # ll test.txt.bz2-rw-r--r-- 1 bin bin 56 Jul 22 20:17 test.txt.bz2
Show change actions:
[root@linuxcool ~] # ll test.txt-rw-r--r-- 1 root root 45 Jul 22 21:11 test.txt [root@linuxcool ~] # chown-c bin:bin test.txt changed ownership of `test.txt' to bin:bin
Change the owner of all files in the current directory to linuxcool and the user group to linuxcoolgroup:
[root@linuxcool] # chown-R linuxcool:linuxcoolgroup * after reading this article, I believe you have a certain understanding of using linux's chown command to change files or directories. Users and user groups want to know more about it. Welcome to follow the industry information channel. Thank you for reading!