tab
Press tab while in the middle of typing a file name for auto-complete (only works when a single match is found):
$ cat exa_
$ cat example.txt
self-
host
weekly!-2
Use !-2 to re-run the second most recent command:
$ ls -l
example.txt
$ cat example.txt
self-host weekly
$ !-2
example.txtstat -c "%y" file
Use stat -c "%y" file to display the last modification time of a file in a friendly format:
$ stat -c "%y" example.txt
2026-01-17 07:49:41 -0500paste
Use paste to view two files side-by-side:
$ paste example.txt example2.txt
self- self
host host
weekly weeklydiff -y file1 file2
Use diff -y file1 file2 to view side-by-side differences between two files:
$ cat example.txt
self-
host
weekly
$ cat example2.txt
self
host
weekly
$ diff -y example.txt example2.txt
self- | self
host host
weekly weeklydiff -u file1 file2
Use diff -u file1 file2 to compare differences between two files:
$ cat example.txt
self-
host
weekly
$ cat example2.txt
self
host
weekly
$ diff -u example.txt example2.txt
-self-
+self
host
weeklyunzip -l file.zip
Use unzip -l file.zip to list the contents of a ZIP file without extracting the archive:
$ unzip -l example.zip
example/
example/self-host.txt
example/weekly.txtid -u
Use id -u to display your user's numeric ID:
$ id -u
1001date +%s
Use date +%s to print the epoch time (seconds elapsed since 1970-01-01) from the command line (because why not?):
$ date +%s
1766514680echo $RANDOM
Use echo $RANDOM to generate a random number:
$ echo $RANDOM
1337101stat -c %y
Use stat -c %y <file> to view a file's most recent modification date and time:
$ stat -c %y example.txt
2025-12-12 07:01:56 -0500pwd
Use pwd to quickly view the absolute path of the current working directory:
$ pwd
/home/esholly/newslettersort <file.ext> | uniq
Use sort <file.ext> | uniq to view unique, sorted values from a file:
$ cat example.txt
self
host
weekly
weekly
$ sort example.txt | uniq
host
self
weeklywc -c <file>
Use wc -c <file> to quickly count the number of characters in a file:
$ wc -c example.txt
24 example.txtwc -w <file>
Use wc -w <file> to quickly count the number of words in a file:
$ wc -w example.txt
4 example.txtcommand -v <application>
Use command -v <application> to quickly determine if an application is installed on your machine:
$ command -v rsync
/usr/bin/rsync
$ command -v rclone
$ timeout
Use timeout to limit the amount of time a command is allotted to run:
$ timeout 10s command.shfree -h
Use free -h to quickly check your system's memory usage:
$ free -h
total used free
Mem: 31Gi 8.6Gi 4.6Gi
Swap: 975Mi 953Mi 22Mils -ltr
Use ls -ltr to list files and directories in the current folder sorted by last modified:
$ ls -lt
Oct 1 .env
Oct 4 self-host-weekly.txt
Oct 6 example.txt
Oct 7 docker-compose.ymlls -lt
Use ls -lt to list files and directories in the current folder sorted by last modified:
$ ls -lt
Oct 7 docker-compose.yml
Oct 6 example.txt
Oct 4 self-host-weekly.txt
Oct 1 .envgrep -c "pattern" file.txt
Use grep -c "pattern" file.txt to count the number of times a pattern appears in a file:
$ grep -c "self-hosted" example.txt
1ls -lhS
Use ls -lhS to list the directories and files in the current folder with human-readable sizes:
$ ls -lhS
8.5M example.txt
18k docker-compose.yml
25 self-host-weekly.txtdate "<format>"
Use date "<format>" to easily view the date and time in a particular format directly from the command line (best paired with aliases for easy reference):
$ date "+%F %T"
2025-09-19 08:00:00uptime -p
Use uptime -p to easily see the formatted system uptime:
$ uptime -p
up 4 days, 11 hours, 21 minutesrealpath <file>
Use realpath <file> to quickly view the absolute path of a file:
$ realpath example.txt
/home/users/rick/example.txtseq <first> <increment> <last>
Use seq <first> <increment> <last> to easily generate a sequence of numbers:
$ seq 10 5 30
10
15
20
25
30ls -l <filename>
Use ls -l <filename> to quickly view the permissions of an individual file:
$ ls -l example.txt
-rwxrw---- user user example.txttr -dc A-Za-z0-9_ < /dev/urandom | head -c 16 | xargs
Use tr -dc A-Za-z0-9_ < /dev/urandom | head -c 16 | xargs to quickly generate a password from the command line (create a bash alias for quick reference in the future):
$ tr -dc A-Za-z0-9_ < /dev/urandom | head -c 16 | xargs
M0hPYmTAu877Lj6qls | wc -l
Use ls | wc -l to quickly count the number of files in the current directory:
$ ls | wc -l
58for i in *; do test -d $i && du -sh $i; done
Use for i in *; do test -d $i && du -sh $i; done to output a list of directories in the current folder and their sizes (skipping files and subdirectories):
$ for i in *; do test -d $i && du -sh $i; done
755M audiobookshelf
184K caddy
68k filebrowser
86M navidromels -lt
Use ls -lt from the command line to quickly list files and directories by last modified time:
$ ls -lt
Jul 4 07:04 docker-compose.yml
Jul 4 07:02 .env
Jul 4 06:57 example.txthistory > commands.txt
Use history > commands.txt to save the terminal's command history directly to a file:
$ history > commands.txt
$ cat commands.txt
1008 ps aux | grep node
1009 docker ps
1010 contrab -l
1011 node -v
1012 dockcheck.shuname -r
Use uname -r to quickly display the system's kernel version:
$ uname -r
6.1.0-37-amd64reset
Use reset to clear the terminal history from the current view:
$ reset
$ _cat <file>.json | jq .
Use cat <file>.json | jq . to easily format and view JSON files with indentation:
$ cat test.json | jq .
{
"name": "Self-Host Weekly",
"date": "2025-06-06",
"website": "selfh.st"
}find /directory -mtime -1
Use find /directory -mtime -1 to quickly locate files modified in the last 24 hours (or any time period of your liking):
$ find /user/test -mtime -1
selfhost-weekly.txt
docker-compose.ymlls -d */
Use ls -d */ to view a listing of only the directories in the current folder:
$ ls -d */
actual/ caddy/ forgejo/ ghost/ openssl rand -base64 x
Use openssl rand -base64 x (replacing x with a number of your choice) to generate a random password:
$ openssl rand -base64 12
8AlOdTRS0oFkg6cvecho $?
Use echo $? after executing a command to easily retrieve its exit status from the command line:
$ echo $?
0curl -I
Use curl -I (i) to fetch only the HTTP headers of a request rather than the entire body:
$ curl -I https://news.ycombinator.com/
HTTP/2 403
date: Fri, 25 Apr 2025 07:00:00 GMT
content-type: text/html; charset=UTF-8
etc...ls -la
Use ls -la to list all files – including hidden – in a directory:
$ ls -l
docker-compose.yml
example.config
$ ls -la
docker-compose.yml
.env
example.configcurl wttr.in
Use curl wttr.in to view a formatted forecast of the local weather directly from the terminal:
pkill
Use pkill to kill a running process by name instead of the PID required for the kill command:
$ kill 5952
$ pkill syncthingls -S
Use ls -S to list files in the current directory sorted by size:
$ ls -S
this.txt week.txt self-hosted.txt in.txtlsof -i :443
Use lsof -i :443 to quickly list the process(es) listening on port 443 from the command line:
$ lsof -i :443
COMMAND PID USER FD TYPE DEVICE NODE NAME
caddy 398 root 7u IPv4 32984 TCP *:httpsecho *.<filetype>
Use echo *.<filetype> to list of all files of a specified filetype from the command line:
$ echo *.txt
this.txt week.txt in.txt self.txt hosted.txt&&
Use && to execute a second command only if the first succeeds:
/$ mkdir test_folder && cd test_folder
/test_folder$ _;
Use ; to run multiple commands in succession (unlike &&, the second command will run regardless of the first's success):
/$ mkdir test_folder; cd test_folder
/test_folder$ _>
Use > to write the output of a command to a specified file:
/$ echo "This Week in Self-Hosted" > example.txt
/$ cat example.txt
This Week in Self-Hosted>>
Use >> to append characters to the end of an existing file:
/$ cat example.txt
This Week in
/$ echo "Self-Hosted" >> example.txt
/$ cat example.txt
This Week in
Self-Hostedcd ../..
Use cd ../.. to traverse back two directories from the current location via the command line (as opposed to executing cd .. twice to achieve the same):
appdata/ghost/selfhst$ cd ../..
appdata$groups
Use the groups command to view a list of the groups the current user belongs to:
/$ groups
sholly cdrom floppy sudo audio video users docker selfhstwc -l <file>
Use wc -l <file> to easily display the number of lines in a given file directly from the command line:
/$ wc -l example.txt
8 example.txtuniq <file>
Use the uniq command to easily view the unique lines of a file from the command line:
/$ cat example.txt
This
This
Week
Week
in
Self-Hosted
/$ uniq example.txt
This
Week
in
Self-Hostedhead -n 5 <file>
Use head -n 5 <file> to quickly view the first five (or any number of) lines of a file from the terminal:
/$ head -n 5 example.txt
This
is
This
Week
intail -n 5 <file>
Use tail -n 5 <file> to quickly view the last five (or any number of) lines of a file from the terminal, which is helpful for tasks like viewing the latest output from a log file:
/$ tail -n 5 example.txt
is
This
Week
in
Self-Hosteddu -sh *
Use du -sh * to easily preview a list of all files and folders in a directory with sizes displayed in a human-readable format:
/$ du -sh *
20K docker-compose.yml
1K .env
56K example.txtls -lt
Use ls -lt to list files and folders in a directory sorted by modification time, which can be helpful for quickly finding recently modified files in large folders:
/$ ls -lt
Dec 06 05:01 docker-compose.yml
Dec 05 11:56 example.txt
Nov 01 08:34 log.txtwhich
Use the which command to easily find the location of an executable file for troubleshooting, debugging, and other use cases:
/$ which docker
/usr/bin/docker
/$ which cat
/usr/bin/cathistory
Use the history command to easily view a numbered list of commands previously entered into the terminal:
/$ history
1 docker compose up
2 cat compose
3 ls -l
4 python3 customScript.pyhistory + !
After running history, preface a number from the provided list with ! to easily rerun that command:
/$ history
1 docker compose up
2 cat compose
3 ls
4 python3 customScript.py
/$ !3
compose.yml customScript.pyCtrl + U
Use Ctrl + U to easily delete any text in the current prompt, which can be especially useful when clearing password prompts where the cursor isn't tracked:
/$ docker compose up ghost_
/$ _Ctrl + P
Use Ctrl + P to cycle through the command line history without having to move your fingers from the default typing position.
Ctrl + O
When paired with the Ctrl + P command, Ctrl + O can be used as a shortcut to execute the command queued by Ctrl + P while also automatically queuing the next command from the shell's history.
Ctrl + W
Use Ctrl + W to quickly remove the last word from the command line. (If you've spent any amount of time online, you'll recognize the shorthand for this command, ^W, as a playful reference when people correct or delete something they had previously written.)
/$ docker compose up ghost_
/$ docker compose up_Ctrl + Y
Use Ctrl + Y to paste the string previously added to the buffer via Ctrl + W:
/$ docker compose up ghost_
# Ctrl + W
/$ docker compose up_
# Ctrl + Y
/$ docker compose up ghost_Ctrl + T
Use Ctrl + T to quickly swap the last two characters before the cursor (most helpful for quickly correcting accidental suod or sl occurrences):
/$ suod_
/$ sudo_!-2
Use !-2 to quickly re-run the second most recent command:
/$ ls
example.txt
/$ cat example.txt
This Week in Self-Hosted
/$ !-2
ls
example.txttime read
Use time read as a handy stopwatch that can be used directly from the terminal (press any key to stop):
/$ time read
real 0m4.588sCtrl + k
Use Ctrl + k to delete everything from the current cursor position to the end of the line:
/$ docker compose_ up ghost
/$ docker compose_Ctrl + u
Use Ctrl + u to easily delete all text from the current line preceding the location of the cursor:
/$ docker compose up_
/$ _
/$ docker compose up -d _ghost
/$ ghostCtrl + w
Use Ctrl + w to easily delete the previous word from the command line:
/$ locate example_
<Ctrl + w>
/$ locate _locate
Use the locate command to search for files directly from the command line, separating terms with an asterisk if searching for multiple words. The command also supports several flags, including -i for disabling case sensitivity.
/$ locate example
/home/user1/example.txt
/$ locate -i example
/home/user1/example.txt
/home/user2/Example.txt
/$ locate test*file
/home/user1/test-file.txtwhich
Use the which command to find the first location of an executable file, or pair it with -a (all) to identify all locations:
/$ which ls
/usr/bin/ls
/$ which -a ls
/usr/bin/ls
/bin/lsalias
Use the alias command to create customized shortcuts for frequently used commands:
/$ alias test='cat example.txt'
/$ test
This Week in Self-Hostedunalias
Use the unalias command to remove any bash aliases previously created by the user:
/$ alias test='cat example.txt'
/$ test
This Week in Self-Hosted
/$ unalias test
/$ test
/$ _wc
Use the wc command to show the count of lines, words, and bytes in a file:
/$ wc example.txt
3 4 27 example.txtCtrl + r
Use Ctrl + r to search for a previously used command directly from the command line:
/$ (reverse-i-search): 'docker compo': docker compose up -d ghosttouch
Use the touch command to instantly create a new file from the command line. Multiple files can be created if multiple file names are entered, and the command can also be modified with -c to skip creation if the file already exists or -m to update an existing file's timestamp.
/$ ls
example.txt
/$ touch example-2.txt
/$ ls
example.txt example-2.txt
/$ touch example-3.txt example-4.txt
/$ ls
example.txt example-2.txt example-3.txt example-4.txtCtrl + l
Use Ctrl + l (that's a lowercase "L") to instantly clear the terminal window while preserving any input on the current line:
/$ cat example.txt
This
Week
in
Self-Hosted
$ gzip example.txt_$ gzip example.txt_
grep
Use the grep (global regular expression print) command to search for and identify patterns and strings in files:
/$ cat example.txt
This
Week
in
Self-Hosted
$ grep host example.txt
Self-Hostedrev
Use the rev command to reverse a string of text directly from the command line:
/$ echo "This Week in Self-Hosted" | rev
detsoH-fleS ni keeW sihTnohup
Preface commands with nohup (no hang up) to continue running them after exiting a terminal session. Upon completion, nohup will create a file titled 'nohup.out' with the output of the command for completion verification.
/$ nohup apt update
nohup: ignoring input and appending output to 'nohup.out'
/$ cat nohup.out
...
Reading package lists...
Building dependency tree...
Reading state information...
6 packages can be upgraded.&&
Use && to run multiple commands under the condition that subsequent commands after && will only run if the preceding command is successful (most commonly used to execute apt update and apt upgrade in a single command):
/$ sudo apt update && sudo apt upgrademkdir -m
Use the -m flag when calling mkdir to simultaneously set the permissions of a new directory when creating it:
/$ mkdir -m 770 exampledirectory
/$ ls -l
drwxrwx--- user group exampledirectorycurl ifconfig.me
Use the command curl ifconfig.me to easily view your network's external IP address from the command line:
/$ curl ifconfig.me
12.345.67.890Alt + .
Press the . key while holding Alt to cycle through and reuse arguments from previous commands:
/$ docker compose up -d some-docker-container
/$ docker compose stop <Alt .>
/$ docker compose stop some-docker-container>
Preface a filename with > to clear the contents of the file directly from the command line:
/$ cat example.txt
This Week in Self-Hosted
/$ > example.txt
/$ cat example.txt
/$factor
Use the factor command to list prime factors for a specified number directly from the command line:
/$ factor 14
14: 2 7
/$ factor 46
46: 2 23mkdir -p
Add the -p flag (--parents) to the mkdir command to create a directory of new folders in a single command instead of repeating it multiple times for each new folder.
Users can also utilize brace expansion with mkdir -p to simultaneously create multiple directories of folders with a similar structure.
/$ mkdir -p /this/week/in/self-hosted
/$ tree
.
|___this
|___week
|___in
|___self-hosted
/$ mkdir -p this/{day,week,month}/in/self-hosted
/$ tree
.
|___this
|___day
|___in
|___self-hosted
|___week
|___in
|___self-hosted
|___month
|___in
|___self-hostedcolumn
Use the column command to view the contents of a file in an organized table or column format with options for specifying delimiters, width, names, alignment, and more.
In the example below, column is being used to display the example.txt file using a comma as the delimiter for the table.
/$ cat example.txt
Task,Completed (Y/N)
Research,Y
Setup,Y
Deploy,N
Analyze,N
/$ column example.txt -t -s ","
Task Completed (Y/N)
Research Y
Setup Y
Deploy N
Analyze NPrefacing commands with <space>
Preface a command with a single space to omit it from being logged in the terminal's bash history:
/$ history
1000 docker compose up
1001 cd ~
/$ rm example.txt
/$ history
1000 docker compose up
1001 cd ~rename
Use the rename command to easily rename multiple files (or file extensions) at the same time using patterns in the file names. Depending on your distribution, you may need to install rename (apt install rename) before using it.
/$ ls
example-1.txt example-2.txt
/$ rename 's/example/test/' *.txt
/$ ls
test-1.txt test-2.txt
/$ rename 's/.txt/.csv/' *.txt
/$ ls
test-1.csv test-2.csvcd -
Use the cd - command to easily navigate back to the previous directory when traversing folders:
/$ cd /some/path
/some/path$ cd /another/path
/another/path$ cd -
/some/path$ _Ctrl + x + e
Ctrl + x + e is a useful shortcut for instantly firing up an editor from the command line. By default, the shortcut will open a blank editor – but its usefulness shines when entered along with a line of text, which will automatically appear in the first line of the editor after hitting Ctrl + x + e.
This is particularly handy when running complex commands that may need to be documented for future reference.
/$ _
GNU nano 7.2
_
/$ echo -e "correct\fhorse\fbattery\fstaple"
GNU nano 7.2
echo -e "correct\fhorse\fbattery\fstaple"_cal
Use the cal command to display the current calendar month with the current date highlighted on the command line. The command can also be paired with flags for additional functionality: -y to show the entire year with the current date highlighted, -j to show the month using the Julian calendar, or with a two-digit month or four-digit year to specify a different point in time.
/$ cal
February 2024
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29
/$ cal 02 2023
February 2023
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28cut
Use the cut command to parse characters or sections from the lines of a file and write them to the standard output. Cut also supports multiple options for parsing – cut by byte (-b), character (-c), or delimiter (-d).
In the example below, we use the delimiter option (-d) to extract the second section (-f) after the comma in each line of the file.
/$ cat example.txt
This,Week
in,Self-Hosted
/$ cut -d "," -f 2 example.txt
Week
Self-Hostedfold
Use the fold command to wrap each line of a file based on a specified number of characters when viewing the output from a display with a limited width. By default the command wraps lines every 80 characters, which can be configured with the -w flag (-w50 for 50 characters, etc.). Adding the -s flag also ensures words are not broken as the command runs.
/$ cat example.txt
This Week in Self-Hosted is a weekly newsletter published every Friday morning with a recap of the latest and greatest in self-hosted news, software, and content.
/$ fold example.txt
This Week in Self-Hosted is a weekly newsletter published every Friday morning w
ith a recap of the latest and greatest in self-hosted news, software, and conten
t.
/$ fold -w75 -s example.txt
This Week in Self-Hosted is a weekly newsletter published every Friday
morning with a recap of the latest and greatest in self-hosted news,
software, and content.watch
Use the watch command to monitor changes to the output of another command over intervals of time. This is useful when monitoring things like script results, disk usage, and other tools that print a response as an output.
The command also comes with a number of helpful options including specifying an interval other than the default two seconds (-n), highlighting the differences between outputs (-d), or terminating the watch command when the output changes (-g). If not configuring the command with an option to automatically stop, use Ctrl + C to manually exit.
/$ watch date
Fri Feb 2 07:30:00 EST 2024
2time
Prefacing a command with time outputs the amount of time it takes to execute. This is useful for measuring and optimizing the performance of scripts, downloads, and other tools.
The output of time consists of three values: the real time elapsed, the CPU time in user mode, and the CPU time in kernel mode.
/$ time python3 generate-rss.py
real 0m8.210s
user 0m1.779s
sys 0m0.327syes
In Linux, the yes command outputs a string of characters until stopped ('y' by default if a string isn't provided). This is helpful when executing recurring tasks or writing scripts that include commands with prompts for user input.
And while this can be useful for those times you'd like to step away while a process runs, there's a reason many commands require manual user input – so be cautious when using yes to automate those you aren't familiar with.
/$ yes This Week in Self-Hosted
This Week in Self-Hosted
This Week in Self-Hosted
This Week in Self-Hosted
This Week in Self-Hosted
...
/$
/$ yes | bash docker_restart.sh
Restart Docker service? y
/$comm
Use the comm command to compare two sorted files line-by-line directly from the terminal. As shown below, the output of the command includes three columns – the first for unique lines from the first file, the second for unique lines from the second file, and the third for shared lines between the two files.
The command can also be used with various flags to alter its output (-1, -2, -3 to suppress the various columns, -output-delimiter to separate columns with a specified character, -check-order to ensure the files are sorted correctly).
/$ comm example-1.txt example-2.txt
This
Week
in
Self-Hosted
Open-Sourcetee
Use tee to write the output of a command to a file while also viewing it in the terminal:
/$ cat example.txt | tee output.txt
Self-
Host
Weekly
/$ cat output.txt
Self-
Host
Weeklyz-commands
Certain popular commands (cat, grep, less, etc.) can be prefaced with the letter z to allow command line users to interact with gzip-compressed files without extracting them. This is helpful, for example, if you're reading compressed logs in a directory you don't have permissions to write/extract to.
/$ cat example.txt
This Week
in Self-Hosted
/$ gzip example.txt
/$ zcat example.txt.gz
This Week
in Self-Hosteddos2unix
Occasionally, I'll struggle running commands against a text file only to discover it was created on Windows and includes carriage returns at the end of each line. To quickly convert a file to Unix-compatible line breaks (line feeds) from the command line, install and run dos2unix.
(Note that dos2unix probably won't be installed on your machine by default, so look up the installation instructions for your operating system before executing.)
/$ dos2unix this_week_in_self_hosted.txt
dos2unix: converting file this_week_in_self_hosted.txt to Unix format...Ctrl + e
Use Ctrl + e to relocate your cursor to the end of the line when typing a long command. The shortcut is much quicker than holding an arrow key and easier than using the Home key as your fingers won't need to leave the default typing position.
/$ dcker co|mpose up ghost-blog
/$ dcker compose up ghost-blog|Ctrl + a
When typing a long command, use Ctrl + a to relocate your cursor back to the beginning of the line if you find yourself needing to make an adjustment:
$ dcker compose up bookstack|
$ |dcker compose up bookstack
$ do|cker compose up bookstackfind -size +100M
Use find -size +100M to find all files in the working directory greater than or equal to 100MB. Adjust 100M to your liking if you'd like to search for files of a different size (for example, 1G for 1GB).
/$ find -size +100M
./self-host-weekly.db
./self-host-weekly.logdu -h --max-depth=1
The command du -h --max-depth=1 allows users to list the directories in a folder while displaying their sizes in a human-readable format. Breaking it down into individual pieces: du lists directories and sizes within the current directory, -h converts the displayed sizes to human-readable format, and --max-depth=1 defines what folder level the command runs (all subfolders will be displayed if omitted).
/$ du -h --max-depth=1
16M ./This
27M ./Week
756k ./In
1.1G ./Self-Hosted> file.txt
Use > file.txt to flush the contents of a file from the command line (helpful for clearing old log files when troubleshooting via CLI):
/$ cat example.txt
This Week in Self-Hosted
/$ > example.txt
/$ cat example.txt
/$!$
The characters !$ can be used as a shortcut to reuse or repeat the argument used in the most recent command. For instance, they can be used to easily navigate to a folder path that was recently created or modified.
/$ mkdir /self/host/weekly
/$ cd !$
cd /self/host/weekly
/self/host/weekly$ who -b
Use who -b to quickly display the date and time of the machine's last reboot:
$ who -b
system boot 2023-10-27 05:34echo "!!"
Use echo "!!" to create a script of the previously executed command – helpful for capturing complex commands that will need to be reused in the future:
$ rsync -av --delete /home/appdata /backup
$ echo "!!" > selfhost.sh
$ cat selfhost.sh
rsync -av --delete /home/appdata /backupmkdir -p
Appending the -p flag (--parents) to the mkdir command allows users to create entire directory trees at once rather than using multiple mkdir commands to create nested folders:
mkdir -p personal/storage/photosnl
Use nl to preface each line with a number when viewing the contents of a file.
$ cat example
Self-
Host
Weekly
$ nl example
1 Self-
2 Host
3 Weeklytac
Use the command tac (cat backwards) to view the contents of a file in reverse order. This is particularly helpful when viewing logs, as the most recent writes are typically appended to the end of the file.
user@selfhst:/$ cat example
This
Week
in
Self-Hosted
user@selfhst:/$ tac example
Self-Hosted
in
Week
ThisFixing errors with ^typo^correction
Use ^typo^correction to fix mistakes in previous commands without having to retype the entire command from scratch:
user@selfhst:/$ cd /home/usr/appdata
-bash: cd: /home/usr/appdata: No such file or directory
user@selfhst:/$ ^usr^user
user@selfhst:/home/user/appdata$ _Prefacing commands with <space>
Preface a command with a single space to prevent it from being recorded in the terminal's history:
$ ls -l
$ cd..
$ cd /
$ history
10 ls -l
11 cd /curl ifconfig.me
Displays your network's external IP address in the terminal:
$ curl ifconfig.me
xx.xxx.xx.xxxsudo !!
Prefaces the previously executed command with sudo to avoid having to retype the entire command a second time:
$ apt update
E: Could not open lock file ...
$ sudo !!
sudo apt update
[sudo] password for user: