# HTB ACADEMY — Linux Fundamentals

{% embed url="<https://academy.hackthebox.com/module/18/>" %}

## **Introduction**

### 1 - Linux structure

( Read only )&#x20;

### 2 - Linux Distributions

( Read only )

### 3 - Introduction to Shell

( Read only )

## **The Shell**

### **1 -** Prompt Description

( Read only )

### 2 - Getting Help

( Read only )

### 3 - System Information

**Question : Find out the machine hardware name and submit it as the answer.**

To find it, we need to know on which machine we are, the `uname` command is the more appropriate. We use the -m argument to displays only the hardware architecture of the system.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FoxMH0qNZFCHWl12iUdQn%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2020-57-08.png?alt=media&#x26;token=f7aa0be7-b747-47fb-821a-0e206f55dc65" alt=""><figcaption></figcaption></figure>

> Answer : x86\_64

**Question : What is the path to htb-student's home directory?**

to diplay the path of htb-student's home directory we need to use the pwd command.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FC5LqWvpnPC03fVoKAAZp%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2021-04-42.png?alt=media&#x26;token=27d3d0dd-470c-453b-a80f-9c66c126c679" alt=""><figcaption></figcaption></figure>

> Answer : /home/htb-student

**Question : What is the path to the htb-student's mail?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FCryxlqgvoGmHYTZApIs8%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2021-07-57.png?alt=media&#x26;token=32f38181-eb30-40c2-8e84-050a28da7152" alt=""><figcaption></figcaption></figure>

> answer : /var/mail/htb-student

**Question : Which shell is specified for the htb-student user?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2Fwukb4bJhHy5DnMKJxZwF%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2021-12-07.png?alt=media&#x26;token=01a5a37f-391f-4387-a5a3-9afff04df45d" alt=""><figcaption></figcaption></figure>

> Answer : /bin/bash

**Question : Which kernel version is installed on the system? (Format: 1.22.3)**

To see the kernel version we can use the `uname` command with the `-a` parameter to display system information in one line. We can use also the `uname -r` command to have only the kernel version.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FENgzE8jwf8gvun9yYzZD%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2021-13-35.png?alt=media&#x26;token=cb7c034b-5ce9-45e8-aab6-205ef54a02c9" alt=""><figcaption></figcaption></figure>

> Answer : 4.15.0

**Question : What is the name of the network interface that MTU is set to 1500?**

To see the name of network interfaces using, we can use the `ip a s` command.&#x20;

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FUjpMdZaHgCotlJVRNrJO%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2021-18-17.png?alt=media&#x26;token=24543ca6-2fd0-41c9-9ac7-db8bc77b4d51" alt=""><figcaption></figcaption></figure>

> Answer : ens192

## **Workflow**

### 1 - Navigation

**Question : What is the name of the hidden "history" file in the htb-user's home directory?**

First i needed to go to the htb-user's home directory and then do the `ls -la` command&#x20;

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2F61FbrjB1g6F505tHxKQe%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-05%2022-38-46.png?alt=media&#x26;token=70bd3dc1-be5a-487a-b710-6b817dad4481" alt=""><figcaption></figcaption></figure>

> Answer : .bash\_history

**Question : What is the index number of the "sudoers" file in the "/etc" directory?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FU2Oril7jCvl1SjpG3CIF%2Fimage.png?alt=media&#x26;token=e4cca819-8f18-456f-bb8b-b9fb5bf625ef" alt=""><figcaption></figcaption></figure>

> Answer : 147627

### 2 - Working with Files and Directories

**Question : What is the name of the last modified file in the “/var/backups” directory?**

The `ls -t` command in Linux is used to list files and directories sorted by **modification time** in descending order, meaning the most recently modified files appear at the top.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FNXGrydZBmvtdcJuRuQ4x%2Fimage.png?alt=media&#x26;token=a6678d2f-7201-4d6b-a97a-fc751dcc3662" alt=""><figcaption></figcaption></figure>

> Answer : apt.extended\_states.0

**Question : What is the inode number of the "shadow\.bak" file in the "/var/backups" directory?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2F35KeLBYfid8aUiKfShCn%2Fimage.png?alt=media&#x26;token=326a7e11-45e5-40cb-97f3-5f598eaf2e22" alt=""><figcaption></figcaption></figure>

> Answer : 265293

### 3 - Editing Files

( Play with vimtutor )&#x20;

### 4 - Find Files and Directories

**Question : What is the name of the config file that has been created after 2020-03-03 and is smaller than 28k but larger than 25k?**

To find it, we using find command.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FKq6sBFWScCfvy4Ybe9n8%2FCapture%20d%E2%80%99%C3%A9cran%20du%202024-11-06%2012-40-51.png?alt=media&#x26;token=0a788f8f-8e2e-457a-8459-1f12ee0af836" alt=""><figcaption></figcaption></figure>

> Answer : 00-mesa-defaults.conf

