DEV Community

K-Sato
K-Sato

Posted on • Edited on

Understanding Linux Permissions

Table of contents

Introduction

The multi-user capability of Unix-like systems is a feature that is deeply ingrained into the design of the operating system.

File Permissions

On a Linux system, each file and directory is assigned access rights for the owner of the file.

You can check the permission settings with ls -l.

$ ls -l 
drwxr-xr-x. 13 root  root  1027 Jan  3 12:32 bin/cat
Enter fullscreen mode Exit fullscreen mode

Let's explore what drwxr-xr-x. 13 root root 1077 Jan 3 12:32 bin/cat means one by one.

Command Meaning
d File Type
rwxr-xr-x. File Mode
13 Number of links
root The owner of the file
root The group the file belongs to
1027 Size of the file
Jan 3 12:32 Time Stamp
bin/cat The name of the file/directory

File Type

Command File Type
- File
d Directory
l Symbolic Link

File Mode

The r letter means the user has permission to read the file/directory. The w letter means the user has permission to write the file/directory. And the x letter means the user has permission to execute the file/directory.

Command Meaning
r read
w write
x execute
- not allowed

Let's take a look at the 9 letters in the command.
The first 3 letters show the permissions for the file owner, the second 3 letters show the permissions for the group owner and the last 3 letters show the permissions for other users.

rwx/ r-x/ r-x/

Owner: rwx
Group: r-x
Users: r-x
Enter fullscreen mode Exit fullscreen mode

Change File Modes

The chmod command is used to change the permissions of a file or directory.

Octal Mode

Each permission may be specified with an octal number: read = 4; write = 2; execute = 1; no permission = 0.

Meaning  Number
read(r) 4
write(w) 2
execute(x) 1

Example

The command below means giving permissions to read(4), write(2) and execute(1) to the owner and permissions to read(4) and execute(1) to the group user and permissions to read(4) to other users.

chmod 754 myfile
Enter fullscreen mode Exit fullscreen mode

Symbolic Mode

The below is the basic syntax of chmod.

% chmod who operator permission filename
Enter fullscreen mode Exit fullscreen mode

You can use the following commands to change modes.

Command Meaning
u(user) user access
g(group) group access
o(other) other access
a(all) user, group, and other access
Command Meaning
+ add specified permissions
- remove specified permissions
= set the specified permissions

Example

In the following example, read permission are taken away from others.

% chmod o-r filea
Enter fullscreen mode Exit fullscreen mode

In the following example, read and execute permissions are added for user, group, and others.

$ chmod a+rx fileb
Enter fullscreen mode Exit fullscreen mode

In the following example, read, write, and execute permissions are assigned to the group.

$ chmod g=rwx filec
Enter fullscreen mode Exit fullscreen mode

References

Top comments (76)

Collapse
 
david_j_eddy profile image
David J Eddy

When it comes to Linux I make it a point to read even intro level articles like this one. Why? 'cause I am constantly learning new things, like I did here.

Thank you for this. Keep up the good posting!

Collapse
 
k_penguin_sato profile image
K-Sato

Thank you for your kind words!

Collapse
 
ferricoxide profile image
Thomas H Jones II

If you really want to get into powerful permissioning systems, take a look at extended filesystem access control lists (via the setfacl and getfacl utilities), extended attributes (xattrs managed via the chattr and lsattr commands) and, the ultimate cause of headaches, SELinux.

If you're running an Internet-facing system, these are all security-extensions that you want to be reasonably well versed in.

Collapse
 
aghost7 profile image
Jonathan Boudreau

There's also suid/sgid permissions. Normally, when you execute a program, it will run as the user which called it. suid will instead run the program as the owner of the file. For example, if you are logged in as user developer and try to execute a suid program owned by root, it will execute as root instead of developer.

su, sudo, passwd rely on suid to work.

Collapse
 
ferricoxide profile image
Thomas H Jones II

