Skip to main content

Anki Cloze Cards — Common Linux Command-Line Tools 🧰

IBelow haveare groupedAnki thecloze content(deletion) into four major sections to keep the structure clean and readable. The actual flashcard text is provided inside indented markdown blocks sonotes you can easilypaste copyinto Anki (note type: Cloze).
Each note has 1–4 blanks and pasteis themdesigned directlyto intobe yourmemorable, Ankipractical, Clozeand notes.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) 1. Navigation, FilesOrientation & Permissionsnavigation 🧭

This section covers moving around the file system and managing files, directories, and their permissions.

  1. pwd

    Working Directory & Navigation Knowing where you are and how to jump back is the foundation of terminal usage.

    To print the working directory in Linux, useprints the {{c1::pwd}current working directory}}.
ls -l shows a {{c1::long listing}} command.(permissions, Toowner, returnsize, intuitivelytime). tols the-a *previous*includes directory{{c1::hidden youfiles were(dotfiles)}}. in,ls use-lah thecombines command{{c1::-l}}, {{c2::cd -}}.
    Extra tip: You can instantly return to your user's home directory by using cd ~.

    Advanced Listing You rarely use plain ls when doing server maintenance.

    The command {{c1::ls -lah}} lists directory contents in a long format, including {{c2::hidden (dot)}} files, with {{c3::human-readable}} file sizes.
    

    Creating Directories & Files Creating structures efficiently saves a lot of time.

    To create a directory along with its parent directories as needed, use the command {{c1::mkdir -p}}. To quickly create an empty file or update an existing file's timestamp, use {{c2::touch}}.
    

    Copying in Archive Mode This is critical when making backups of configuration directories.

    The command {{c1::cp -a}} copies directories in "archive mode", which preserves vital metadata like {{c2::permissions}} and {{c3::times}human-readable sizes (-h)}}.
    
    cd

    Dangerous..

    Deletionsgoes Always{{c1::up double-checkone directory}}. cd ~ goes to your path{{c1::home beforedirectory}}. executingcd this!-
    switches to the {{c1::previous directory}}.
    Totree recursively-L delete2 shows a directory andtree forcelimited the removal without prompting, useto {{c1::rmdepth -rf}2}} (use with extreme caution!). (Often needs installing.)

    Symbolic Links Very common in web server configurations (e.g., Nginx sites-enabled).

    To createdisplay ayour symbolicusername link,and usehostname thequickly: command {{c1::ln -s}whoami}} followed by the target path and the intended link name.
    

    Understanding chmod Permissions Permissions mapping is a daily necessity for a system admin.

    The command `chmod {{c1::755}} script.sh` sets the permissions to `rwxr-xr-x`, meaning the owner gets read/write/execute access, while the group and others get {{c2::read}hostname}}. and(Extra, {{c3::execute}}useful access only.
    

    Recursive Ownership Changes Often used when setting up web roots for service accounts.

    To change the owner and group of a directory recursively, use the command {{c1::chown}} combined with the {{c2::-R}} flag.
    
    baseline.)

    📖2) 2.Create Reading,/ Searchingmove &/ Textcopy Pipelines/ delete (file ops) 📁

    This section focuses on streaming data, reading logs, and transforming text output using pipes.

    1. touch

      Choosing the Right Pager Don't flood your screen with giant log files.

      For reading small files,file.txt {{c1::cat}creates an empty file}} or {{c2::updates its timestamp}}.
    mkdir -p a/b/c creates 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 LINKNAME creates 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 -i for {{c1::interactive confirmation}} (safer deletes). (Extra.)

    3) Reading files fast 👀

      cat is useful, butbest for paging{{c1::small throughfiles}}; largefor textbig files interactively, you should prefer {{c2::less}}. In

      Tailingless, Logsq Live{{c1::quits}}, Essential/text for{{c2::searches}}, real-timeand debugging.

      n
      jumps to {{c3::next match}}.
      Tohead view-n the20 lastfile 50 lines of an error log, use `tail` withshows the {{c1::first 20 lines}}. tail -n 50}}50 option.file To "follow" appended log lines in real-time, useshows the {{c2:c1::-f}last 50 lines}} option. . tail

      Grep-f

      Essentials{{c1::follows appended lines}} (great for logs). nl -ba file shows line numbers; -b a means 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 ls opens the command’s {{c1::manual page}}. man -k network performs a {{c1::keyword search}} (apropos). Many commands support --help for {{c1::quick usage info}}. which python prints the {{c1::path}} to the executable found in PATH. type ls can reveal whether ls is an {{c1::alias}}, {{c2::function}}, {{c3::builtin}}, or external command. Use {{c1::command -v}} name for a portable “where is it?” check. (Extra, common in scripts.)

        5) Searching inside files is(grep/sed/awk) arguably🧠

          grep "listen" nginx.conf searches for the most{{c1::literal usedpattern}} diagnosticin technique.a
          file.
          In the command `grep -R "DB_HOST" .`, the `-R` flag stands forsearches {{c1::recursive search}}. To simultaneously include line numbers in your output, you would append the {{c2::-n}} flag.

          The Stream Editor (Sed) Basics Used for mass finding/replacing data streaming through the terminal.

          The stream editor {{c1::sed}} processes text one line at a time. The command `sed 's/http:/https:/g'` uses the {{c2::g}} flag to replace {{c3::all matches}recursively}} in the line.current 
            directory. Printinggrep control:-n By"error" default,app.log sedincludes {{c1::line numbers}}. grep -i "warning" app.log is {{c1::case-insensitive}}. grep -v PATTERN prints everylines line.that Combine{{c1::do theNOT match}}. (Extra.) grep -E enables {{c1::extended regex}} (like -n+, |, () without heavy escaping). (suppress)Extra.) flagsed with's/OLD/NEW/g' thefile does a substitution; pg commandmeans to{{c1::replace selectivelyall printmatches linesper (e.g.,line}}. sed -n '1,20p').

            In-Place File Edits with Sed Direct manipulations require caution but are incredibly powerful.

            To perform an in-place edit using sed (which modifies the file directlyuses on-n disk), you must use theto {{c1::-i}suppress auto-print}} flag.and p
            to {{c2::print selected lines}}. In

            Awk for Column Data When parsing space-delimited logs,regex, awk^ is king.

            Thematches {{c1::awk}start of line}} commandand is\$ excellentmatches for{{c2::end columnof processing.line}}.
            Forsed example,'/^$/d' `file deletes lines that are {{c1::blank}}. sed -i.bak 's/old/new/g' file edits {{c1::in place}} while keeping a {{c2::backup}}. In awk '{print \$1, \$9}'`, extracts\$1 is the first and ninth {{c2::fields}}.

            Sorting and Unique-ing Collapsing duplicate log entries to find anomalies.

            The {{c1::uniq}first field}} commandand collapses adjacent duplicates, meaning it is almost inevitably preceded by\$9 the {{c2::sort}ninth field}} command in a text pipeline.
            
            . awk

            Bash-F: Redirection'{print Operators\$1}' Mastering/etc/passwd

            standardsets outthe andfield standardseparator error streams.
            In Bash redirection,to {{c1::>:}}. completely(Extra, overwriteshighly a file, {{c2::>>}} safely appends to a file, and {{c3::2>}} specifically redirects standard error.
            
            practical.) awk

            The'NR==1{print}' file

             uses teeNR Command Splittingas the stream to a file and the screen at the same time.
            The {{c1::tee}} command takes standard input and writes it to both {{c2::standard outputrecord (theline) terminal)}} and one or more {{c3::files}number}}. 
            (Extra.)

            ⚙️6) 3.Counting System,/ Networksorting &/ Remoteunique Operations(pipelines) 📊

            This section is all about managing running processes, network connections, and archives.

            1. wc

              Piping-l Processfile

              Statescounts The standard way to check if a specific daemon is running.
              To show all running processes and filter specifically for `nginx`, use the pipeline: `{{c1::pslines}}.
            aux}sort -n numbers.txt performs a {{c1::numeric sort}}. uniq only removes {{c1::adjacent duplicates}} |→ often use it after {{c2::grep nginx}sort}}`. uniq

            Signaling-c

            Processesprefixes Askingeach nicelygroup versus pulling the plug.
            To gracefully request a process to terminate viawith its PID, use the command `kill {{c1::count}}.
            sort users.txt | uniq -TERM}}c 1234`.| Tosort force-nr termination asgives a last{{c1::frequency resort,table}} use `killsorted {{c2::-KILL}descending}} 1234`.
              Targeting by name: Instead of finding the PID first, you can use pkill followed by the process name. cut

              Systemd-d: Services-f1 &/etc/passwd

              Logsuses The modern Linux initialization and logging standard.
              On modern distributions, system services are started/enabled using thedelimiter {{c1::systemctl}:}} command,and whileprints system logs are queried usingfield {{c2::journalctl}1}} (usernames).
              
              tr

              Network'[:lower:]' Sockets'[:upper:]'

              Seeing what ports your web server is binding to.
              To view TCP and UDP listening ports along with their associated process names, the standard modern command isconverts {{c1::sslowercase}} -tulpn}to {{c2::uppercase}}.
              
              tr

              Debugging-d Web'\r'

              Requests Checking HTTP responses directly from the console without a browser.
              The commanddeletes {{c1::curlcarriage -I}returns}} fetches(fix onlyWindows the HTTP {{c2::headers}} of a target URL, while {{c3::curl -v}} provides a verbose output useful for TLS and connection debugging.
              

              DNS Troubleshooting Verifying domain propagation.

              To perform a DNS lookup for the domain `example.com`, the modern tool typically used is {{c1::dig}}, though older tutorials may still reference {{c2::nslookup}}CRLF). 
              (Extra, common pain

              Tarball Creation & Extraction The default way to bundle up folders in Linux.

              To create a gzip-compressed tar archive of a directory, use the command `tar {{c1::-czf}} archive.tar.gz dir/`. To extract that same archive, use `tar {{c2::-xzf}}`.
              

              Secure File Transfers Moving backups or code safely using SSH protocols.

              To copy a file securely over SSH from your local machine to the `/tmp/` directory on a remote server, use the syntax: {{c1::scp file.txt user@server:/tmp/}}.
              
              point.)

              🛠️7) 4.Composition: Help,pipes, Discoveryredirection, &tee, Environmentxargs States🧩

              This section is tailored to discovering help, finding lost files, and managing the active shell environment.

              1. The

                Manualpipe Pages| Keyword Search What if you forget the name of the tool you need?

                Thesends {{c1::man}stdout of one command}} command opens comprehensive manual pages. If you need to search within descriptions by a keyword, you should useinto {{c2::manstdin -k}of another}}.
                
              2. >

                Command Execution Origins Understanding whether you are running{{c1::overwrites}} a binary,file, alias,while or>> built-in{{c2::appends}}.

              shell2> function.redirects
              {{c1::stderr}} to a file.
              To&> discoverredirects {{c1::stdout and stderr}} to the sourcesame pathfile of(Bash). tee -a binaryfile like{{c1::appends}} Python,while usestill `which`.printing To find out if a command is actually an alias or a shell builtin, useto the {{c1:c2::type}terminal}} command instead. . xargs

              turns {{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 Filesfiles (find/locate) 🗂️

                find . -name "*.conf" finds files by Date{{c1::name orpattern}}. Size Locating hidden bloat or analyzing recent compromises.
                To search for files modified strictly within the last 7 days inside `/var/log`, use the command `find /var/log -type f -mtime -7 finds regular files modified in the last {{c1::-mtime7 days}}.
                find . -7}}`.type f -size +100M 
                  Size flags: To search forfinds files larger than 100MB,{{c1::100 use the -size +100M flag. MB}}. locate

                  Locatenginx.conf

                  vs.searches Find The trade-off between speed and accuracy.
                  Thea {{c1::locate}database index}} command→ results may be stale unless updated. (Extra concept.)
                  find . -iname "*.jpg" is case-{{c1::insensitive}} name matching. (Extra.) find . -maxdepth 1 -type f limits search depth to {{c1::1}}. (Extra.)

                  9) Permissions & ownership 🔐

                    chmod 644 file corresponds to {{c1::rw-r–r–}}. chmod 755 script.sh corresponds to {{c1::rwxr-xr-x}}. In permissions, r=4, w=2, x=1, so 7 equals {{c1::rwx}}. (Extra, core mental model.) chmod -R 755 dir/ changes permissions {{c1::recursively}} (use carefully). chown user:group file changes {{c1::owner}} and {{c2::group}}. chown -R www-data:www-data /var/www/site applies ownership changes {{c1::recursively}}. umask affects the {{c1::default permissions}} for newly created files/dirs. Typical defaults: umask 022 leads to new files being {{c1::644}} and dirs {{c2::755}} (before special cases). (Extra.)

                    10) Processes & system state 🧯

                      ps aux shows {{c1::all processes}} (common BSD-style format). top provides a fast{{c1::live}} filenameprocess searchview; usinghtop is a pre-compiledmore {{c2::database}interactive}}, whichalternative means(may youneed mustinstall). periodicallykill update1234 itssends index{{c1::SIGTERM}} by default (a polite request). kill -KILL 1234 sends {{c1::SIGKILL}} → cannot be {{c2::caught/ignored}} (last resort). pkill nginx kills processes by {{c1::name/pattern}}. systemctl status nginx shows {{c1::service status}} (systemd systems). systemctl enable nginx enables start on {{c1::boot}}. journalctl -u nginx -f follows logs for itunit {{c1::nginx}} in {{c2::real time}}. journalctl -b shows 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 a shows {{c1::addresses/interfaces}}; ip r shows {{c2::routes}}. ss -tulpn lists listening {{c1::TCP/UDP}} sockets with {{c2::process info}} (needs privileges for full details). ping -c 4 example.com sends {{c1::4}} ICMP echo requests. curl -I URL fetches only {{c1::HTTP headers}}. curl -v URL enables {{c1::verbose}} output (connection/TLS details). dig example.com +short returns a {{c1::short}} DNS answer list. Quick port test: {{c1::nc}} -vz host 443 (or {{c2::curl}} to reflectan recentHTTP 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.log compresses to {{c1::large.log.gz}}. xz -T0 bigfile uses {{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@host opens a {{c1::remote shell}} over SSH. ssh -i ~/.ssh/id_ed25519 user@host uses a specific {{c1::private key}}. scp file changes.user@host:/tmp/ copies a file over {{c1::SSH}}. sftp

                            Printinguser@host

                            theprovides 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 cmd runs a command as {{c1::root}} (or another user). Use sudo -u USER cmd to 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 Confirming& yourshell pathsbasics or🧪

                              custom
                              variables.echo
                              To"\$HOME" print text orprints the value of athe shell{{c1::HOME}} variableenvironment (likevariable.
                              `\$HOME`)env directly toshows the console,process use{{c1::environment}} (variables). printenv PATH prints the {{c1::echo}PATH}} command. variable. export

                              EnvironmentVAR=value

                              Variable Scope Differentiating local variables from inherited variables.
                              To setsets an environmentenv variablevar for the duration of the current shell session so that child processes inherit it (e.g., `NODE_ENV=production`), use the {{c1::export}current shell session}} command.and 
                              its {{c2::child processes}}. history

                              Reviewing| Pasttail

                              Commands A lifesaver when you execute a complex chained pipeline and need to see exactly what you did.
                              To output a numbered list of your previously executed shell commands, useshows the {{c1::history}most recent}} command.commands.
                              VAR=value cmd sets VAR only 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::--}} cmd prevents option confusion. (Extra nuance.) chmod u+x script.sh adds execute for the {{c1::user (owner)}}; symbolic modes can be clearer than octal. (Extra.) ls -lt sorts by {{c1::modification time}} (newest first). (Extra.) sort -u both sorts and removes duplicates in {{c1::one step}}. (Extra.) Safer grep in binaries: grep -I treats binary files as {{c1::non-matching}}. (Extra.) curl -sS means {{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)