Linux Basics for Hackers, Part 06: Managing File Permissions
Welcome back, my aspiring cyberwarriors!
One of the most critical skills any hacker must master is understanding the operating system they work within. Linux sits at the foundation of nearly every penetration testing distribution, serves as the backbone of most servers youβll encounter in the field, and provides the power and flexibility that cannot be found in consumer operating systems like Windows or macOS. Without solid Linux skills, the world of hacking remains a largely closed door. And yet, Linux is vast.
There are layers upon layers of knowledge to acquire, from basic navigation to advanced scripting and privilege escalation techniques. Each piece builds upon the last, creating a foundation that separates those who can merely run tools from those who truly understand what theyβre doing under the hood.
In this tutorial, we will examine one of the fundamental security mechanisms built into every Linux system: file permissions. Linux implements a robust permission system that controls exactly who can read, write, and execute any file or directory on the system. Understanding these permissions lets you control who can access, modify, or run your files. More importantly for us as cyberwarriors, understanding these permissions reveals how systems protect themselves and, crucially, where those protections might fail or be misconfigured, leaving them vulnerable to exploitation.
Step 1: Checking Permissions
To view a fileβs permissions, use the ls command with the -l (long) switch. Letβs use that command in the /usr/share/hashcat directory and see what it tells us about the files there.
First, letβs navigate to its directory.
kali > cd /usr/share/hashcat
Then, list its directory in detail.
kali > ls -l

If we look at each line, we can see quite a bit of information on the entries in this directory, including:
(1) whether itβs a file or directory,
(2) the permissions on the file,
(3) the number of links,
(4) the owner of the file,
(5) the group owner of the file,
(6) the size of the file,
(7) when it was created or modified, and finally,
(8) the name of the file.
Letβs examine each of these.
Identifying a File or Directory
The very first character of the line tells us whether itβs a file or a directory. If the line begins with a βdβ, itβs a directory. If it begins with a β-β, itβs a file.

Identifying the Permissions
The next section of characters defines the fileβs permissions. Three sets of rwx stand for read, write, and execute. This determines whether there is permission to read, write, or execute the file. Each set of rwx represents the permissions for the owner, the group, and all others, respectively.
So, letβs look at the hashcat rules directory (hashcat rules transform your wordlist so it may better fit the target password, including the combinator.rule, which changes capitalization, such as occupytheweb -> OccupyTheWeb).
Letβs navigate to the rules directory and then do a long listing.
kali > cd rules
kali > ls -l

We can see that each begins with:
-rw-rβrβ
This means itβs a file (-) with read (r) and write (w) permissions, but no execute (x) permission. Note, here the dash β-β represents nothing or no permission.

The next set of permissions represents the groupβs permissions. Here, we can see that the group has read (r) permissions but not write (-) or execute (-).
Finally, the last set of permissions is for all others. We can see that all others have only the read (r) permission on these files.
Step 2: Changing Permissions
Letβs imagine a case where we wanted the group to be able to write to the hashcat combinator.rule file. Someone in the group has developed an improvement to this rule and wants to write the changes and share them with the rest of the group.
Linux has a command called chmod (change mode) that allows us to change the permissions on a file, as long as weβre root or the fileβs owner. These permissions are represented by their binary equivalents in the operating system.
Permissions by the Numbers
Remember, everything is simply zeros and ones in the underlying operating system, and these permissions are represented by on/off switches in the system. So, if we imagine the permissions as three on/off switches, and these switches use the base-2 number system, the far-right switch represents 1 when on, the middle switch represents 2 when on. The far-left switch is on when 4 is displayed.
So, the three permissions look like this when they are all on:
r w x
4 2 1 = 7

If you sum these three, you get seven. In Linux, when all the permission switches are on, we can represent it with the decimal numerical equivalent of 7. So, if we wanted to represent that the owner (7), the group (7), and all users (7) had all permissions, we could represent it as:
777
Now, letβs go back to our hashcat combinator.rule file. Remember its permissions? They were rw-rβrβ, so we could represent that numerically like:
r w β | r β β | r β β
4 2 0 | 4 0 0 | 4 0 0
This can be represented by 644.
Changing the Actual Permissions of combinator.rule
Now, if we wanted to give the group write (2) privileges, we can use the chmod command to do it. We need to add the write (2) privilege to the combinator.rule file. We do that by:
kali > sudo chmod 6 6 4 combinator.rule
This statement says give the owner read and write permissions (4+2=6), the group the same (4+2=6). and give everyone else read permission (4 + 0 + 0 = 4).
When we now do a ls -l, we can see that the permissions for combinator.rule are now:
r w β r w β r β β

Simple.
Step 3: Changing Permissions with UGO
Although the numeric method is probably the most common way to change permissions in Linux (every self-respecting Linux guru can use it), thereβs another method that some people find easier to work with. Itβs often called the UGO syntax. UGO stands for U=user or owner, G=group, and O=others. UGO has three operators:
+ for adding a permission
β to subtract a permission
= to set a permission
So, if I wanted to subtract the write permission from the group that the combinator.rule belongs to, I could write:
kali > sudo chmod g-w combinator.rule
This command says βfor the group (g) subtract (-) the write (w) permission to combinator.rule.β

You can see that when I now check file permissions by typing ls -l, that the combinator.rule file no longer has write permission for the group.
If I wanted to give back the group write permission, I could type:
kali > sudo chmod g+w combinator.rule
This command says βfor the group adds the write permission to the file combinator.rule.β
Step 4: Giving Ourselves Execute Permission on a New Hacking Tool
Very often, as hackers, we need to download or create new hacking tools. After we download, extract, unzip, build, and install them, weβll often need to grant ourselves permission to execute them. This doesnβt happen automatically. If we donβt, we usually get a message that we donβt have sufficient permissions to execute.

We can see in the screenshot above that our newhackertool does not have execute permission for anyone.
When we do a long listing on our newhackertool, we can see that the permissions are only read and write (6) for the owner.
kali > ls -l

We can give ourselves (root user) permission to execute on a newhackertool by writing:
kali > chmod 766 newhackertool
As you now know, this would give usβthe ownerβall permissions, including execute, and the group and everyone else just read and write permissions (4+2=6). You can see in the screenshot above that after running the chmod command, we get exactly what we expect!
-rwx rw- rw--rwx rw- rw-

Summary
The article focuses on managing file permissions in Linux. We tried to explain how to check permissions using the ls -l command and how to interpret its output, which includes file types, permissions, ownership, and size. The article also discusses changing permissions with the chmod command and introduces numerical representations of permissions. Overall, it equips readers with foundational knowledge to manage file security and identify vulnerabilities in Linux systems.
For more information on using Linux for hacking, check out the book βLinux Basics for Hackersβ on Amazon or visit our training center.
The post Linux Basics for Hackers, Part 06: Managing File Permissions first appeared on Hackers Arise.