WE CODE NOW
  • Home 
  • Blog 
  • Guides 
Guides
  1. Home
  2. Guides
  3. Linux Command Series
  4. Linux File Permissions and Ownership

Linux File Permissions and Ownership

Posted on June 1, 2024  (Last modified on June 8, 2024) • 1 min read • 196 words
Linux
 
File Permissions
 
Ownership
 
Chmod
 
Chown
 
Linux
 
File Permissions
 
Ownership
 
Chmod
 
Chown
 
Share via

Understand file permissions and ownership in Linux, including how to view, change, and manage permissions and ownership using chmod, chown, and groups.

On this page
  • Viewing Permissions and Ownership
    • Using ls
  • Changing Permissions
    • Using chmod
    • Symbolic Mode
  • Changing Ownership
    • Using chown
    • Using chgrp
  • Managing Groups
    • Creating Groups
    • Adding Users to Groups
  • Conclusion

Linux File Permissions and Ownership  

File permissions and ownership are fundamental concepts in Linux. This guide covers how to view, change, and manage file permissions and ownership using chmod, chown, and groups.

Viewing Permissions and Ownership  

Using ls  

Use ls -l to view file permissions and ownership.

ls -l filename

Permissions are displayed as rwx (read, write, execute).

Changing Permissions  

Using chmod  

Use chmod to change file permissions.

chmod 755 filename

Permissions can be set using numeric or symbolic modes.

Symbolic Mode  

Change permissions using symbolic mode.

chmod u+x filename
chmod g-w filename
chmod o+r filename

Changing Ownership  

Using chown  

Use chown to change file ownership.

chown user:group filename

Using chgrp  

Use chgrp to change the group ownership.

chgrp groupname filename

Managing Groups  

Creating Groups  

Use groupadd to create a new group.

sudo groupadd groupname

Adding Users to Groups  

Use usermod to add a user to a group.

sudo usermod -aG groupname username

Conclusion  

Understanding and managing file permissions and ownership are crucial for system security and administration. Practice using chmod, chown, and managing groups to effectively control access to files and directories in Linux.

 Managing Services with Systemd in Linux
Linux System Logging and Log Management 
On this page:
  • Viewing Permissions and Ownership
    • Using ls
  • Changing Permissions
    • Using chmod
    • Symbolic Mode
  • Changing Ownership
    • Using chown
    • Using chgrp
  • Managing Groups
    • Creating Groups
    • Adding Users to Groups
  • Conclusion
Copyright © 2024 WE CODE NOW All rights reserved.
WE CODE NOW
Link copied to clipboard
WE CODE NOW
Code copied to clipboard