Hacker Kayra
  • 📍Introduction Page
  • ⭐Learning Process
    • 🧠Learning Mindset
    • 🖇️Learning Dependencies
    • 🧮Learning Process
  • 🔠Fundamentals
    • 🛜Networking Fundamentals
    • 🐧Linux Fundamentals
    • 🪟Windows Fundamentals
    • 🕵️Active Directory
    • 🕸️Introduction to Web Applications
    • 🗃️Other Useful Concepts
      • Regular Expressions (RegEx)
    • Cyber Security Products
      • Lab Setup
      • ✅Fortigate Firewall
      • MDM Lab
      • IAM Lab
      • PAM Lab
      • DLP Lab
  • 🧰Tools
    • Nmap
    • Nessus
    • Ffuf
    • Hydra
    • John The Ripper
  • ✍️Write Ups
    • 🗃️Hack The Box Machines
      • 🐧Linux
        • Code
    • 🗃️Proving Grounds Boxes
      • 🐧Linux
        • Stapler
        • eLection
        • Loly
        • Blogger
        • Potato
        • Amaterasu
        • Exfiltrated
        • Pelican
        • Astronaut
        • Cockpit
        • Levram
        • Extplorer
        • LaVita
        • pc
        • Scrutiny
        • Zipper
        • Flu
        • Twiggy
        • Codo
        • Crane
        • Hub
        • BlackGate
        • Boolean
        • ClamAV
        • PayDay
        • Snookums
        • Bratarina
        • Nibbles
      • 🪟Windows
        • Algernon
        • AuthBy
        • Craft
        • Kevin
        • Squid
        • Jacko
        • DVR4
        • Hepet
        • Shenzi
        • Nickel
        • Slort
        • MedJed
        • Active Directory
          • Access
          • Vault
    • 🪪Certificates
      • Certified Professional Penetration Tester (eCPPTv3)
      • Web Application Penetration Tester eXtreme (eWPTXv3)
    • 🚩CTF Events
      • Cyber Hub 2025 CTF
  • 📚Study Notes
    • Penetration Tester (HTB CPTS)
      • Penetration Testing Process
      • Reconnaissance, Enumeration & Attack Planning
        • Network Enumeration with Nmap (Continue Here)
        • Footprinting (Just Do Formatting)
        • Vulnerability Scanning (Check)
        • File Transfers
        • Using the Metasploit Framework
        • Web Information Gathering
        • Shells & Payloads
      • Exploitation & Lateral Movement
        • Attacking Common Services (Just Do Formatting)
        • Password Attacks
        • Active Directory Enumeration & Attacks (TBC)
        • Pivoting, Tunneling, and Port Forwarding
      • Web Exploitation
        • Using Web Proxies (Check)
        • Attacking Web Applications With Ffuf (Check)
        • Login Bruteforcing
        • Cross-Site Scripting (XSS)
        • Command Injection
        • SQL Injection
        • File Upload Attacks
        • File Inclusion
        • Web Attacks (Check)
        • Attacking Common Applications (Check)
      • Post-Exploitation
        • Linux Privilege Escalation
        • Windows Privilege Escalation (TBC)
      • Documentation & Reporting
  • 🧑‍💻Other
    • Leet Code
      • Quick Guide: Big-O Notation
      • Problem 01 - Two Sum
    • Data Structure & Algorithms (DSA)
  • 🗄️Archive/Backup/Bin
    • Sysmon Usecases (IBM)
    • 🐧Linux Fundamentals (TryHackMe)
      • Introduction
      • Basic Commands
      • Wildcards & Operators
      • Permissions
      • Common Directories
      • Terminal Text Editors
      • General/Useful Utilities
    • 🪟Windows Fundamentals (TryHackMe)
      • Introduction
      • The File System
      • User Accounts
      • Settings & Control Panel & Task Manager
      • System Configuration
    • Active Directory (TryHackMe)
      • Breaching Active Directory
    • FOR508: Advanced Incident Response, Threat Hunting, and Digital Forensics
      • Book 2 - Intrusion Analysis
        • Credential Theft
        • Event Log Analysis for Responders and Hunters
    • Certified Threat Hunting Professional (eCTHPv2)
      • Threat Hunting: Hunting the Endpoint & Endpoint Analysis
        • Event IDs, Logging, & SIEMs
    • OSCP
      • Report Writing
      • ✅Passive Information Gathering
      • ✅Active Information Gathering
      • ✅Vulnerability Scanning
      • Introduction to Web Application Attacks
      • Common Web Application Attacks
        • ✅Cross-Site Scripting (XSS)
        • ✅Directory Traversal
        • ✅File Inclusion
        • ✅File Upload Vulnerabilities
        • Command Injection
        • SQL Injection Attacks
        • Client Side Attacks
      • ✅Locating Public Exploits
      • ✅Exploiting Walkthrough
      • Fixing Exploits
      • ✅Antivirus Evasion
      • Password Attacks
      • Windows Privilege Escalation
      • Linux Privilege Escalation
      • Port Redirection and SSH Tunneling
      • Tunneling Through Deep Packet Inspection
      • The Metasploit Framework
      • Active Directory Introduction & Enumeration
      • Attacking Active Directory Authentication
      • Lateral Movement in Active Directory
      • Assembling the Pieces
      • Other General Information
    • ⚡Port Swigger (Web Penetration Testing)
      • ✅Information Disclosure
      • ✅Path Traversal (Directory Traversal)
      • ✅OS Command Injection
      • Business Logic Vulnerabilities
      • ✅Authentication
      • ✅Access Control
    • Certified Bug Bounty Hunter (CBBH)
      • Web Requests
        • HTTP Fundamentals
    • Getting Started
      • Introduction
      • Pentesting Basics
    • Certified Penetration Testing Specialist (CPTS)
      • Introduction
        • ✅Penetration Testing Process
          • Penetration Testing Overview
          • Laws & Regulations
          • Penetration Testing Process
          • Pre-Engagement
          • Information Gathering
          • Vulnerability Assessment
          • Exploitation
          • Post-Exploitation
          • Lateral Movement
          • Proof-of-Concept
          • Post-Engagement
          • Practice
          • Academy Module Layout
        • Getting Started with Hack The Box (HTB)
      • Reconnaissance, Enumeration & Attack Planning
        • ✅Network Enumeration with Nmap
          • Enumeration & Introduction to Nmap
          • Host Discovery
          • Host and Port Scanning
          • Saving The Results
          • Service Enumeration
          • Nmap Scripting Engine
          • Scanning Performance
          • Firewall and IDS/IPS Evasion
        • Footprinting
        • ✅Information Gathering - Web Edition
          • Introduction
          • Passive Information Gathering
          • Active Information Gathering
        • Vulnerability Assessment
        • File Transfers
        • Shells & Payloads
        • Using the Metasploit Framework
      • Exploitation & Lateral Movement
        • Password Attacks
        • Attacking Common Services
        • Pivoting, Tunneling, and Port Forwarding
        • Active Directory Enumeration & Attacks
      • Web Exploitation
        • Using Web Proxies
        • ✅Attacking Web Applications with Ffuf
        • ✅Login Brute Forcing
        • SQL Injection Fundamentals
        • SQLMap Essentials
        • Cross-Site Scripting (XSS)
        • File Inclusion
        • File Upload Attacks
        • Command Injections
        • Web Attacks
        • Attacking Common Applications
      • Post-Exploitation
        • Linux Privilege Escalation
        • Windows Privilege Escalation
      • Reporting & Capstone
        • Documentation & Reporting
        • Attacking Enterprise Networks
    • Old Active Directory
    • Tib3rius Privilege Escalation
      • Linux Privilege Escalation
    • HTB Archived Write-Ups (Check)
      • Irked
      • Nibbles
      • Brainfuck
      • Lame (Check)
    • 📋Cheat Sheets
      • Penetration Testing Cheat Sheet (In Progress)
