Introduction
As part of my journey into cybersecurity and system administration, I recently completed the "Linux Fundamentals Part 1" room on TryHackMe. This room is perfect for beginners who want to get hands-on with Linux basics in a guided, interactive environment.
In this post, I’ll walk through the key concepts, commands, and tasks covered in the room, along with my personal notes and tips.
A bit of Background on Linux
Linux may seem more intimidating than operating systems like Windows, but it's actually incredibly versatile and widely used in everyday life. You might not realize it, but Linux powers many of the systems you interact with regularly, such as websites, car infotainment systems, checkout tills in stores, and even critical infrastructure like traffic light controllers and industrial sensors.
The term "Linux" refers to a family of operating systems based on UNIX. Because Linux is open-source, it has given rise to many different versions, known as distributions or "distros," each tailored for specific use cases. Ubuntu and Debian are two of the most common distributions due to their flexibility. For instance, Ubuntu can be used both as a server operating system for hosting websites and applications, or as a full desktop environment. Impressively, Ubuntu Server can run on systems with as little as 512MB of RAM. Just like Windows has different versions such as 7, 8, and 10, Linux has a wide variety of distributions, each suited to different needs and preferences.
Interacting With Your First Linux Machine (In-Browser)
This TryHackMe room provides access to an Ubuntu Linux machine that you can interact with directly through your browser, making it easy to follow along with the learning material. To begin, you simply need to click the green “Start Machine” button. Once the machine is deployed, a card will appear at the top of the room displaying important details such as the machine’s IP address, an expiry timer, and controls to manage the machine. It’s important to remember to terminate the machine once you’re finished to avoid unnecessary resource usage. For now, just start the machine and you’ll be able to explore and practice Linux commands in a fully interactive environment, right from your browser.
Running Your First few Commands
Ubuntu is known for being lightweight, which makes it appealing, but this often means it lacks a graphical interface unless one is installed. As a result, users interact with the system primarily through the Terminal, a text-based interface that can seem intimidating at first. However, with time and practice, it becomes easier to use. Basic tasks like navigating files, viewing content, and creating files are done using simple commands. Two introductory commands are echo, which displays text, and whoami, which shows the current user. For example, echo Hello prints "Hello", while echo "Hello Friend!" prints the full phrase with spaces. The whoami command reveals the username of the logged-in user.
To get information about current user, we use:
whoami
To print infos in the terminal, we use echo
+ information, in our case:
echo TryHackMe
Interacting With the Filesystem!
So far, only the echo
and whoami
commands have been introduced, which are useful but limited. To work effectively in a Linux environment without a graphical interface, it's essential to interact with the filesystem. This includes navigating directories, viewing file contents, and understanding where you are in the system.
The ls
command lists files and folders in the current directory, helping you see what’s available. To move between directories, you use cd
, and once inside a directory, you can again use ls to view its contents. To read the contents of a file, the cat command is used, which outputs the file’s data directly in the terminal. Finally, pwd
shows the full path of your current location in the filesystem, which is helpful for orientation and navigation.
Let's navigate inside this machine to find our answers:
Searching for Files
Although Linux may seem complex at first, one of its greatest strengths is how efficient it becomes with familiarity. As you get used to it, commands like echo
, whoami
, ls
, cd
, cat
, and pwd
become second nature. To further boost efficiency, Linux offers powerful tools like find
and grep
.
The find
command allows you to search for files across directories without manually navigating through each one. For example, find -name passwords.txt
searches for a file with that exact name, while find -name *.txt
finds all .txt files using a wildcard.
On the other hand, grep
lets you search inside files for specific content. It's especially useful for large files like logs. For instance, grep "81.143.211.90" access.log
filters and displays only the lines containing that IP address, saving time and effort compared to reading the entire file.
Together, find
and grep
showcase how Linux can streamline tasks and make system interaction much more efficient.
grep "THM" access.log
An Introduction to Shell Operators
Linux operators enhance command-line efficiency by allowing more control over how commands are executed and how their outputs are handled. The &
operator runs commands in the background, which is useful for long tasks like copying large files without blocking the terminal. The &&
operator chains commands together, ensuring the second command runs only if the first succeeds.
The >
operator redirects output to a file, replacing its contents if the file already exists. For example, echo hey > welcome
creates or overwrites the file "welcome" with the word "hey". In contrast, the >>
operator appends output to the end of a file without overwriting existing content. So, echo hello >> welcome
adds "hello" below "hey" in the same file.
These operators are key tools for streamlining tasks and managing output effectively in Linux.
Conclusions
Great job reaching this point! We've just completed a solid introduction to Linux, covering the most essential tools and concepts you'll use regularly. Here's a quick recap of what we've learned:
Why Linux is so widely used: Its efficiency, flexibility, and power make it a favorite in tech environments.
Basic interaction: We’ve run your first commands and started navigating a Linux machine.
Filesystem navigation: Commands like ls, cd, cat, and pwd help you explore and manage files.
Efficient searching: Tools like find and grep let you locate files and search their contents quickly.
Shell operators: We learned how to run commands in the background (&), chain them (&&), and redirect output (> and >>).
We're building a strong foundation, and with a bit of practice, these commands will become second nature. When you're ready, moving on to Linux Fundamentals Part 2 will deepen your skills even further.
Top comments (0)