Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active March 26, 2026 15:37
Show Gist options
  • Select an option

  • Save peteristhegreat/01ffb3573ee503cb6ace84d6fb825a48 to your computer and use it in GitHub Desktop.

Select an option

Save peteristhegreat/01ffb3573ee503cb6ace84d6fb825a48 to your computer and use it in GitHub Desktop.
Linux notes
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Miscellaneous Linux Commands

Introduction

Linux users are expected to interact with the Linux systems quickly and efficiently.

A bare minimum number of commands will get you by, but if you are interested in sharing what works for you, or common/favorite one-liners or pieces of your bash script continue reading.

General Links

And if it isn't on this page, of course, check Google, StackOverflow, and the man pages (RTFM = Read the Fine Manual).

Manual Lookup

man
show the manual for the command, press q to quit, spacebar, page up, page down, arrows to scroll.

<command> -h
try to show the help or usage of a command.

<command> -?
try to show the help or usage of a command.

Wildcards

In bash, you can "glob" together a list of files by throwing in some wildcards.

abc*
Find abcd, abce, abcdefghij... and so on and anything else that starts with abc.

"ab c"
Include the space in the name, can have variables inside.

'ab c'
Include the space in the name, variables and special characters are treated like regular text.

Listing Files

ls
list files, similar to dir in windows.

ll
aliased to ls -l, shows columns of info about the list of the files in the directory.

tree
shows all the files in a directory tree.

../
up a directory.

./
in the current directory.

/
the root of the harddrive (like c: in windows).

pwd
display the present working directory.

cd
change directory.

~
shorthand for the current user's home directory, like /home/user.

<tab>
auto completes a partially written filename.

<tab><tab>
lists all the possible filenames for the typed out prefix before the cursor.

Viewing Text

cat
dumps the whole file to the screen.

less
lets you scroll up and down on the file, press q to quit.

more
lets you page down, only.

most
lets you scroll up, down, left and right.

head
show the first few lines of a file.

tail
show the last few lines of a file.

|
pipe the output of the command on the left to the command on the right.

echo
show one line of text.

clear
clear the current page of text and force the current line to the top of the page.

<Shift><PgUp>
scroll up to previous lines of text on the terminal.

resize
fixes poor wrapping of text at the command prompt, necessary after resizing the window, to have the terminal recognize the new column width..

Copy / Paste

XConfig needs to be configured properly for this to work:

  • XSelection needs to be changed from Clipboard to Primary.
  • The session needs to be restarted to see the changes.

Start a selection with a click drag.

Fill in a selection to the end with a right click.

Any selection in linux is auto-copied to the clipboard.

Paste in xterm (the default terminal in MICADS) with a center click.

Not installed, but future tool for ease of clipboard access is xclip.

Text Editors

In general terminal editors are faster to open and interact with files. On remote systems with lower bandwidth and higher latency, terminal editors are superior.

nano
terminal editor... Ctrl+ to save, exit, etc..

vi, vim
terminal editor... multiple modes, Read, Display, Visual, etc, many special commands start with :.

navigation with hjkl keys... press ESC to get out of a mode...

emacs
terminal editor... Ctrl+ or Alt+ (short handed to C and M ) for special interactions.

gedit, kate, gvim, xemacs
graphical editors.

Creating/Deleting Files and Folders

touch
make a file, or update the timestamp on a file.

>
capture output on the left into the file or handle on the right.

>>
append output on the left onto the filename on the right.

mkdir
make a directory.

cp
copy a file or directory.

mv
move and/or rename a file.

scp
secure copy a file or directory from one system to another.

rsync
remote synchronization between two computers (very powerful).

rm
remove a file or directory (needs -rf for non-empty directories).

Finding and Filtering Text

grep
general purpose find inside files tool, successors include: awk, ag.

find
find a specific filename and sometimes do something with it.

which
find a file (usually a script or binary executable) in the PATH folders list.

locate
find a filename (or pattern) on the computer that was in the snapshot index last night at midnight.

uniq
show only unique lines.

sort
show the lines sorted alphabetically.

Bash Variables and Functions

$var
the dollar sign indicates the start of a variable, usually an environment variable, e.g. $PATH.

alias
makes a nickname for command(s) with specific options, like ll = ls -l and gotis, or lists all aliases.

function
makes a reusable function or subroutine, that can handle parameters passed in, a la bash scripting.

export
makes a variable that lives for the length of the "session" that the user is logged in.

env
queries and lists all the "exported" variables in the '''env'''ironment for use with the session/login.

xterm
the text, the command prompt, etc that the session lives in, useful for launching another window.

set
used for changing/listing options for bash. Like "set -x" and "set +x" to turn on and off echoing all commands..

Bash History

https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps

!!
"bang, bang", previous command.

!$
"bang, cash", previous end parameter.

!xxxxx
"bang", some letters for previous command, executes the last command that started with those letters.

<ESC>,<Ctrl><E>
Expands one of the above shortcuts to its full length.

<Ctrl><R>
Reverse search through command history, with interactive input, repeat to search further back.

Sessions

su
switch user, start a session as a different user, or without parameters, starts a super user session.

ssh
tunnel into another system with a secure shell.

exit
end a session or shell.

logout
end a session or shell.

script
start a new bash session and save all the text output for later review.

screen
screen manager with terminal emulation, a nify way to keep persistent sessions open across logins, also does shared sessions easily.

screen -d -m -S shared
screen -x shared

tmux
terminal multiplexer, a newer nifty way to keep persistent sessions open across logins (utf support, not installed).

Linking & Symlinks

ln -s
create a symbolic link, one file pointing to the actual file somewhere else on the harddrive.

unlink
remove a symbolic link.

Process Control

Ctrl+Z
Pause a process.

bg
Move a paused process to the background jobs.

fg
Move a background job or a paused job to the foreground.

jobs
List all the jobs associated with the current session.

Ctrl+C
Kill the current foreground process.

top
View the current running process on the screen, q to quit, or Ctrl-c.

htop
Like top, but more colorful and a little more friendly.

Other Users

w
list all the other users on the system, and login time, idle time, last command, etc.

wall
broadcast a message to everyone else on the computer.

write
send a message to a single other user login to that computer.

`echo "message to send" | write <username>`

finger
get identification information about a user's name.

getent passwd "user"
gets entries about a user from the passwd administrative database.

Printing

lp
sends a file to the printer address under LPDEST.

Permissions

chmod
change the permissions for a file, who can execute, read, write, etc..

chgrp
change what group has access to a file.

chown
change what user owns the file.

sudo
'''S'''uper '''u'''ser '''do''', or take action with elevated permissions for the current user.

Zipping / Unzipping

tar
stands for tape archive, many options for compressing and decompressing files, great for .tar, .tar.bz, .tar.gz and others.

unzip
unzip a file.

Diffing and Versioning

diff
show all the differences between two files.

tkdiff
show all the differences between two files, graphical window.

svn
centralized versioning system.