Powered by GitBook
On this page
  • Fundamentals
  • Philosophy
  • Components
  • Linux Distributions
  • File System Hierarchy
  • The Linux Shell
  • Getting Help With Commands
  • System Information Commands
  • Navigating the Filesystem
  • Text Editing in the Terminal
  • Shortcuts
  • Finding Files and Directories
  • File Descriptors and Redirections
  • Filter Contents
  • Permission Management
  • Permission Representation
  • Permission Meanings
  • Special Permissions
  1. Fundamentals

Linux Fundamentals

Here you will find basic concepts about the Linux operating system.

Fundamentals

  • Linux is an operating system like Windows, iOS, Android, or macOS.

Philosophy

  • Linux is built on core principles:

    • Everything Is a File: Most system elements, including configuration settings, are stored as text files.

    • Small, Single-Purpose Programs: Linux provides many tools, each designed to perform one task well.

    • Chaining Programs: Small programs can be combined to handle complex tasks efficiently.

    • Avoid captive user interfaces: Emphasis is placed on command-line interfaces (shells) rather than restrictive, captive user interfaces.

    • Configuration data stored in a text file: Configurations are accessible in text format (e.g., the /etc/passwd file), making it easier to understand and modify system behavior.

Components

  • Bootloader: Initiates the boot process (e.g., GRUB is commonly used in many distros).

  • Kernel: The core of Linux that manages hardware resources and system processes.

  • Daemons: Background services that ensure functions like scheduling, printing, and networking run smoothly.

  • Shell: The command-line interface (e.g., Bash, Zsh) that allows users to interact directly with the OS.

  • Graphics Server & Window Manager: Provide the graphical user interface (GUI) for visual interactions (examples include GNOME, KDE, and Cinnamon).

  • Utilities: Applications that perform specific tasks to enhance system functionality.

