In this part, we'll learn how to change ownership of files and folders.
1.COMMAND:
chown
DESCRIPTION:
change file owner and group
SYNOPSIS
chown [OPTION]... [OWNER][:[GROUP]] FILE...
OPTION:
-R, --recursive
operate on files and directories recursively
Example:
piniheaven@fish:~/Documents$ ls
assemble C++primer_ex C++primer_note Ebook linux QT_ex QT_note tutorial
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 piniheaven piniheaven 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown jack ./tutorial/essay.txt #change essay.txt's owner
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown piniheaven:Students ./tutorial/essay.txt #change essay.txt's owner and group
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 piniheaven Students 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown -R jack:piniheaven ./tutorial #change all files's owner and group in tutorial directory
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt
1.COMMAND:
chown
DESCRIPTION:
change file owner and group
SYNOPSIS
chown [OPTION]... [OWNER][:[GROUP]] FILE...
OPTION:
-R, --recursive
operate on files and directories recursively
Example:
piniheaven@fish:~/Documents$ ls
assemble C++primer_ex C++primer_note Ebook linux QT_ex QT_note tutorial
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 piniheaven piniheaven 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown jack ./tutorial/essay.txt #change essay.txt's owner
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown piniheaven:Students ./tutorial/essay.txt #change essay.txt's owner and group
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 piniheaven Students 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents$ sudo chown -R jack:piniheaven ./tutorial #change all files's owner and group in tutorial directory
piniheaven@fish:~/Documents$ ls -l ./tutorial/
total 0
-rw-rw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt