The chown
command stands for ‘Change Owner’; it’s used to change the owner and personnel of knowledge, directories, and symbolic links inside the tool.
To better understand its function, it’s vital to grab that throughout Linux, each report and list is assigned 3 varieties of owner attributes:
- Client: The Client is the one who owns the report,
- Group: Group accommodates other shoppers who’re inside the report’s personnel, and ,
- Others: Consumers that aren’t inside the report’s personnel.
Every of the ones categories can have different permission levels for finding out, writing, and executing the ideas.
The chown
command implies that you’ll be able to alternate the Client and Group ownership of a report or list.
chown
generally requires administrative (root) privileges to run. Should you’re now not logged in as root, you’ll in all probability need to use sudo
previous than the command, like sudo chown client:personnel filename
, to make changes.
Listed below are some ways to use the chown
command:
1. Change the Owner
The basic syntax for changing the owner is chown owner filename
.
Example :
To change the owner of a report named report.txt
to user1
, it’s essential use:
chown user1 report.txt
2. Change the Owner and Group
You’ll alternate the owner and personnel at the similar time by the use of maintaining aside the owner and personnel with a :
(colon).
Example :
To change the owner of report.txt
to user1
and the personnel
to group1
, it’s essential use:
chown user1:group1 report.txt
3. Change the Owner of a Checklist and Its Contents
You’ll alternate the owner of a list and all its contents using the -R
(or --recursive
) selection.
Example :
To change the owner of a list named dir
and all its contents to user1
, it’s essential use:
chown -R user1 dir
4. Change the Owner of All Knowledge in a Checklist
To change the owner of all data in a list without changing the owner of the list itself or any subdirectories, you’ll be capable to use the *
wildcard.
Example:
chown user1 dir/*
5. Change the Group Best possible
If you want to alternate the group without changing the owner, you’ll be capable to do so by the use of prefixing the group with a :
(colon).
Example:
To change the group of report.txt
to group1
, it’s essential use:
chown :group1 report.txt
6. Change the Owner and Group to the Login Client
You’ll alternate the owner and personnel of a report or list to the login client without specifying the patron name.
Example:
chown $USER:$USER report.txt
The put up How you can Use chown in Linux appeared first on Hongkiat.
Supply: https://www.hongkiat.com/blog/linux-command-chown/
0 Comments