Skip to the content.

đź”— Link to the Room

🏷️ Table of Contents

  1. Introduction
    1.1 What is SSH?
  2. Introduction to Flags and Switches
    2.1 The Manual Page
  3. Filesystem Interaction Continued
    3.1 Creating Files and Folders
    3.2 Removing Files and Folders
    3.3 Copying and Moving Files and Folders
    3.4 Determining File Type
  4. Permissions 101
    5.1 Briefly: The Differences Between Users and Groups
    5.2 Switching Between Users
    5.3 Understanding File Permissions in Numeric Format
    5.4 Converting Symbolic Permissions to Numbers
    5.5 More Common Examples
    5.6 Why This Matters
  5. Common Directories
    6.1 etc
    6.2 var
    6.3 root
    6.4 tmp

Introduction

In this task, instead of using the in-browser terminal, we’re connecting to a remote Linux machine using SSH (Secure Shell).

What is SSH?

SSH is a way to remotely connect to another computer securely. It encrypts everything you type, so data traveling over the internet cannot be easily read by anyone else. Once the data reaches the remote machine, it is decrypted so the commands can run.

SSH allows you to run commands on a remote device as if you were sitting in front of it. All communication is encrypted, keeping your data safe over the internet.

SSH is like a secure remote control for a Linux machine.

image

It’s time for you to deploy your machines on thm.

 

Introduction to Flags and Switches

 

Many Linux commands can be extended with extra options, called flags or switches. Flags are added to commands with a hyphen (e.g., -a) or two hyphens for long options (e.g., --all). Without flags, commands run their default behavior.

Example: ls Command

image image

Most commands have a --help option, which lists all available flags and what they do: ls --help

 

The Manual Page

Every Linux command has a manual page (man page) with full documentation. Syntax example: man ls

image

The man page tells you what the command does, which flags are available and examples of usage.

Flags and switches let you control how commands behave, and man pages are your built-in guide to understand them.

 


❓What directional arrow key would we use to navigate down the manual page?down

❓What flag would we use to display the output in a "human-readable" way?-h

 

Filesystem Interaction Continued

 

In Linux, you interact with files and folders using simple commands. Here’s a quick guide:

Command What It Does
touch Create a blank file
mkdir Create a new folder
rm Remove a file or folder (use -R for folders)
cp Copy a file or folder
mv Move or rename a file/folder
file Check the type of a file

 

Creating Files and Folders

To create a file use touch file_name touch will create a blank file. To edit file (add content) use commands like vi, nano or so.

image

To create a directory (new folder) use mkdir folder_name mkdirliterally means make directory

image

 

Removing Files and Folders

To remove file use rm file_name To remove a folder recursively use option -R. Syntax example: rm -R directory_name

image

 

Copying and Moving Files and Folders

To copy a file use cp followed by the name of the file you want to be copied, then followed by the name of the new copy.

image

To move a file use mv. Note: mv will merge or modify the second file that you provide as an argument. You can use mv to rename a file (or folder). You can move files into folders by providing the folder name as the second argument.

Example of renaming the file note2 to be named note3:

image

 

Determining File Type

Linux files don’t always rely on extensions. Use the file command to check what a file actually contains:

image

 


❓How would you create the file named "newnote"?touch newnote

❓On the deployable machine, what is the file type of "unknown1" in "tryhackme's" home directory?ASCII text

❓How would we move the file "myfile" to the directory "myfolder"mv myfile myfolder

❓What are the contents of this file?THM{**********}

 

Permissions 101

 

In Linux, files and folders have permissions that control who can read, write, or execute them. Not all users can access all files, and permissions help keep your system secure.

Use ls -l or ls -lh to see files and their permissions:

image

The first column shows permissions:

r = read w = write x = execute

Permissions are grouped into Owner Group Others.

 

Briefly: The Differences Between Users and Groups

a real-world context: the system user that runs a web server must have permissions to read and write files for an effective web application. However, companies such as web hosting companies will have to want to allow their customers to upload their own files for their website without being the webserver system user – compromising the security of every other customer.

 

Switching Between Users

To switch to another user use su user_name

image

To switch to another user and inherit this user’s environment use su -l user_name -l stands for --login

image

 

Understanding File Permissions in Numeric Format

In Linux, every file and directory has a set of permissions that control who can read, write, or execute it. These permissions are often displayed in symbolic format, such as: rwxrwxrwx

Section Applies To Example
First 3 Owner rwx
Next 3 Group rwx
Last 3 Others rwx

Each letter represents a specific permission: r = read w = write x= execute

 

Converting Symbolic Permissions to Numbers

Each permission has a numeric value:

Permission Value
Read (r) 4
Write (w) 2
Execute (x) 1

To calculate the numeric value, we add the values together for each group.

![image]https://github.com/user-attachments/assets/7e6e5127-1b33-4f1c-9606-89cf6511ee0d)

 

More Common Examples

Symbolic Numeric Meaning
rwxr-xr-x 755 Owner can do everything, others can read and execute
rw-r–r– 644 Owner can read/write, others can only read
rwx—— 700 Only the owner has access

 

Why This Matters

Many commands like chmod use numeric permissions, for example chmod 750 system_overview.txt This means:

 


❓On the deployable machine, who is the owner of "important"?user2

❓What would the command be to swich to the user "user2"su user2

❓Output the contents of "important", what is the flag?THM{**_*****}

 

Common Directories

 

Linux has several important root directories that store system, user, and temporary data.

etc

System Configuration - /etc is root directory is one of the most important root directories on your system.

image

 

var

Variable Data - /var stores frequently updated data from services and applications. Log files are written in /var/log

image

 

root

Root User Home - Home directory for the root user (superuser). Different from /home, which is for regular users.

 

tmp

Short for temporary, used for short-lived files. Cleared automatically on reboot. Any user can write here, useful for pentesting scripts or temporary storage.

image

 


❓What is the directory path that would we expect logs to be stored in?/var/log

❓What root directory is similar to how RAM on a computer works?/tmp

❓Name the home directory of the root user/root

Â