-
Notifications
You must be signed in to change notification settings - Fork 120
Command line Cheat Sheet
Lance Pollard edited this page Sep 25, 2012
·
7 revisions
This is a generic/intro guide to the bash shell.
The reason for this is to provider relatively new coders with a simple reference to the command-line.
- Press
tab
after typing a few letters for tab-completion. - If you're on a Mac, iTerm is a better terminal to use.
- The
\
backslash is used to write a command across multiple lines (for readability).
pwd
cd ./packages
cd packages
ls
mv packages lib
cp ./lib/tower.js ./tmp/tower.js
touch ./tmp/tower.js
mkdir ./tmp
# make nested directories
mkdir ./tmp/The\ Beatles\White\ Album\ Disc\ 1
rm -rfv ./tmp
chmod 755 ./bin/tower
# on Mac
mdls ./bin/tower
Mac Spotlight actually uses that information when you search.
open ./bin/tower
open .
If you put this command in your ~./bash_profile
it will open that file when you start your computer.
# `L`: follow redirect if server is throwing some intermediate redirect.
# `O`: save as local file(s) rather than sending to STDOUT.
curl -L https://github.com/downloads/viatropos/tower/tower.png -O
curl -X POST \
-F attachment[files][]="[@some/image.png;type=image/png" \
http://localhost:3000/attachments.json
curl -H "Accept: application/json" -H "Content-type: application/json" \
http://localhost:3000/posts.json
curl -H "Accept: application/json" -H "Content-type: application/json" \
-X POST \
-d '{"post":{"title":"A Post!"}}' \
http://localhost:3000/posts.json
curl -H "Accept: application/json" -H "Content-type: application/json" \
-X PUT \
-d '{"post":{"title":"New Title"}}' \
http://localhost:3000/posts/301860cb52ad676200000003.json
curl -H "Accept: application/json" -H "Content-type: application/json" \
-X DELETE \
http://localhost:3000/posts/301860cb52ad676200000003.json
wget -l 1 https://github.com/
You can use rsync, but I would use rsync through wget
:
wget
Apache bench.
ab -n 1000 -c 5 http://localhost:3000/posts.json
ssh username@hostname
uname -a
ifconfig
history
...and make aliases for them:
history | awk '{print $2}' | awk 'BEGIN {FS="|"} {print $1}' | sort | uniq -c | sort -r
which tower
ps -ax
tail -n 500
top
ulimit -n 10240
# Mac:
screencapture -iW ~/Desktop/screen.jpg # currently focused window
screencapture -S ~/Desktop/screen.jpg # entire desktop
# copies the directory listing
ls -l | pbcopy
# get pasteboard lines containing foo and save them in a_file
pbpaste | grep foo > a_file
sed
awk
grep
find
which
chmod
curl
wget
touch
cp
cd
pwd
ls
kill
ps
wc
cat
echo
ping
sudo
history
alias
sort
uniq
open
# eject disk
drutil tray open
# open movie with vlc
open -a vlc movie.avi
pdftotext
brew
git
- ImageMagick
- http://cb.vu/unixtoolbox.xhtml
- http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
- http://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile
- http://superuser.com/questions/370070/linux-equivalent-to-mac-os-xs-fs-usage
- http://serverfault.com/questions/7346/what-are-useful-command-line-commands-on-mac-os-x
- http://www.commandlinefu.com/commands/browse