The extension to suid-/sgid-enabled operations being that, when you run auditing services on a system, actions are logged both by actual executing-user and effective executing user.

Collapse
 
daisp profile image
Danny Priymak • Edited

This article did not introduce anything brand new to me, but nonetheless very concise and well written!
Thank you for sharing.

Collapse
 
k_penguin_sato profile image
K-Sato

Thank you for taking the time to read it!!

Collapse
 
manish_singh_91409eb2867f profile image
Manish Singh

Understanding Linux permissions is crucial for security and efficiency. Your insights simplify a complex topic, empowering users to manage files effectively. I diagnose and repair technical errors with great accuracy. Just as mastering Linux permissions enhances system control, resolving Canon Printer errors like Support Code 5100 and Error 5200 ensures seamless printing.

If you’re encountering a Canon printer support code 5100 or Canon error 5200, these issues typically relate to problems with the printer’s printhead or ink system. The Canon printer support code 5100 often appears when there is a paper jam, an obstruction, or if the printhead has become misaligned or clogged. To resolve this, turn off the printer, carefully check for any paper or debris blocking the printhead, and gently clean the printhead with a soft cloth. After ensuring there are no blockages, restart the printer to see if the issue persists.

On the other hand, Canon error 5200 usually occurs due to issues with the ink cartridges or printhead. This error can sometimes appear when the ink cartridge is improperly installed or when there is insufficient ink. Try removing and reinstalling the ink cartridges to ensure they are properly seated in place. Additionally, check the printer for any other obstructions that may be causing the error.

If neither solution works for your Canon printer support code 5100 or Canon error 5200, updating the printer’s firmware or contacting Canon’s support team for further assistance may be necessary. By addressing these common issues promptly, you can restore your printer to its normal functioning.

Collapse
 
arunschirps profile image
Arun

From what I know, I guess you can forgo "a" in the "a+rx".

Collapse
 
k_penguin_sato profile image
K-Sato

Thank you for sharing your knowledge:)!

Collapse
 
manish_singh_91409eb2867f profile image
Manish Singh

Your insightful article on Linux Permissions is both inspiring and educational, making complex concepts accessible. Understanding permissions empowers users to manage security effectively.

For those navigating HP Envy printer issues, mastering troubleshooting is just as essential as understanding Linux permissions. Learn how to resolve common HP Envy 4500, 4520, 5530, and 6000 printing problems in my latest blog.

If your HP Envy 4500 will not print, HP Envy 4520 will not print, HP Envy 5530 will not print, or HP Envy 6000 printer not printing, you are not alone. These are common issues faced by users, but with a few simple troubleshooting steps, you can get your printer back to working properly.

First, check the basics. Ensure that your HP Envy printer is properly connected to your computer or network, whether through Wi-Fi or USB. If your printer is connected wirelessly, check the Wi-Fi signal and ensure your printer is on the correct network. If it's a USB connection, make sure the cable is securely plugged into both the printer and the computer.

Next, check the printer queue on your computer. Sometimes, pending print jobs can block new tasks from being processed. Clear any old or stuck print jobs from the queue to see if that resolves the issue.

Another potential cause for the HP Envy 4500 will not print, HP Envy 4520 will not print, HP Envy 5530 will not print, or HP Envy 6000 printer not printing problem is low or empty ink cartridges. Ensure that your printer has sufficient ink and that the cartridges are properly installed.

Finally, make sure your printer is set as the default printer on your computer. In some cases, the printer may not respond if another device is selected as the default. If the issue persists, restart both the printer and your computer, and check for any available software or firmware updates for your printer model.

By following these troubleshooting steps, you can resolve the issue of your HP Envy 4500, HP Envy 4520, HP Envy 5530, or HP Envy 6000 printer not printing and get your device back to full functionality. If these solutions don't work, you may need to contact HP support for further assistance.

Collapse
 
manish_singh_91409eb2867f profile image
Manish Singh

