0% found this document useful (0 votes)
30 views2 pages

Managing File System Permissions From The Command Line: Changing File and Directory User or Group Ownership

The document discusses Linux file system permissions and how to manage them from the command line using the chmod, chown, and umask commands. It provides examples of using chmod to recursively set permissions on directories and files, using chown to change file and directory ownership, and using umask to set default permissions for a user. Special permissions like suid, sgid, and sticky bits are also explained.

Uploaded by

pmmanick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Managing File System Permissions From The Command Line: Changing File and Directory User or Group Ownership

The document discusses Linux file system permissions and how to manage them from the command line using the chmod, chown, and umask commands. It provides examples of using chmod to recursively set permissions on directories and files, using chown to change file and directory ownership, and using umask to set default permissions for a user. Special permissions like suid, sgid, and sticky bits are also explained.

Uploaded by

pmmanick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Managing File System Permissions from the

Command Line
The chmod command supports the -R option to recursively set permissions on the files in an
entire directory tree. When using the -R option, it can be useful to set permissions
symbolically using the X option.

u, g, o, a (for user, group, other, all)

chmod -R g+rwX demodir

chmod go-rw file1 Remove read and write permission for group and other on file1:

chmod a+x file2 Add execute permission for everyone on file2:

chmod 644 samplefile Set read and write permissions for user, read permission for
group and other, on samplefile

chmod 750 sampledir

Changing File and Directory User or Group Ownership


chown student test_file

chown -R student test_dir

The chown command can also be used to change group ownership of a file by preceding the
group name with a colon (:). For example, the following command changes the group
test_dir to admins:

[root@host ~]# chown :admins test_dir

The chown command can also be used to change both owner and group at the same time by
using the owner:group syntax. For example, to change the ownership of test_dir to
visitor and the group to guests, use the following command:

[root@host ~]# chown visitor:guests test_dir


Special Permissions

Use the echo command to change the default umask for the operator1 user to 007.

echo "umask 007" >> ~/.bashrc


cat ~/.bashrc

u+s
File executes as the user that
(suid) owns the file, not the user No effect.
that ran the file.
g+s File executes as the group Files newly created in the directory have their group
(sgid) that owns the file. owner set to match the group owner of the directory.
o+t
Users with write access to the directory can only
(sticky) No effect. remove files that they own; they cannot remove or
force saves to files owned by other users.

You might also like