git
distributed versioning system, awesome (see [attachment:progit-en.1084.pdf Git Book (cached)] or [https://progit2.s3.amazonaws.com/en/2016-03-22-f3531/progit-en.1084.pdf Git Book]).

Scripting Language Interpreters

Script files are read a line at a time, and interpreted at run time, plain text files.

perl
files end in pl, original support for Regular Expressions (aka regex or regexp).

python
files end in py, popular language.

bash
stands for borne again shell, and is the language that handles all the input to the command-line.

sh
posix standard shell command script.

ruby
files end in rb, popular language, newer than python.

Compilers and Library Tools

These files are compiled down to a binary file.

gcc
c compiler.

g++
c++ compiler.

ld
linker, connects complied .o files into an executable.

make
manages compiling and linking process for most projects in a Makefile.

configure
provides inputs for the Makefile that are specific to the system/install.

Disk Utilities

du
'''d'''isk '''u'''sage, estimate file space usage - space used under a particular directory or files on a file system..

du -sh ./* show the filesize of each sub folder in the current directory

df
'''d'''isk '''f'''ree, report file system disk space usage, also useful for checking for nfs mounts.

df -h show all the mounted disks and their used/available size

dd
'''d'''ata '''d'''escription, convert and copy a file, also used for cloning partitions and harddisks.

GUI Applications

From an ssh session, run gnome-session to start a GNOME/Ubuntu style desktop or run plasma-desktop to start a KDE/Plasma style desktop.

The gnome session is the default way that a ubuntu user logs into the computer.

Categories

Note: search one of these on this page to find an app.

GUI apps with Shortcuts

| Notes | Shortcut | Name | Comment | Categories | Exec |

Generator Script

You can find these apps in the kickoff launcher in the corner of plasma-desktop.

Generate the table below with the following script:

cd /usr/share/applications
find_and_strip ()
{      
  str=$(grep -rhoP "(?<=^($1)).*" $2); 
  echo $str; 
}
(
for i in * */*; 
do 
  if [ -d $i ]; then 
    continue; 
  fi; 
  echo -e "$i\t$(find_and_strip "Name=" $i)\t$(find_and_strip "Comment=" $i)\t$(find_and_strip "Categories=" $i)\t$(find_and_strip "Exec=" $i)"; 
done) | xclip
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Linux Shell Commands Reference</title>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Syne:wght@700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tippy.js/6.3.7/tippy.min.css">
<style>
:root {
--bg: #0a0c10;
--surface: #111419;
--border: #1e2330;
--glow-base: 0 0 12px;
--c1: #00e5ff;
--c2: #69ff47;
--c3: #ff6b6b;
--c4: #ffd166;
--c5: #b388ff;
--c6: #ff9a3c;
--c7: #4dd0e1;
--c8: #f06292;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--bg);
font-family: 'JetBrains Mono', monospace;
color: #c9d1d9;
min-height: 100vh;
padding: 32px 28px 40px;
background-image:
repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,.015) 39px, rgba(255,255,255,.015) 40px),
repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,.015) 39px, rgba(255,255,255,.015) 40px);
}
header {
text-align: center;
margin-bottom: 36px;
}
header h1 {
font-family: 'Syne', sans-serif;
font-size: clamp(1.8rem, 4vw, 3rem);
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
background: linear-gradient(90deg, var(--c1), var(--c2), var(--c5), var(--c3));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
header p {
margin-top: 6px;
font-size: .75rem;
color: #4a5568;
letter-spacing: .15em;
text-transform: uppercase;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 14px;
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px 14px 16px;
position: relative;
overflow: hidden;
transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); }
.card::before {
content: '';
position: absolute;
inset: 0 0 auto 0;
height: 3px;
border-radius: 8px 8px 0 0;
}
.c1::before { background: var(--c1); }
.c2::before { background: var(--c2); }
.c3::before { background: var(--c3); }
.c4::before { background: var(--c4); }
.c5::before { background: var(--c5); }
.c6::before { background: var(--c6); }
.c7::before { background: var(--c7); }
.c8::before { background: var(--c8); }
.c1:hover { border-color: var(--c1); box-shadow: var(--glow-base) rgba(0,229,255,.18); }
.c2:hover { border-color: var(--c2); box-shadow: var(--glow-base) rgba(105,255,71,.18); }
.c3:hover { border-color: var(--c3); box-shadow: var(--glow-base) rgba(255,107,107,.18); }
.c4:hover { border-color: var(--c4); box-shadow: var(--glow-base) rgba(255,209,102,.18); }
.c5:hover { border-color: var(--c5); box-shadow: var(--glow-base) rgba(179,136,255,.18); }
.c6:hover { border-color: var(--c6); box-shadow: var(--glow-base) rgba(255,154,60,.18); }
.c7:hover { border-color: var(--c7); box-shadow: var(--glow-base) rgba(77,208,225,.18); }
.c8:hover { border-color: var(--c8); box-shadow: var(--glow-base) rgba(240,98,146,.18); }
.card-title {
font-family: 'Syne', sans-serif;
font-size: .7rem;
font-weight: 700;
letter-spacing: .18em;
text-transform: uppercase;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px solid var(--border);
}
.c1 .card-title { color: var(--c1); }
.c2 .card-title { color: var(--c2); }
.c3 .card-title { color: var(--c3); }
.c4 .card-title { color: var(--c4); }
.c5 .card-title { color: var(--c5); }
.c6 .card-title { color: var(--c6); }
.c7 .card-title { color: var(--c7); }
.c8 .card-title { color: var(--c8); }
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.chip {
display: inline-block;
font-size: .72rem;
font-weight: 600;
padding: 3px 9px;
border-radius: 4px;
border: 1px solid transparent;
white-space: nowrap;
transition: background .15s, box-shadow .15s;
cursor: default;
}
.c1 .chip { background: rgba(0,229,255,.08); border-color: rgba(0,229,255,.25); color: #a0f0ff; }
.c2 .chip { background: rgba(105,255,71,.08); border-color: rgba(105,255,71,.25); color: #b6ffaa; }
.c3 .chip { background: rgba(255,107,107,.08);border-color: rgba(255,107,107,.25);color: #ffb3b3; }
.c4 .chip { background: rgba(255,209,102,.08);border-color: rgba(255,209,102,.25);color: #ffe8a0; }
.c5 .chip { background: rgba(179,136,255,.08);border-color: rgba(179,136,255,.25);color: #d5bfff; }
.c6 .chip { background: rgba(255,154,60,.08); border-color: rgba(255,154,60,.25); color: #ffd0a0; }
.c7 .chip { background: rgba(77,208,225,.08); border-color: rgba(77,208,225,.25); color: #aaeef5; }
.c8 .chip { background: rgba(240,98,146,.08); border-color: rgba(240,98,146,.25); color: #ffb8d0; }
.c1 .chip:hover { background: rgba(0,229,255,.18); box-shadow: 0 0 8px rgba(0,229,255,.3); }
.c2 .chip:hover { background: rgba(105,255,71,.18); box-shadow: 0 0 8px rgba(105,255,71,.3); }
.c3 .chip:hover { background: rgba(255,107,107,.18);box-shadow: 0 0 8px rgba(255,107,107,.3); }
.c4 .chip:hover { background: rgba(255,209,102,.18);box-shadow: 0 0 8px rgba(255,209,102,.3); }
.c5 .chip:hover { background: rgba(179,136,255,.18);box-shadow: 0 0 8px rgba(179,136,255,.3); }
.c6 .chip:hover { background: rgba(255,154,60,.18); box-shadow: 0 0 8px rgba(255,154,60,.3); }
.c7 .chip:hover { background: rgba(77,208,225,.18); box-shadow: 0 0 8px rgba(77,208,225,.3); }
.c8 .chip:hover { background: rgba(240,98,146,.18); box-shadow: 0 0 8px rgba(240,98,146,.3); }
@media (min-width: 800px) {
.wide { grid-column: span 2; }
}
footer {
text-align: center;
margin-top: 32px;
font-size: .65rem;
color: #2d3748;
letter-spacing: .12em;
text-transform: uppercase;
}
/* ── Tippy custom theme ── */
.tippy-box[data-theme~='terminal'] {
background: #0d1117;
border: 1px solid #30363d;
border-radius: 6px;
box-shadow: 0 8px 24px rgba(0,0,0,.6);
font-family: 'JetBrains Mono', monospace;
font-size: .72rem;
max-width: 280px;
padding: 0;
}
.tippy-box[data-theme~='terminal'] .tippy-content { padding: 0; }
.tippy-box[data-theme~='terminal'] .tippy-arrow { color: #30363d; }
.tt {
padding: 9px 11px 10px;
line-height: 1.55;
border-radius: 6px;
border-top: 2px solid transparent;
}
.tt-cmd { font-weight: 700; font-size: .78rem; margin-bottom: 4px; letter-spacing: .03em; }
.tt-desc { color: #8b949e; font-size: .69rem; line-height: 1.5; }
.tt-example {
margin-top: 7px;
background: #161b22;
border: 1px solid #21262d;
border-radius: 4px;
padding: 4px 8px;
color: #c9d1d9;
font-size: .67rem;
white-space: pre;
}
.tt.a1 { border-top-color: var(--c1); } .tt.a1 .tt-cmd { color: var(--c1); }
.tt.a2 { border-top-color: var(--c2); } .tt.a2 .tt-cmd { color: var(--c2); }
.tt.a3 { border-top-color: var(--c3); } .tt.a3 .tt-cmd { color: var(--c3); }
.tt.a4 { border-top-color: var(--c4); } .tt.a4 .tt-cmd { color: var(--c4); }
.tt.a5 { border-top-color: var(--c5); } .tt.a5 .tt-cmd { color: var(--c5); }
.tt.a6 { border-top-color: var(--c6); } .tt.a6 .tt-cmd { color: var(--c6); }
.tt.a7 { border-top-color: var(--c7); } .tt.a7 .tt-cmd { color: var(--c7); }
.tt.a8 { border-top-color: var(--c8); } .tt.a8 .tt-cmd { color: var(--c8); }
</style>
</head>
<body>
<header>
<h1>Linux Shell Commands</h1>
<p>Quick Reference &nbsp;·&nbsp; Shell Proficiency &nbsp;·&nbsp; Hover any command for details</p>
</header>
<div class="grid">
<!-- Manual Lookup -->
<div class="card c1">
<div class="card-title">Manual Lookup</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">man</div><div class="tt-desc">Show the manual for a command. Press <strong>q</strong> to quit; spacebar / arrows to scroll.</div><div class="tt-example">man ls</div></div>'>man</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">&lt;cmd&gt; -h</div><div class="tt-desc">Show help or usage info for a command (most tools support this flag).</div><div class="tt-example">grep -h</div></div>'>&lt;cmd&gt; -h</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">&lt;cmd&gt; -?</div><div class="tt-desc">Alternative help flag — behaviour varies by tool.</div><div class="tt-example">find -?</div></div>'>&lt;cmd&gt; -?</span>
</div>
</div>
<!-- Wildcards -->
<div class="card c4">
<div class="card-title">Wildcards</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">abc*</div><div class="tt-desc">Glob — match anything starting with "abc": abcd, abcXYZ, etc.</div><div class="tt-example">ls report_*.csv</div></div>'>abc*</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">"ab c"</div><div class="tt-desc">Double quotes preserve spaces in a name. Variables and special chars still expand inside.</div><div class="tt-example">cd "my folder"</div></div>'>"ab c"</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">&apos;ab c&apos;</div><div class="tt-desc">Single quotes preserve spaces AND treat everything as literal — no variable expansion.</div><div class="tt-example">echo &apos;$PATH is literal&apos;</div></div>'>&#39;ab c&#39;</span>
</div>
</div>
<!-- Listing & Navigation -->
<div class="card c2 wide">
<div class="card-title">Listing &amp; Navigation</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">ls</div><div class="tt-desc">List files in the current directory. Like <strong>dir</strong> in Windows. Add <strong>-la</strong> for full detail.</div><div class="tt-example">ls -la /etc</div></div>'>ls</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">ll</div><div class="tt-desc">Alias for <strong>ls -l</strong> — detailed view with permissions, owner, size, and timestamp.</div><div class="tt-example">ll /var/log</div></div>'>ll</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">tree</div><div class="tt-desc">Print all files and directories as an indented tree. Use <strong>-L</strong> to limit depth.</div><div class="tt-example">tree -L 2</div></div>'>tree</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">../</div><div class="tt-desc">Parent directory — one level up. Chain them: <strong>../../</strong> goes up two levels.</div><div class="tt-example">cd ../../etc</div></div>'>../</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">./</div><div class="tt-desc">Current directory. Required when running scripts or binaries here (not in $PATH).</div><div class="tt-example">./build.sh</div></div>'>./</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">/</div><div class="tt-desc">Filesystem root — the top of the entire directory tree. Like <strong>C:\</strong> in Windows.</div><div class="tt-example">ls /</div></div>'>/</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">pwd</div><div class="tt-desc">Print Working Directory — show the full absolute path of where you are right now.</div><div class="tt-example">pwd</div></div>'>pwd</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">cd</div><div class="tt-desc">Change directory. With no argument, returns to your home directory.</div><div class="tt-example">cd /var/log</div></div>'>cd</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">~</div><div class="tt-desc">Shorthand for your home directory (e.g. <strong>/home/alice</strong>). Use anywhere in a path.</div><div class="tt-example">cd ~/Documents</div></div>'>~</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">&lt;Tab&gt;</div><div class="tt-desc">Auto-complete a partially typed filename or command. One press to complete; two to list options.</div></div>'>&lt;tab&gt;</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">&lt;Tab&gt;&lt;Tab&gt;</div><div class="tt-desc">List all completions that match the prefix you have typed so far.</div></div>'>&lt;tab&gt;&lt;tab&gt;</span>
</div>
</div>
<!-- Viewing Text -->
<div class="card c4 wide">
<div class="card-title">Viewing Text</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">cat</div><div class="tt-desc">Dump an entire file to stdout. Best for small files; use <strong>less</strong> for large ones.</div><div class="tt-example">cat /etc/hosts</div></div>'>cat</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">less</div><div class="tt-desc">Scroll up and down through a file. Press <strong>q</strong> to quit, <strong>/</strong> to search forward.</div><div class="tt-example">less /var/log/syslog</div></div>'>less</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">more</div><div class="tt-desc">Page through a file downward only — the older predecessor to <strong>less</strong>.</div><div class="tt-example">more bigfile.txt</div></div>'>more</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">most</div><div class="tt-desc">Like <strong>less</strong> but also scrolls left and right — handy for very wide output.</div><div class="tt-example">most wide.log</div></div>'>most</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">head</div><div class="tt-desc">Print the first 10 lines of a file. Change the count with <strong>-n</strong>.</div><div class="tt-example">head -n 20 file.txt</div></div>'>head</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">tail</div><div class="tt-desc">Print the last 10 lines. Use <strong>-f</strong> to follow a live log in real time.</div><div class="tt-example">tail -f /var/log/syslog</div></div>'>tail</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">|</div><div class="tt-desc">Pipe — connect two commands: left command&apos;s stdout becomes right command&apos;s stdin.</div><div class="tt-example">ls -la | grep ".log"</div></div>'>|</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">echo</div><div class="tt-desc">Print a string to stdout. Commonly used in scripts to display messages or variable values.</div><div class="tt-example">echo $HOME</div></div>'>echo</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">clear</div><div class="tt-desc">Clear the terminal screen. Shortcut: <strong>Ctrl+L</strong>.</div><div class="tt-example">clear</div></div>'>clear</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">&lt;Shift&gt;&lt;PgUp&gt;</div><div class="tt-desc">Scroll the terminal&apos;s scrollback buffer upward to review previous output.</div></div>'>&lt;Shift&gt;&lt;PgUp&gt;</span>
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">resize</div><div class="tt-desc">Resync the shell&apos;s idea of column/row width after resizing the terminal window — fixes garbled wrapping.</div><div class="tt-example">resize</div></div>'>resize</span>
</div>
</div>
<!-- Text Editors -->
<div class="card c5">
<div class="card-title">Text Editors</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">nano</div><div class="tt-desc">Beginner-friendly terminal editor. <strong>Ctrl+O</strong> to save, <strong>Ctrl+X</strong> to exit. Key hints shown at the bottom.</div><div class="tt-example">nano config.txt</div></div>'>nano</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">vi</div><div class="tt-desc">Classic modal terminal editor. Press <strong>i</strong> to insert text, <strong>ESC</strong> to return to command mode.</div><div class="tt-example">vi notes.txt</div></div>'>vi</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">vim</div><div class="tt-desc">Improved vi. Navigate with <strong>hjkl</strong>. Save and quit with <strong>:wq</strong>; quit without saving: <strong>:q!</strong></div><div class="tt-example">vim script.sh</div></div>'>vim</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">emacs</div><div class="tt-desc">Powerful terminal editor. Uses <strong>C-x C-s</strong> to save, <strong>C-x C-c</strong> to quit.</div><div class="tt-example">emacs notes.txt</div></div>'>emacs</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">gedit</div><div class="tt-desc">GNOME graphical text editor with syntax highlighting. Requires a desktop session.</div><div class="tt-example">gedit file.txt &amp;</div></div>'>gedit</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">kate</div><div class="tt-desc">KDE graphical editor with split-view and a built-in terminal panel.</div><div class="tt-example">kate file.txt &amp;</div></div>'>kate</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">gvim</div><div class="tt-desc">Graphical Vim — all the power of vim with a windowed GUI and menu bar.</div><div class="tt-example">gvim script.py &amp;</div></div>'>gvim</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">xemacs</div><div class="tt-desc">Graphical fork of Emacs with an X11 window, menus, and toolbar.</div><div class="tt-example">xemacs notes.txt &amp;</div></div>'>xemacs</span>
</div>
</div>
<!-- Creating/Deleting Files -->
<div class="card c3 wide">
<div class="card-title">Creating &amp; Deleting Files</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">touch</div><div class="tt-desc">Create an empty file, or update the access/modification timestamp on an existing one.</div><div class="tt-example">touch newfile.txt</div></div>'>touch</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">&gt;</div><div class="tt-desc">Redirect stdout to a file, <strong>overwriting</strong> it. Creates the file if it does not exist.</div><div class="tt-example">echo "hello" &gt; out.txt</div></div>'>&gt;</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">&gt;&gt;</div><div class="tt-desc">Redirect stdout and <strong>append</strong> to a file — existing content is preserved.</div><div class="tt-example">echo "line" &gt;&gt; log.txt</div></div>'>&gt;&gt;</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">mkdir</div><div class="tt-desc">Create a new directory. Use <strong>-p</strong> to create nested parent directories in one step.</div><div class="tt-example">mkdir -p a/b/c</div></div>'>mkdir</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">cp</div><div class="tt-desc">Copy a file or directory. Use <strong>-r</strong> to copy directories recursively.</div><div class="tt-example">cp -r src/ dest/</div></div>'>cp</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">mv</div><div class="tt-desc">Move or rename a file or directory. Works across directories too.</div><div class="tt-example">mv old.txt new.txt</div></div>'>mv</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">scp</div><div class="tt-desc">Securely copy files between hosts over SSH. Use <strong>-r</strong> for directories.</div><div class="tt-example">scp file.txt user@host:/path/</div></div>'>scp</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">rsync</div><div class="tt-desc">Efficiently sync files locally or over a network, transferring only what has changed.</div><div class="tt-example">rsync -avz src/ user@host:/dst/</div></div>'>rsync</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">rm</div><div class="tt-desc">Remove a file. Use <strong>-rf</strong> to delete directories recursively. <em>No recycle bin — permanent!</em></div><div class="tt-example">rm -rf old_folder/</div></div>'>rm</span>
</div>
</div>
<!-- Finding and Filtering -->
<div class="card c2">
<div class="card-title">Finding &amp; Filtering</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">grep</div><div class="tt-desc">Search for a pattern inside files. Use <strong>-r</strong> for recursive, <strong>-i</strong> for case-insensitive, <strong>-n</strong> for line numbers.</div><div class="tt-example">grep -rin "error" /var/log/</div></div>'>grep</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">find</div><div class="tt-desc">Search for files by name, type, size, date, and more. Can run a command on each result with <strong>-exec</strong>.</div><div class="tt-example">find . -name "*.log" -mtime -7</div></div>'>find</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">which</div><div class="tt-desc">Show the full path of a command or binary as found in your <strong>$PATH</strong>.</div><div class="tt-example">which python3</div></div>'>which</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">locate</div><div class="tt-desc">Find files by name using a nightly snapshot index. Much faster than <strong>find</strong>, but may be out of date.</div><div class="tt-example">locate nginx.conf</div></div>'>locate</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">uniq</div><div class="tt-desc">Remove duplicate adjacent lines. Pipe from <strong>sort</strong> first to guarantee full deduplication.</div><div class="tt-example">sort names.txt | uniq</div></div>'>uniq</span>
<span class="chip" data-tippy-content='<div class="tt a2"><div class="tt-cmd">sort</div><div class="tt-desc">Sort lines alphabetically. Use <strong>-n</strong> for numeric, <strong>-r</strong> for reverse, <strong>-u</strong> for unique.</div><div class="tt-example">sort -n scores.txt</div></div>'>sort</span>
</div>
</div>
<!-- Bash Variables -->
<div class="card c5">
<div class="card-title">Bash Variables &amp; Functions</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">$var</div><div class="tt-desc">Dollar sign dereferences a variable. Common built-ins: <strong>$PATH</strong>, <strong>$HOME</strong>, <strong>$USER</strong>, <strong>$PWD</strong>.</div><div class="tt-example">echo $PATH</div></div>'>$var</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">alias</div><div class="tt-desc">Create a shortcut nickname for a command. Run alone to list all active aliases.</div><div class="tt-example">alias ll="ls -la"</div></div>'>alias</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">function</div><div class="tt-desc">Define a reusable bash function with optional parameters. Put it in <strong>.bashrc</strong> to persist.</div><div class="tt-example">function greet() { echo "Hi $1"; }</div></div>'>function</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">export</div><div class="tt-desc">Mark a variable so it is inherited by child processes and subshells in this session.</div><div class="tt-example">export EDITOR=vim</div></div>'>export</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">env</div><div class="tt-desc">List all exported environment variables. Also used to run a command in a modified environment.</div><div class="tt-example">env | grep HOME</div></div>'>env</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">xterm</div><div class="tt-desc">Launch a new terminal window. Append <strong>&amp;</strong> to run it in the background without blocking.</div><div class="tt-example">xterm &amp;</div></div>'>xterm</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">set</div><div class="tt-desc">View or change shell options. <strong>set -x</strong> echoes every command (debug mode); <strong>set +x</strong> turns it off.</div><div class="tt-example">set -x # debug on
set +x # debug off</div></div>'>set</span>
</div>
</div>
<!-- Bash History -->
<div class="card c5">
<div class="card-title">Bash History</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">!!</div><div class="tt-desc">"bang bang" — re-run the previous command. Classic use: forgot sudo.</div><div class="tt-example">sudo !!</div></div>'>!!</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">!$</div><div class="tt-desc">"bang dollar" — expands to the last argument of the previous command.</div><div class="tt-example">cat long/path/file.txt
vim !$</div></div>'>!$</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">!xxxxx</div><div class="tt-desc">Re-run the most recent command that <em>starts with</em> those letters.</div><div class="tt-example">!git # re-runs last git cmd
!ssh # re-runs last ssh cmd</div></div>'>!xxxxx</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">&lt;ESC&gt;,&lt;Ctrl+E&gt;</div><div class="tt-desc">Expand a history shorthand (<strong>!!</strong>, <strong>!$</strong>, etc.) to its full text on the command line before running it.</div></div>'>&lt;ESC&gt;,&lt;Ctrl&gt;&lt;E&gt;</span>
<span class="chip" data-tippy-content='<div class="tt a5"><div class="tt-cmd">&lt;Ctrl+R&gt;</div><div class="tt-desc">Reverse-search through command history interactively. Keep pressing to go further back.</div></div>'>&lt;Ctrl&gt;&lt;R&gt;</span>
</div>
</div>
<!-- Sessions -->
<div class="card c1 wide">
<div class="card-title">Sessions</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">su</div><div class="tt-desc">Switch User. Without arguments starts a root shell. Use <strong>su - user</strong> for a full login shell.</div><div class="tt-example">su - alice</div></div>'>su</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">ssh</div><div class="tt-desc">Secure Shell — open an encrypted remote terminal session on another machine.</div><div class="tt-example">ssh alice@192.168.1.10</div></div>'>ssh</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">exit</div><div class="tt-desc">End the current shell session. Also closes an SSH connection or a <strong>su</strong> session.</div><div class="tt-example">exit</div></div>'>exit</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">logout</div><div class="tt-desc">End a login shell session. Equivalent to <strong>exit</strong> in most contexts.</div><div class="tt-example">logout</div></div>'>logout</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">script</div><div class="tt-desc">Record everything printed to the terminal into a file for later review or audit.</div><div class="tt-example">script session.log</div></div>'>script</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">screen</div><div class="tt-desc">Terminal multiplexer — keep sessions alive across disconnects. Also supports shared sessions.</div><div class="tt-example">screen -d -m -S shared
screen -x shared</div></div>'>screen</span>
<span class="chip" data-tippy-content='<div class="tt a1"><div class="tt-cmd">tmux</div><div class="tt-desc">Modern terminal multiplexer — persistent sessions, split panes, and full UTF-8 support.</div><div class="tt-example">tmux new -s work
tmux attach -t work</div></div>'>tmux</span>
</div>
</div>
<!-- Linking -->
<div class="card c7">
<div class="card-title">Linking &amp; Symlinks</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">ln -s</div><div class="tt-desc">Create a symbolic (soft) link — a pointer to another file or directory anywhere on the filesystem.</div><div class="tt-example">ln -s /opt/app/bin/app ~/bin/app</div></div>'>ln -s</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">unlink</div><div class="tt-desc">Remove a symbolic link without touching the target file it points to.</div><div class="tt-example">unlink ~/bin/app</div></div>'>unlink</span>
</div>
</div>
<!-- Process Control -->
<div class="card c6">
<div class="card-title">Process Control</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">Ctrl+Z</div><div class="tt-desc">Suspend (pause) the foreground process. Resume it with <strong>fg</strong> or push to background with <strong>bg</strong>.</div></div>'>Ctrl+Z</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">bg</div><div class="tt-desc">Resume a suspended job in the <strong>background</strong>, freeing your terminal prompt.</div><div class="tt-example">bg %1</div></div>'>bg</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">fg</div><div class="tt-desc">Bring a background or suspended job to the <strong>foreground</strong>.</div><div class="tt-example">fg %1</div></div>'>fg</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">jobs</div><div class="tt-desc">List all jobs (background/suspended) belonging to the current shell session.</div><div class="tt-example">jobs -l</div></div>'>jobs</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">Ctrl+C</div><div class="tt-desc">Send SIGINT to the foreground process — kills most programs immediately.</div></div>'>Ctrl+C</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">top</div><div class="tt-desc">Live process viewer with CPU/memory stats. Press <strong>q</strong> to quit, <strong>k</strong> to kill a process by PID.</div><div class="tt-example">top</div></div>'>top</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">htop</div><div class="tt-desc">Colorful, interactive replacement for <strong>top</strong> — visual CPU bars, mouse support, easier navigation.</div><div class="tt-example">htop</div></div>'>htop</span>
</div>
</div>
<!-- Other Users -->
<div class="card c6">
<div class="card-title">Other Users</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">w</div><div class="tt-desc">Who is logged in, plus their login time, idle time, and current command.</div><div class="tt-example">w</div></div>'>w</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">wall</div><div class="tt-desc">Broadcast a message to every logged-in user on the system.</div><div class="tt-example">wall "Rebooting in 5 minutes!"</div></div>'>wall</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">write</div><div class="tt-desc">Send a direct message to a single logged-in user&apos;s terminal.</div><div class="tt-example">echo "ping" | write alice</div></div>'>write</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">finger</div><div class="tt-desc">Display identification info about a user: real name, login, home directory, shell.</div><div class="tt-example">finger alice</div></div>'>finger</span>
<span class="chip" data-tippy-content='<div class="tt a6"><div class="tt-cmd">getent passwd</div><div class="tt-desc">Look up user info from the system database — works with local files, LDAP, and NIS.</div><div class="tt-example">getent passwd alice</div></div>'>getent passwd</span>
</div>
</div>
<!-- Permissions -->
<div class="card c3">
<div class="card-title">Permissions</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">chmod</div><div class="tt-desc">Change file permissions — who can read, write, or execute. Use octal (<strong>755</strong>) or symbolic (<strong>u+x</strong>) notation.</div><div class="tt-example">chmod 755 script.sh</div></div>'>chmod</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">chgrp</div><div class="tt-desc">Change the group ownership of a file or directory.</div><div class="tt-example">chgrp devteam project/</div></div>'>chgrp</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">chown</div><div class="tt-desc">Change the owning user and/or group of a file.</div><div class="tt-example">chown alice:staff file.txt</div></div>'>chown</span>
<span class="chip" data-tippy-content='<div class="tt a3"><div class="tt-cmd">sudo</div><div class="tt-desc">"Superuser do" — run a single command with elevated (root) privileges.</div><div class="tt-example">sudo apt update</div></div>'>sudo</span>
</div>
</div>
<!-- Printing -->
<div class="card c4">
<div class="card-title">Printing</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a4"><div class="tt-cmd">lp</div><div class="tt-desc">Send a file to the printer defined by <strong>$LPDEST</strong>. Use <strong>-d</strong> to specify a different printer by name.</div><div class="tt-example">lp -d laser1 report.pdf</div></div>'>lp</span>
</div>
</div>
<!-- Zipping -->
<div class="card c7">
<div class="card-title">Zipping / Unzipping</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">tar</div><div class="tt-desc">Tape archive — pack &amp; compress files. <strong>-czf</strong> creates .tar.gz; <strong>-xzf</strong> extracts it.</div><div class="tt-example">tar -czf out.tar.gz folder/
tar -xzf out.tar.gz</div></div>'>tar</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">unzip</div><div class="tt-desc">Extract a .zip archive. Use <strong>-d</strong> to set the destination directory.</div><div class="tt-example">unzip archive.zip -d ./out/</div></div>'>unzip</span>
</div>
</div>
<!-- Diffing -->
<div class="card c8">
<div class="card-title">Diffing &amp; Versioning</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">diff</div><div class="tt-desc">Show line-by-line differences between two files. Use <strong>-u</strong> for unified patch-style output.</div><div class="tt-example">diff -u old.txt new.txt</div></div>'>diff</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">tkdiff</div><div class="tt-desc">Graphical two-pane diff viewer. Requires a desktop session (X11).</div><div class="tt-example">tkdiff old.txt new.txt</div></div>'>tkdiff</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">svn</div><div class="tt-desc">Subversion — centralized version control. All commits go to a shared central repository.</div><div class="tt-example">svn commit -m "fix: null check"</div></div>'>svn</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">git</div><div class="tt-desc">Distributed version control — the modern standard. Full history tracked locally; push/pull to share.</div><div class="tt-example">git commit -am "update"</div></div>'>git</span>
</div>
</div>
<!-- Scripting -->
<div class="card c8">
<div class="card-title">Scripting Languages</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">perl</div><div class="tt-desc">Files end in <strong>.pl</strong>. Pioneer of regex support; still widely used for text processing and sysadmin tasks.</div><div class="tt-example">perl -ne &apos;print if /error/i&apos; app.log</div></div>'>perl</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">python</div><div class="tt-desc">Files end in <strong>.py</strong>. Hugely popular general-purpose language. Use <strong>python3</strong> on modern systems.</div><div class="tt-example">python3 script.py</div></div>'>python</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">bash</div><div class="tt-desc">"Bourne Again Shell" — the language of the Linux command line and the default for shell scripts.</div><div class="tt-example">bash myscript.sh</div></div>'>bash</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">sh</div><div class="tt-desc">POSIX standard shell — more portable than bash but fewer features. Used in <strong>#!/bin/sh</strong> shebangs.</div><div class="tt-example">sh script.sh</div></div>'>sh</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">ruby</div><div class="tt-desc">Files end in <strong>.rb</strong>. Expressive, object-oriented scripting language. Newer than Python.</div><div class="tt-example">ruby script.rb</div></div>'>ruby</span>
</div>
</div>
<!-- Compilers -->
<div class="card c8">
<div class="card-title">Compilers &amp; Linkers</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">gcc</div><div class="tt-desc">GNU C Compiler. Turns <strong>.c</strong> source files into object files or a final executable.</div><div class="tt-example">gcc -o app main.c</div></div>'>gcc</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">g++</div><div class="tt-desc">GNU C++ Compiler. Turns <strong>.cpp</strong> source files into object files or a final executable.</div><div class="tt-example">g++ -o app main.cpp</div></div>'>g++</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">ld</div><div class="tt-desc">The GNU linker. Combines compiled <strong>.o</strong> object files into a final executable or shared library.</div><div class="tt-example">ld -o app main.o util.o</div></div>'>ld</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">make</div><div class="tt-desc">Automate compiling and linking via rules in a <strong>Makefile</strong>. Rebuilds only what has changed.</div><div class="tt-example">make all
make clean</div></div>'>make</span>
<span class="chip" data-tippy-content='<div class="tt a8"><div class="tt-cmd">configure</div><div class="tt-desc">A generated script that probes your system and produces a tuned <strong>Makefile</strong> for the build.</div><div class="tt-example">./configure --prefix=/usr/local
make &amp;&amp; make install</div></div>'>configure</span>
</div>
</div>
<!-- Disk Utilities -->
<div class="card c7">
<div class="card-title">Disk Utilities</div>
<div class="chips">
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">du</div><div class="tt-desc">Disk Usage — estimate space used under a directory. Use <strong>-sh</strong> for a single human-readable total.</div><div class="tt-example">du -sh /var/log</div></div>'>du</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">du -sh ./*</div><div class="tt-desc">Show the size of every item in the current directory — quickly spot what is eating disk space.</div><div class="tt-example">du -sh ./* | sort -h</div></div>'>du -sh ./*</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">df</div><div class="tt-desc">Disk Free — report filesystem disk space usage. Also useful for spotting NFS mounts.</div><div class="tt-example">df -h</div></div>'>df</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">df -h</div><div class="tt-desc">List all mounted filesystems with used and available space in human-readable units (GB/MB).</div><div class="tt-example">df -h</div></div>'>df -h</span>
<span class="chip" data-tippy-content='<div class="tt a7"><div class="tt-cmd">dd</div><div class="tt-desc">"Data Duplicator" — low-level byte-for-byte copy. Clone disks, create images, or wipe drives.</div><div class="tt-example">dd if=/dev/sda of=disk.img bs=4M</div></div>'>dd</span>
</div>
</div>
</div>
<footer>Linux Shell Quick Reference &nbsp;·&nbsp; Hover any command chip for description &amp; example</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tippy.js/6.3.7/tippy.umd.min.js"></script>
<script>
tippy('.chip', {
content(ref) { return ref.getAttribute('data-tippy-content'); },
allowHTML: true,
theme: 'terminal',
placement: 'top',
arrow: true,
delay: [100, 50],
duration: [150, 100],
offset: [0, 8],
maxWidth: 290,
appendTo: document.body,
});
</script>
</body>
</html>
su myuser -c "export DISPLAY=localhost:0.0; background_cmd &"
cat file1.txt file2.txt > file3.txt; mv file3.txt file2.txt # prepend one file onto another
ll -R # recursively do an ll command
rm -rf <dir> # remove a non-empty directory
pv *.tar.gz | tar -xz
tar -xvf file.tar.gz
tar -xvf file.tar.bz2
ln -s <target> <symbol>
. /etc/profile # shorthand for calling source, basically reloads the session
grep -r "text" <dir>
unlink <symbol>
ldd <executable> # list dependent libraries
chmod 664 <file(s)>
chmod 775 <directory>/
chmod u+x <script_name> # make a file executable
unzip file.zip -d folder # unzip a file to a folder
df -h # show disk space, human readable
du # instead run "baobab" for a gui version that's better
du -sh ./* # show folder's disk usage
mkdir -p path/to/make # make the directory for an entire path
tree -f | grep "GLOBALS" # show the full file path (and all symlinks) when listing files in a tree, and then search it
tree -d # only show directories, no files
top f -show columns
top j processor core
top <space> close
top i multicore info
top 1 list total core usages
htop
chgrp -R mygroup src # change a folder recursively to the RTSS group
> logfile.txt # truncate log file
xrdb ~/.Xdefaults
pound!/usr/bin/env bash #bash shebang
set -x # debugging bash scripts
set +x # no more debugging bash script
exec bash # clear all env variables
gdb /path/to/executable /path/to/core/dump type bt # how to analyze a core dump
gdb info locals
gdb bt full
git show --pretty="" --name-only HEAD # show the filenames only from a recent commit
git diff-tree --no-commit-id --name-only HEAD # same as above
git checkout SHA -- file # cherrypick an older version of a file in place
git show HEAD^:path/to/main.cpp > old_main.cpp # checkout an older version of a file to a new name
git log --name-only --oneline
git diff 15dc8^! # only show diff for a single commit
git diff --color-words
git diff --color-words=.
git diff --color-words='[^|]+' event_logger_cfg.txt | ansi2html.sh --bg=dark --palette=solarized > ~/rev2_diff.html
git difftool -y -x "colordiff -y -W $COLUMNS" | less -R # show output in columns
git diff --color HEAD^ HEAD -G"^[^\*#]" | ansi2html.sh > diff_report.html
git diff -G"^[^ \*#][^\*#]"
git diff -G'(^[^\*# ])|(^#\w)|(^\s+[^\*#])'
git diff --stat --color HEAD^ HEAD -G"^[^\*#]" | ansi2html.sh > diff_summary.html
git log --name-only --oneline #lists all the file changes, one line per file
git diff HEAD~15 #diff the working tree with the 15th previous commit
git diff HEAD~15 HEAD #diff last commit with the 15th previous commit
git difftool HEAD^ HEAD #show a diff between the current files and last commit
git status --porcelain | grep '^??' | cut -c4- >> .gitignore # ignore all untracked files
git ls-files -co --exclude-standard | grep '\.pic$' | xargs git add # add all of a type recursively to git
git difftool --cached
git log --name-only HEAD~5..HEAD --pretty=format:
ls -lrtd $(git status --porcelain | grep '^.[?M]' | sed 's/^.. //')
vim vim -S ~/session.vim
vim :mksession or :mks!
vim gf # go to file under cursor
vim Ctrl-^ # go to prev file
vim Ctrl-x,Ctrl-o # auto complete to (
vim Ctrl-x,Ctrl-l # auto complete to end of line
vim gd # go to definition
vim Ctrl-] # go to ctags definition
vim set number
vim set nonumber
vim Shift-V,<,.,.,. # Shift indentation left 4 times
vim Ctrl-V,Shift-I,# ,<ESC> # Comment out rows in python
vim Ctrl-S, Ctrl-Q # Lock and unlock scroll
vim :<line_strt>,<line_end>s/findtxt/replacetxt/g # replace all text between lines
vim :%!xxd # switch into hex
vim :%!xxd -r # exit from hex
vim :set tw=79 # hard text wrap at 79 characters
vim :set formatoptions+=t # required for the hard text wrap
vim :set tw=0 # undo hard text wrapping
vim :set list
vim :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
when-changed -1 src/bash_script.bash -c "unbuffer shellcheck %f | head -n$(tput lines)"
python setup.py install --user
uname -a # Get the Linux version
ls -lR folder | grep ^l # list all symlinks and what they point to, recursively
grep "str" filename
grep -r -I --exclude-dir={.svn,useless_folder} "search_term" .
gunzip -c file.gz > file
timeout 5 unbuffer df -k | grep --line-buffered /mounted_folder | cut -c54-
grep -ohr -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' . # only show the ip addresses that come through
grep -n -c 3 -i "str" filename # list lines before and after found lines in file
grep -v "svn" # print lines not matching svn
symlinks -rv . # show all symlinks in a directory, recursively
pwd -P # show the actual path, not symbolic
qmake -r # recursively run qmake
qmake -query # list all the paths used by qmake
find . -type f -print0 | xargs -0 dos2unix
find . -maxdepth 1 -type f -exec mv {} old/ \;
find . -maxdepth 1 -type f -executable -delete
find -name "Makefile*" -delete # find and delete all variants of Makefile
find . -type f -mmin -120 # find files less than 2 hours old
find . -type f -mtime -1 # find files modified in the last day
find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u # unique sorted list of types in directory
find . -type f -name "*.py" # find all of type
du -sh ./* | sort -h ; baobab #Human readable sort
sort -o file.txt file.txt # in place sort
sudo find . ! -user myuser -exec chown myuser:mygroup {} \;
find . -name '*condor*.pic' -exec cp --parents \{\} ../p4 \; # keep the folder structure when copying find results
echo "__" >> ~/.bashrc # append onto the end of bashrc
alias youralias='your cmd' # basic alias usage
alias disable alias by preceeding command with a backslash, ie \xterm
xterm -e "su - myuser" & # launch myuser properly in a new shell
rsync -avzhPCO local/path/to/u* user@remote:/remote/path/to/u*
rsync -azP /home/myuser/ myuser@remote:/home/myuser/
rsync -azP --exclude=var /home/myuser/ myuser@remote:/home/myuser/
rsync -a <source>/ <target>/ # copy into a non empty directory
rsync --dry-run -avh ./usr $HOME # archive, verbose, human readable, dry-run
history # list previous commands
history -c # clear list of commands
fc -l 10 # list last 10 commands
fc -l ssh # list last ssh command
make -j4 # use 4 jobs with make
tail -n +1 <filenames> # cat all the files with a heading line
tail -f <logfile> # keep an open feed to a file, showing appended lines
scp <filename> computer_name:/path/to/copy/to
svn diff -rPREV
svn cd $MYFOLDER/src
svn mkdir feature_a
svn cd feature_a
svn import <foldername> $SVN_HOST/<foldername>/trunk -m "Initial Import"
svn co $SVN_HOST/<foldername>/trunk <foldername>
lp -o landscape <filename> # print a file in landscape to nearby printer
firefox http://localhost:631/jobs/?WHICH_JOBS=completed&ORDER=dec&QUERY=myuser ... lp related
setterm -blink off
cat temp.txt | tee output.log # send output to both stderr, stdout, and a log file
cd - # goes to the previous directory
cd -P <symbolic_linked_directory> # jumps to full path of sym link
sudo comment_all_pcs_tabs.py -i *.pic
bang bang !! # run last command
bang cash !$ # reuse the last parameter
bang question mark !?string # reuse based on a wildcard start of the string
bang with tongue !****:p # only print the command, don't run it
rev <file name> # print out the reversed contents of filename
fortune -s # one sentence fortune
yes <string> # repeated string
figlet -f <font> <string> #
figlet fonts *.flf: banner big block bubble digital ivrit lean mini script shadow
sed -i -e 's/foo/bar/g' filename # replace foo with bar in place in filename
sed -i # in place
sed -e '<expression>' #command to run
sed 's//' # substitution
sed '//g' # global
./configure --prefix=$HOME # configure a package to install to the home directory
rpm2cpio <filename>.rpm | cpio -idmv
find . -name "*.rpm" -type f -print | xargs -I {} bash -c "echo {};rpm2cpio {} | cpio -idmv"
xargs -L 1
for i in ./*; do echo $i; done
find . -type f -exec my_command {} \;
xclip -o > helloworld.c # paste contents of clipboard to a file
wall "Message" # Writes to all a message aka broadcast...
script <session_log_file.txt> # store the entire session until exit
cat filename.txt | ansi2html.sh --bg=dark --palette=solarized > filename.html
cat <<HERE # How to use HEREDOC in bash and scripts
HERE
cat <<-HERE # Indented HEREDOC with tabs!
HERE
unbuffer colored_cmd | most
ps -ef | grep "process name"
pgrep "process name"
ps aux # show disowned processes
perl -0777 -pie 's/bar/baz' filename # in place find and replace like sed
perl ... ./Build install --install_base /home/username/usr # install to non-standard directory
getent passwd "username" | cut -d ':' -f 5 # print out a user's full name from unix username
symlinks -r .
find . -xtype l
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com # send email to someone with an attachment
var=${parameter:-defaultValue}
games bomber - bovo - kapman - katomic - kblackbox - kblocks - kbounce - kbreakout - kdiamond
games - kfourinline - kgoldrunner - killbots - kiriki - kjumpingcube - klines
games - kmahjongg - kmines - knetwalk - kolf - kollision - kpat - kreversi - sol
games - konquest - ksudoku - kubrick - lskat -
screen -d -m -S shared ---------- setup the shared session
screen -x shared ---------------- the screen clears and shows a new bash session now inside screen
export DISPLAY=localhost:0.0 ----- setup display properly for a screen session
date +%Y%m%d_%H%M%S # printout a timestamp for a filename that sorts in order nicely
(shopt -s dotglob; mv -- foo/* .) # move a directory up a level
== Miscellaneous Linux Commands ==
=== Introduction ===
Linux users are expected to interact with the Linux systems quickly and efficiently.
A bare minimum number of commands will get you by, but if you are interested in sharing what works for you, or common/favorite one-liners or pieces of your bash script continue reading.
==== General Links ====
https://web.archive.org/web/20161121100913/http://archive.oreilly.com/linux/cmd/
http://explainshell.com/
And if it isn't on this page, of course, check Google, StackOverflow, and the man pages (RTFM = Read the Fine Manual).
=== Manual Lookup ===
man
show the manual for the command, press `q` to quit, spacebar, page up, page down, arrows to scroll
<command> -h
try to show the help or usage of a command
<command> -?
try to show the help or usage of a command
=== Wildcards ===
In bash, you can "glob" together a list of files by throwing in some wildcards.
abc*
Find abcd, abce, abcdefghij... and so on and anything else that starts with abc
"ab c"
Include the space in the name, can have variables inside
'ab c'
Include the space in the name, variables and special characters are treated like regular text
=== Listing Files ===
ls
list files, similar to `dir` in windows
ll
aliased to `ls -l`, shows columns of info about the list of the files in the directory
tree
shows all the files in a directory tree
../
up a directory
./
in the current directory
/
the root of the harddrive (like c: in windows)
pwd
display the present working directory
cd
change directory
~
shorthand for the current user's home directory, like `/home/user`
<tab>
auto completes a partially written filename
<tab><tab>
lists all the possible filenames for the typed out prefix before the cursor
=== Viewing Text ===
cat
dumps the whole file to the screen
less
lets you scroll up and down on the file, press q to quit
more
lets you page down, only
most
lets you scroll up, down, left and right
head
show the first few lines of a file
tail
show the last few lines of a file
|
pipe the output of the command on the left to the command on the right
echo
show one line of text
clear
clear the current page of text and force the current line to the top of the page
<Shift><PgUp>
scroll up to previous lines of text on the terminal
resize
fixes poor wrapping of text at the command prompt, necessary after resizing the window, to have the terminal recognize the new column width.
=== Copy / Paste ===
XConfig needs to be configured properly for this to work:
- XSelection needs to be changed from `Clipboard` to `Primary`.
- The session needs to be restarted to see the changes.
Start a selection with a click drag.
Fill in a selection to the end with a right click.
Any selection in linux is auto-copied to the clipboard.
Paste in xterm (the default terminal in MICADS) with a center click.
Not installed, but future tool for ease of clipboard access is `xclip`.
=== Text Editors ===
In general terminal editors are faster to open and interact with files. On remote systems with lower bandwidth and higher latency, terminal editors are superior.
nano
terminal editor... Ctrl+<key> to save, exit, etc.
vi, vim
terminal editor... multiple modes, Read, Display, Visual, etc, many special commands start with `:`
navigation with `hjkl` keys... press `ESC` to get out of a mode...
emacs
terminal editor... Ctrl+<key> or Alt+<Key> (short handed to C <key> and M <key>) for special interactions
gedit, kate, gvim, xemacs
graphical editors
=== Creating/Deleting Files and Folders ===
touch
make a file, or update the timestamp on a file
`>`
capture output on the left into the file or handle on the right
`>>`
append output on the left onto the filename on the right
mkdir
make a directory
cp
copy a file or directory
mv
move and/or rename a file
scp
secure copy a file or directory from one system to another
rsync
remote synchronization between two computers (very powerful)
rm
remove a file or directory (needs `-rf` for non-empty directories)
=== Finding and Filtering Text ===
grep
general purpose find inside files tool, successors include: awk, ag
find
find a specific filename and sometimes do something with it
which
find a file (usually a script or binary executable) in the PATH folders list
locate
find a filename (or pattern) on the computer that was in the snapshot index last night at midnight
uniq
show only unique lines
sort
show the lines sorted alphabetically
=== Bash Variables and Functions ===
$var
the dollar sign indicates the start of a variable, usually an environment variable, e.g. $PATH
alias
makes a nickname for command(s) with specific options, like `ll` = `ls -l` and `gotis`, or lists all aliases
function
makes a reusable function or subroutine, that can handle parameters passed in, a la bash scripting
export
makes a variable that lives for the length of the "session" that the user is logged in
env
queries and lists all the "exported" variables in the '''env'''ironment for use with the session/login
xterm
the text, the command prompt, etc that the session lives in, useful for launching another window
set
used for changing/listing options for bash. Like "set -x" and "set +x" to turn on and off echoing all commands.
=== Bash History ===
https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps
!!
"bang, bang", previous command
!$
"bang, cash", previous end parameter
!xxxxx
"bang", some letters for previous command, executes the last command that started with those letters
<ESC>,<Ctrl><E>
Expands one of the above shortcuts to its full length
<Ctrl><R>
Reverse search through command history, with interactive input, repeat <Ctrl><R> to search further back
=== Sessions ===
su
switch user, start a session as a different user, or without parameters, starts a super user session
ssh
tunnel into another system with a secure shell
exit
end a session or shell
logout
end a session or shell
script
start a new bash session and save all the text output for later review
screen
screen manager with terminal emulation, a nify way to keep persistent sessions open across logins, also does shared sessions easily
screen -d -m -S shared
screen -x shared
tmux
terminal multiplexer, a newer nifty way to keep persistent sessions open across logins (utf support, not installed)
=== Linking & Symlinks ===
ln -s
create a symbolic link, one file pointing to the actual file somewhere else on the harddrive
unlink
remove a symbolic link
=== Process Control ===
Ctrl+Z
Pause a process
bg
Move a paused process to the background jobs
fg
Move a background job or a paused job to the foreground
jobs
List all the jobs associated with the current session
Ctrl+C
Kill the current foreground process
top
View the current running process on the screen, q to quit, or Ctrl-c
htop
Like top, but more colorful and a little more friendly
=== Other Users ===
w
list all the other users on the system, and login time, idle time, last command, etc
wall
broadcast a message to everyone else on the computer
write
send a message to a single other user login to that computer
`echo "message to send" | write <username>`
finger
get identification information about a user's name
getent passwd "user"
gets entries about a user from the passwd administrative database
=== Printing ===
lp
sends a file to the printer address under LPDEST
=== Permissions ===
chmod
change the permissions for a file, who can execute, read, write, etc.
chgrp
change what group has access to a file
chown
change what user owns the file
sudo
'''S'''uper '''u'''ser '''do''', or take action with elevated permissions for the current user
=== Zipping / Unzipping ===
tar
stands for tape archive, many options for compressing and decompressing files, great for .tar, .tar.bz, .tar.gz and others
unzip
unzip a file
=== Diffing and Versioning ===
diff
show all the differences between two files
tkdiff
show all the differences between two files, graphical window
svn
centralized versioning system
git
distributed versioning system, awesome (see [attachment:progit-en.1084.pdf Git Book (cached)] or [https://progit2.s3.amazonaws.com/en/2016-03-22-f3531/progit-en.1084.pdf Git Book])
=== Scripting Language Interpreters ===
Script files are read a line at a time, and interpreted at run time, plain text files.
perl
files end in pl, original support for Regular Expressions (aka regex or regexp)
python
files end in py, popular language
bash
stands for borne again shell, and is the language that handles all the input to the command-line
sh
posix standard shell command script
ruby
files end in rb, popular language, newer than python
=== Compilers and Library Tools ===
These files are compiled down to a binary file.
gcc
c compiler
g++
c++ compiler
ld
linker, connects complied .o files into an executable
make
manages compiling and linking process for most projects in a Makefile
configure
provides inputs for the Makefile that are specific to the system/install
=== Disk Utilities ===
du
'''d'''isk '''u'''sage, estimate file space usage - space used under a particular directory or files on a file system.
`du -sh ./*`
show the filesize of each sub folder in the current directory
df
'''d'''isk '''f'''ree, report file system disk space usage, also useful for checking for nfs mounts
`df -h`
show all the mounted disks and their used/available size
dd
'''d'''ata '''d'''escription, convert and copy a file, also used for cloning partitions and harddisks
== GUI Applications ==
From an ssh session, run `gnome-session` to start a GNOME/Ubuntu style desktop or run `plasma-desktop` to start a KDE/Plasma style desktop.
The gnome session is the default way that a ubuntu user logs into the computer.
=== Categories ===
Note: search one of these on this page to find an app
=== GUI apps with Shortcuts ===
|| Notes || Shortcut || Name || Comment || Categories || Exec ||
=== Generator Script ===
You can find these apps in the kickoff launcher in the corner of `plasma-desktop`.
Generate the table below
cd /usr/share/applications
find_and_strip ()
{
str=$(grep -rhoP "(?<=^($1)).*" $2);
echo $str;
}
(
for i in * */*;
do
if [ -d $i ]; then
continue;
fi;
echo -e "$i\t$(find_and_strip "Name=" $i)\t$(find_and_strip "Comment=" $i)\t$(find_and_strip "Categories=" $i)\t$(find_and_strip "Exec=" $i)";
done) | xclip
@peteristhegreat

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment