Linux Fundamentals Part 2 : TryHackMe

Secure Shell or SSH simply is a protocol between devices in an encrypted form.
- SSH allows us to remotely execute commands on another device remotely.
- Any data sent between the devices is encrypted when it is sent over a network such as the Internet
Syntax:
ssh username@ip_address
Task 3 Introduction to Flags and Switches
A majority of commands allow for arguments to be provided. These arguments are identified by a hyphen and a certain keyword known as flags or switches.
What directional arrow key would we use to navigate down the manual page?
Ans: down
What flag would we use to display the output in a “human-readable” way?
Ans: -h
Task 4 Filesystem Interaction Continued
Determining File Type
file nam_of_the_file
How would you create the file named “newnote”?
Ans: touch newnote
On the deployable machine, what is the file type of “unknown1” in “tryhackme’s” home directory?
Ans: ASCII text
How would we move the file “myfile” to the directory “myfolder”
Ans: mv myfile myfolder
What are the contents of this file?
Ans: THM{FILESYSTEM}
Task 5 Permissions 101
su - switch user
-rwx r-x — — 1 owner group 4096 Feb 26 10:00 example_file
In this example:
- The owner has read, write, and execute permissions (
rwx
). - The group has read and execute permissions (
r-x
). - Others have no permissions (
---
).
Numeric Representation:
- Permissions can also be represented using a numeric value.
- Read is represented by 4, write by 2, and execute by 1.
- The sum of these values represents the permission set.
rwxr-x — — can be represented as 750
- 7 for the owner (4+2+1)
- 5 for the group (4+1)
- 0 for others (no permissions)
On the deployable machine, who is the owner of “important”?
Ans: user2
What would the command be to switch to the user “user2”?
Ans: su user2
Now switch to this user “user2” using the password “user2”
Question Done
Output the contents of “important”, what is the flag?
Ans: THM{SU_USER2}
Task 6 Common Directories
/etc Directory:
- Importance: One of the most crucial root directories on a Linux system.
- Purpose: Stores system files used by the operating system.
- Examples:
sudoers
: Contains a list of users and groups with permission to runsudo
commands.passwd
andshadow
: Store encrypted passwords for each user in sha512 format.
/var Directory:
- Purpose: Main root folder for frequently accessed or written data by services and applications.
- Examples:
log
: Stores log files from running services and applications.opt
: May contain optional software packages or additional programs.tmp
: Used for temporary data that is not associated with a specific user.
/root Directory:
- Purpose: Home directory for the “root” system user.
- Note: Unlike the
/home
directory,/root
is specifically for the root user. - Content Example:
- May contain files and folders belonging to the root user (e.g.,
myfile
,myfolder
,passwords.xlsx
).
/tmp Directory:
- Purpose: Volatile and temporary storage for data that is needed to be accessed once or twice.
- Behavior: Contents are cleared out upon system restart.
- Security Implication: Any user can write to this folder by default, making it useful for storing temporary data during penetration testing.
What is the directory path that would we expect logs to be stored in?
Ans: /var/log
What root directory is similar to how RAM on a computer works?
Ans: /tmp
Name the home directory of the root user
Ans: /root