**Question : How many files exist on the system that have the ".bak" extension?**

we use another time the find command but we use in output the wl -l command to return the number of files found.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FWn0xhPUglCYuHhQlvPzy%2Fimage.png?alt=media&#x26;token=d949d877-37c0-4961-9e8d-fcb3891953ff" alt=""><figcaption></figcaption></figure>

> Answer : 4

**Question : Submit the full path of the "xxd" binary.**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2Fe5488ybcWwJpQzcy6GHy%2Fimage.png?alt=media&#x26;token=c4a8ac8f-8c73-4511-a314-0b090245d117" alt=""><figcaption></figcaption></figure>

We submit the first one result :&#x20;

> Answer : /usr/bin/xxd

**Question : How many files exist on the system that have the ".log" file extension?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FhGBTRxTZSfQ2PL6aqYfV%2Fimage.png?alt=media&#x26;token=aa28459d-9ab1-43d5-ac1e-0984c7dc9b03" alt=""><figcaption></figcaption></figure>

> Answer : 32&#x20;

**Question : How many total packages are installed on the target system?**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FAdOJq5gxhMORUDiPsfcY%2Fimage.png?alt=media&#x26;token=f6512007-dd7a-41a4-b2c9-e85963b8d862" alt=""><figcaption></figcaption></figure>

> Answer : 737

### 4 - Filter Contents

**Question : How many services are listening on the target system on all interfaces? (Not on localhost and IPv4 only)**

The `grep -v` command is used to invert the match in a file or command output. In other words, it displays all lines that do not match the specified pattern.

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FmhTSmoojfsWzT9LQqod5%2Fimage.png?alt=media&#x26;token=7e53764a-9a4b-4f63-8697-f214807a3fa6" alt=""><figcaption></figcaption></figure>

> Answer : 7

**Question : Determine what user the ProFTPd server is running under. Submit the username as the answer.**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FqlTZJI7gCCbpcr5WFulc%2Fimage.png?alt=media&#x26;token=1dd6aeeb-a1f2-446c-8a7f-a2c5fd86de20" alt=""><figcaption></figcaption></figure>

> Answer : proftpd

**Question : Use cURL from your Pwnbox (not the target machine) to obtain the source code of the "<https://www.inlanefreight.com>" website and filter all unique paths of that domain. Submit the number of these paths as the answer.**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FCrW9Y5Yq1TTcywJhMd1r%2Fimage.png?alt=media&#x26;token=9c0247b8-1b88-4e5c-90a8-72db173ff4ad" alt=""><figcaption></figcaption></figure>

> Answer : 34

### 5 - Regular Expressions

( Read only )

## **System Management**

### 1 - User Management

**Question : Which option needs to be set to create a home directory for a new user using "useradd" command?**

> Answer : -m

**Question : Which option needs to be set to lock a user account using the "usermod" command? (long version of the option)**

> Answer : --lock

**Question : Which option needs to be set to execute a command as a different user using the "su" command? (long version of the option)**

> Answer : --command

### 2 - Permission Management

( Read only )&#x20;

### 3 - Service and Process Management

**Question : Use the "systemctl" command to list all units of services and submit the unit name with the description "Load AppArmor profiles managed internally by snapd" as the answer.**

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2Fm9IAaV7mkz5KXvYk7Jqj%2Fimage.png?alt=media&#x26;token=25f83498-1fde-48d9-a028-454f9308c78c" alt=""><figcaption></figcaption></figure>

> Answer : snapd.apparmor.service

### 4 - Task Scheduling

I didn't find the answer&#x20;

### 5 - Network Services

( Read only )

### 6 - Working with Web Services

**Question : Find a way to start a simple HTTP server inside Pwnbox or your local VM using "npm". Submit the command that starts the web server on port 8080 (use the short argument to specify the port number).**

> Answer : http-server -p 8080

**Question : Find a way to start a simple HTTP server inside Pwnbox or your local VM using "php". Submit the command that starts the web server on the localhost (127.0.0.1) on port 8080.**

> Answer : *php -S 127.0.0.1:8080*

### 7 - Backup and Restore

( Read only )

### 8 - File System Management

<figure><img src="https://2931735262-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXA0vUsX6kqTfMT0wCskK%2Fuploads%2FSk1ev3bx80wLkJsNGm6H%2Fimage.png?alt=media&#x26;token=aeeb0a5e-1f15-410c-b901-1ec6dd2acb1f" alt=""><figcaption></figcaption></figure>

> Answer : 3

### 9 - Containerization&#x20;

( Read only )

## **Linux Networking**

### **1 -** Network Configuration

( Read only )

### 2 - Remote Desktop Protocols in Linux

(Read only)

## **Linux Hardening**

### **1 -** Linux Security

( Read only )

### 2 - Firewall Setup

( Read only )

## **Linux Distributions vs Solaris**

### 1 - Solaris

( Read only )

## **Tips & Tricks**

### 1 - shortcuts&#x20;

( Read only )
