Home  >  Article  >  Operation and Maintenance  >  How to check which user a file belongs to in centos

How to check which user a file belongs to in centos

Barbara Streisand
Barbara StreisandOriginal
2022-02-09 11:13:334783browse

In centos, you can use the ls command to check which user the file belongs to. This command is used to display the contents of the specified directory. When the parameter is set to "-l", you can display the file shape, file permissions and file Owner and other information, the syntax is "ls -l [name...]".

How to check which user a file belongs to in centos

The operating environment of this article: centos 7 system, Dell G3 computer.

How to check which user a file belongs to in centos

In Linux systems, it is often necessary to change the permissions of files. At this time, viewing and modifying the user and user group to which the file belongs is also a very important operation. You can use the following command to view the users and user groups to which all files in a folder belong and their corresponding permissions.

ls -l

Taking my local upload folder as an example, the effect is as shown below:

How to check which user a file belongs to in centos

If you want to modify the user and user group to which a file belongs, you need to use the chown command. You can modify the user group to which the file belongs by using the following command:

chown username file

Among them, username is The user to whom the modified file belongs, file is the file you want to operate. The effect is as follows:

How to check which user a file belongs to in centos

The user group and user to which the file belongs can be modified at the same time through the following commands:

chown username:username file

Among them, the two usernames are new user groups respectively. and users, the effect is as follows:

How to check which user a file belongs to in centos

Recommended tutorial: "centos tutorial"

The above is the detailed content of How to check which user a file belongs to in centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn