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 (87)

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
 
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

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
 
babak_painex_72157a69bd5b profile image
Babak Painex • Edited

This article is a great resource for anyone considering solar-powered surveillance options. The guide on Solar Mobile Surveillance Trailers in Indio explains the benefits of these mobile units and how they offer flexible, eco-friendly security solutions. If you're looking to enhance your security while keeping things green, this is a must-read!

Collapse
 
manish_singh_91409eb2867f profile image
Manish Singh

Your deep dive into Linux permissions is truly inspiring! Understanding file types, modes, and access levels empowers users to navigate Linux efficiently. I am skilled in identifying and correcting technical disruptions. Just as Linux permissions dictate file accessibility, resolving HP printer errors like 49.38.03 and 59.F0 ensures seamless device functionality.

Encountering HP printer errors like 49.38.03 error, 59.F0 error, E0 error, or E4 error can be frustrating, especially when you're in the middle of an important printing task. These error codes generally point to different issues within the printer's system, but there are a few effective ways to troubleshoot and fix them.

The 49.38.03 error in hp is commonly associated with an issue related to firmware or a corrupted print job in the printer's memory. To resolve this, try turning off your printer and unplugging it for a few minutes before powering it back on. This helps clear the printer's memory. If this doesn’t work, you may need to update the printer’s firmware to the latest version from the official HP website. Also, make sure to clear the print queue on your computer to remove any problematic print jobs.

The HP printer 59.F0 error typically relates to a problem with the printer’s fuser or its temperature. This error may be caused by a faulty fuser unit or issues with the electrical components connected to it. Start by turning off the printer, waiting for a few minutes, and then turning it back on. If the problem persists, inspect the fuser for any damage or misalignment. In some cases, replacing the fuser may be necessary.

If you encounter an HP printer E0 error, this often indicates a hardware failure, particularly related to the printer’s motor or power supply. Try restarting your printer and checking if the error clears. If not, you may need to perform a hard reset or check the wiring connections. If the issue is not resolved, professional assistance may be required.

Similarly, the HP printer E4 error usually appears when there’s an issue with the paper feed mechanism. This could be due to a paper jam, dirty rollers, or an obstruction within the printer. To fix this, power off the printer, open the paper tray, and check for any jammed paper or debris. Cleaning the rollers might also help clear this error.

While these errors can be troublesome, following these troubleshooting steps for the 49.38.03 error, hp 59.F0 error, E0 error, and E4 error should help restore your printer to proper working order. However, if the issues persist, consider reaching out to HP customer support for further assistance and repairs.

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.

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