# Delete all containersfor i in $(dockerps-a-q); dodockerrm $i; done# List all containersdockerps-a# Remove a container after it’s stoppeddockerrun--rm [...]
kubectl (run commands against Kubernetes clusters)
# Get info on pods in use. Has info on why they failed if they did.kubectldescribepods# Get services across all namespaceskubectlgetsvc--all-namespaces# Port forward the <pod> from 5432 to localhost 5300 portkubectlport-forward<pod>5300:5432
nix-env (manipulate or query Nix user environments)
# See installed packagesnix-env-q# Install packagesnix-env-iA
basename (strip directory and suffix from filenames)
basename"/Users/nikivi/Documents/books/Thinking, fast and slow.pdf"# => Thinking, fast and slow.pdf
# All users can read and write but cannot executechmod666# All actions for all userschmod777# Only owner can do all actions; group and other users are allowed only to readchmod744
# Shows the last 10 lines of filetail/etc/passwd# -n option allows to change the number of lines to display# where n is the number of lines you want to see# ietail-5/etc/passwd# Use tail +n to print lines starting at line n
# Will search in current directory (.) for the file 'hello_world.py'# and will return the path to the filefind.-name'hello_world.py'# You can also search multiple directories# will search both Documents and Desktop folders for the filefindDocumentsDesktop-name'hello_world.py'
# Print lines from a file or input stream that match an expression# -i = case insensitive search# -v = return all lines that do not contain {}grep-v{}story.txt
# Search for manual page by keywordman-kkeyword# ie if you are looking for command to sort something, run# output will include man page name, man section and quick descriptionman-ksort# **Online manual sections**# (1) = user commands# (2) = system calls# (3) = higher-level unix programming library documentation# (4) = device interface and driver information# (5) = file descriptions (system configuration files)# (6) = games# (7) = file formats, conventions, and encodings (ASCII, suffixes, and so on)# (8) = system commands and servers# Open manual page of passwd on section 5man5passwd# I can often get information about options of some command using either --help or -h flags# ievim--help# vim -h would also work
sort (put the lines of a text file in alphanumeric order)
# Will process the results of ps aux command with grep# and will then sort the output with 'sort' commandpsaux|grepbash|sort# -n option sorts in numerical order# -r option reverses the order of the sort
PlistBuddy (read and write values to plists)
# Change version of Alfred workflow info.plist/usr/libexec/PlistBuddy-c"Set :version \"X.Y.Z\""info.plist
# Shows the first 10 lines of filehead/etc/passwd# -n option allows to change the number of lines to display# where n is the number of lines you want to see# iehead-5/etc/passwd
tar (manipulate tape archives)
# Extract tar files. -x = 'extract'. -v = verbose. -f = point to tar fletar-xvfsome_file.tar.gz
env (set environment and execute command, or print environment)
# View enviroment variablesenv# Variables to know$HOME # Expands to the path of my home folder$PS1 # Represents my command prompt line# I can thus change the way my command prompt looks like thisPS1="\w >"$PATH # Lists all the directories that can be executable with commands# Add directory /Users/nikivi/bin to the pathexport PATH=/Users/nikivi/bin:$PATH# If you put executables there, they will be available# Exported variables get passed on to child processes. Not-exported variables do not.
cat (concatenate and print files)
# Print what is in file1 and file2 to screencatfile1file2
# Creates a shareable link of my local server on port 3000ngrokhttp3000
rmdir (remove empty directories)
# Remove directoryrmdirdir# Remove non empty directoresrm-rfdir# Don't use -rf flags with globs such as star (*)# Best to double check commands before running