> For the complete documentation index, see [llms.txt](https://ravins-organization.gitbook.io/ctf-writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ravins-organization.gitbook.io/ctf-writeups/2024/huntress-ctf-2024/miscellaneous/linux-basics.md).

# Linux Basics

Welcome to Linux Basics!  You're expected to answer a series of questions to get the flag. To view the questions, and answer them, you'll use the answer tool.

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2Fqlt2EpYeVYWVInMghyQN%2Fimage.png?alt=media&amp;token=8620ae46-7386-49a2-bf1c-836206a9efe4" alt=""><figcaption></figcaption></figure>

This was the given start screen and we have to answer a whole bunch of questions, so we will do them in order.

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2Fx601rRhwu5Q0TwGgcCEv%2Fimage.png?alt=media&amp;token=5a093e75-fecf-4be2-9a46-689f491ec982" alt=""><figcaption><p>Answer 0</p></figcaption></figure>

For question 1, it was about generating random permutations, after googling it, I saw it was shuf and I tried it.

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2Fv8iw1c3h2oOL67C2ByU3%2Fimage.png?alt=media&amp;token=809099ad-fd6c-4702-a0ac-d989b2f9a536" alt=""><figcaption><p>Answer 1</p></figcaption></figure>

For question 2, it asks for the modification date of myfile.txt, so I used ls -la to see the last modification date

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FmdbGU6E8fs9qj83UuHyz%2Fimage.png?alt=media&amp;token=b48d8ac5-42d5-43e9-96b0-2109c1f37c0e" alt=""><figcaption><p>Answer 2</p></figcaption></figure>

For question 3 we can use the same command, we can see that the file size is 22200 bytes which is 22kb to the nearest whole number

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FLY3d8XFU4pa4iZws0fMY%2Fimage.png?alt=media&amp;token=7176651b-e313-4d1a-9773-c25ad1f91d76" alt=""><figcaption><p>Answer 3</p></figcaption></figure>

For question 4 as well, we can use the same command to see that the user that owns the file is root

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FGeBDOp6DfkSwak6TD4JD%2Fimage.png?alt=media&amp;token=fd058edf-466e-4ea3-84ee-66b06213e425" alt=""><figcaption><p>Answer 4</p></figcaption></figure>

For question 5, we can use the permissions given to convert them to octal. The permssions were&#x20;

`-rwxr-xr--` which converted to octal is done as below

Owner permissions (rwx):

Read (r): 4 Write (w): 2 Execute (x): 1 Total for owner: 4 + 2 + 1 = 7 Group permissions (r-x):

Read (r): 4 No write (-): 0 Execute (x): 1 Total for group: 4 + 0 + 1 = 5 Other permissions (r--):

Read (r): 4 No write (-): 0 No execute (-): 0 Total for others: 4 + 0 + 0 = 4

Thus giving us, 754

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FWvsR74KK5GyuPmumIl0E%2Fimage.png?alt=media&amp;token=e63382b9-ae30-429f-99f5-ea6d4c2ec07c" alt=""><figcaption><p>Answer 5</p></figcaption></figure>

For question 6, we need to find the user id of 'admin', which we can solve with the command `cat /etc/passwd` to find the user id of admin to be `1338`

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2F4f12vMWM2QUddiViRiOM%2Fimage.png?alt=media&amp;token=6a0b7c6f-adc2-4799-a516-94c425215a5b" alt=""><figcaption><p>Answer 6</p></figcaption></figure>

I will go through questions 7,8 and 9 all at once as they are mostly quite easy. For Question 7, john cannot write to /home/user/myfile.txt, answer 8 is yes as the admin user can execute the file and for answer 9, we refer back to our `cat /etc/passwd` and see that rose is the only other user that is in the admin group, thus it is rose.

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FOOcJrfJ355tbIqvzk6zL%2Fimage.png?alt=media&amp;token=ee645630-0828-4d15-b8a4-4ab991b7a738" alt=""><figcaption><p>Answer 7,8 and 9</p></figcaption></figure>

For answer 10, we have to find what kind of file is myfile.txt. By using the `file` command, we can see that it is a jpeg file.

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FiBlAPC4YnHzZa9y6sPsx%2Fimage.png?alt=media&amp;token=a9cbe486-0b2b-4000-895b-2eed08fbd8a7" alt=""><figcaption><p>Answer 10</p></figcaption></figure>

With this, we can get the flag. The flag is `flag{8873fe66f8e7a6019d7d71261864f6c5}`
