Intro To 'chgrp' Command In Linux
2023-05-03 - By Robert Elder
I use the 'chgrp' command to change the group ownership of files and directories. For example, here is a file that currently belongs to the group 'robert':
ls -l file1.txt
-rw-rw-r-- 1 robert robert 0 May 4 10:49 file1.txt
This command will change the group ownership of file1.txt from 'robert' to 'dialout':
chgrp dialout file1.txt
Below, you can see how the group has been updated to 'dialout':
ls -l file1.txt
-rw-rw-r-- 1 robert dialout 0 May 4 10:49 file1.txt
You can see which groups the current user belongs to by running the 'groups' command:
groups
and the output is as follows:
robert adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare tomcat
If the current user is not the owner of the file, but belongs to a group that owns the file, then the file permissions located at this position will apply:
Using the 'ls' command, you can see that the read write, but not execute permissions are enabled for the dialout group:
ls -l file1.txt
-rw-rw-r-- 1 robert dialout 0 May 4 10:49 file1.txt
Let's add the execute permission for the group now:
chmod g+x file1.txt
ls -l file1.txt
-rw-rwxr-- 1 robert dialout 0 May 4 10:49 file1.txt
Now, let's take away all of the group permissions entirely:
chmod g-rwx file1.txt
ls -l file1.txt
-rw----r-- 1 robert dialout 0 May 4 10:49 file1.txt
And that's why the 'chgrp' command is my favourite Linux command.
Intro To 'stty' Command In Linux
Published 2023-10-04 |
$1.00 CAD |
Intro To 'nproc' Command In Linux
Published 2023-07-15 |
Intro To 'comm' Command In Linux
Published 2023-09-06 |
How To Force The 'true' Command To Return 'false'
Published 2023-07-09 |
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21 |
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01 |
Intro To 'chroot' Command In Linux
Published 2023-06-23 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|