Linux
Linux Terminal Commands
man ls # List manual
ls # List directory
ls -l # Shows more details
ls -a # Shows hidden
ls -h # Shows human readable info
cd # Change directory
cd .. # Move to parent directory
cd ~ # Move to home
cd <tab> # View suggested inputs
pwd # Print working directory full path
tree # Show all files and folders in the current directory
tree /path # Show the structure of a specific directory.
tree -L 2 # Limit the depth of displayed subdirectories to 2 levels.
tree -d # Show only directories
tree -f # Show the full path
touch file.txt # Create file
mkdir dir # Make directory
rm file.txt # Remove file
rmdir # Remove directory
cp test.txt ~/Downloads # Copy file
mv test.txt ~/Downloads # Move file/rename file
cat -n file.txt # Concatenate and display file content.
which # Locate a command.
which command # Find the path of an executable
which ls # Check if a command is available in the system
history # Show the list of recent commands
history | grep "pattern" # Search for commands containing specific text
alias # Create shortcuts for commands.
alias ll='ls -l' # Create an alias for a command
alias # List all defined aliases
Source: Linux Terminal, FreeCodeCamp
TMUX & Byobu
Terminal Multiplexer (TMUX) enable multiple terminnal session on a single window. On SSH, this enable the terminal to stay alive when the connection lost. Byobu is a wrapper around TMUX that provides a user-friendly interface and sync session across multiple clients. TMUX support themes too.
byobu : Enter
F2 : New Window
F3 : Previous Window
F4 : Next Window
F8 : Change window title
Shift + F2 : Split Vertically (Up/Down)
Ctrl + F2 : Split Horizontally (Left/Right)
Ctrl + F6 : Delete Tab
F7 : Scrollback Mode. Press spacebar to select, and enter to copy.
Shift + Alt + Dir : Resize a split window (pane)
byobu-tmux rename-session -t old-name "new-session-name"
byobu list-sessions
byobu attach -t "my-project" # Open that sesion
clear && byobu-tmux clear-history
Linux Distributions
Distribution Comparison
| Family | Distribution | Key Strengths |
|---|---|---|
| Debian | Ubuntu | High stability, massive community, ideal for beginners and servers. |
| Linux Mint | Lightweight, user-friendly interface (Cinnamon). | |
| Kali Linux | Specialized for penetration testing and digital forensics. | |
| Independent | Arch Linux | Minimalist, DIY approach, bleeding-edge rolling release. |
| Red Hat | Fedora | Innovative features, upstream-first, strong security (SELinux). |
| CentOS Stream | Enterprise-grade foundation, stable, binary compatible with RHEL. |
Linux Mechanism
Linux shell
A shell connects user to the system through terminal. Automate tasks using shell scripts. Scripts is a file which tells the shell to execute in order. Linux-based system use .sh for script file, Windows use .ps1 for powershell and .bat or .cmd for command prompt, cross-platform python use .py
| Shell | Description |
|---|---|
| Bash (Bourne Again Shell) | Default on many Linux systems. |
| Zsh (Z Shell) | Enhanced with more features and better scripting. |
| Fish (Friendly Interactive Shell) | User-friendly with autosuggestions. |
| Dash, Ksh, Csh, Tcsh | Other alternatives. |
Processes
Foreground Process: Runs in terminal Background Process: Ends when system reboot or user logs out
Package Management
- Debian-based (Ubuntu, Debian)
- apt (Advanced Package Tool)
- dpkg (Debian Package Manager): Install a
.debfile:
- RedHat-based (RHEL, CentOS, Fedora)
- yum (Yellowdog Updater, Modified)
- dnf (Modern replacement for yum in Fedora)
- rpm (RedHat Package Manager)
- Universal
- snap (Canonical's universal package format): Slow in ubuntu
- flatpak (Universal package system for Linux)
File Compression
- tar (Tape Archive) - Combines multiple files into one archive without compression. Often used with gzip for compression.
- gzip (GNU Zip) - Compresses a single file using the .gz format. Cannot combine multiple files into one (use tar first).
- gunzip - Used to extract files compressed with gzip.
Filesystem Knowledge
| Directory | Purpose |
|---|---|
| /home | Stores user files (e.g., /home/user) |
| /etc | System-wide configuration files (e.g., /etc/passwd) |
| /var | Variable data like logs (/var/log), cache, and temporary files |
| /tmp | Temporary files (auto-cleared on reboot) |
| /usr | User-installed programs (/usr/bin, /usr/lib) |
| /proc | Virtual filesystem with system/process info (/proc/cpuinfo) |
To access an external drive, it must be "mounted" to a directory.
Environment Management
Environment variables are added to ~/.bashrc or ~/.profile
| File | Purpose |
|---|---|
| ~/.bashrc | User-specific shell configuration, runs on new interactive shells |
| ~/.profile | User login script, used in login shells |
| /etc/environment | System-wide environment variables |
Build Tools
gcc is a compiler for C language and g++ is a compiler for C++ language.
make (Makefile System) is a build automation tool for unix that compiles complex projects efficiently. make only recompiles modified files.
cmake is a cross-platform build system generator.
Users
- Root User (sudo, root) – The superuser with full system control.
- Regular User – A non-root user with limited permissions.
- System Users – Used for system processes (e.g., www-data for web servers).
Install Ubuntu 22.04 on VM Windows
Shared Folder Location on Host:
C:\MyFolder\Linux_Ubuntu\Ubuntu_SharedFolderC:\Users\path\to\UbuntuSF
VM Folder: C:\Users\yourname\VirtualBox VMs\Ubuntu
Linux using Oracle VM
- Download Oracle VM Virtualbox: https://www.virtualbox.org/
- Download Ubuntu image: https://ubuntu.com/download/desktop
- Create / Load Machine (guest system): Goto machine -> new machine
| Details | Description |
|---|---|
| Name | The name of the environment. If you include the word Ubuntu in your name the Type and Version will auto-update. |
| Machine Folder | This is where your virtual machines will be stored so you can resume working on them whenever you like. |
| ISO Image | Here you need to add a link to the ISO you downloaded from the Ubuntu website. |
| User profile | To secure the ubuntu |
| Add guess addition | Some addition like window sizing support could be added |
| Define the Virtual Machine's resources | Recommended to use at least 8GB RAM, 4 CPUs, 32GB hard disk |
| Create disk | You can create a new disk or load existing disk |
Settings
- Bidirectional "copy and paste" and "drag and drop": Goto VM settings -> general -> advanced, set to bidirectional
- Enable network: Goto VM settings -> Network -> Adapter1 -> Choose Bridged Adapter1
- Adding USB: Goto VM settings -> Add new USB -> Choose USB
- Adding shared folder: Goto VM settings -> Shared Folders -> Set as auto mount and add folder path -> run VM. Make sure guess addition is added, then add user to vboxsf group: { sudo adduser username vboxsf } -> restart
- USB: Download vb extension pack on host here. Then goto File -> tools -> extension pack manager -> load the extension pack downloaded. Create vboxuser
sudo groupadd vboxusers. Add yourself into the groupsudo usermod -aG vboxusers your_username. In VM settings -> USB -> add filter -> start ubuntu -> goto file, then USB is there.