# Linux shells

**Task 1 (Introduction)**

Let us start this final Linux Introduction room in which we will learn about automation, package management, logging and more!

**Questions**

**Let’s proceed!**

> ***Answer**: No answer needed*

**Task 2 (Deploy your Linux machine)**

Nothing to do here either but logging in to your deployed machine using SSH.

**Questions**

**I’ve logged into the Linux Fundamentals Part 3 machine using SSH and have deployed the AttackBox successfully!**

Login by using ***ssh \<username>@\<serverip>***. In this case the username is tryhackme.

> ***Answer**: No answer needed*

**Task 3 (Terminal Text Editors)**

**Questions**

**Create a file using Nano**

> ***Answer**: No answer needed*

**Edit “task3” located in “tryhackme”’s home directory using Nano. What is the flag?**

Write ***nano task3*** to read the file.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*lbo7EvmQzVyka-ev.png" alt="" height="446" width="700"><figcaption></figcaption></figure>

Using nano to read the task3.txt file

> ***Answer**: THM{TEXT\_EDITORS}*

**Task 4 (General Utilities)**

**Questions**

**Ensure you are connected to the deployed instance (10.10.213.251)**

> ***Answer**: No answer needed*

**Now, use Python 3’s “HTTPServer” module to start a web server in the home directory of the “tryhackme” user on the deployed instance.**

You will need to write ***python3 -m http.server*** to start a server on your deployed machine (the one you accessed with SSH).

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*kx-SSfYNu-19vh1I.png" alt="" height="237" width="700"><figcaption></figcaption></figure>

Serving the file, and downloading it from another terminal

> ***Answer**: No answer needed*

**Download the file** [**http://10.10.213.251:8000/.flag.txt**](http://10.10.213.251:8000/.flag.txt) **onto the TryHackMe AttackBox. What are the contents?**

Now that the server is running, you should be able to download the file by running a new terminal window.

In the new window write:

```
wget <serving machine ip>/.flag.txt.
```

Now you can access the file from your attacker machine without logging into it.

> ***Answer**: THM{WGET\_WEBSERVER}*

**Create and download files to further apply your learning — see how you can read the documentation on Python3’s “HTTPServer” module. Use Ctrl + C to stop the Python3 HTTPServer module once you are finished.**

> ***Answer**: No answer needed*

**Task 5 (Processes 101)**

**Questions**

**Read me!**

> ***Answer**: No answer needed*

**If we were to launch a process where the previous ID was “300”, what would the ID of this new process be?**

The PID increments for the order in which the process starts. So the answer should be 301.

> ***Answer**: 301*

**If we wanted to cleanly kill a process, what signal would we send it?**

The answer is SIGTERM. If you want to avoid cleaning up you can use SIGKILL.

> ***Answer**: SIGTERM*

**Locate the process that is running on the deployed instance (10.10.213.251). What flag is given?**

Enter ***ps aux*** to list the current running services of all users. If you look carefully you can find a key:

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*DzFIS7MCtPeBVUbQ.png" alt="" height="59" width="700"><figcaption></figcaption></figure>

Looking throught the ps aux output

> ***Answer**: THM{PROCESSES}*

**What command would we use to stop the service “myservice”?**

> ***Answer**: systemctl stop myservice*

**What command would we use to start the same service on the boot-up of the system?**

> ***Answer**: systemctl enable myservice*

**What command would we use to bring a previously backgrounded process back to the foreground?**

> ***Answer**: fg*

**Task 6 (Maintaining Your System: Automation)**

**Questions**

**Ensure you are connected to the deployed instance and look at the running crontabs.**

> ***Answer**: No answer needed*

**When will the crontab on the deployed instance (10.10.213.251) run?**

To figure this out simply write ***crontab -e*** in the terminal.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*-ABgLrBKLo_uOfq8.png" alt="" height="298" width="700"><figcaption></figcaption></figure>

The crontab on the deployed instance

You can find the command in the bottom of the file. It runs on a interval specified by a special command: @reboot. Which means that it runs verything the system reboots.

> ***Answer**: @reboot*

**Task 7 ( Maintaining Your System: Package Management)**

**Questions**

Since TryHackMe instances do not have an internet connection…this task only requires you to read through the material.

> ***Answer**: No answer needed*

**Task 8 ( Maintaining Your System: Logs)**

Log files are located in the /var/log directory and contain logging information for applications and services running on your system.

**Questions**

**Look for the apache2 logs on the deployable Linux machine**

The apache2 logs are found at */var/log/apache2*.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*EzMrCP9fXJDiLVcO.png" alt="" height="114" width="700"><figcaption></figcaption></figure>

Looking for the apache2 log file

> ***Answer**: No answer needed*

**What is the IP address of the user who visited the site?**

Access the access log by opening access.log.1 with cat.

<figure><img src="https://miro.medium.com/v2/resize:fit:875/0*Xuz1HG9fJaT2fu3c.png" alt="" height="46" width="700"><figcaption></figcaption></figure>

Reading the access.log.1 file

The answer is right there on the second line.

> ***Answer**: 10.9.232.111*

**What file did they access?**

Look at the screenshot above. They have accessed the file catsanddogs.jpg.

> ***Answer**: catsanddogs.jpg*

**Task 9 (Conclusion)**

**Questions**

**Terminate the machine deployed in this room from task 2.**

> ***Answer**: No answer needed*

**Continue your learning in other Linux-dedicated rooms**

> ***Answer**: No answer needed*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://foothold.gitbook.io/blog/linux-shells.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
