This command is used to change the ownership of a file/folder or even multiple files/folders for a specified user/group. chown owner_name file_name
$ chown user1 script.sh
change owner name
chown owner_name file name
to change the ownership
chown master file1.txt
if you are a user and you want to change ownership to root then use sudo before syntax
sudo chown root file1.txt
reports when a file change is made
chown -c master filed1.txt
it is used to show the verbose informarion for every processed file
chown -v master file1.txt
it suppresses most of the error messages.
chown -f master file1.txt
change the owner and group
chown master: group 1 greek 1
change the owner and group
chown master: group 1 greek 1
change the owner from particular ownership only
chown --from= master root greek1
change the owner from particular ownership only
chown --from= master root greek1
change group from a particular group
chown --from =group 1 root greek 1
copy ownership of one file to another file
chown --reference=grrek1 greek2
change ownership of multiplw files
chown master: group greek2 greek 3
it is used to show the verbose information for every file procesed
chown -v master file1.txt
to change group oownership
chown :group1 file1.txt
change the owner from a particular owner
chown --from=master root greek 1
change group from a particular group
chown --from=; froup1 root greek 1
copy ownership of one file to another file
chown --refrence= greek1 greek2
changes owner of the file to root
chown root file1.txt
changing the file1 to mygroup
chown mygroup file1
it shows the currenr=t owner and group and also to which owner and group it is changing
chown --from pavani:mygrouop root:friends file1
we can get the owner or group information
chown --refrence=ref file1
display details of perations it performed
chown root:pavani link1 -v
to view the owner and the group of the file
chown ls -l colors.txt
it prints the information only if the changes are made in the owner or the directory file
chown -c mygroup: file1
a symbolic link of a file is created
$ lnn -s root linux
ownership of a symbolic link file using chown command.-h option is used to apply the changes.
chown -h pilot linux
using the directory name we change the owner or group of a directory by using the chown command
chown linux folder
hides the error message in the output when the file or directory is not found
chown -f root colors.txt
changes the owner of the multiple files
$ chown root colors.txt numbers.txt yesh.txt
changes the group file using group id instead of group name
$id -g root
$ chown: 100 pavani