Introduction
We covered the second volume of basics and fundamentals of Linux operating system. We covered permissions, processes, services, files and directories, downloading and uploading, system configurations,etc. This was part of Pre Security pathway and TryHackMe Linux Fundamentals Room.
CompTIA Security+ SY0-601 Study Notes
The video begins by explaining that the content will focus on Linux basics as laid out in TryHackMe’s pre-security path.It emphasizes that the video will not go into deep reading of materials but will instead focus on answering questions and explaining how to approach them.
Basic Linux Commands
Echo Command:
- The instructor explains how to use
echo
to display text in the terminal (e.g.,echo "TryHackMe"
). - They show how
echo
can be used to write text to a file, for example:echo "TryHackMe" > file1
.
ID Command:
- The
id
command is used to display the current user’s ID and group information.
Hostname Command:
- The
hostname
command shows the name of the machine.
Man Pages:
- Man pages provide detailed information about commands and their usage. The instructor emphasizes the importance of using
man <command>
(e.g.,man cat
) to explore the different options and flags that a command supports.
Cat Command:
- The
cat
command is used to display the contents of files in the terminal. The video demonstrates howcat
works with a file namedtest.txt
and explains thatcat
is useful for viewing text-based content quickly.
LS Command:
ls
is used to list files and directories in the current directory. The instructor goes further by explaining options likels -a
to display hidden files andls -l
for long format listing, which shows details like permissions and ownership of files.- Directories are identified by the “d” at the beginning of the permissions string, while regular files do not have the “d.”
Touch Command:
touch
is used to create empty files. The instructor demonstrates creating a file namedtest2.txt
usingtouch test2.txt
and verifying it with thels
command.
Executing Binaries:
- Binary files are executable files in Linux. The instructor explains how to check the nature of a file using the
file
command (e.g.,file shiva2
). - Two ways to execute binaries are discussed:
- Absolute Path: Providing the full path to the binary (e.g.,
/home/user/shiva2
). - Relative Path: Using
./binaryname
to execute the binary from the current directory.
- Absolute Path: Providing the full path to the binary (e.g.,
Changing Users:
- The
su
command allows switching to another user. For example,su root
switches to the root user, provided the user knows the root password. The instructor explains the differences between switching users withsu
alone andsu <username>
.
Linux File System
pwd Command:
- This command is used to print the current working directory.
ls Command:
- Lists the contents of the current directory.
cd Command:
- Used to change directories.
The instructor shows how to differentiate between directories and files using ls -la
and explains how directories are marked with a “d” in their permissions.cat Command:
- The
cat
command is used to display the contents of a file in the terminal.
Searching for Files in Linux
grep Command:
grep
is used to search for specific patterns or strings in files. In this case, the instructor demonstrates how to usegrep
to find a flag within an access log file by searching for the prefix “THM
Shell Operators
Redirection Operators:
- The video explains the difference between single (
>
) and double (>>
) arrows for file redirection. - Single arrows overwrite file contents, while double arrows append to the file without removing the existing content.
Background Processes:
- The
&
operator is used to run a process in the background, allowing the user to continue using the terminal while the command executes. - Additionally, the instructor mentions that
Ctrl+Z
can be used to send a process to the background.
Example: Using Echo and Redirection
The instructor demonstrates how to use echo
to replace or append content to a file, showing the difference between single and double redirection arrows.
Practical Examples
Using echo
to display and write text.Navigating the file system with cd
, pwd
, ls
.Searching for strings with grep
.Redirection with >
and >>
.Running commands in the background using &
.
Room Answers | TryHackMe Linux Fundamentals
What is the username of who you’re logged in as on your deployed Linux machine?
Which directory contains a file?
What is the contents of this file?
Use the cd command to navigate to this file and find out the new current working directory. What is the path?
Use grep on “access.log” to find the flag that has a prefix of “THM”. What is the flag?
If I wanted to replace the contents of a file named “passwords” with the word “password123”, what would my command be?
Now if I wanted to add “tryhackme” to this file named “passwords” but also keep “passwords123”, what would my command be
What directional arrow key would we use to navigate down the manual page?
What flag would we use to display the output in a “human-readable” way?
How would you create the file named “newnote”?
What are the contents of this file?
Now switch to this user “user2” using the password “user2”
Output the contents of “important”, what is the flag?
What is the directory path that would we expect logs to be stored in?
What root directory is similar to how RAM on a computer works?
Name the home directory of the root user
Edit “task3” located in “tryhackme”‘s home directory using Nano. What is the flag?
Download the file http://MACHINE_IP:8000/.flag.txt onto the TryHackMe AttackBox
What are the contents?
If we were to launch a process where the previous ID was “300”, what would the ID of this new process be?
If we wanted to cleanly kill a process, what signal would we send it?
Locate the process that is running on the deployed instance (MACHINE_IP). What flag is given?
What command would we use to stop the service “myservice”?
What command would we use to start the same service on the boot-up of the system?
What command would we use to bring a previously backgrounded process back to the foreground?
When will the crontab on the deployed instance (MACHINE_IP) run?
What is the IP address of the user who visited the site?
What file did they access?