Linux Distributions

  • Linux distributions (or "distros") are operating systems built on the Linux kernel. They are adapted for various purposes for example, servers, desktops, embedded systems, and mobile devices.

  • Examples of distros and their usages:

    • Fedora/Ubuntu: Used as a desktop linux that's suitable for beginners and everyday users.

    • Kali Linux/ ParrotOS: Used by cybersecurity specialists.

    • Debian is known for its stability and reliability, making it a favorite for desktops, servers, and embedded systems. Other operating systems are based on Debian, including but not limited to Kali Linux and Ubuntu.

File System Hierarchy

Path
Description

/

The root directory containing essential files for booting and system operation.

/bin

Contains essential command binaries.

/boot

Static bootloader files, kernel images, and related files.

/dev

Device files that allow access to hardware components.

/etc

Configuration files for the system and installed applications.

/home

User directories for personal data storage.

/lib

Shared library files that are required for system boot.

/media

Mount points for external removable media (e.g., USB drives).

/mnt

Temporary mount point for filesystems.

/opt

Optional software and third-party applications.

/root

The home directory for the root user.

/sbin

System administration binaries used by the root user.

/tmp

Temporary files created by the system and applications.

/usr

User-related programs, libraries, and documentation.

/var

Variable data files, such as logs, emails, and spool files.

