Jasper Alblas
Jasper Alblas
Hi! It is time to look at the Linux Fundamentals 1 room on TryHackMe. This is the first part of the Linux Fundamentals series on TryHackMe. Linux is the most fundamental skill for pentesters. Learn Linux, and you will become more efficient at everything. Let’s look at this room!
Room URL: https://tryhackme.com/room/linuxfundamentalspart1
I am making these walkthroughs to keep myself motivated to learn cyber security, and ensure that I remember the knowledge gained by THMs rooms. Join me on learning cyber security. I will try and explain concepts as I go, to differentiate myself from other walkthroughs.
The “Linux Fundamentals” series introduces Linux, a widely-used operating system powering devices like smart cars, Android devices, supercomputers, and enterprise servers. This room covers Linux history and guides beginners to:
It’s the start of a journey to becoming proficient with Linux!
Not much more to say here but let’s move on to part 2 🙂
Answer: No answer needed
Linux is an operating system, much like Windows and OS X. Linux however is much more lightweight. Linux is the umbrella term of different variants of Operation Systems built upon UNIX, which is an operating system itself.
Linux powers software such as:
Since UNIX is open source, there a a plethora of different versions of Linux. Two of the most common ones are Ubuntu and Debian, since these two are so extensible. Ubuntu for example, can be used as server or all full-fledged desktop.
Linux began in 1991 as a personal project by Finnish student Linus Torvalds.
Answer: 1991
Not much to do be here besides starting up the Ubuntu machine on TryHackMe.
Answer: No answer needed.
Since Linux is so lightweight, it is more normal to have program without a GUI (Graphic User Interface). In this case we use the terminal to interact with these programs. The terminal is purely text-based, and will probably be quite intimidating at first. But you will soon learn that it has a great efficiency and speed to it as you become comfortable!
Let’s get started with two of the msot useful commands:
Using echo:
echo "Hello Friend!"
Using whoami to find out the username of who we’re logged in as:
whoami
We can simply use the echo command in the terminal following by a string, which outputs the text argument to the terminal.
Answer: echo TryHackMe
Here we can use the whoami command, which returns the following answer:
Answer: tryhackme
In this room we will learn about the following commands:
Use “ls” to to list the contents of the current directory:
ls
#output
'Important Files' 'My Documents' Notes Pictures
Pro tip: You can list the contents of a directory without having to navigate to it by using ls and the name of the directory. I.e. ls Pictures
Now that we know what folders exist, we need to use the “cd” command (short for change directory) to change to that directory. Say if I wanted to open the “Pictures” directory – I’d do “cd Pictures“.
You can read the contents in a file by using a command called cat. “Cat” is short for concatenating and is a great way for us to output the contents of files.
ls
#output
todo.txt
cat todo.txt
#output
Here's something important for me to do later!
It’s easy to lose track of where we are on the filesystem exactly, which is why there exists the command pwd. This stands for print working directory.
Let’s use pwd to list the full path of the current directory:
pwd
#output
/home/ubuntu/Documents
Use the ls command to list the contents of a folder.
Answer: 4
Here we simply have to check each folder in turn by changing directory to each and listing its contents:
cd folder4
ls
Answer: folder4
Use the cat command to read the file found in folder4. See the screenshot above.
Answer: Hello World
Here we simply use the pwd command to print out our current directory.
Answer: /home/tryhackme/folder4
It’s time to learn two new commands:
Using find to find a file with the name of “passwords.txt”
find -name passwords.txt
#output
./folder1/passwords.txt
Find has managed to find the file. But let’s say that we don’t know the name of the file, or want to search for every file that has an extension such as “.txt”.
We can simply use what’s known as a wildcard (*) to search for anything that has .txt at the end. In our case, we want to find every .txt file that’s in our current directory.
Using find to find any file with the extension of “.txt”. Here two files are found.
find -name *.txt
#output
./folder1/passwords.txt
./Documents/todo.txt
Another great utility that is a great one to learn about is the use of grep. The grep command allows us to search the contents of files for specific values that we are looking for.
We can use grep to search the entire contents of this file for any entries of the value that we are searching for. Going with the example of a web server’s access log, we want to see everything that the IP address “81.143.211.90” has visited:
grep "81.143.211.90" access.log
#output
81.143.211.90 - - [25/Mar/2021:11:17 + 0000] "GET / HTTP/1.1" 200 417 "-" "Mozilla/5.0 (Linux; Android 7.0; Moto G(4))"
Since we are interested in files starting with THM, we can use a wildcard after THM, to find every entry starting with THM.
grep THM* access.log
Answer: THM{ACCESS}
In this final task we will learn about the following operators:
This operator allows us to execute commands in the background. For example, let’s say we want to copy a large file. This will obviously take quite a long time and will leave us unable to do anything else until the file successfully copies. The “&” shell operator allows us to execute a command and have it run in the background (such as this file copy) allowing us to do other things!
Although it looks similar to the previous operator, it does nothing similar.
We can use “&&” to make a list of commands to run for example command1 && command2
. However, it’s worth noting that command2 will only run if command1 was successful.
This operator is what’s known as an output redirector. What this essentially means is that we take the output from a command we run and send that output to somewhere else, often in a new file.
Using the > Operator:
echo hey > welcome
Using cat to output the “welcome” file:
cat welcome
hey
This operator is also an output redirector like in the previous operator (>
) we discussed. However, what makes this operator different is that rather than overwriting any contents within a file, for example, it instead just puts the output at the end.
Using the >> Operator:
echo hello >> welcome
Using cat to output the “welcome” file:
cat welcome
heyhello
Note that the file now contains both ‘hey’ and ‘welcome’.
The & operator allows us to execute commands in the background.
Answer: &
The > operator is a output redirector. When outputting to a file we overwrite the contents of a file with the input.
Answer: echo password123 > passwords
In this case we need to use the >> operator, which is similar to the > operator, but instead of overwriting the file it appends to the file.
Answer: echo tryhackme >> passwords
Go and play with all these commands. Understanding Linux and the most common commands will help you in so many different IT fields!
Answer: No answer needed
We are done with Linux Fundamentals Part 1! Awesome. I hope you picked up some Linux skills on the way. Thanks for reading this walkthrough of the TryHackMe: Linux Fundamentals I room.
You can find my other walkthroughs here.
You are welcome to give my article a clap or two 🙂
I would be so grateful if you support me by buying me a cup of coffee:
I learned a lot through HackTheBox’s Academy. If you want to sign up, you can get extra cubes, and support me in the process, if you use the following link: