# Take screenshot & save it to Desktop with current date as namescreencapture -ixoa -t jpg ~/"Desktop/$(date).jpg"
# Delete all containersfor i in $(docker ps -a -q); do docker rm $i; doneβ# List all containersdocker ps -aβ# Remove a container after itβs stoppeddocker run --rm [...]
# Get info on pods in use. Has info on why they failed if they did.kubectl describe podsβ# Get services across all namespaceskubectl get svc --all-namespacesβ# Port forward the <pod> from 5432 to localhost 5300 portkubectl port-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
βchmod (change file mode bits)
# All users can read and write but cannot executechmod 666β# All actions for all userschmod 777β# Only owner can do all actions; group and other users are allowed only to readchmod 744
βtail (output the last part of files) https://www.explainshell.com/explain/tailβ
# 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
βplaygo (send .go file to the Go Playground)
# Open Go playground of file in browserplaygo <file>
βtr (translate or delete characters)
# Convert all input to upper casels | tr a-z a-zβ# Take the output and put into a single linels | tr "\n" " "β# Get rid of all numbersls -lt | tr -d 0-9
βdiff (compare files line by line)
# Compare file1 with file2diff file1 file2
βfind (walk a file hierarchy)
# 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 filefind Documents Desktop -name 'hello_world.py'
βgrep (file pattern searcher)
# 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
βman (open manual pages)
# Search for manual page by keywordman -k keywordβ# ie if you are looking for command to sort something, run# output will include man page name, man section and quick descriptionman -k sortβ# **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 5man 5 passwdβ# 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' commandps aux | grep bash | 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
βkill (send a signal to a process)
# Force quit the process with id 1456kill -9 1456β# Stop process 1456kill -STOP 1456
βhead (output the first part of files)
# 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 -xvf some_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 screencat file1 file2
βngrok (expose your localhost to the web)
# Creates a shareable link of my local server on port 3000ngrok http 3000
rmdir (remove empty directories)
# Remove directoryrmdir dirβ# Remove non empty directoresrm -rf dirβ# Don't use -rf flags with globs such as star (*)# Best to double check commands before running
βmediumexporter (export medium.com articles to markdown)
# i.e.mediumexporter https://medium.com/@nikitavoloboev/karabiner-god-mode-7407a5ddc8f6 > medium_post.md
file (determine file type)
# See type of filefile <file>
time (time command execution)
# Time how long command took to runtime <cmd>