Anki Cloze Cards — Common Linux Command-Line Tools 🧰
Below are Anki cloze (deletion) notes you can paste into Anki (note type: Cloze).
Each note has 1–4 blanks and is designed to be memorable, practical, and cross‑distro. ✅
I also added a few high-value extras (e.g., du, df, chmod meaning, safer find, rsync, ssh tips) that fit perfectly with the topic.
1) Orientation & navigation 🧭
pwdprints the {{c1::current working directory}}.ls -lshows a {{c1::long listing}} (permissions, owner, size, time).ls -aincludes {{c1::hidden files (dotfiles)}}.ls -lahcombines {{c1::-l}}, {{c2::-a}}, and {{c3::human-readable sizes (-h)}}.cd ..goes {{c1::up one directory}}.cd ~goes to your {{c1::home directory}}.cd -switches to the {{c1::previous directory}}.tree -L 2shows a directory tree limited to {{c1::depth 2}}. (Often needs installing.)- To display your username and hostname quickly:
{{c1::whoami}}and{{c2::hostname}}. (Extra, useful baseline.)
2) Create / move / copy / delete (file ops) 📁
touch file.txt{{c1::creates an empty file}} or {{c2::updates its timestamp}}.mkdir -p a/b/ccreates directories {{c1::including parents as needed}}.cp a.txt b.txt{{c1::copies a file}}.cp -r src/ dst/copies a directory {{c1::recursively}}.cp -a src/ dst/uses {{c1::archive mode}} to preserve {{c2::permissions and timestamps}}.mv old new{{c1::renames}} or {{c2::moves}} files/directories.rm -r folder/deletes a directory {{c1::recursively}}.rm -rf folder/means {{c1::recursive}} + {{c2::force}} → {{c3::dangerous (no prompts)}}.ln -s TARGET LINKNAMEcreates a {{c1::symbolic link (symlink)}}.- A hard link shares the same {{c1::inode}} as the original file; a symlink stores a {{c2::path}}. (Extra but core concept.)
- Use
rm -ifor {{c1::interactive confirmation}} (safer deletes). (Extra.)
3) Reading files fast 👀
catis best for {{c1::small files}}; for big files prefer {{c2::less}}.- In
less,q{{c1::quits}},/text{{c2::searches}}, andnjumps to {{c3::next match}}. head -n 20 fileshows the {{c1::first 20 lines}}.tail -n 50 fileshows the {{c1::last 50 lines}}.tail -f{{c1::follows appended lines}} (great for logs).nl -ba fileshows line numbers;-b ameans number {{c1::all lines}} (including blank). (Good to remember.)- Quick “watch a file change” tool:
{{c1::watch}} -n 1 'tail -n 20 file'. (Extra.)
4) Help & discovery 🔎
man lsopens the command’s {{c1::manual page}}.man -k networkperforms a {{c1::keyword search}} (apropos).- Many commands support
--helpfor {{c1::quick usage info}}. which pythonprints the {{c1::path}} to the executable found inPATH.type lscan reveal whetherlsis an {{c1::alias}}, {{c2::function}}, {{c3::builtin}}, or external command.- Use
{{c1::command -v}} namefor a portable “where is it?” check. (Extra, common in scripts.)
5) Searching inside files (grep/sed/awk) 🧠
grep "listen" nginx.confsearches for the {{c1::literal pattern}} in a file.grep -R "DB_HOST" .searches {{c1::recursively}} in the current directory.grep -n "error" app.logincludes {{c1::line numbers}}.grep -i "warning" app.logis {{c1::case-insensitive}}.grep -v PATTERNprints lines that {{c1::do NOT match}}. (Extra.)grep -Eenables {{c1::extended regex}} (like+,|,()without heavy escaping). (Extra.)sed 's/OLD/NEW/g' filedoes a substitution;gmeans {{c1::replace all matches per line}}.sed -n '1,20p' fileuses-nto {{c1::suppress auto-print}} andpto {{c2::print selected lines}}.- In regex,
^matches {{c1::start of line}} and\$matches {{c2::end of line}}. sed '/^$/d' filedeletes lines that are {{c1::blank}}.sed -i.bak 's/old/new/g' fileedits {{c1::in place}} while keeping a {{c2::backup}}.- In
awk '{print \$1, \$9}',\$1is the {{c1::first field}} and\$9the {{c2::ninth field}}. awk -F: '{print \$1}' /etc/passwdsets the field separator to {{c1:::}}. (Extra, highly practical.)awk 'NR==1{print}' fileusesNRas the {{c1::record (line) number}}. (Extra.)
6) Counting / sorting / unique (pipelines) 📊
wc -l filecounts {{c1::lines}}.sort -n numbers.txtperforms a {{c1::numeric sort}}.uniqonly removes {{c1::adjacent duplicates}} → often use it after {{c2::sort}}.uniq -cprefixes each group with its {{c1::count}}.sort users.txt | uniq -c | sort -nrgives a {{c1::frequency table}} sorted {{c2::descending}}.cut -d: -f1 /etc/passwduses delimiter {{c1:::}} and prints field {{c2::1}} (usernames).tr '[:lower:]' '[:upper:]'converts {{c1::lowercase}} to {{c2::uppercase}}.tr -d '\r'deletes {{c1::carriage returns}} (fix Windows CRLF). (Extra, common pain point.)
7) Composition: pipes, redirection, tee, xargs 🧩
- The pipe
|sends {{c1::stdout of one command}} into {{c2::stdin of another}}. >{{c1::overwrites}} a file, while>>{{c2::appends}}.2>redirects {{c1::stderr}} to a file.&>redirects {{c1::stdout and stderr}} to the same file (Bash).tee -a file{{c1::appends}} while still printing to the {{c2::terminal}}.xargsturns {{c1::input lines}} into {{c2::command arguments}}.- Safer filenames:
find ... -print0 | xargs -0 ...handles {{c1::spaces/newlines}} correctly. - Even safer:
find ... -exec cmd {} +avoids some {{c1::xargs pitfalls}}. (Extra.)
8) Finding files (find/locate) 🗂️
find . -name "*.conf"finds files by {{c1::name pattern}}.find /var/log -type f -mtime -7finds regular files modified in the last {{c1::7 days}}.find . -type f -size +100Mfinds files larger than {{c1::100 MB}}.locate nginx.confsearches a {{c1::database index}} → results may be stale unless updated. (Extra concept.)find . -iname "*.jpg"is case-{{c1::insensitive}} name matching. (Extra.)find . -maxdepth 1 -type flimits search depth to {{c1::1}}. (Extra.)
9) Permissions & ownership 🔐
chmod 644 filecorresponds to {{c1::rw-r–r–}}.chmod 755 script.shcorresponds to {{c1::rwxr-xr-x}}.- In permissions,
r=4,w=2,x=1, so7equals {{c1::rwx}}. (Extra, core mental model.) chmod -R 755 dir/changes permissions {{c1::recursively}} (use carefully).chown user:group filechanges {{c1::owner}} and {{c2::group}}.chown -R www-data:www-data /var/www/siteapplies ownership changes {{c1::recursively}}.umaskaffects the {{c1::default permissions}} for newly created files/dirs.- Typical defaults:
umask 022leads to new files being {{c1::644}} and dirs {{c2::755}} (before special cases). (Extra.)
10) Processes & system state 🧯
ps auxshows {{c1::all processes}} (common BSD-style format).topprovides a {{c1::live}} process view;htopis a more {{c2::interactive}} alternative (may need install).kill 1234sends {{c1::SIGTERM}} by default (a polite request).kill -KILL 1234sends {{c1::SIGKILL}} → cannot be {{c2::caught/ignored}} (last resort).pkill nginxkills processes by {{c1::name/pattern}}.systemctl status nginxshows {{c1::service status}} (systemd systems).systemctl enable nginxenables start on {{c1::boot}}.journalctl -u nginx -ffollows logs for unit {{c1::nginx}} in {{c2::real time}}.journalctl -bshows logs since the last {{c1::boot}}.- Check disk usage quickly:
{{c1::df -h}}(filesystem free space) vs{{c2::du -sh DIR}}(directory size). (Extra, very common.)
11) Networking essentials 🌐
ip ashows {{c1::addresses/interfaces}};ip rshows {{c2::routes}}.ss -tulpnlists listening {{c1::TCP/UDP}} sockets with {{c2::process info}} (needs privileges for full details).ping -c 4 example.comsends {{c1::4}} ICMP echo requests.curl -I URLfetches only {{c1::HTTP headers}}.curl -v URLenables {{c1::verbose}} output (connection/TLS details).dig example.com +shortreturns a {{c1::short}} DNS answer list.- Quick port test:
{{c1::nc}} -vz host 443(or{{c2::curl}}to an HTTP port). (Extra.)
12) Archives & compression 📦
tar -czf site.tar.gz site/creates a {{c1::gzip-compressed}} tar archive.tar -xzf site.tar.gz{{c1::extracts}} a gzip-compressed tar archive.- In
tar,c={{c1::create}},x={{c2::extract}},z={{c3::gzip}},f={{c4::filename}}. gzip large.logcompresses to {{c1::large.log.gz}}.xz -T0 bigfileuses {{c1::all CPU cores}} (-T0) for compression.zip -r project.zip project/creates a zip archive {{c1::recursively}}.unzip project.zip{{c1::extracts}} a zip archive.
13) Remote access & transfer (SSH family) 🔑
ssh user@hostopens a {{c1::remote shell}} over SSH.ssh -i ~/.ssh/id_ed25519 user@hostuses a specific {{c1::private key}}.scp file user@host:/tmp/copies a file over {{c1::SSH}}.sftp user@hostprovides an {{c1::interactive}} file-transfer session.- Better large sync tool:
{{c1::rsync}} -avz SRC/ user@host:DST/(preserves attrs, efficient). (Extra, extremely practical.) - SSH config shortcut: define a host in
{{c1::~/.ssh/config}}to avoid retyping usernames/keys. (Extra.)
14) Privilege escalation 🛡️
sudo cmdruns a command as {{c1::root}} (or another user).- Use
sudo -u USER cmdto run as {{c1::a specific user}}. (Extra.) - Prefer editing protected files with
{{c1::sudoedit}}rather than running a full editor as root. (Extra safety.)
15) Environment & shell basics 🧪
echo "\$HOME"prints the value of the {{c1::HOME}} environment variable.envshows the process {{c1::environment}} (variables).printenv PATHprints the {{c1::PATH}} variable.export VAR=valuesets an env var for the {{c1::current shell session}} and its {{c2::child processes}}.history | tailshows the {{c1::most recent}} commands.VAR=value cmdsetsVARonly for {{c1::that command invocation}} (not permanently). (Extra, very useful.)
16) High-yield “extras” that pair well with the toolbox ⭐
- To run a command as another user without a shell:
sudo -u user {{c1::--}} cmdprevents option confusion. (Extra nuance.) chmod u+x script.shadds execute for the {{c1::user (owner)}}; symbolic modes can be clearer than octal. (Extra.)ls -ltsorts by {{c1::modification time}} (newest first). (Extra.)sort -uboth sorts and removes duplicates in {{c1::one step}}. (Extra.)- Safer grep in binaries:
grep -Itreats binary files as {{c1::non-matching}}. (Extra.) curl -sSmeans {{c1::silent}} but still show {{c2::errors}}. (Extra.)
Want these as a single “deck-ready” TSV? 📌
Tell me your preferred import format:
- Plain cloze lines (as above)
- TSV with columns:
Text+Tags - Grouped by tags (e.g.,
linux::files,linux::network,linux::text)