Learn Terminal Commands Quickly

Welcome to the Terminal Command Hub. Learn the essential commands for development and server management. (This page is powered by a reusable JavaScript library.)

 

[
    {
        "groupTitle": "Section 1: The Basics",
        "topics": [
            {
                "title": "What is the Terminal?",
                "explanation": "The terminal (or Command Line Interface - CLI) is a text-based way to control your computer. Instead of clicking buttons, you type commands. It is faster, more powerful, and essential for development, server management, and automation.",
                "example": "// The '$' is a 'prompt', waiting for a command.\n// 'user@hostname' shows who and where you are.\n// '~' is a shortcut for your home directory.\n\nuser@hostname:~$ "
            },
            {
                "title": "sudo (Super User Do)",
                "explanation": "Runs a command with administrator (or 'root') privileges. This is needed for installing software or changing system files. It will usually ask for your password.",
                "example": "// Example: Update the system's package list\nsudo apt-get update\n\n// Example: Install a new program\nsudo apt-get install nginx"
            },
            {
                "title": "clear (Clean Screen)",
                "explanation": "This command simply clears your terminal screen, moving the prompt to the top. It's useful for reducing clutter.\n\nA common keyboard shortcut is `Ctrl + L`.",
                "example": "clear"
            },
            {
                "title": "whoami (Who am I?)",
                "explanation": "A simple command that prints the username of the user you are currently logged in as.",
                "example": "user@hostname:~$ whoami\nuser"
            }
        ]
    },
    {
        "groupTitle": "Section 2: Navigating Folders & Files",
        "topics": [
            {
                "title": "ls (List Files)",
                "explanation": "Lists the files and directories in your current location. It's the most common command.\n\n• `ls`: Simple list.\n• `ls -l`: Long list (shows permissions, owner, size).\n• `ls -a`: Shows *all* files, including hidden ones (that start with a dot, like `.git`).\n• `ls -la`: A combination of the two.",
                "example": "user@hostname:~$ ls\nDesktop  Documents  Downloads  Music  my-project\n\nuser@hostname:~$ ls -la\ndrwxr-xr-x 4 user user 4096 Nov 6 10:00 .\ndrwxr-xr-x 3 root root 4096 Oct 1 08:00 ..\n-rw-r--r-- 1 user user  220 Oct 1 08:00 .bashrc\ndrwxr-xr-x 2 user user 4096 Nov 5 12:00 my-project"
            },
            {
                "title": "cd (Change Directory)",
                "explanation": "Moves you from one folder to another.\n\n• `cd my-project`: Go into the 'my-project' folder.\n• `cd ..`: Go *up* one level.\n• `cd ~`: Go back to your home directory.\n• `cd /var/www`: Go to an absolute path.",
                "example": "user@hostname:~$ pwd\n/home/user\nuser@hostname:~$ cd my-project\nuser@hostname:~/my-project$ pwd\n/home/user/my-project\nuser@hostname:~/my-project$ cd ..\nuser@hostname:~$ "
            },
            {
                "title": "pwd (Print Directory)",
                "explanation": "Tells you the *full path* of the directory you are currently in. Useful if you get lost.",
                "example": "user@hostname:~/my-project/src$ pwd\n/home/user/my-project/src"
            }
        ]
    },
    {
        "groupTitle": "Section 3: Creating & Moving Files",
        "topics": [
            {
                "title": "mkdir (Make Directory)",
                "explanation": "Creates a new, empty folder (directory).",
                "example": "// Create a single directory\nmkdir new-folder\n\n// Create nested directories all at once\nmkdir -p new-project/css/components"
            },
            {
                "title": "touch (Create File)",
                "explanation": "Creates a new, empty file. If the file already exists, it updates its 'last modified' timestamp.",
                "example": "touch index.html\ntouch css/style.css"
            },
            {
                "title": "cp (Copy)",
                "explanation": "Copies files or directories. The structure is `cp [SOURCE] [DESTINATION]`. \n\n• `cp file.txt backup.txt`: Copy and rename a file.\n• `cp -r project/ backup/`: Copy a directory.",
                "example": "// Copy a file\ncp index.html index-backup.html\n\n// Copy a file into another directory\ncp index.html ./backup/\n\n// Copy an entire directory\ncp -r ./src ./src-backup"
            },
            {
                "title": "mv (Move / Rename)",
                "explanation": "Moves or renames files and directories. The command is the same for both actions.\n\n• **Rename**: `mv old-name.txt new-name.txt`\n• **Move**: `mv file.txt ./new-folder/`",
                "example": "// Rename a file\nmv temp.txt config.txt\n\n// Move a file into a folder\nmv config.txt ./includes/"
            }
        ]
    },
    {
        "groupTitle": "Section 4: Deleting Files & Folders",
        "topics": [
            {
                "title": "rm (Remove File)",
                "explanation": "Deletes a file. **This is permanent!** There is no 'Recycle Bin'. Use with caution.\n\n• `rm file.txt`: Delete one file.\n• `rm -f file.txt`: *Force* delete without asking.",
                "example": "rm old-logo.png\nrm -f temp-cache-file.tmp"
            },
            {
                "title": "rmdir / rm -r (Remove Dir)",
                "explanation": "Deletes directories.\n\n• `rmdir`: Deletes an *empty* directory.\n• `rm -r`: **DANGEROUS**. Recursively deletes a directory and *everything* inside it. There is no 'undo'.",
                "example": "// Remove an empty folder\nrmdir empty-folder\n\n// Remove a folder and all its contents\nrm -r project-to-delete"
            }
        ]
    },
    {
        "groupTitle": "Section 5: Viewing & Finding",
        "topics": [
            {
                "title": "cat (View File)",
                "explanation": "'Catenate'. Dumps the *entire* content of a file to the screen. Best for small files.",
                "example": "cat config.php"
            },
            {
                "title": "less (View File)",
                "explanation": "The best way to view large files. It opens an interactive pager, letting you scroll up and down. \n\nPress `q` to quit. Press `/` to search.",
                "example": "less large-server.log"
            },
            {
                "title": "find (Discover Files)",
                "explanation": "Searches for files and directories based on name, size, type, etc. Very powerful.\n\nStructure: `find [WHERE] [CRITERIA]`",
                "example": "// Find all files named 'style.css'\nfind . -name \"style.css\"\n\n// Find all files ending in .js\nfind ./src -name \"*.js\"\n\n// Find all directories\nfind . -type d"
            },
            {
                "title": "grep (Search Inside Files)",
                "explanation": "Searches *inside* files for a specific text pattern. Incredibly useful for finding code or errors.\n\n`grep -r`: Recursive search (searches all files in all subfolders).",
                "example": "// Find \"error\" in a log file\ngrep \"error\" server.log\n\n// Recursively find \"myFunction\" in all files\ngrep -r \"myFunction\" ./src"
            }
        ]
    },
    {
        "groupTitle": "Section 6: Archiving (Zip)",
        "topics": [
            {
                "title": "zip / unzip",
                "explanation": "The standard command for creating and extracting `.zip` archives.\n\n• `zip`: Create an archive.\n• `unzip`: Extract an archive.",
                "example": "// Zip a folder recursively\nzip -r my-archive.zip ./my-project\n\n// Extract an archive\nunzip my-archive.zip"
            },
            {
                "title": "tar (Archive)",
                "explanation": "A very common Linux/Mac archiver, often combined with Gzip (`.tar.gz`).\n\n• `c`: Create\n• `z`: Gzip\n• `v`: Verbose (show files)\n• `f`: File (must be last)\n• `x`: Extract",
                "example": "// Create (c) a gzipped (z) archive\ntar -czvf my-archive.tar.gz ./my-project\n\n// Extract (x) a gzipped (z) archive\ntar -xzvf my-archive.tar.gz"
            }
        ]
    },
    {
        "groupTitle": "Section 7: File Transfer & Servers",
        "topics": [
            {
                "title": "ssh (Secure Shell)",
                "explanation": "Logs you into a remote server's terminal. This is the primary way to manage a web server.",
                "example": "// Connect to a server\nssh username@your-server-ip.com\n\n// Connect using a specific port\nssh -p 2222 username@your-server-ip.com"
            },
            {
                "title": "scp (Secure Copy)",
                "explanation": "Copies files to or from a remote server over SSH.\n\nStructure: `scp [SOURCE] [DESTINATION]`",
                "example": "// Upload a file to a server\nscp file.txt user@server:/var/www/\n\n// Download a file from a server\n// (The '.' means 'current local folder')\nscp user@server:/var/www/backup.sql ."
            },
            {
                "title": "rsync (Sync Files)",
                "explanation": "A more advanced tool for syncing files and directories. It's much faster than `scp` for large projects because it only copies the *changes*.",
                "example": "// Sync a local folder UP to a server\nrsync -avz ./my-project/ user@server:/var/www/"
            }
        ]
    },
    {
        "groupTitle": "Section 8: Database (MySQL)",
        "topics": [
            {
                "title": "mysql (Database Client)",
                "explanation": "Connects to a MySQL or MariaDB database from the terminal. This gives you a new `mysql>` prompt where you can run SQL queries.",
                "example": "// Connect to a database\nmysql -u my_user -p\n\n// It will ask for your password.\n// Then you can run SQL:\n// SHOW DATABASES;\n// USE my_database;\n// SELECT * FROM users;"
            },
            {
                "title": "mysqldump (Backup DB)",
                "explanation": "Dumps the *entire* contents of a database into a single `.sql` file. This is the standard way to make a backup.",
                "example": "// Dump 'my_database' to a file\nmysqldump -u my_user -p my_database > database-backup.sql"
            },
            {
                "title": "mysql (Import DB)",
                "explanation": "Restores a database from a `.sql` backup file.",
                "example": "// Import a backup file into 'my_database'\nmysql -u my_user -p my_database < database-backup.sql"
            }
        ]
    },
    {
        "groupTitle": "Section 9: Permissions",
        "topics": [
            {
                "title": "chmod (Change Mode)",
                "explanation": "Changes the permissions of a file or directory. It uses octal (0-7) numbers to set permissions for the (U)ser, (G)roup, and (O)thers.\n• 4 = Read (r)\n• 2 = Write (w)\n• 1 = Execute (x)\nAdd them up: 7 = rwx, 5 = r-x, 4 = r--",
                "example": "// Give User (rwx), Group (r-x), Others (r-x)\n// This is very common for executable scripts and folders.\nchmod 755 my_script.sh\n\n// Give User (rw-), Group (r--), Others (r--)\n// Common for files.\nchmod 644 config.txt"
            },
            {
                "title": "chown (Change Owner)",
                "explanation": "Changes the owner and group of a file or directory. You usually need `sudo` to run this.",
                "example": "// Change the owner of a file to 'www-data'\nsudo chown www-data file.txt\n\n// Change the owner AND group\nsudo chown www-data:www-data file.txt\n\n// Change a whole folder recursively\nsudo chown -R www-data:www-data /var/www"
            }
        ]
    },
    {
        "groupTitle": "Section 10: Networking",
        "topics": [
            {
                "title": "ping (Check Connection)",
                "explanation": "Sends a small 'packet' of data to a server to see if it's online and how long the response takes. Good for checking if a website is down or if your internet is working.",
                "example": "ping google.com\n\n// Press Ctrl + C to stop"
            },
            {
                "title": "curl (Client URL)",
                "explanation": "A powerful tool for transferring data *from* or *to* a server. It can download files, test APIs, and much more. It just prints the raw output to the terminal.",
                "example": "// Get the HTML content of a website\ncurl https://example.com\n\n// Download a file (use -O to save with original name)\ncurl -O https://example.com/image.jpg"
            },
            {
                "title": "wget (Web Get)",
                "explanation": "A simple command-line tool whose only job is to download files from the internet. It's more straightforward than `curl` for basic downloads.",
                "example": "// Download a file\nwget https://example.com/file.zip\n\n// Download and rename it\nwget -O my-file.zip https://example.com/file.zip"
            }
        ]
    },
    {
        "groupTitle": "Section 11: Process Management",
        "topics": [
            {
                "title": "top / htop (View Processes)",
                "explanation": "A real-time dashboard of all the processes running on your system. It shows you CPU usage, memory usage, and which programs are active. `htop` is a more colorful, user-friendly version you may need to install (`sudo apt-get install htop`).",
                "example": "// Run the dashboard (press 'q' to quit)\ntop"
            },
            {
                "title": "ps (Process Status)",
                "explanation": "Takes a 'snapshot' of the currently running processes. `ps aux` is a common command to see *all* running processes and who owns them.",
                "example": "ps aux\n\n// You can pipe this to 'grep' to find a process\nps aux | grep 'nginx'"
            },
            {
                "title": "kill (Stop Process)",
                "explanation": "Stops a running process. You must give it the Process ID (PID), which you can find using `ps` or `top`.",
                "example": "// Find the process ID (PID)\nps aux | grep 'my_app'\n// (Output might say PID is '1234')\n\n// Send the kill signal\nkill 1234"
            }
        ]
    },
    {
        "groupTitle": "Section 12: Shell Features",
        "topics": [
            {
                "title": "Piping `|`",
                "explanation": "The 'pipe' `|` operator is one of the most powerful features. It takes the **output** of the command on its left and uses it as the **input** for the command on its right.",
                "example": "// 1. Get all running processes\n// 2. 'Pipe' that list to grep\n// 3. 'grep' searches that list for 'nginx'\nps aux | grep 'nginx'\n\n// Find all files, then pipe to 'grep' to filter\nfind . -name \"*.log\" | grep 'error'"
            },
            {
                "title": "Redirection `>` / `>>`",
                "explanation": "This redirects the output of a command into a file instead of printing it to the screen.\n• `>` (Overwrite): Creates or overwrites the file with the output.\n• `>>` (Append): Adds the output to the end of the file.",
                "example": "// Save the file list to 'file_list.txt'\nls -l > file_list.txt\n\n// Add 'Hello' to the end of 'log.txt'\necho \"Hello\" >> log.txt"
            },
            {
                "title": "Editors: `nano` / `vim`",
                "explanation": "These are text editors that run inside the terminal. They are essential for editing config files on a server.\n• `nano`: Simple and easy to use. Shows commands at the bottom (Ctrl+X to exit).\n• `vim`: Extremely powerful, but has a steep learning curve. (Press 'i' to insert text, press 'Esc' then `:wq` to save and quit).",
                "example": "// Edit a file with nano (beginner-friendly)\nnano /etc/nginx/nginx.conf\n\n// Edit a file with vim (advanced)\nvim /etc/nginx/nginx.conf"
            }
        ]
    }
]