Command Line
Browse all articles, tutorials, and guides about Command Line
Guides
Introduction to Linux
Learn Linux step by step: the command line, files and permissions, apt and dnf, users and sudo, processes, networking, Bash scripts and systemd.
Introduction to Bash
Learn Bash scripting step by step with real output: expansions, quoting, arrays, functions, arguments, strict mode, traps, ShellCheck and bats tests.
Posts
How to Get the Current Branch Name in Git
Need to programmatically get the current Git branch name? Learn multiple methods to retrieve the branch name for scripts, CI/CD pipelines, and shell prompts.
How to Get the Current Date, Time and Epoch Seconds in Linux and Bash
Print and format the current date and time with date, get Unix epoch seconds and milliseconds, convert between dates and timestamps, measure how long a command takes, and turn your favorite format into a custom command.
Close a Port on Windows from the Command Line
Find the PID with netstat -ano | findstr :PORT, checking the Local Address column, then end it with taskkill /PID <pid> /F, or block the port with netsh.
How to Find Files Containing Specific Text on Linux
Need to locate files with specific content? Learn how to use grep, find, and other Linux tools to search through files and directories efficiently.
How to Reset Local Git Branch to Match Remote Repository HEAD
Learn different methods to reset your local Git branch to exactly match the remote repository HEAD, including hard reset, fetch and reset, and when to use each approach safely.
How to Push a New Local Branch to Remote Git Repository and Track It
Push a new branch with git push -u origin <branch>, fix "src refspec does not match any", and rename or delete a branch locally and on the remote.
How to Recursively Grep All Directories and Subdirectories
Learn how to use grep with recursive options to search through entire directory trees efficiently, exclude directories, list only matching file names, and filter live log streams without buffering delays.
How to Copy Command Output Directly to Your Clipboard in Linux
Pipe command output to the clipboard with wl-copy on Wayland, xclip or xsel on X11, pbcopy on macOS and clip.exe on WSL. Paste it back, write clipboard functions for scripts, and copy to your local clipboard over SSH.
How Does cat << EOF Work in Bash?
Understand heredocs in Bash - the << EOF syntax that lets you write multi-line strings, create files with embedded content, and pass complex input to commands.
How to Get Your Local IP Address
Learn multiple methods to find your local IP address using command line tools, programming languages, and system utilities across different operating systems.