Linux Reference Page
Linux
Recipes
Copy single file with sudo
sudo cat <file> | ssh <host> sudo tee <path>
Copy files with sudo
sudo tar -zc * | ssh <host> sudo tar -zxC <destination directory>
Install uv and trzsz
curl -LsSf https://astral.sh/uv/install.sh | sh
. ~/.local/bin/env
cd ~/.local
uv venv
uv pip install trzsz
ln -s ~/.local/.venv/bin/trz ~/.local/bin/trz
ln -s ~/.local/.venv/bin/tsz ~/.local/bin/tsz
VIM Reference
Cursor Movement
| h | left |
| j | down |
| k | up |
| l | right |
| $ | end of line |
| 0 | start of line |
Editing
| r | Replace a character |
| R | Replace mode at cursor |
| i | Insert mode at cursor |
| I | Insert mode at beginning of line |
| o | Insert mode, insert line below |
| O | Insert mode, insert line above |
| a | Insert mode after cursor |
| A | Insert mode at end of line |
| J | Join the line below with a space |
| gJ | Join line below without a space |
| [Esc] | Exit insert/replace mode |
Copy & Paste
| yy | yank (copy) line |
| 2yy | yank 2 lines |
| yw | yank word |
| Y / y$ | yank to end of line |
| p | put (paste) after cursor |
| P | put (paste) before cursor |
| dd | cut line |
| 2dd | cut 2 lines |
| dw | cut word |
Visual Commands
| > | Shift text right |
| < | Shift text left |
| y | yank (copy) marked text |
| d | delete marked text |
| ~ | change case |
| u | transform to lowercase |
| U | transform to uppercase |
Saving & Exiting
| :e[dit] file | edit [file] in new buffer |
| :bn[ext] | next buffer |
| :bp[revious] | previous buffer |
| :buffers or :ls | list all open buffers |
| :w[rite] | write (save) |
| :w[rite] !sudo tee % | write using sudo |
| :w[rite]q[uit] or ZZ | save and exit |
| :sav[eas] file | save as [file] |
| :q[uit]! or ZQ | exit without saving |
GNU References
| Output, Summarize, or Hash Files | |
|---|---|
| Write and concatenate files | cat |
| Transform data into printable data | base64 |
| Output the first part of a file | head |
| Output the last part of a file | tail |
| Split a file into pieces | split |
| Print newline, word, and byte counts | wc |
| Print or check MD5 digests | md5sum |
| Print or check SHA-1 digests | sha1sum |
| Operating on File Contents/Sorting | |
|---|---|
| Sort text files | sort |
| Shuffle text files | shuf |
| Uniquify files | uniq |
| Compare two sorted files by line | comm |
| Join lines on a common field | join |
| Print a line of text | echo |
| Directory Listing and Operations | |
|---|---|
| List directory contents | ls |
Color setup for ls |
dircolors |
| Copy files and directories | cp |
| Copy files and set attributes | install |
| Convert and copy a file | dd |
| Move or rename files or directories | mv |
| Remove (delete) files or directories | rm |
| Remove files more securely | shred |
| Make links between files | ln |
| Make a new directory | mkdir |
| Print the value of a symlink or cannonical file name | readlink |
| Remove an empty directory | rmdir |
| Remove files via the unlink syscall | unlink |
| Report file system space usage | df |
| Estimate file space usage | du |
| Report file or file system status | stat |
| File Attribute Manipulation | |
|---|---|
| Change file owner and group | chown |
| Change file group ownership | chgrp |
| Change file access permissions | chmod |
| Change file timestamp | touch |
| File Name Manipulation | |
|---|---|
| Strip directory and suffix from a file name | basename |
| Strip last file name component | dirname |
| Check file name validity and portability | pathchk |
| Print the resolved file name | realpath |
| Working Context | |
|---|---|
| Print the current working directory | pwd |
| Print all or some environment variables | printenv |
| Run a command immune to hangups | nohup |
| Send a signal to a process | kill |
Poetry
A is for awk, which runs like a snail, and
B is for biff, which reads all your mail.
C is for cc, as hackers recall, while
D is for dd, the command that does all.
E is for emacs, which rebinds your keys, and
F is for fsck, which rebuilds your trees.
G is for grep, a clever detective, while
H is for halt, which may seem defective.
I is for indent, which rarely amuses, and
J is for join, which nobody uses.
K is for kill, which makes you the boss, while
L is for lex, which is missing from DOS.
M is for more, from which Less was begot, and
N is for nice, which it really is not.
O is for od, which prints out things nice, while
P is for passwd, which reads in strings twice.
Q is for quota, a Berkeley-type fable, and
R is for ranlib, for sorting ar [sic] table.
S is for spell, which attempts to belittle, while
T is for true, which does very little.
U is for uniq, which is used after Sort, and
V is for vi, which is hard to abort.
W is for whoami, which tells you your name, while
X is, well, X, of dubious fame.
Y is for yes, which makes an impression, and
Z is for zcat, which handles compression.