Command Line and Shell Quick Reference
A quick reference/cheat sheet about various command line and shell related related things. From shell and bash syntax to common command line tools.
Compressed files
tar -xf $FILE
You can add -v
in there to print the file names as well.
If you're not dealing with stdin, then it should auto-detect the compression type.
Finding files
locate
To find from current directory:
locate "$PWD*/<FILE GLOB>"
find
Manual: https://www.gnu.org/software/findutils/manual/find.html
find <OPTIONS> <PATH>
Options
-type
: Specifies file type. Typically usef
.-name
: Name of the file.
Shell/Bash Syntax
- Assign variables without
$
- Read variables with
$
elif
diff
Finds difference between two files/directories
-q
/--brief
: Report only the files that differ.-r
/--recursive
: Recursive
Rsync
- Ending dir name in
/
copies contents and without copies directory.
Useful Options
-v
: verbose-a
: archive. A combination of a bunch of other useful options such as recursive.-P
: Combination of--partial
which allows resumption of interrupted sync, and--progress
which shows progress.-n
: Dry run--delete
: Delete files from destination that aren't in source directory.
lsblk
Lists devices. Useful for finding USB drives, other external storage, etc.
Those devices are usually in /dev/
udisk
udisksctl mount -b DEVICE_NAME
udisksctl unmount -b DEVICE_NAME
Where DEVICE_NAME
is a device from lsblk.
Automatically mounts a device.