Appreciating your insightful take on Linux permissions, empowering users with control and security! Your breakdown clarifies a complex topic brilliantly. I assist users by troubleshooting their technical concerns. Bridging Linux mastery with seamless streaming, let's tackle Troubleshooting Common NFL Live Streaming Problems on YouTube TV and YouTube TV App Crashes for uninterrupted game-day action.

If you're experiencing NFL live streaming problems on YouTube TV, you're not alone. These issues can stem from a variety of factors, such as poor internet connection, software glitches, or server outages. To resolve NFL live streaming problems on YouTube TV, start by checking your internet connection to ensure it’s stable and fast enough for streaming. If the issue persists, try restarting the YouTube TV app or your device. Another helpful tip is to clear the app's cache or update it to the latest version.

How to Resolve NFL login problems on YouTube TV, make sure that your account credentials are correct. Sometimes, logging out and logging back in can resolve minor authentication errors. Additionally, ensure that your subscription is active and that there are no billing issues preventing you from accessing content.

Another common issue users face is the YouTube TV app crash. If your app is constantly crashing, try uninstalling and reinstalling it, or restart your device to clear temporary issues. If you encounter a YouTube TV black screen, this could be a result of outdated software or a connection issue. Restart the app, check for updates, and ensure that your device meets YouTube TV’s system requirements.

By following these steps, you should be able to resolve NFL live streaming problems on YouTube TV, NFL login problems, YouTube TV app crashes, and the YouTube TV black screen issue.

Collapse
 
djassam profile image
Mike Boro

This concise guide on Linux permissions provides essential insights for users. Demystifying the intricacies, it empowers individuals to navigate and control their system effectively. A valuable resource for anyone seeking clarity on the nuanced world of Linux permissions. TC Lottery MOD APK

Collapse
 
manish_singh_91409eb2867f profile image
Manish Singh

Understanding Linux permissions is crucial for system security and efficiency. Your detailed breakdown is inspiring for both beginners and experts. I am experienced in troubleshooting system-related problems. For those troubleshooting Canon printer errors like B200, B203, and 5200 on MG2522 setups, mastering permissions can also aid in debugging system-level issues efficiently.

If you're facing issues with your Canon MG2522 setup, or encountering errors like Canon B200 error, Canon printer error B203, or Canon 5200 error, you're not alone. These errors can be frustrating, but with some simple troubleshooting, you can often fix the problem and get your printer back to working condition.

The Canon B200 error typically indicates an issue with the printer's printhead or ink system. It might occur when the printhead is clogged, improperly installed, or the ink cartridges are not seated correctly. To resolve this, first turn off the printer and remove the ink cartridges. Then, gently clean the printhead with a soft cloth and reinsert the cartridges. If the error persists, the printhead may need to be replaced, which can be done through Canon's official service centers.

If you're dealing with Canon printer error B203, it’s often related to a communication problem between the printer and the computer, or an issue with the printhead or ink cartridges. Try restarting both the printer and your computer, ensuring all connections are secure. It’s also worth checking the ink levels and ensuring that the cartridges are installed correctly. If this doesn’t work, reinstalling the printer drivers or using the Canon software to reset the printer settings can help resolve the error.

For the Canon 5200 error, this error typically occurs due to a paper jam, a problem with the printhead, or incorrect ink cartridge placement. Check the printer for any paper stuck inside and remove it carefully. Also, make sure the ink cartridges are correctly installed and that there are no obstructions blocking the printhead. If you still encounter the Canon 5200 error, consider performing a hard reset on the printer by unplugging it for about 10 minutes and then reconnecting it.

Once you've addressed these errors, ensure that your MG2522 setup is correctly configured. Double-check that you’ve followed all steps for connecting the printer to your device, and that the necessary drivers are installed on your computer. If you continue to face issues, refer to the user manual or visit Canon’s official support site for additional help and resources.

By following these steps, you should be able to resolve common errors like Canon B200 error, Canon printer error B203, and Canon 5200 error, and complete your MG2522 setup with ease.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.