Skip to content

Instantly share code, notes, and snippets.

@schaitanya
Forked from miron/cli.sh
Created March 8, 2013 15:21
Show Gist options
  • Save schaitanya/5117164 to your computer and use it in GitHub Desktop.
Save schaitanya/5117164 to your computer and use it in GitHub Desktop.

OSX (built in)

list the directories in the current directory
ls -d */
get or set kernel state
sysctl
TCP window scale option
sysctl net.inet.tcp.rfc1323
shows date in historyfile
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "
show wan-ip
curl ifconfig.me
reads also from .ssh/config
scp
don't write to .ssh/known_hosts
ssh -o "UserKnownHostsFile /dev/null"
for surpassing warning
2>&1 | grep -v "^Warning: Permanently added"
network monitors
nettop
netstat
iftop (available via brew)
filetype
file
list listening ports
lsof -iP | grep -i "listen"
load SQL commands from gzipped file into database
mkfifo --mode=0666 /tmp/namedPipe
gzip --stdout -d file.gz > /tmp/namedPipe
LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName;
rm or cd file or dir with hyphen
rm/cd ./-somefileordir
java version
java -version
java compiler version
javac -version
java make tool version
ant -version
java project management tool
mvn
version control
svn
rcs
can also fetch mail via imap
rsync
vimdiff local vs remotefile
vimdiff /etc/php5/cli/php.ini scp://root@remotehost:remoteport//etc/php5/cli/php.ini
starts apache server
sudo apachectl start
switch between app-windows (german keyboard)
cmd-shift-`
formated print with tab and newline
printf \t \n ...
pipe to STDOUT and file
tee
display calendar
cal
html parser
tidy
command line speed test
curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
format text (TEX)
fmt
convert document-files
textutil
show acl permissions
ls -ldeo /Users/spartan/.ssh
remove strange acls
chmod -a# 0 /Users/spartan/.ssh
extended attributes
list
ls -lO
display and manipulate
xattr
update gem
sudo gem update --system
compare files in two directories
diff -rq folder1 folder2
exclude directories in find (don't add the trailing slash to the directory)
find . -path ./misc -prune -o -name '.txt' -print
short descriptions of system commands, words
whatis
short descriptions of system commands, strings
apropos
locate programs
whereis
type of command
type
show path to all versions of program
type -a program
locate a program file in the user's path
which
get picture dimensions
sips -g pixelWidth -g pixelHeight [image-file]
Mac OS X's Built-in Port Scanner
/Applications/Utilities/Network Utility.app/Contents/Resources/stroke
portscanner
nc -zv servername 3306
port open
# Connection to servername 3306 port [tcp/mysql] succeeded!
xml parser
xpath
xmllint
postfix control program
postfix
speed up terminal in osx
cd /private/var/log/asl
ls *.asl
sudo rm !$
add users,...
dscl
mount and manipulate local and remote .dmg images
hdid
_mount a crypted user profile to /Volumes/
_
hdiutil attach /Users//.sparsebundle
hdiutil eject ...
shrink after manipulation of files within the bundle
hdiutil compact ...
list bill of materials of .pkg installers
lsbom
metadata search
mdfind
specify searchdir
mdfind -onlyin
start mysql
mysql.server start (available via brew)
start macvim without gui
ln -s /usr/local/bin/mvim /usr/local/bin/vim (available via brew)
cpu and memory info
hostinfo
query and manipulate osx installer packages
pkgutil
Mac OS X VPN service daemon
vpnd
Point-to-Point Protocol Daemon
pppd
group record manipulation tool
dseditgroup
text to speech
say
paste from clipboard
pbpaste
calendars with events
calendar /usr/share/calendar
sleep from commandline
pmset sleepnow
font smoothing
defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
show hidden files in finder and timemachine
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
operate on files in Timemachine
/System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass
show path of commands inside Xcode
xcrun -find
show hidden files in open dialog
cmd shift .
performance monitor
iperf (available via brew)

homebrew

which packages depend on ...
brew uses --installed
dependency tree
brew uses --recursive
show packages with dependencies
brew info $(brew list) |xargs -0 | grep -ZB2 Depends\ on
packages without dependencies
brew leaves
delete old versions
brew cleanup
vim with lua
brew install --with-lua vim

bash

shell options
shopt
print keybindings
bind -P
print shellscript before executing, execute commands from file
bash -x
brief summaries of builtin commands
help
secure deletion
ls *.txt
rm !$
open last commandline in editor
fc
search history
Ctrl-R
cycle
Ctrl-R
run
RETURN
edit
←, →
quit search
Ctrl-G

git

remove file from repository
git rm
get the latest source from SVN
git svn clone ... ...
git checkout master
git svn rebase
check differencies between modified and remote
git diff master
reset to previous git reset --hard HEAD^

vim

invisible characters in vim
:set invlist
replace space with newline in vim (^M is Control-V Enter)
%s/ /^M/g
comment block
C-v I# ESC
paste in insert mode
C-o open current file's directory in vim
:Ex[plore]
unhighlight search in vim
:noh
write to read only with vim
:w !sudo tee %

emacs

incremental search
C-s
quit menu
C-g
switch buffer
C-x b
quit undo-tree
q
list buffers
C-x C-b
close windows except cursor
C-x 1
select from completion
TAB
view list of M-x commands
C-TAB
kill buffer
C-x k
switch to other window of buffers
C-x o
vims *
M-b beginning of word,
C-s C-w select word,
C-w further selection of word if underscore,
C-s

screen

split verticaly in screen _
^a |
switch region
^a TAB
create session
^a c
choose session
^a "
close region
^a X
close all regions beside actual one
^a Q
scroll buffer (vim style navigation)
^a [
clearscreen (cmd-k clears every region)
^ l

misc

locate random webservers for browsing
nmap -Pn -sS -p 80 -iR 0 --open
check if package is installed or not
dpkg-query -W -f='${Status} ${Version}\n' ...
fetch mail via imap
fetchmail
fetchmailconf
list listening ports
netstat -tulpen
don't do, copies rootdirectory to remotemachine
scp -P 401 root@servername:/* 'somefile'
show linux distro
cat /etc/issue
lsb_release -a
show configuration
debconf-show
tcp-settings
grep . /proc/sys/net/ipv4/tcp_*
exact match
locate -r "^(.*/)*header.inc.php$"

overtone

project.cj add overtone dep
lein deps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment