Skip to content

Instantly share code, notes, and snippets.

Last active Oct 5, 2021
What would you like to do?
Shell Tips
# mostly "notes to self" as I occasionally forget
# system info
uname -a
# search for a process
ps aux | grep [something]
# immediately terminate process
kill -9 [pid]
# cat gzip file
zcat [fileName.gz]
# -xvzf ~ extract, verbose, gzip, file
tar -xvzf [fileName.tar.gz]
# count words in file
wc -w [fileName]
# count lines (pipe into)
cat [fileName] | wc -l
# sort lines (pipe into)
cat [fileName] | sort
# ignore given directories
tree -I '.git|node_modules'
hostname # server domain
hostname -i # ip
hostname --fqdn # fully qualified domain name
whoami # username associated with current effective user id
whereis node #
ps aux | peco #
diskonaut /home #
imgp -xp 1366x768 ~/Pictures #
tldr man # simple man
aria2c [path] # downloads
# delete specific folders recursively (node_modules in this case)
find . -name "node_modules" -type d -prune -exec rm -rfv '{}' +
# search file content
# -Rin ~ recursive, ignore case, line number (-l instead of -n for file name only)
# can also use --exclude=\*.jpg --include=\*.{css,html} --exclude-dir={dir1,dir2}
grep -Rin "text-to-find" --include=\*.js --exclude-dir={.git,node_modules} . # example
# copy file into subfolders (one level deep)
for d in */; do cp someFile.txt "$d"; done
# zip of latest commit on current branch
# excludes node_modules via .gitignore (for example)
git archive -o HEAD
# available versions of npm package
npm view [packageName] versions
# in ~/.profile or ~/.bashrc for example:
# add to path (examples)
export PATH+=":$HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
# also
alias g='git'
# ~/.gitconfig
s = status
a = add . -A
m = commit
l = log
d = diff
p = pull
c = checkout
r = remote
b = branch -v
e = commit --amend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment