All tags
Start here · shellAdvanced tmux, a config that grows with you, formats, layouts and more9 steps · 52 min read · People who know the tmux basicsStart the guide shell
Narrow down
Guides2
- GuideAdvanced tmux, a config that grows with you, formats, layouts and moreThis advanced tmux guide builds on the beginners series with a modular config covering vi-style copy mode, clipboard integration, and a functional status bar. It dives into layouts, workspace scripts, formats, popups, menus, plugins like tmux-resurrect, and SSH workflows including nested tmux sessions, all tested against tmux 3.8.9 steps · 52 min read
- GuideReplace a cron job with a systemd timer, and see when it runs nextReplace a cron job with a systemd timer, so you can ask the machine when the job runs next and what it said the last time.6 steps · 4 min read
Shell211
- Tip
zmv -n '(*).log' '$1.txt'zmv -n previews a bulk rename in zsh before it touches a filePreview a pattern-based bulk rename in zsh before running it.3 Dec 2026 - Tip
zoxide query -ls projectzoxide query -ls shows which folders your shell thinks you use mostList the folders zoxide remembers, with scores, to understand its jumps.3 Dec 2026 - Tip
eval "$(fzf --bash)"Fzf Alt-C jumps into any subdirectory with a fuzzy searchUse fzf's Alt-C binding to change directory with fuzzy search.3 Dec 2026 - Tip
SetEnv PROJECT_ENV=stagingSsh SetEnv sends a variable to the server, if AcceptEnv allows itSets an environment variable in the remote session straight from your ssh config.3 Dec 2026 - Tip
LocalCommand echo "%r@%h %n" >>> ~/.ssh/connections.logSsh LocalCommand runs a command on your own machine after you connectRuns a local command right after ssh connects, with tokens such as the remote hostname.3 Dec 2026 - Tip
echo {01..10}{01..10..2} in bash counts with zero padding and a stepBrace expansion can pad numbers with zeros and skip values with a step.3 Dec 2026 - Tip
shopt globskipdotsshopt globskipdots decides whether .* matches the . and .. entriesControls whether a pattern like .* also matches the current and parent folder entries.3 Dec 2026 - Tip
echo $EPOCHSECONDS$EPOCHSECONDS and $EPOCHREALTIME give you the time without calling dateTwo bash variables hold the current Unix time in seconds, or with microseconds.3 Dec 2026 - Tip
cmd > file 2>&1In bash, 2>&1 only follows where stdout points at that momentExplains why `cmd > file 2>&1` and `cmd 2>&1 > file` send errors to different places.3 Dec 2026 - Tip
export HISTIGNORE='ls*:pwd:cd*'HISTIGNORE keeps boring commands out of your bash historyLists command patterns that bash never saves in the history, like ls, pwd and exit.3 Dec 2026 - Tip
set -fset -f turns off globbing until you set +fSwitches off filename expansion in the current shell, so a * is passed on as a plain character.3 Dec 2026 - Tip
sudo tee /etc/update-motd.d/60-disk >/dev/null <<'EOF'Ubuntu runs your scripts in /etc/update-motd.d at every loginAdd your own status lines to the message shown when you log in.1 Dec 2026 - Tip
stty -ixonCtrl-S freezes the terminal, Ctrl-Q wakes it up againExplains why the terminal stops responding after Ctrl-S and how to stop that for good.30 Nov 2026 - Tip
grep -l 'TODO' *.py | xargs -o vimXargs -o lets an interactive program like vim work from a pipeConnects the command xargs starts to your terminal, so editors and prompts work normally.30 Nov 2026 - Tip
APP_HOST=example.com${!PREFIX@} lists every bash variable whose name starts the sameLoop over all settings like APP_PORT and APP_HOST without naming each one.30 Nov 2026 - Tip
set -eShopt -s inherit_errexit makes set -e work inside $( ) in bashStop a command substitution at the first failing line, like the rest of the script.30 Nov 2026 - Tip
cd /srv/app/releases || exit 1cd folder || exit stops a shell script that ends up in the wrong placeMake a script quit when cd fails, before it runs commands in the wrong folder.30 Nov 2026 - Tip
Ctrl-b [A in tmux copy mode adds a selection to what you already copiedCollects text from several places into one paste buffer.30 Nov 2026 - Tip
Ctrl-o # runs make, then shows the next history lineCtrl-o reruns a sequence of bash commands from your historyReplay a few commands in a row from history, one keypress each.30 Nov 2026 - Tip
man -k checksumman -k searches every man page description in your terminalFinds the command you need when you only know what it should do.30 Nov 2026 - Tip
grep -vxFf allowed.txt users.txtgrep -vxFf shows which lines of one list are missing from anotherCompare two lists without sorting them first, line for line and exact.30 Nov 2026 - Tip
make 2>&1 | tmux split-window -IPiping into tmux split-window -I shows output in a new paneSends a command's output from a script into a fresh pane.30 Nov 2026 - Tip
diff -y -W 100 old.conf new.confdiff -y shows two files side by side in the terminalPuts two versions next to each other in columns, which is easier to read for short config files.30 Nov 2026 - Tip
source s.sh; echo "$PWD $X" # /tmp 1source runs a file in your current shell, ./script in a new oneKnow why cd and variables from a script vanish, and when source keeps them.30 Nov 2026 - Tip
a=(a b c d e)${arr[@]:1:2} takes a slice out of a bash arrayGet some elements of an array, like all but the first, without a loop.30 Nov 2026 - Tip
tmux new -t work -s work2tmux new -t work starts a second session that shares the windowsLets two screens look at different windows of the same session.30 Nov 2026 - Tip
tmux has-session -t "$S" 2>/dev/null && exec tmux attach -t "$S"A small shell script builds your tmux session with all windowsRecreates the same windows, panes and commands with one command.30 Nov 2026 - Tip
files=("my file.txt" notes.md)Quote "${files[@]}" so bash keeps names with spaces in one pieceExpand an array without breaking elements that contain spaces.30 Nov 2026 - Tip
GLOBIGNORE='*.bak:*~'GLOBIGNORE hides backup files from every shell wildcardKeep *.bak or *~ files out of every * you type in that session.30 Nov 2026 - Tip
exec > >(tee -a /var/log/nightly.log) 2>&1exec with tee logs everything a shell script printsSend all output of a script to a log file while you still see it on screen.30 Nov 2026 - Tip
tmux kill-pane -atmux kill-pane -a closes every pane except the one you are inClears all other panes in the window in one command.30 Nov 2026 - Tip
sleep $((RANDOM % 300))sleep $((RANDOM % 300)) spreads shell cron jobs over a few minutesAdd a random delay so many machines do not hit the same server at once.30 Nov 2026 - Tip
^ cursor on the i, press Ctrl-tCtrl-t swaps two letters you typed the wrong way round in the shellFix a typo like sl or sytemctl with one key instead of retyping.30 Nov 2026 - Tip
echo ./*./* protects shell commands from file names that start with a dashStop a file called -rf from being read as an option by rm or mv.30 Nov 2026 - Tip
tmux select-pane -d -t 2tmux select-pane -d stops a pane from taking your typingProtects a pane, such as a running job, from stray keystrokes.30 Nov 2026 - Tip
set -xBASH_XTRACEFD sends set -x output of a bash script to its own fileKeep trace lines out of the normal error output of a script.30 Nov 2026 - Tip
head -n 3 config.env | od -cOd -c shows every byte of a line, including the ones your terminal hidesFind the stray carriage return, tab or odd byte that breaks a script or config.30 Nov 2026 - Tip
Ctrl-b ECtrl-b E spreads tmux panes out evenly without changing the layoutEvens out pane sizes while keeping your own arrangement.30 Nov 2026 - Tip
bash -c 'exit -1'; echo $? # 255A shell exit code only goes up to 255, so exit 256 means successKeep exit codes between 0 and 255, because larger numbers wrap around.30 Nov 2026 - Tip
tmux split-window -f -v -l 10tmux split-window -f adds a pane across the whole windowAdds a log strip under all your panes instead of under just one.30 Nov 2026 - Tip
ls[0-9] and [!0-9] in a shell glob match one character from a setPick files by a digit or letter in a fixed spot, without regex.30 Nov 2026 - Tip
[[ -v b ]] && echo set || echo unset # set[[ -v name ]] tells bash whether a variable is set at allTell an unset variable apart from one that is set to an empty string.30 Nov 2026 - Tip
hosts=(web db cache)${!arr[@]} lists the indexes of a bash array, gaps and allLoop over positions or keys of an array, also after removing elements.30 Nov 2026 - Tip
declare -f mkcddeclare -f prints the code of a shell function you loaded earlierSee what a function in your shell really does, and where it came from.30 Nov 2026 - Tip
history -d 1042history -d removes a password you typed from bash historyDelete one line, or a range, from your history after typing something secret.30 Nov 2026 - Tip
Ctrl-b .Ctrl-b . moves a tmux window to another number or sessionMoves the current window to a new index or another session.30 Nov 2026 - Tip
wait "$db_pid"; db_status=$?wait PID gives you the exit code of one bash background jobRun jobs in parallel and still check which of them failed.30 Nov 2026 - Tip
Alt-b back one wordAlt-b and Alt-f move through a shell command one word at a timeJump over words on the command line instead of holding the arrow keys.30 Nov 2026 - Tip
EOFA quoted EOF stops the shell from expanding a here-documentWrite a script or config with dollar signs from a here-document, untouched.30 Nov 2026 - Tip
Alt-u UPPERCASE the rest of the wordAlt-u and Alt-l fix the case of a word on the shell lineChange a word to upper, lower or title case while you type a command.30 Nov 2026 - Tip
"\e[A": history-search-backwardThe Up arrow can search bash history for what you already typedType the start of a command, press Up, and get only matching history lines.30 Nov 2026 - Tip
set -e((i++)) stops a bash script under set -e when i is 0Avoid a counter that silently ends your script on its first increment.30 Nov 2026 - Tip
echo '203.0.113.10 nas.example.com' | sudo tee -a /etc/hosts >/dev/nullSudo tee writes to a root-owned file where a shell redirect failsAppend a line to a file owned by root, because sudo echo > file fails.30 Nov 2026 - Tip
envsubst < site.conf.tpl > site.confenvsubst fills shell variables into a template fileTurn a config template with $VARIABLES into a real file without sed.30 Nov 2026 - Tip
key='abc123xyz'${#var} gives the length of a bash string or arrayCount characters or array items without wc or a loop.30 Nov 2026 - Tip
tmux split-window -e AWS_PROFILE=stagingtmux split-window -e starts a pane with its own environment variableGives one new pane an extra environment variable without touching others.30 Nov 2026 - Tip
rm old-*.logCtrl-x * expands a wildcard on the bash line before you run itSee exactly which files a glob matches, and edit the list, before pressing Enter.30 Nov 2026 - Tip
echo "needs bash 4 or newer, this is $BASH_VERSION" >&2BASH_VERSINFO stops a script that needs a newer bash than macOS shipsFail early with a clear message when bash is too old for your script.30 Nov 2026 - Tip
select action in start stop status quit; doselect gives a bash script a numbered menu in a few linesLet a user pick an option by number without writing your own menu loop.30 Nov 2026 - Tip
Ctrl-b Alt-nCtrl-b Alt-n jumps to the next tmux window with activityGoes straight to the window that rang a bell or printed output.30 Nov 2026 - Tip
v="a b"[[ ]] in bash does not split variables, where [ ] doesKnow why [[ ]] is safer in bash scripts and when you still need [ ].30 Nov 2026 - Tip
exec 3>>report.logexec 3> keeps a file open for the rest of a shell scriptOpen a log file once and write to it many times through a number.30 Nov 2026 - Tip
tmp=$(mktemp ./hosts.json.XXXXXX)Write to a temp file, then mv, so a shell script never leaves half a fileReplace a config or data file in one step, so readers never see it half written.30 Nov 2026 - Tip
Ctrl-b 'Ctrl-b ' jumps to tmux window 10 and up by numberReaches windows numbered above 9 without cycling through them.30 Nov 2026 - Tip
journalctl -u nginx --since "$(systemctl show -p ActiveEnterTimestamp --value nginx)"journalctl since ActiveEnterTimestamp shows logs from the last service startRead only the log lines since a service last started, without looking up the time.30 Nov 2026 - Tip
IFS=, read -ra hosts <<< "$line"IFS=, read -ra splits a line into a shell arrayBreak a comma separated line into array elements without cut or awk.30 Nov 2026 - Tip
shopt -s nocaseglobshopt -s nocaseglob makes shell wildcards ignore upper and lower caseMatch photo.JPG and photo.jpg with one pattern.30 Nov 2026 - Tip
tabs -4tabs -4 makes the terminal show tab characters four columns wideChanges how wide tab characters look in your terminal for cat and less.30 Nov 2026 - Tip
s=foo; s+=bar; echo "$s" # foobar+= appends to a bash string or array in placeAdd to a string or array without repeating the variable name on the right.30 Nov 2026 - Tip
shopt -s extglob*.@(jpg|png) matches several extensions in one shell globMatch a list of extensions without the empty results that braces leave.30 Nov 2026 - Tip
version=$(< VERSION)$(< file) reads a file into a shell variable without catLoad a small file into a variable without starting an extra cat process.30 Nov 2026 - Tip
local out=$(false)local x=$(cmd) hides a failed command in a shell functionDeclare and assign on separate lines so a failure inside $( ) is not lost.30 Nov 2026 - Tip
if [ -t 1 ]; then[ -t 1 ] tells a shell script whether a person is watchingUse colours and progress output only when output goes to a terminal.30 Nov 2026 - Tip
f() {"$@" passes every argument on to the next command, spaces and allForward the arguments of a script or function without breaking names with spaces.30 Nov 2026 - Tip
hash -r # forget everythinghash -r makes the shell forget where an old program livedFix 'No such file or directory' after moving or reinstalling a program.30 Nov 2026 - Tip
set -o noclobberset -o noclobber stops > from overwriting existing filesBlocks the > operator from overwriting existing files unless you use >|.28 Nov 2026 - Tip
bash -n backup.sh && echo "syntax ok"bash -n checks a script for syntax errors without running itParses a script and reports syntax errors without executing a single command.28 Nov 2026 - Tip
shopt -s lastpipeshopt -s lastpipe keeps variables set inside a piped while loopRuns the last command of a pipeline in the current shell so its variables survive.28 Nov 2026 - Tip
source "$script_dir/config.env"BASH_SOURCE finds the folder a script lives inFinds the directory of the running script so it can load files next to it.28 Nov 2026 - Tip
printf -v stamp '%(%Y-%m-%d_%H%M)T' -1printf %(…)T puts today's date in a name without calling dateWrites the current date into a shell variable using only the printf builtin.28 Nov 2026 - Tip
read -r -s -p "Token: " token; echoread -s -p hides what you type, and -t gives up after a timeoutPrompts for input without echoing it and gives up after a set number of seconds.28 Nov 2026 - Tip
timeout 3 bash -c '</dev/tcp/192.168.1.x/443' && echo open || echo closedBash can test a TCP port through /dev/tcp without netcatChecks whether a TCP port accepts connections using only bash, no nc needed.28 Nov 2026 - Tip
disown -h %1disown lets a running job survive closing the terminalMarks a running background job so it keeps going after you close the shell.28 Nov 2026 - Tip
pushd /var/logpushd and popd give your shell a stack of folders to jump back toKeeps a numbered stack of folders so you can hop back and forth between them.28 Nov 2026 - Tip
PROMPT_COMMAND='history -a'PROMPT_COMMAND runs a command before every bash promptRuns a command of your choice before each prompt is shown.28 Nov 2026 - Tip
shopt -s dotglobshopt -s dotglob makes * match hidden files tooLets the * wildcard include files whose names start with a dot.28 Nov 2026 - Tip
printf '%s\n' "holiday photo.jpg" "notes 2026.txt" | xargs -d '\n' -n1 echoXargs -d '\n' keeps file names with spaces in one pieceMakes xargs split its input only at newlines, so names with spaces stay whole.28 Nov 2026 - Tip
shopt -s failglobshopt -s failglob makes bash refuse a wildcard that matches nothingMakes bash print an error and skip the command when a wildcard matches no files.28 Nov 2026 - Tip
type -a echotype -a lists everything a command name can mean in bashShows every alias, builtin, function and file behind a command name.28 Nov 2026 - Tip
false | true | falseBash PIPESTATUS shows which part of a pipeline failedReads the exit code of every command in the last pipeline, not only the final one.28 Nov 2026 - Tip
set -uset -u makes a script stop on a typo in a variable nameMakes bash exit with an error instead of treating an unset variable as empty.28 Nov 2026 - Tip
tmux new-window -atmux new-window -a opens the new window right after the current oneCreates a new tmux window directly after the current one instead of at the end.28 Nov 2026 - Tip
set -g display-time 3000set -g display-time 3000 keeps tmux messages on screen longerSets how long tmux status line messages stay on screen, in milliseconds.28 Nov 2026 - Tip
set -g focus-events onset -g focus-events on tells programs inside tmux when the window gains focusPasses terminal focus in and out events through tmux to programs running inside it.28 Nov 2026 - Tip
set -g set-clipboard onset -g set-clipboard on lets tmux copy to your terminal's clipboardLets tmux copy selected text to the clipboard of your terminal, even over SSH.28 Nov 2026 - Tip
tmux rotate-window -Dtmux rotate-window shifts every pane one place without touching the layoutMoves every pane in a tmux window to the next position while keeping the layout.28 Nov 2026 - Tip
tmux find-window 'Permission denied'tmux find-window searches window names and visible text for a wordFinds the tmux window whose name, title or visible text matches a pattern.28 Nov 2026 - Tip
tmux setw monitor-silence 30Setw monitor-silence 30 highlights a tmux window that has gone quietHighlights a tmux window in the status bar after it has printed nothing for a set time.28 Nov 2026 - Tip
set -g detach-on-destroy offset -g detach-on-destroy off moves you to another session when one endsSwitches a tmux client to another session when its session closes, instead of detaching.28 Nov 2026 - Tip
set -g set-titles onset -g set-titles on makes your terminal tab show the tmux sessionMakes the terminal tab or window title show the tmux session and window name.28 Nov 2026 - Tip
tmux -L test -f /tmp/test.conf new -s trytmux -L test starts a second, separate tmux serverRuns an independent tmux server on a named socket, separate from your normal sessions.28 Nov 2026 - Tip
if-shell 'test "$(uname)" = Darwin' 'set -g status-style bg=blue' 'set -g status-style bg=green'Tmux if-shell runs a tmux command only when a shell test passesRuns a tmux command only if a shell test succeeds, so one config works on many machines.28 Nov 2026 - Tip
tmux show-environment -s SSH_AUTH_SOCKtmux show-environment -s prints the session environment as shell commandsPrints a tmux session variable as a shell command, so an old pane can pick up the new value.28 Nov 2026 - Tip
tmux clear-historytmux clear-history wipes the scrollback of a paneDeletes the scrollback of a tmux pane so copy mode starts fresh.27 Nov 2026 - Tip
tmux link-window -s work:logs -t home:tmux link-window shows the same window in two sessionsPuts one running tmux window in a second session, without starting it twice.27 Nov 2026 - Tip
set -g pane-border-status topset -g pane-border-status top puts a label on every tmux paneShows a label with a title or the running command in the border of every tmux pane.27 Nov 2026 - Tip
alias sudo='sudo 'alias sudo='sudo ' with a trailing space lets your aliases work after sudoMakes sudo ll and other aliases after sudo work instead of giving command not found.27 Nov 2026 - Tip
Ctrl-U # cut from the cursor to the start of the lineCtrl-U cuts the line you are typing and Ctrl-Y pastes it backParks a half-typed command so you can run another one first and paste it back.27 Nov 2026 - Tip
Ctrl-_ # undo the last editCtrl-_ undoes your last edit on the bash command lineTakes back your last change on the command line, one step per press.27 Nov 2026 - Tip
Ctrl-Z # pause the running commandCtrl-Z pauses a running command, bg sends it to the background and fg brings it backPauses a command that blocks your terminal and lets it continue in the background.27 Nov 2026 - Tip
local -n _list=$1local -n lets a bash function change an array you pass by namePasses an array to a bash function by name, so the function can change the original.27 Nov 2026 - Tip
declare -p appsdeclare -p shows exactly what is inside a bash variable or arrayPrints the type and exact quoted value of a bash variable, array or function.27 Nov 2026 - Tip
shopt -s histappendshopt -s histappend with history -a keeps bash history from every terminalSaves every command from every open terminal to your bash history instead of only the last one.27 Nov 2026 - Tip
shopt -s histverifyshopt -s histverify shows what !! or !$ expands to before bash runs itPuts the result of !! or !$ on your command line first, so you check it before it runs.27 Nov 2026 - Tip
set completion-ignore-case oncompletion-ignore-case in ~/.inputrc makes Tab completion ignore upper and lower caseLets Tab complete Documents when you type doc, and lists every match at once.27 Nov 2026 - Tip
count=10Local keeps a bash function from overwriting your variablesKeeps the variables of a bash function inside that function, so callers keep their values.27 Nov 2026 - Tip
f="my holiday photo.jpg"${var//old/new} replaces every match inside a bash variableSwaps text inside a bash variable, once or everywhere, without calling sed.27 Nov 2026 - Tip
PROMPT_DIRTRIM=2PROMPT_DIRTRIM=2 shortens a long path in your bash promptKeeps only the last few folders of the current path in your prompt.27 Nov 2026 - Tip
SECONDS=0The SECONDS variable tells a bash script how long it has been runningTimes a script or one step of it in bash without calling date.27 Nov 2026 - Tip
Alt-Ctrl-e # or press Esc, then Ctrl-eAlt-Ctrl-e expands variables, aliases and !! on the bash line before you press EnterShows on the prompt what a command becomes once bash fills in variables and aliases.27 Nov 2026 - Tip
shopt -s autocdshopt -s autocd lets you change folder by typing only its nameMoves into a folder when you type its name, without typing cd.27 Nov 2026 - Tip
for f in *.log; doShopt -s nullglob stops a for loop from running on a literal *.logMakes a bash glob that matches no files disappear, so loops skip instead of failing.27 Nov 2026 - Tip
grep -n -C 3 'segfault' /var/log/sysloggrep -C 3 shows the lines around each matchShows a few lines before and after every match, so you see what led up to an error.27 Nov 2026 - Tip
grep -F '192.168.1.1' /var/log/nginx/access.loggrep -F searches for text literally, dots and brackets includedSearches for text exactly as you typed it, without regex characters getting in the way.27 Nov 2026 - Tip
grep -n -m 1 'Out of memory' /var/log/sysloggrep -m 1 stops reading after the first matchMakes grep quit after the first match, or after any number you choose.27 Nov 2026 - Tip
grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' /var/log/auth.loggrep -o prints only the part of the line that matchedPrints only the matched text, like IP addresses, instead of the whole log line.27 Nov 2026 - Tip
grep -w port /etc/ssh/sshd_configgrep -w matches whole words, so log stops matching loginOnly matches your search term as a whole word, not inside longer words.27 Nov 2026 - Tip
Ctrl-x Ctrl-eCtrl-x Ctrl-e opens a long bash command in your editorOpens the command you are typing in your text editor and runs it when you save.27 Nov 2026 - Tip
export HISTTIMEFORMAT='%F %T 'HISTTIMEFORMAT adds a date and time to your bash historyShows the date and time next to every command in your bash history.27 Nov 2026 - Tip
set -xset -x with a better PS4 shows the line number of every traced commandShows the file and line number in front of every command bash traces with set -x.27 Nov 2026 - Tip
journalctl -u ssh --no-pager | grep -c Acceptedjournalctl --no-pager sends the output straight to the next commandPrints the output directly instead of opening a pager, which suits scripts and pipes.26 Nov 2026 - Tip
journalctl -o short-unix -u myappjournalctl -o short-unix gives time stamps scripts can calculate withPrints the time as seconds since 1970 so a script can calculate with it.26 Nov 2026 - Tip
echo 'price=42 EUR' | grep -oP '\d+(?= EUR)'Grep -P uses Perl-compatible regular expressionsLets grep use Perl-style patterns such as lookahead and \d, which the basic and extended syntax lack.25 Nov 2026 - Tip
mkdir ~/projects/new-siteAlt+. pastes the last word of your previous commandInserts the last argument of the previous command at the cursor, and cycles back through older ones.24 Nov 2026 - Tip
tmux has-session -t work 2>/dev/null || tmux new -d -s worktmux has-session tells a script whether a session already existsExits with success when the named session exists and with failure when it does not.21 Nov 2026 - Tip
Ctrl-b ?Ctrl-b ? shows every tmux key binding inside tmuxOpens a searchable list of all key bindings, including the ones you added yourself.21 Nov 2026 - Tip
Ctrl-b PageUpCtrl-b PageUp scrolls tmux back without any setupEnters scrollback straight away and moves one page up, with no mouse and no extra config.21 Nov 2026 - Tip
bind -r L resize-pane -R 5bind -r makes a tmux key repeat without pressing the prefix againLets you press a key several times after one prefix, which suits resizing and moving.21 Nov 2026 - Tip
Enter # copy and leave copy modeSpace starts a selection in tmux copy mode and Enter copies itSelects text in copy mode with the keyboard and copies it into tmux's paste buffer.21 Nov 2026 - Tip
Ctrl-b 0Ctrl-b and a digit jumps straight to that tmux windowSwitches to a window by its number, shown in the status bar, with two key presses.21 Nov 2026 - Tip
bind | split-window -hbind | and – to split tmux panes with keys that make senseReplaces the default split keys with a pipe for side by side and a dash for stacked.21 Nov 2026 - Tip
Ctrl-b ( # previous sessionCtrl-b ( and Ctrl-b ) switch between tmux sessionsMoves to the previous or next tmux session without detaching first.21 Nov 2026 - Tip
set -s escape-time 10set -s escape-time 10 stops the Escape lag in Vim inside tmuxCuts the delay tmux adds after Escape, so Vim and similar editors react at once.21 Nov 2026 - Tip
tmux join-pane -s 2 # take window 2 and put it into this windowtmux join-pane moves a pane from another window into this onePulls a pane out of another window and places it next to the pane you are in.21 Nov 2026 - Tip
Ctrl-b Alt-1 # even-horizontalCtrl-b Alt-1 to Alt-5 pick one tmux pane layout directlyApplies a fixed pane layout straight away, with the number of the layout as the key.21 Nov 2026 - Tip
set -g mode-keys viset -g mode-keys vi gives tmux copy mode vi keysMakes copy mode use vi movement and selection keys instead of the emacs style ones.21 Nov 2026 - Tip
setw -g monitor-activity onsetw -g monitor-activity on flags tmux windows that print somethingMarks a window in the status bar when something new appears in it while you look elsewhere.21 Nov 2026 - Tip
Ctrl-b SpaceCtrl-b Space cycles through the tmux pane layoutsRearranges the panes of the current window into the next of tmux's five built-in layouts.21 Nov 2026 - Tip
Ctrl-b n # next windowCtrl-b n and Ctrl-b p walk through your tmux windowsMoves to the next or the previous window in the session with a single key after the prefix.21 Nov 2026 - Tip
Ctrl-b ,Ctrl-b , renames the tmux window you are inGives the current tmux window a name you choose, so the status bar tells you what is running where.21 Nov 2026 - Tip
tmux attach -d -t worktmux attach -d takes over a session from another screenAttaches to a session and disconnects every other client that is still attached to it.21 Nov 2026 - Tip
set -g prefix C-aset -g prefix C-a moves the tmux prefix to a closer keyChanges the tmux prefix key from Ctrl-b to Ctrl-a, which is easier to reach.21 Nov 2026 - Tip
Ctrl-b =Ctrl-b = lists the last things you copied in tmuxShows every paste buffer tmux holds, so you can paste an older copy instead of the newest.21 Nov 2026 - Tip
Ctrl-b sCtrl-b s lists your tmux sessions and lets you pick oneOpens a list of all sessions to choose from, with a live preview of each.21 Nov 2026 - Tip
Ctrl-b :Ctrl-b : opens the tmux command prompt for any tmux commandLets you run any tmux command from inside tmux, without leaving the session.21 Nov 2026 - Tip
set -g default-terminal "tmux-256color"set -g default-terminal tmux-256color fixes broken colours in tmuxTells programs inside tmux the right terminal type, so colours and keys work as expected.21 Nov 2026 - Tip
Ctrl-b dCtrl-b d detaches from tmux and leaves everything runningLeaves the tmux session without stopping anything in it, so you can come back later.21 Nov 2026 - Tip
tmux display-message -p '#S' # session nametmux display-message -p prints facts like the session namePrints a tmux format such as the session name or pane path to the terminal, for use in scripts.21 Nov 2026 - Tip
Ctrl-b xCtrl-b x closes the tmux pane you are in, after a confirmationCloses only the current pane, asking first, and leaves the rest of the window alone.21 Nov 2026 - Tip
Ctrl-b &Ctrl-b & closes a whole tmux window after one confirmationCloses the current tmux window and every pane in it, but asks first.21 Nov 2026 - Tip
Ctrl-b ;Ctrl-b ; jumps back to the tmux pane you used beforeToggles between the current pane and the one you were in just before.21 Nov 2026 - Tip
eval "$(fzf --bash)"Fzf turns Ctrl-R into a fuzzy search of your shell historyReplaces Ctrl-R with a fuzzy, live-filtered search of your shell history.19 Nov 2026 - Tip
make 2>&1 | lessUse |& to pipe stderr along with stdout in BashSends both normal output and error messages through the pipe, shorter than 2>&1.24 Oct 2026 - Tip
diffdiff <(cmd1) <(cmd2) compares output without temp filesCompares the output of two commands directly, without saving them to temporary files.10 Oct 2026 - Tip
tmux capture-pane -p -S - | grep -n 'error'tmux capture-pane -p dumps the pane's text to stdoutPrints everything in a tmux pane, scrollback included, so you can grep it.2 Oct 2026 - Tip
tmux list-keys -T prefix | grep split-windowtmux list-keys | grep finds the binding you forgotSearches all tmux key bindings from the shell, including the ones you added yourself.29 Sep 2026 - Tip
set -g renumber-windows onset -g renumber-windows on closes the gap when you close a windowRenumbers tmux windows automatically so there is no gap after one is closed.25 Sep 2026 - Tip
tmux new -As worktmux new -As work attaches to a session or creates itAttaches to the tmux session called work, or creates it when it does not exist.24 Sep 2026 - Tip
Ctrl-b Ctrl-Left # 1 cellCtrl-b Alt-arrow resizes a tmux pane five cells at a timeResizes the active tmux pane in steps of five cells with the Alt and arrow keys.22 Sep 2026 - Tip
Ctrl-b l # last windowCtrl-b l jumps back to the window you were just inToggles between the current and the previous tmux window, like alt-tab for windows.18 Sep 2026 - Tip
set -g status-position topset -g status-position top moves the tmux status bar to the topPuts the tmux status bar at the top of the screen instead of the bottom.14 Sep 2026 - Tip
select-layout tiledTmux select-layout tidies a mess of panes in one commandRearranges all panes in a tmux window into an even grid or evenly sized rows.7 Sep 2026 - Tip
tmux capture-pane -p -S -3000 > build.logtmux capture-pane -p dumps a pane's scrollback to a fileSaves what a tmux pane shows, including its history, to a text file or the terminal.30 Aug 2026 - Tip
/error # search forward for 'error'In tmux copy mode, / searches forward and ? searches backwardFinds text in a tmux pane's scrollback after Ctrl-b [, with n for the next match.27 Aug 2026 - Tip
Ctrl-b w # sessions and windowsCtrl-b w shows every window of every session as a treeOpens a list of all tmux sessions and windows with a preview, so you can jump to any of them.23 Aug 2026 - Tip
Ctrl-b $Ctrl-b $ renames the tmux session you are inGives the current tmux session a clearer name without restarting it.19 Aug 2026 - Tip
tmux kill-session -a -t worktmux kill-session -a closes every session except the one you nameKills all tmux sessions apart from the one you keep, for a quick clean-up.15 Aug 2026 - Tip
setw synchronize-panes onsetw synchronize-panes on types into every pane at onceSends everything you type to all panes in the tmux window, handy for the same command on several servers.12 Aug 2026 - Tip
set -g base-index 1set -g base-index 1 makes window numbers match the keyboard rowStarts numbering tmux windows at 1, so the first window sits under the 1 key.8 Aug 2026 - Tip
bind | split-window -h -c "#{pane_current_path}"Open new tmux panes in the folder you are already inMakes tmux splits and new windows start in the current pane's directory instead of your home folder.4 Aug 2026 - Tip
bind r source-file ~/.tmux.conf \; display-message "Reloaded"bind r to reload your tmux config without restarting anythingAdds a key that re-reads ~/.tmux.conf inside a running tmux session.1 Aug 2026 - Tip
set -g history-limit 50000set -g history-limit 50000 gives every pane a much longer scrollbackRaises how many lines each tmux pane remembers, so long output is still there when you scroll back.28 Jul 2026 - Tip
cp /etc/ssh/sshd_config{,.bak}cp file{,.bak} makes a backup copy without typing the name twiceExpands to a command with the file name and a .bak copy, saving you from typing the path twice.26 Jul 2026 - Tip
set -g mouse onset -g mouse on lets you click panes, drag borders and scrollTurns on mouse support in tmux, so clicking selects panes and the wheel scrolls the history.24 Jul 2026 - Tip
Ctrl-b qCtrl-b q numbers your panes so you can jump to one with a digitShows a big number on every tmux pane for a moment, and pressing a digit selects that pane.21 Jul 2026 - Tip
shopt -s extglobWith extglob, !(*.log) matches everything except your log filesLists or selects every file except the ones matching a pattern, using Bash extended globs.18 Jul 2026 - Tip
Ctrl-b { # swap with the previous paneCtrl-b { and Ctrl-b } swap the active pane with its neighbourMoves the active tmux pane one place up or down in the layout without closing anything.17 Jul 2026 - Tip
shopt -s globstarshopt -s globstar lets ** match files in every subfolderTurns on ** in Bash so one pattern matches files in every subfolder.13 Jul 2026 - Tip
Ctrl-b !Ctrl-b ! turns a cramped pane into a window of its ownMoves the active tmux pane out of the split layout into a new window.13 Jul 2026 - Tip
Ctrl-b zCtrl-b z zooms one pane to the whole window and brings the others backMakes the active tmux pane fill the whole window, and a second press restores the layout.9 Jul 2026 - Tip
tmux ls -F '#{session_name}: #{session_windows} windows'tmux ls -F prints sessions the way a script wants themLists tmux sessions in a format you choose, for example only the name and window count.6 Jul 2026 - Tip
trap 'rm -rf "$tmp"' EXITtrap EXIT cleans up your temp files, even when the script diesRuns a cleanup command whenever the script exits, including after an error.4 Jul 2026 - Tip
tmux new -As worktmux new -As work attaches to a session or creates it, one command for bothAttaches to the tmux session you name, or creates it when it does not exist yet.2 Jul 2026 - Tip
rm -rf "${BUILD_DIR:?BUILD_DIR is not set}"/*${var:?} stops a script before an empty variable eats your filesStops the script with an error when a variable is empty, before a delete can hit the wrong path.24 Jun 2026 - Tip
set -o pipefailset -o pipefail makes a pipeline fail when any part of it failsMakes a pipeline report failure when any command in it fails, not only the last one.18 Jun 2026 - Tip
cd Alt+.Alt+. pastes the last argument of your previous commandPastes the last word of your previous command at the cursor, so you do not retype paths.9 Jun 2026 - Tip{ cmd1; cmd2; } > file redirects a whole shell group at onceSends the output of several commands to one file with a single redirect.7 Jun 2026
- Tip
sudo !!sudo !! reruns your last command with sudoReruns the previous command with sudo in front of it, so you do not retype it.2 Jun 2026 - Tip
wait -nwait -n continues a shell script when the first background job endsResumes the script as soon as any one background job has finished.2 Jun 2026 - Tip
sudo !!Type sudo !! when you forgot the sudoReruns your previous command with sudo in front, so you do not retype it.1 Jun 2026 - Tip
export CDPATH=.:~/dev:~/dev/workCDPATH lets cd jump to a folder from anywhere in your shellLets cd find folders by name in a list of parent directories.31 May 2026 - Tip
systemctl status ngnix^old^new reruns the last shell command with one word changedRepeats the previous command after fixing one word with a quick substitution.30 May 2026 - Tip
while getopts 'f:v' opt; doGetopts parses the flags of a shell script without extra toolsReads short command line flags in a script with a built-in parser.30 May 2026 - Tip
mapfile -t logs < <(find /var/log -name '*.log')mapfile -t loads command output into a shell array, one line per itemReads the lines of a command into a bash array without word splitting problems.30 May 2026 - Tip
f=/srv/media/holiday.final.mp4${file%.*} and ${file##*/} trim a shell variable without sedStrips an extension or a directory from a variable with built-in pattern removal.30 May 2026 - Tip
backup_dir=${BACKUP_DIR:-/var/backups}${var:-default} gives a shell variable a fallback, ${var:=x} also sets itUses a default value when a variable is unset or empty.30 May 2026 - Tip
while read -r line; do count=$((count+1)); done < <(ls /etc)while read with < <(cmd) keeps shell variables that a pipe losesKeeps variables set in a read loop by feeding it with process substitution.29 May 2026 - Tip
find . -name '*.py' -exec grep -l 'TODO' {} +find -exec grep -l {} + runs one command for many files instead of one eachRuns a command on batches of matched files instead of once per file.20 May 2026 - Tip
*/5 * * * * flock -n /run/lock/sync.lock /usr/local/bin/sync.shFlock -n stops a cron job from overlapping with its own previous runSkips a scheduled run when the previous one still holds a lock file.1 May 2026 - Tip
*/10 * * * * /usr/local/bin/sync.sh >> /var/log/sync.log 2>&1End a cron line with >> file 2>&1 to keep all output in one logSends both normal output and errors of a scheduled job to a log file you can read later.29 Apr 2026 - Tip
trap 'echo "failed at line $LINENO: $BASH_COMMAND" >&2' ERRtrap ERR with $LINENO tells you which line of a shell script failedPrints the line number and command when a bash script hits an error.15 Apr 2026
Other tips85
- Tip
xmlstarlet sel -t -v '//item/title' -n feed.xmlxmlstarlet sel -t -v pulls values out of XML with an XPathRead single values from an XML file with an XPath, from the command line.3 Dec 2026 - Tip
sed -n '$=' access.logsed -n '$=' prints how many lines a file hasPrint the number of lines in a file, or the line numbers of matches, with sed.3 Dec 2026 - Tip
f=$(mktemp --suffix=.json)Mktemp --suffix gives a temp file the extension a tool expectsCreate a unique temporary file that ends in a chosen extension3 Dec 2026 - Tip
comm --total a.txt b.txtcomm --total counts the lines that differ between two sorted filesAdds a last line with how many lines are only in file one, only in file two, and in both.3 Dec 2026 - Tip
printf '%s\n' a b c d e f | xargs -n1 -P3 --process-slot-var=SLOT sh -c 'echo "slot $SLOT got $0"; sleep 0.2'Xargs --process-slot-var gives every parallel job a worker numberSets an environment variable in each parallel xargs job, holding the slot number it runs in.3 Dec 2026 - Tip
patch -R g.txt < f.patchpatch -R undoes a patch you appliedReverses a patch, so the files go back to how they were before it was applied.3 Dec 2026 - Tip
find / -maxdepth 1 -fstype procfind -fstype matches files by the type of filesystem they live onSelects files that sit on a given filesystem type, and -printf %F shows which type that is.3 Dec 2026 - Tip
tmux wait-for build-donetmux wait-for blocks a script until another pane sends a signalPauses a command until something in another pane says it's done, without polling or sleep.2 Dec 2026 - Tip
echo 'cost: 1,50 and 2,25' | awk '{n=gsub(/,/,"."); print n": "$0}'Awk gsub() replaces every match in a line or in a single fieldReplaces all matches of a pattern in the line or in one chosen column, and counts them.2 Dec 2026 - Tip
awk -F, 'NR>1 {print > ($2".csv")}' data.csvawk can split one file into several, named after a columnWrites each line to a file named after a value in that line, such as a country code.2 Dec 2026 - Tip
echo 20261201 | awk '{print substr($0,1,4)"-"substr($0,5,2)"-"substr($0,7,2)}'Awk substr() cuts a piece out of a line, like a date from a numberExtracts part of a string by start position and length, counting from 1.2 Dec 2026 - Tip
echo 'hello world' | sed 's/.*/\U&/'Sed \U and \L change the case of the text you just matchedUpper- or lowercases a match inside the replacement part of an s command in GNU sed.2 Dec 2026 - Tip
tail -c 2000 export.jsontail -c works in bytes, which helps with huge or one line filesLook at the end of a file that has very long lines or none.1 Dec 2026 - Tip
ls -vls -v lists numbered files so that 2 comes before 10Sort names with numbers in them the way a person would count.1 Dec 2026 - Tip
. /etc/os-releaseSourcing /etc/os-release gives a Linux script the distro name and versionLet a script check which distribution and release it runs on, without parsing text.30 Nov 2026 - Tip
find /srv/downloads -type f -size +100M -size -1G -exec ls -lh {} +Two find -size tests give you a size rangeLists files between two sizes, for example everything between 100 MB and 1 GB.30 Nov 2026 - Tip
echo '2.5 3.7' | awk '{print int($1), int($2), sprintf("%.0f", $1)}'Awk int() cuts decimals off, and printf rounds half to evenShows how awk turns decimals into whole numbers, and why 2.5 can become 2.30 Nov 2026 - Tip
echo 'web1:8080,5' | awk -F'[:,]' '{print $1, $2, $3}'Awk -F '[:,]' splits a line on more than one separatorSplits fields on several different characters at once, using a regular expression as separator.30 Nov 2026 - Tip
diff -Naur original/ changed/ > fix.patchdiff -Naur makes a patch that also adds and removes filesCreates a patch of a whole folder that includes new and deleted files, not only changed ones.30 Nov 2026 - Tip
find . -name '*.orig' -print0 | xargs -0 -p rmXargs -p asks for a yes before each command it runsShows every command xargs is about to run and waits for you to confirm it.30 Nov 2026 - Tip
wc -L access.logwc -L prints the length of the longest line in a fileCheck how wide a file is before you print it, wrap it or set a column width.30 Nov 2026 - Tip
find . -name '*.gz' -print0 | xargs -0 -n 1 gzip -tXargs exits with 123 when one of its commands failedExplains xargs exit codes, so a script can tell whether every command it ran succeeded.30 Nov 2026 - Tip
tail -f access.log | cut -d' ' -f1 | uniqStdbuf -oL makes a command in the middle of a pipe print each line right awayStop a pipeline from holding back output until a buffer of several kilobytes is full.30 Nov 2026 - Tip
patch -p1 --dry-run < ../fix.patchTest a diff with a patch dry run before it changes any fileTests a patch file against your folder first, so a failed patch doesn't leave half-changed files.30 Nov 2026 - Tip
find /srv/archive \( -name '*.txt' -fprint txt.list \) -o \( -name '*.gz' -fprint gz.list \)find -fprint writes several result lists in one passSorts search results into separate files without walking the folder tree twice.30 Nov 2026 - Tip
sort hosts.txt | uniq -dUniq -d shows only the duplicate lines and uniq -u only the unique onesFind the entries that appear twice in a list, or the ones that appear once.30 Nov 2026 - Tip
cut -d, -f2 --complement people.csvcut can drop a single column and keep all the othersRemove a single field from a CSV or log without listing every field you want to keep.30 Nov 2026 - Tip
diff --strip-trailing-cr windows.txt unix.txtdiff can ignore Windows line endings with one optionCompares a Windows file with a Unix file without every line showing up as changed.30 Nov 2026 - Tip
find /srv -maxdepth 1 -type d,lfind -type d,l matches several file types in one testLists folders and symlinks together without writing two type tests joined with -o.30 Nov 2026 - Tip
diff <(jq -S . old.json) <(jq -S . new.json)Jq -S sorts keys, so diff shows what really changed between two filesCompare two JSON files without noise from key order or formatting.30 Nov 2026 - Tip
echo '{"DB_HOST":"db","DB_PORT":5432,"DEBUG":false}' \Jq to_entries turns an object into KEY=value lines for a .env fileConvert a flat object of settings into lines a shell or Docker can read.30 Nov 2026 - Tip
rm -I *.logrm -I asks once before a big delete instead of for every fileGet one sanity check before a large or recursive delete, without the endless prompts of rm -i.30 Nov 2026 - Tip
export SITE=example.com RETRIES=3Jq's $ENV reads environment variables straight into a filterPull values from environment variables into jq output without passing them as arguments.30 Nov 2026 - Tip
sort -u -k1,1 logins.txtsort -u -k1,1 keeps one line per key instead of one per whole lineRemove duplicates based on one column, like keeping one line per host name.30 Nov 2026 - Tip
echo /srv/media/films/2024/clip.mkv | rev | cut -d/ -f1 | revRev | cut | rev gets the last field of a line, however many fields it hasTake the last part of a path or line when the number of fields changes.30 Nov 2026 - Tip
find . -name '*.txt' -o -name '*.log' -printfind -o needs parentheses, or -print only applies to the last nameExplains why find with two -name tests and -print shows only one kind of file.30 Nov 2026 - Tip
diff -I '^# generated' old/app.conf new/app.confdiff -I skips lines that match a pattern, like timestampsLeaves out changes in lines such as generated dates, so two exports can be compared.30 Nov 2026 - Tip
iconv -f latin1 -t utf-8 old.csv > new.csviconv converts an old Latin-1 file to UTF-8 so the accents show up rightFix the garbled characters in an old export by converting its encoding.30 Nov 2026 - Tip
printf 'a b\nc d\n' | xargs -L 1 echo line:Xargs -L 1 runs one command per input line, not per wordKeeps each input line together as the arguments of one command run.30 Nov 2026 - Tip
awk 'length > 120 {print FILENAME ":" FNR ": " length}' *.pyawk 'length > 120' finds the lines that are too longLists every line above a certain length with file name and line number.30 Nov 2026 - Tip
diff -b old.conf new.confdiff -b ignores changes in the amount of whitespaceHides differences that are only extra or fewer spaces, so the real changes stand out.30 Nov 2026 - Tip
csplit -s -z -f part- dump.sql '/^CREATE TABLE/' '{*}'csplit cuts a text file into pieces wherever a pattern matchesSplit a long log or dump into separate files at every line that starts a new section.30 Nov 2026 - Tip
awk -F, '{s+=$2} END {print s}' costs.csvawk '{s+=$2} END {print s}' adds up a column of numbersAdds up all the numbers in one column of a file or command output.27 Nov 2026 - Tip
find /mnt/user/downloads -name '*.zip' -execdir unzip -n {} \;find -execdir runs a command inside the folder where each file livesRuns a command from the folder of each matched file, so output lands next to it.27 Nov 2026 - Tip
cp -r --update=none /mnt/user/photos/import/* /mnt/user/photos/library/Use cp --update=none instead of cp -n, which changed behaviour twiceCopies or moves files without overwriting existing ones, with an exit status you can predict.27 Nov 2026 - Tip
mv app.log "app-$(date -r app.log +%F).log"Date -r prints the modification time of a file in any format you likeShows when a file was last changed, formatted the way your script needs it.27 Nov 2026 - Tip
ln -sf /srv/app/releases/v2 /srv/app/currentln -sfn repoints a symlink to a folder instead of creating a link inside itReplaces a symlink that points to a directory, rather than adding a link inside that directory.27 Nov 2026 - Tip
for i in $(seq -w 1 "$n"); doSeq -w counts with leading zeros, so file names sort the right wayPrints a number sequence with leading zeros, so numbered names line up and sort correctly.27 Nov 2026 - Tip
tail -n +2 export.csvtail -n +2 prints a file from its second line, so the header is gonePrints a file starting at a chosen line, for example to skip a CSV header.27 Nov 2026 - Tip
touch -r notes.orig.md notes.mdtouch -r copies the timestamp of one file onto anotherGives a file the same modification time as another file, or any date you choose.27 Nov 2026 - Tip
sed 's/\/mnt\/user\/appdata\/old/\/mnt\/user\/appdata\/new/' app.confUse s|old|new| in sed when your text is full of slashesSwaps the slash in a sed replacement for another character, so paths stay readable.27 Nov 2026 - Tip
join <(sort hosts.txt) <(sort roles.txt)join matches two files on a shared column, like a tiny SQL joinCombines lines from two text files that share the same value in a key column.27 Nov 2026 - Tip
sort -t, -k3,3n people.csvsort -t and -k sort a file on one column instead of the whole lineSorts lines on one chosen column, as text or as numbers, instead of on the whole line.27 Nov 2026 - Tip
sort -o list.txt list.txtsort -o sorts a file in place, where a redirect would empty itSorts a file and writes the result back into the same file without emptying it first.27 Nov 2026 - Tip
printf '%s\n' 1.10.0 1.9.2 1.2.0 | sort -VSort -V puts version numbers in the right orderSorts version numbers like 1.9 and 1.10 in the order a person would expect.27 Nov 2026 - Tip
cat -E script.sh | headTr -d '\r' strips Windows line endings from a fileRemoves the hidden carriage returns that make Windows text files misbehave on Linux.27 Nov 2026 - Tip
wc -l < access.logwc -l < file gives you only the number, without the file namePrints just the line count of a file, so you can use it directly in a script.27 Nov 2026 - Tip
find . -maxdepth 1 -name '*.conf' | xargs -I {} cp {} {}.bakXargs -I {} puts each input line exactly where you want it in the commandPlaces each input line at a chosen spot in the command, not just at the end.27 Nov 2026 - Tip
find /mnt/user/photos -iname '*.jpg'find -iname matches file names whatever their upper and lower caseFinds files by name while ignoring upper and lower case, so .JPG and .jpg both match.27 Nov 2026 - Tip
find ~/Downloads -name '*.iso' -ok rm {} \;find -ok asks before it runs a command on each fileAsks for a yes or no before find runs a command such as rm on each file.27 Nov 2026 - Tip
NAME="web 1"Jq --arg passes a variable from your script into a jq filter without quoting troubleHands shell variables to jq safely, as strings or as real JSON values.26 Nov 2026 - Tip
realpath ../../data/./file.txtrealpath resolves a path and can print it relative to another folderTurns a messy path with dots and symlinks into a clean absolute path, or one relative to a folder.25 Nov 2026 - Tip
cmp -l file1.bin file2.bin | headcmp compares two files byte by byte, and cmp -l lists every differenceCompares two files byte by byte and reports where they first differ, or all differing bytes with -l.25 Nov 2026 - Tip
echo "a very long sentence that keeps going and going" | fold -s -w 20Fold -s -w 60 wraps long lines at spacesWraps long lines to a chosen width and breaks them at spaces instead of in the middle of words.25 Nov 2026 - Tip
nl -ba -w 4 -s ': ' /etc/hostsnl -ba puts line numbers in front of every line, blank ones tooAdds line numbers to the output of a file or command, numbering empty lines as well.25 Nov 2026 - Tip
echo 1610612736 | numfmt --to=iecNumfmt --to=iec turns byte counts into readable sizes like 1.5GConverts plain numbers into human-readable sizes, and works on any number that you pipe into it.25 Nov 2026 - Tip
printf '%q\n' "$name"printf %q quotes a string so the shell can read it back safelyPrints a value with escaping, so spaces and special characters survive when it is pasted back into a shell command.25 Nov 2026 - Tip
inotifywait -m -e close_write /srv/inboxinotifywait waits until a file changes, then lets your script go onBlocks until something happens to a file or folder, so a script can react without polling.24 Nov 2026 - Tip
split -b 1G -d --additional-suffix=.part big.iso big.iso.split -b cuts a big file into pieces you can send or storeSplits a large file into fixed-size parts with numbered names, which cat can join back together.24 Nov 2026 - Tip
date -d '2 days ago' +%Fdate -d understands phrases like 'next friday' and '2 days ago'Turns plain-English dates such as yesterday or next friday into a real date on the command line.24 Nov 2026 - Tip
pkill -x nodepkill -x only kills processes whose name matches exactlyStops processes by exact name, so killing 'vim' does not also take down 'gvim' or 'vimdiff'.24 Nov 2026 - Tip
tac /var/log/app.log | head -n 20tac prints a file backwards, last line firstPrints the lines of a file in reverse order, which puts the newest log entry on top.24 Nov 2026 - Tip
tree -L 2tree -L 2 shows a folder structure two levels deepDraws the files and folders of a directory as a tree, cut off at the depth you choose.23 Nov 2026 - Tip
awk '!seen[$0]++' list.txt > unique.txtawk '!seen[$0]++' removes duplicate lines without sortingRemoves duplicate lines from a file and keeps the original order of the rest.19 Nov 2026 - Tip
sed -i.bak 's/old-host/new-host/g' config.txtsed -i.bak keeps a copy of the file you just changedEdits a file in place with sed and saves the original as a backup copy.19 Nov 2026 - Tip
mount | column -tColumn -t lines up messy output in tidy columnsAligns the output of any command, or a CSV file, into readable columns.19 Nov 2026 - Tip
find . -name '*.png' -print0 | xargs -0 -n 1 -P 4 optipngXargs -P runs commands in parallel, no GNU parallel neededRuns a command on several inputs at the same time instead of one after another.27 Aug 2026 - Tip
find . -name '*.tmp' -deletePut -delete last in find, or it deletes more than you thinkDeletes the files that match your tests, as long as -delete comes last in the command.19 Aug 2026 - Tip
find . -name '*.tmp' -print0 | xargs -0 rm --find -print0 | xargs -0 survives file names with spacesPasses file names between find and xargs safely, even with spaces or quotes in them.8 Aug 2026 - Tip
printf '%-20s %8s\n' NAME SIZEprintf '%-20s %8d' lines up shell output where echo cannotFormats text into fixed-width columns in a script.3 Jun 2026 - Tip
find . -name node_modules -prune -o -type f -name '*.js' -printfind -name node_modules -prune skips a folder instead of walking itSkips a whole directory tree during a search, such as a dependency folder.19 May 2026 - Tip
set -eset -e is switched off inside an if, so check shell exit codes yourselfExplains why set -e does not stop a function that runs as an if condition.14 Apr 2026 - Tip
find . -regextype posix-extended -iregex '.*\.(jpe?g|png|gif)$'find -regextype posix-extended -regex matches several names in one testMatches file paths with one regular expression instead of several -name tests.19 Feb 2026 - Tip
find /etc -maxdepth 1 -type f -name '*.conf'find -maxdepth 1 searches one folder without going into the subfoldersLimits how many directory levels find goes down.19 Feb 2026 - Tip
find /srv -type f -printf '%s\t%p\n' | sort -nr | head -n 10find -printf with sort shows the biggest files without using lsPrints byte sizes and paths so you can sort and find the largest files.18 Feb 2026
Storage20
- Tip
zipgrep db_host backup.zipzipgrep searches the text inside a zip without unpacking itFind which file in an archive mentions a word, without extracting anything.1 Dec 2026 - Tip
#rsync -av --delete /srv/media/ /mnt/backup/media/Alt-# comments out the bash line and saves it in historyPark a half-written command in history without running it.30 Nov 2026 - Tip
readonly BACKUP_DIR=/srv/backupreadonly keeps a shell script from changing an important path by accidentLock a variable after you set it, so later code cannot overwrite it.30 Nov 2026 - Tip
!rsync:p!cmd:p shows what bash would rerun without running itPreview a history expansion before you run it, then press Up to use it.30 Nov 2026 - Tip
env -i ./backup.shenv -i runs a command with an empty environment, like cron and systemd doReproduce the 'works in my shell, fails in cron' problem on purpose.30 Nov 2026 - Tip
sed -n '/BEGIN backup/,/END backup/p' /var/log/app.logsed -n '/start/,/end/p' prints the block between two lines on LinuxPull one section out of a config or log, from a start line to an end line.30 Nov 2026 - Tip
df -P | awk -v max="$limit" 'NR > 1 && $5+0 > max {print $6, $5}'Awk -v passes a shell variable into an awk programHands a value from your shell script to awk without breaking the quoting.27 Nov 2026 - Tip
f="backup-2026-11-27.tar.gz"${var:offset:length} cuts a piece out of a bash stringTakes a fixed part of a string in bash, counting from the start or the end.27 Nov 2026 - Tip
mkdir -p ~/config-exportcp --parents copies a file and rebuilds its folder path at the destinationCopies files into a target folder while keeping the directory path they came from.27 Nov 2026 - Tip
rsync -av --remove-source-files ~/Downloads/done/ [email protected]:/mnt/user/media/incoming/rsync --remove-source-files moves files instead of copying themCopies files to another machine with rsync and deletes each one once it safely arrived.27 Nov 2026 - Tip
pv backup.tar.gz | tar xzpv puts a progress bar on anything you pipeShows progress, speed and time left for data going through a pipe.25 Nov 2026 - Tip
timeout -k 5 30 ./backup.shtimeout stops a command that hangsStops a command after a set time, and force-kills it if it will not quit.23 Oct 2026 - Tip
rsync -ani --delete ~/Documents/ /mnt/backup/Documents/rsync -ani shows exactly what would change before it changes anythingPrints what rsync would copy or delete, without touching any file.11 Sep 2026 - Tip
tmux new -d -s backup 'rsync -a /source/ /target/'tmux new -d -s job 'command' runs a command in the background that survives logoutStarts a command in a detached tmux session, so it keeps running after you log out.10 Sep 2026 - Tip
rsync -a photos/ /backup/ # puts the contents straight in /backup/The trailing slash in rsync decides where your files landWith a slash on the source rsync copies the contents; without it, the folder itself.6 Sep 2026 - Tip
IFS=$'\t' read -r name size <<< $'backup.tar\t1048576'$'\t' puts a real tab or newline into a shell stringWrites tab and newline characters in a shell string with ANSI-C quoting.12 Jun 2026 - Tip
mkdir -p backup/{2025,2026}/{01..12}Brace expansion builds a folder tree in one shell commandCreates many folders at once by letting the shell expand braces.2 Jun 2026 - Tip
IFS=@ read -r user host <<< "jordi@nas"A here-string <<< feeds a variable to a command inside the shellGives a command a string as input without a pipe or a temporary file.30 May 2026 - Tip
0 3 * * * tar czf /backup/home-$(date +%F).tgz /homeA % in a cron command must be written as \% or the line breaksExplains why a percent sign inside a crontab line cuts the command short and how to escape it.27 Apr 2026 - Tip
shellcheck backup.shshellcheck finds quoting mistakes in a shell script before they runScans a shell script for common mistakes such as unquoted variables.15 Apr 2026
Network16
- Tip
printf 'key=1\nport=80\n' | sed '/^port=/a timeout=5'Sed '/pattern/a text' adds a new line after every matching lineInserts a line of text after each line that matches a pattern.2 Dec 2026 - Tip
tail -f /var/log/nginx/access.log /var/log/nginx/error.logtail can follow several files at once and label each blockWatch more than one log in a single terminal window.1 Dec 2026 - Tip
curl -fsS --fail-early \curl fail-early stops at the first broken URL in a batchMake a multi URL curl command exit with an error as soon as one transfer fails.30 Nov 2026 - Tip
curl -q -fsS https://example.com/api/statuscurl -q as the first option ignores your .curlrcMake a script behave the same on every machine, whatever the local curl config says.30 Nov 2026 - Tip
echo /var/log/nginx/access.log | awk -F/ '{print $NF, $(NF-1)}'Awk '{print $NF}' prints the last column, however many there areGrabs the last field of each line, even when lines have a different number of fields.30 Nov 2026 - Tip
sed '0,/^port=/s//port=8081 #/' app.confsed '0,/old/s//new/' changes only the first match in a whole fileReplace the first occurrence in a file and leave every later one alone.30 Nov 2026 - Tip
prod_url=https://example.com${!name} reads a bash variable whose name is in another variablePick a setting like prod_url or test_url based on another variable.30 Nov 2026 - Tip
if ! diff -q /etc/nginx/nginx.conf /srv/backup/nginx.conf > /dev/null; thenDiff exits with 0, 1 or 2, and scripts can use thatUses diff's exit code to act only when a file really changed.30 Nov 2026 - Tip
curl -s -o /dev/null \curl -w %{onerror} prints a message only when the request failedStay quiet on success and print the exit code and error text on failure.30 Nov 2026 - Tip
declare -A port=(declare -A gives bash a lookup table with names as keysStores values under names in a bash script, so you can look them up by key.27 Nov 2026 - Tip
cp --backup=numbered nginx.conf /etc/nginx/nginx.confcp --backup=numbered keeps the file you were about to overwriteSaves every overwritten file as a numbered copy, so you can always go back.27 Nov 2026 - Tip
sed -n '210,218p' /etc/nginx/nginx.confsed -n '10,20p' prints just a range of lines from a filePrints only the lines between two line numbers, without opening an editor.27 Nov 2026 - Tip
diff -u nginx.conf.bak nginx.confdiff -u gives a compact change list that patch and git understandCompares two files and prints only the changes, with a few lines of context, in the format patch tools expect.24 Nov 2026 - Tip
cd /var/log/nginxcd – takes you back to the last directorySwitches back to the directory you were in before the last cd.8 Jun 2026 - Tip
printf 'header = "Authorization: Bearer %s"\n' "$API_TOKEN" | curl -K - https://api.example.com/meCurl -K – reads options from stdin so a token stays out of psPasses secrets to curl through stdin instead of visible command-line arguments.7 May 2026 - Tip
curl -fsS https://example.com/health || echo "check failed"curl -fsS gives scripts a real exit code and keeps error messagesMakes curl fail on HTTP errors with an exit code while still printing error messages.6 May 2026
Git10
- Tip
diff -r -x .git -x '*.log' one twodiff -r -x skips folders and files you don't care aboutLeaves out files and folders matching a pattern when comparing two directories recursively.3 Dec 2026 - Tip
git log --format='%h %an %ar %s' -10git log with your own format string shows exactly the fields you wantBuilds your own log line with placeholders for hash, author, date and subject.30 Nov 2026 - Tip
git rev-list --count HEADgit rev-list with count gives you a commit count for scriptsPrints a single number of commits, useful for build numbers and quick checks.30 Nov 2026 - Tip
git config --global pager.branch falsePager.branch false stops git branch from opening a pagerPrints short git output straight to the terminal instead of in less.30 Nov 2026 - Tip
zip -r site.zip site -x '*.DS_Store' '*/.git/*'zip -x keeps .DS_Store and .git out of a zip fileLeaves Mac and git clutter out of a zip archive you make in the terminal.27 Nov 2026 - Tip
grep -rn --include='*.conf' --exclude-dir=.git 'listen' /etc/nginxgrep -r --include and --exclude-dir search only the files you care aboutLimits a recursive grep to certain file types and skips folders like .git.27 Nov 2026 - Tip
git branch --show-currentgit branch --show-current prints only the name of your branchPrints the name of the current branch and nothing else, which is handy in scripts and prompts.25 Nov 2026 - Tip
git diff --name-only main...HEADgit diff --name-status lists changed files with a letter for what happenedLists only the files that changed, either as plain names or with a status letter for added, modified or deleted.25 Nov 2026 - Tip
git switch - # back on your feature branchgit switch – takes you back to the branch you were onJumps back to the previous Git branch without typing its name.23 Oct 2026 - Tip
find . -type f -name '*.php' -not -path '*/vendor/*' -not -path './.git/*'find -not -path excludes a folder, and -name only sees the last partFilters out whole folders from the result by matching the full path.20 Feb 2026
Docker8
- Tip
docker compose logs --tail 50 web # now at the top of a clean screenCtrl-l clears the shell screen and keeps the line you are typingClear the terminal without losing the half-typed command.30 Nov 2026 - Tip
exec "$@"exec "$@" at the end of an entrypoint shell script passes signals onLet the real program replace your wrapper script so stop signals reach it.30 Nov 2026 - Tip
cat -A docker-compose.ymlcat -A shows the tabs, line endings and odd characters you cannot seePrints a file with tabs, line ends and control characters made visible.28 Nov 2026 - Tip
if systemctl is-active --quiet docker.service; thenSystemctl is-active --quiet gives a script a plain yes or noReturns exit code 0 when a unit is active, so shell scripts can test a service without parsing text.28 Nov 2026 - Tip
expand -t 2 compose.yaml > compose.fixed.yamlexpand -t 2 turns tabs into spaces, for YAML files that refuse tabsConverts tab characters into spaces, so YAML files with tab indentation load again.27 Nov 2026 - Tip
docker ps -aq --filter status=exited | xargs -r docker rmXargs -r skips the command when there is no input at allStops xargs from running the command when the pipeline before it produced no input.27 Nov 2026 - Tip
find /mnt/user -name 'docker-compose.yml' -print -quitfind -print -quit stops searching after the first matchMakes find stop at the first matching file instead of searching the whole folder tree.27 Nov 2026 - Tip
tmux send-keys -t work:1.0 'docker compose logs -f' Entertmux send-keys types into a pane you are not looking atSends a command to a chosen tmux pane from the shell, as if you had typed it there.3 Sep 2026
Python3
- Tip
printf '12.5\n3\n4.25\n' | python3 -c 'import sys; print(sum(float(l) for l in sys.stdin if l.strip()))'A python -c one-liner adds up a column of numbers from a pipeTotal a list of numbers from another command without awk or a spreadsheet.30 Nov 2026 - Tip
readlink -f /usr/bin/python3readlink -f follows every symlink and prints the real pathResolves a chain of symlinks and prints the real absolute path of the target.28 Nov 2026 - Tip
python3 -m zipfile -l backup.zippython -m zipfile -l lists a zip archive when unzip is missingLists, tests, extracts or creates zip archives with the Python standard library.24 Nov 2026
Media3
- Tip
name=jellyfin${var^^} and ${var,,} change the case of a bash variableTurns a bash variable into upper or lower case without tr or awk.27 Nov 2026 - Tip
v="sonarr-4.0.10"[[ $s =~ regex ]] fills BASH_REMATCH with the parts that matchedMatches a regular expression in bash and gives you the captured parts without sed.27 Nov 2026 - Tip
rsync -a --info=progress2 ~/Videos/ /mnt/nas/Videos/rsync --info=progress2 shows one progress line for the whole transferShows a single progress line for the whole copy instead of one per file.18 Sep 2026
Web1
AI1
Nothing matches.