how to alternate File ownership & groups in Linux

0

File ownership and teams for files are basic to the Linux working system. each file in Linux is managed by using a particular user and a particular workforce. determine Who Owns the File, Then Use both chown or chgrp show possession and team data the usage of the following command: 1 2 ls -l file.txt -rw-rw-r– 1 root www-information 0 Feb 25 15:fifty one file.txt This file is owned through the foundation person and belongs to the www-information crew. altering the possession of a File using chown which you can trade the ownership of a particular file the use of the chown command. For safety functions most effective, the foundation person or participants of the sudo staff may switch ownership of a file. to change the ownership of a file: 1 2 3 four chown robert file.txt   ls -l file.txt -rw-rw-r– 1 robert www-data zero Feb 25 15:fifty one file.txt The file file.txt is now owned through Robert. through default, chown follows symbolic hyperlinks and adjustments the proprietor of the file pointed to by the symbolic hyperlink. for those who are looking to trade ownership of all information inside of a directory, you should use the -R choice. 1 chown -R consumer directory/ changing the workforce possession of a File the usage of chgrp All customers on the gadget belong to at the least one workforce. you will see out which teams you belong to the usage of the next command: 1 groups username that you may then alternate the team possession of a particular file the usage of the chgrp command: 1 2 3 four chgrp webdev file.txt   ls -l file.txt -rw-rw-r– 1 robert webdev zero Feb 25 15:fifty one file.txt The file file.txt now belongs to the webdev workforce. changing each the owner and the workforce using chown which you can alternate each the owner and group of a file using just the chown command. 1 2 3 four chown tito:editors file.txt   ls -l file.txt -rw-rw-r– 1 tito editors zero Feb 25 15:fifty one file.txt The file file.txt is now owned via Tito and belongs to the editors staff.

Share.

Leave A Reply