The Linux Shell

  • The Linux shell (or terminal) is a text-based interface that lets you communicate directly with the operating system. Using the shell, you can navigate directories, manage files, execute programs, and automate tasks with scripts, often more efficiently than through a GUI.

  • The most commonly used shell in Linux is the Bourne-Again Shell (BASH), and is part of the GNU project.

  • The default prompt typically displays your username, hostname, and current working directory.

    • For example: <username>@<hostname>:<current_directory>$

    • Root User: The prompt often changes to a hash (#) instead of a dollar sign ($), indicating administrative privileges.

    • Home Directory: Represented by a tilde (~).

  • The PS1 variable in Linux systems controls how your prompt appears. These settings are typically found in your shell’s configuration file (e.g., .bashrc for Bash).

Getting Help With Commands

  • When you encounter an unfamiliar tool or need to understand optional parameters, you have several resources at your disposal:

    • Manual Pages (man): Use the man command to view detailed manuals. For example: man ls

    • Help Options: Most commands offer quick help via: command --help or command -h

    • Apropos: Use apropos <keyword> to search the short descriptions of all man pages for a given keyword.

System Information Commands

  • Below are some commands that help us in understanding system details, processes, and user settings:

    • whoami: Displays the current username.

    • id: Shows user identity and group memberships.

    • hostname: Prints the system's hostname.

    • uname: Displays system and kernel information.

    • ifconfig: Views the network interfaces.

    • ps: List current processes.

    • who: Shows who is logged into the system.

    • env: Displays or sets environment variables.

Navigating the Filesystem

  • Just as a Windows user relies on the mouse to navigate, Linux users rely on the terminal to move through directories and manage files.

  • pwd: Displays the current directory.

  • ls:Lists files and directories.

    • ls -la shows all files, including hidden ones (those starting with a dot).

  • cd:Changes the current directory.

    • You can specify a full path without navigating one folder at a time.

    • A single dot (.) refers to the current directory.

    • Two dots (..) refer to the parent directory.

  • touch <filename>: Creates a new, empty file.

  • cat <filename>: Displays a file's contents.

  • mkdir <dirname>: Creates a new directory.

    • Use the -p option to create multiple parent directories in one go.

  • tree <dirname>: Visualizes the directory hierarchy.

  • mv <filename> <new-filename>: Moves or renames a file.

  • cp <filename> <new-filepath>: Copies a file.

Text Editing in the Terminal

  • nano is a beginner-friendly, text-based editor:

  • When we open nano, below we see two lines with short descriptions. The caret (^) stands for our [CTRL]key.

  • vim is an another open-source editor for all kinds of ASCII text. It is an improved clone of the previous vi.

    • Vim is a modal editor that can distinguish between text and command input. it offers a total of 6 modes:

Mode
Description

Normal

Default mode where keystrokes are interpreted as commands (no text insertion).

Insert

For entering text; characters are added to the buffer.

Visual

For selecting text blocks to edit, delete, or copy.

Command

For executing single-line commands (accessed by typing :) to perform operations like saving, quitting, or searching.

Replace

Overwrites existing text with new input.

Ex

Allows sequential command execution, similar to the old Ex editor.

vimtutor can be used to practice and learn Vim’s commands interactively

Shortcuts

  • Clearing the Terminal: Use the clear command or the shortcut [Ctrl] + [L].

  • Command History:

    • Use the arrow keys (↑/↓) to scroll through previous commands.

    • Use [Ctrl] + [R] to search command history by typing part of a previous command.

  • Auto-Complete: Typing part of a path (e.g., cd /dev/s) and pressing [TAB] lets the shell auto-complete directory names.

Finding Files and Directories

  • which : Returns the full path of the executable that will be run for the specified command. This allows us to determine if specific programs are available on the operating system.

  • find <location> <options>: Searches for files and directories in the specified location with filtering options.

    • -type f: Searches for files.

    • -name *.<ext>: Finds files with names matching the *.<ext>pattern.

    • -user root: Filters for files owned by the root user.

    • -size +#k: Finds files larger than # KiB.

    • -newermt yyyy-mm-dd: Finds files modified after yyyy-mm-dd.

    • -exec ls -al {} \;: Executes the command (ls -al) on each found file (the curly brackets act as placeholders).

  • locate <pattern>: Quickly searches for files using a local database.

    • sudo updatedb: Updates the locate database.

File Descriptors and Redirections

  • A file descriptor (FD) in Unix/Linux operating systems is a reference, maintained by the kernel, that allows the system to manage Input/Output (I/O) operations. It acts as a unique identifier for I/O resources.

  • By default, the first three file descriptors in Linux are:

    • STDIN (0): Standard input (data fed into a command).

    • STDOUT (1): Standard output (regular output from a command).

    • STDERR (2): Standard error (output for error messages).

  • We can redirect the descriptors to other sources.

    • Example: 2>/dev/null redirects the error messages to null (Discard)

    • Example: 2> stderr.txt 1> stdout.txt redirects both the error messages and the output to the files.

    • Example: cat < stdout.txt redirects the content in stdout.txt to the cat command (Inputted to the cat commant hence the <)

  • Another way to redirect STDOUT is to use pipes (|). These are useful when we want to use the STDOUT from one program to be processed by another.

    • Example: find /etc/ -name *.conf 2>/dev/null | grep systemd | wc -l

When we use the greater-than sign (>) to redirect our STDOUT, a new file is automatically created if it does not already exist. If this file exists, it will be overwritten without asking for confirmation. If we want to append STDOUT to our existing file, we can use the double greater-than sign (>>).

Filter Contents

  • Sometimes you want to inspect file contents without opening a text editor. Instead, you can use pagers, tools that let you view files interactively, one screen at a time.

  • more: displays file contents screen by screen.

    • Example: cat /etc/passwd | more

    • Start at the beginning and scroll forward; press [Q] to quit.

  • less <filename>: Similar but offers additional features over more.

  • head <filename>: Shows by default only the first 10 lines of a file.

  • tail <filename>: Shows by default only the last 10 lines of a file.

  • sort: Sorts the data using different options.

  • grep "pattern": Filters results using specified patterns.

    • The option -v can be used to set reverse filtering.

  • cut: Extracts specific sections from each line of a file based on a delimiter.

    • Example: cut -d":" -f1 Grabs the first field delimited by a colon (:)

  • tr "<section-to-replace>" "<new-section>": Replaces a specific section from each line by another provided section.

  • column -t: Format output into aligned columns

  • awk: Process text and extract columns with ease.

    • Example: awk '{print $1, $NF}' Displays the first and last fields of each line.

  • sed: Makes substitutions

    • Exmaple: sed 's/bin/HTB/g' Changes bin with HTB globally.

  • wc: Counts words, lines, or characters.

Permission Management

  • Linux permissions are assigned to both individual users and groups. A user may belong to multiple groups, with each membership potentially granting additional rights to perform specific actions on files and directories.

  • Every file or directory has an owner and an associated group. Permissions are defined separately for the owner, the group, and others, specifying which actions are allowed.

  • When a new file or directory is created, it automatically becomes owned by the creator and is associated with their primary group.

  • A user can belong to multiple groups, with each membership potentially granting additional rights to perform certain actions on files and directories.

Permission Representation

  • Linux permissions can be expressed using either letters or numbers. In numeric mode, a three-digit value specifies the permissions for the owner, group, and others (for example, 744):

    • First digit: Owner permissions

    • Second digit: Group permissions

    • Third digit: Other users

  • Each permission has an assigned numeric value:

    • r (read): 4

    • w (write): 2

    • x (execute): 1

  • For example, consider a file that has read, write, and execute permissions for its owner, and only read permission for the group and others:

    • Owner: rwx = 4 + 2 + 1 = 7

    • Group: r-- = 4 + 0 + 0 = 4

    • Others: r-- = 4 + 0 + 0 = 4

Permission Meanings

  • Read (r):

    • Files: Allows you to access the file's contents.

    • Directories: Permits you to list the directory’s contents (i.e., the names of files and subdirectories), though not necessarily view the contents of those files.

  • Write (w):

    • Files: Enables you to modify or change the file's contents.

    • Directories: Allows you to modify the directory’s contents—such as creating, deleting, or renaming files and subdirectories.

  • Execute (x):

    • Files: Permits you to run the file as a program.

    • Directories: Provides access to the directory. With execute permission, you can traverse the directory (using commands like cd), view detailed file information (with commands like ls -l), and access subdirectories.

Special Permissions

  • SUID (Set User ID): When set on an executable file, the SUID bit ensures the file runs with the privileges of the file’s owner, regardless of who executes it.

  • SGID (Set Group ID): When applied, SGID makes a file execute with the privileges of its group owner. In directories, it causes new files to inherit the group ownership of the directory, which is particularly useful in collaborative environments.

  • Sticky Bit: Applied at the directory level, the sticky bit restricts file deletion. Even if a user has write permissions for a directory, only the file’s owner (or root) can remove or rename its files.

PreviousNetworking FundamentalsNextWindows Fundamentals

Last updated 3 months ago

🔠
🐧
Page cover image