Linux Privilege Escalation on HTB: A Beginner's Guide

Published on 2025-09-10 by sobbing

When I first started trying machine labs on HTB (HackTheBox), I struggled a lot with privilege escalation because I only had a very brief introduction to it without actually learning it. I was mainly focusing on AD (Active Directory) at the time, so it felt really foreign trying to get root on the available labs. The most I would do on Linux machines was run linpeas and quickly skim the output for low hanging fruit. If nothing obvious stood out, I would call it a day, look at the available walkthroughs and it felt like finding the solution on my own was impossible. On top of that, I wasn't familiar at all with Linux at the time which only led to more confusion. This led me to take a full break from the lab machines because it felt too difficult.

After finishing my AD studies and getting much more familiar with Linux, I decided to give the Linux machines another go on HTB. Over time, I noticed patterns for escalation paths and became more familiar with what to look for. It felt like the once scattered puzzle pieces were finally coming together. I started developing shortcuts for my methodology and added things that were missing. If given time, privilege escalation can be really fun and not as daunting as it may seem at first glance. I still have a lot more to learn, but below I'll share the most common ways I came across to escalate to root for easy Linux machines on HTB with examples. Something to note is that a lot of machines will use a combination of these in order to reach root (as shown in the provided example). In this case, enumeration would be key to see how everything links together. The more you work on these machines, the more you will notice patterns and everything becomes more intuitive.

Before that, I strongly recommend giving these resources a look if you ever feel stuck and want to improve:


0. Initial Enumeration

Before looking for privilege escalation, you should gather information about the system:

whoami
id
uname -a
hostname

Once you get a basic idea of the system, you should grasp a quick understanding of:

Of course, linpeas checks most of this, but its important to do it manually especially if you're still learning the basics. I usually only run linpeas after I've quickly enumerated the system manually.

1. Sudo Misconfigurations

1.1 What is it

1.2 Why it matters

1.3 How to exploit

sudo -l

2. SUID Binaries

2.1 What is it

2.2 Why it matters

2.3 How to exploit

find / -perm -4000 -type f 2>/dev/null

3. Vulnerable Services

3.1 What is it

3.2 Why it matters

3.3 How to exploit

ss -tulp

4. Cron Jobs

4.1 What is it

4.2 Why it matters

4.3 How to exploit

ls -la /etc/cron.*

5. Unsafe Password Storage

5.1 What is it

5.2 Why it matters

5.3 How to exploit

cat ~/.bash_history
find / -name "*.db" 2>/dev/null
find / -name "*.conf" 2>/dev/null
find / -name "*password*" 2>/dev/null

Side Notes

One of the reasons why I would recommend learning Linux before attempting to learn privilege escalation is because it will make everything more intuitive and will allow you to better understand how to link everything together. This in turn can give you a sense of direction and you have a better understanding of potential misconfigurations. For example, understanding the Linux FHS (Filesystem Hierarchy Standard) allows you to know that:

Lastly, sometimes the way you got your foothold could be a massive hint on where you can pick up breadcrumbs for getting privilege escalation. For example, lets say that you got a foothold after exploiting a vulnerability in a website. The website can have interesting configuration files with sensitive information like revealing mysql credentials that can get you credentials for another user.


Example:

HTB - Artificial (Easy):

Artificial was running a self-hosted web user interface for managing and scheduling backups.

Simply port forwarding it with SSH allows us to interact with it from the attacker machine. The problem here is that it required a password to use.

ssh -L 9898:localhost:9898 gael@<ip>

From there I decided to give it's related files a look to see if I could find credentials in configuration files for a quick win. Unfortunately, my user didn't have access to view the files of importance in/opt/backrest.

I then went to check the backup location for it where I did have access to read files. I found a username and a password hash that was base64 encoded which I had to decode then crack in order to get the password for it.

Once I was logged in, the first thing I did was read the documentation for using it. I realized I could use hooks to run a script that could give me a reverse shell when I was adding a repo, I just needed to make sure the hook would run under any condition. https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet.

Since backrest was running with root privileges, I would naturally be gaining a root shell from this method. Therefore, after running any action on the repo hello (in this case, I ran Check Now), the hook would run, giving me a reverse shell with root privileges.

Conclusion

I would have loved to make this longer for better explanations and more examples, but I feel like it would have been left unread or would be overwhelming, so I tried to keep it as nice and simple as possible. I would hope this helps to at least give you a sense of direction when it comes to privilege escalation for Linux to where it feels like you're playing a game of hide and seek. On the bright side, it only gets harder with Windows :)

Probably going to make a full write up post later, but I've only been completing active boxes, so I need to give retired boxes a look. Feel free to DM me any questions, maybe, I think.