Youssef Samir

Get in touch

Linux

Explore Linux, the open-source operating system that powers servers, desktops, and various devices worldwide.

Managing Window Sizes

  • Windows + T: Adjust window sizes.
  • Alt + Ctrl + T: Open a new terminal.

File System Overview

  • /root: Home directory of the root user.
  • /etc:
    • Contains Linux configuration files.
    • Subdirectories:
      • /shadow: Contains password hashes.
      • /hosts: Holds DNS records.
      • /<default package manager>/sources.list: Lists software repositories.
      • /resolv.conf: DNS configurations (overridable).
      • /systemd/resolved.conf: Permanent DNS configurations (cannot be overridden).
      • /fstab: File system table, specifying automatic mounts on boot.
  • /home: User's home directory.
  • /mnt: Where filesystems are mounted.
  • /media: USB devices are mounted here.
  • /bin: Application binaries.
  • /lib: Libraries and shared programs.
  • /opt: Applications.

Basic Commands

  • pwd: Print working directory.
  • whoami: Display current user.
  • cd:
    • ..: Move one level up.
    • ~: Move to home directory.
  • whatis <command>: Show command function.
  • ls:
    • -l: Long listing.
    • -a: Show hidden files.
  • man <program name>: Display manual pages.
  • locate <keyword>: Locate keyword occurrences.
  • whereis <keyword>: Locate binary file.
  • which <keyword>: Return binary location.
  • find <directory> <options> <expression>: Search in directory.

Notes

  • Use double dash (--) for word options.
  • Use single dash (-) for single-letter options.

Files and Operations

  • cat:
    • <filename>: Create a file.
    • <filename>: Append to a file.
  • touch <filename>: Create a new file.
  • mkdir <directory name>: Create a new directory.
    • -p: Make nested directories if they don't exist.
  • rmdir <directory>: Remove an empty directory.
  • cp <file source> <file destination>: Copy a file.
  • mv <source> <destination>: Move a file or directory.
  • rm <filename>: Remove a file.
    • -r: Recursively remove a directory.
    • -f: Force removal.
    • -i: Prompt before removal.

Text Manipulation

  • grep <keyword>: Filter for keywords.
    • -i: Case-insensitive.
    • -o: Print each occurrence on a separate line.
  • tee: Read from standard input and write to standard output and files.
  • wc: Word count.
    • -l: Number of lines.
    • -w: Number of words.
    • -m: Number of characters.
  • echo <string> > <file>: Write string to a file.
  • echo <string> >> <file>: Append string to a file.
  • diff <file 1> <file 2>: Show differences between files.
  • head <file>: View the beginning of a file.
  • tail <file>: View the last lines of a file.
  • cut -d "<delimiter>": Cut a string using a delimiter.
  • nl <file>: Display line numbers in a file.
  • sed: Stream editor for search and replace.
  • more <file>: Page through a file.
  • less <file>: Scroll through a file.
  • sort: Sort a file.
  • uniq: Remove duplicate lines.
  • base64 -d <file>: Decode a base64-encoded text.

Networks

  • ifconfig: Query active network connections.
  • iwconfig: Query active wireless connections.
  • nmcli dev wifi: View WiFi AP and info.
  • dhclient <interface>: Request a new IP address.
  • dig <domain name> ns: Get domain nameserver info.
  • netstat: Network status.
  • curl <website>: Send GET request to a server.

Package Manager

Debian (apt)

  • apt-get update: Update package list.
  • apt-get upgrade: Upgrade packages.
  • apt-get install <package name>: Install a package.
  • dpkg -i <package.deb>: Install a local .deb package.

Arch (pacman)

  • pacman -Syu: Update package lists and upgrade system.
  • pacman -S <package name>: Install a package.
  • pacman -R <package name>: Remove a package.

Permissions

  • useradd <username>: Add a new user.
  • su <username>: Switch user.
  • passwd: Change current user's password.
  • chown <username> <file/dir>: Change file/directory ownership.
  • chmod <rwx ogu octal notation> <file/dir>: Change permissions.

Process Management

  • ps: List processes.
  • top: Display processes ordered by resource usage.
  • kill -<signal number> <PID>: Send a signal to a process.
  • renice <nice absolute value> <PID>: Change process priority.

Environment Variables

  • env: View default environment variables.
  • export <environment variable>: Export a variable to the system.

Compressing and Archiving

  • unzip: Unzip .zip files.
  • tar: Archive multiple files into a single file.
  • gzip: Compress files.
  • dd if=<input file> of <output file>: Bitwise copy of a file or filesystem.

Services

  • service <service name> <start|stop|restart>: Control service state.

Hacking

WiFi Recon

  • airmon-ng check kill: Kill interfering processes.
  • airmon-ng start|stop|restart <interface>: Set WiFi card to monitor/active modes.
  • airodump-ng <interface>: Capture and display key data from APs and clients.
  • aireplay-ng --deauth 100 -a <BSSID> -c <BSSID> <interface>: Deauthenticate clients from an AP.
  • aircrack-ng -w <dictionary> -b <BSSID> <hash file.cap>: Crack password hash with a dictionary attack.

HCX and Dump Cat

  • Stop NetworkManager.service and wpa_supplicant.service.
  • Use hcxdumptool and hcxpcapngtool for capturing and processing packets.