Linux, you can use the Chown command to modify the folder's user rights.
1. Log in to Linux with normal user A, and use Su-to switch to the root user
2. Under root user, you can see the contents of the folder
3. But unable to open git folder through file system
Prompt cannot display remote folder (should be insufficient permissions)
This is because, with ordinary user A in the command line to switch to the root user, the permissions of the file system or the normal user permissions, you need to modify the folder's user rights.
4. Switch to the directory where the folder is located, and use the Chown command to modify the permissions. (If the folder also contains folders, you can add the-r parameter to the Chown command)
Command: # chown a-r git
Chown Command Explanation
Chown the owner of the specified file to the specified user or group, the user can be either a user name or a user ID; a group can be a group name or a group ID; a file is a space-separated list of files to change permissions, and wildcard characters are supported. System administrators often use the Chown command to give users permission to use a file after copying it to another user's directory.
1. Command format:
chown [Options] ... Owner [: [Group]] file ...
2. Command function:
Change the file owner and group by Chown. You can use the user name and user identification number settings when you change the owner or group of the file. Ordinary users cannot change their files to other owners. Its operation permissions are generally administrators.
3. Command parameters:
Necessary parameters:
-C Displays information about the changed parts
-F Ignore Error messages
-H Fix Symbolic link
-R handles all files in the specified directory and its subdirectories
-V displays detailed processing information
-deference acts on the point of a symbolic link, not the linked file itself
Select parameters:
--reference=< directory or File > Specify the directory/file as the reference, the operation of the file/directory to the reference file/directory of the same owner and group
--from=< Current User: Current group > changes only if the current user and group are the same as the specified user and group
--HELP Display Help information
--version displaying version information
4. Usage examples:
Example 1: Changing Owners and groups
Command:
Chown Mail:mail Log2012.log
Output:
[[email protected] test6]# ll---xr--r--1 root users 302108 11-30 08:39 linklog.log---xr--r--1 root users 302108 11-30 08 : log2012.log-rw-r--r--1 root users 11-30 08:39 log2013.log-rw-r--r--1 root users 0 11-30 08:39 Log2014.log -rw-r--r--1 root users 0 11-30 08:39 log2015.log-rw-r--r--1 root users 0 11-30 08:39 log2016.log-rw-r--r--1 roo T users 0 11-30 08:39 log2017.log[[email protected] test6]# chown mail:mail log2012.log [[email protected] test6]# ll- --xr--r--1 root users 302108 11-30 08:39 linklog.log---xr--r--1 mail mail 302108 11-30 08:39 log2012.log-rw-r--r--1 Root users 11-30 08:39 log2013.log-rw-r--r--1 root users 0 11-30 08:39 log2014.log-rw-r--r--1 root users0 11-30 08:39 log2015.log-rw-r--r--1 root users 0 11-30 08:39 log2016.log-rw-r--r--1 root users 0 11-30 08:39 Log2017.log[[email protected] test6]#
Description
Example 2: Changing file owners and groups
Command:
Chown Root:log2012.log
Output:
[root@localhost test6]# ll
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 root users 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
[root@localhost test6]# chown mail:mail log2012.log
[root@localhost test6]# ll
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 mail mail 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
[root@localhost test6]#
Description
Example 3: Changing file groups
Command:
Chown:mail Log2012.log
Output:
[root@localhost test6]# ll
Total 604
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 mail mail 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
[root@localhost test6]# chown root: log2012.log
[root@localhost test6]# ll
Total 604
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 root root 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
[root@localhost test6]#
Description
Example 4: Changing the owner and group of all files in the specified directory and its subdirectories
Command:
Chown-r-V Root:mail test6
Output:
[root@localhost test6]# ll
Total 604
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 root root 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
[root@localhost test6]# chown :mail log2012.log
[root@localhost test6]# ll
Total 604
---xr--r-- 1 root users 302108 11-30 08:39 linklog.log
---xr--r-- 1 root mail 302108 11-30 08:39 log2012.log
-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log
-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
How to modify the folder's user rights in Linux chown command