Skip to content

Instantly share code, notes, and snippets.

@miron miron/cheatsheet.md
Last active Aug 15, 2018

Embed
What would you like to do?

OS X (built in)

Get status of dd if you don't know that you can do it with CTRL-T, or when there is no pgrep (rescue disk)
ps -e | awk '/awk/ {next} {if(/ dd/) print "kill -INFO", $1}' | sh
Encode and decode using Base64 representation
base64
repeat some text (default is y) infinetly and save it to a file
yes foo > bar.txt
sudo without password, uncomment this in etc/sudoers
# %wheel ALL=(ALL) NOPASSWD: ALL
dscl . append /Groups/wheel GroupMembership USERNAME
display system message buffer
dmesg
safely edit fstab
vifs
harddisk I/O
iotop
I/O for disc and CPU
iostat
show Mach virtual memory statistics
vm_stat
retrieve internal state of mDNSResponder (/var/log/system.log starts at ---- BEGIN STATE LOG ----)
sudo killall -info mDNSResponder
find the printable strings in a object, or other binary, file
string
indent and format C program source
indent
list dynamicaly linked libraries
otool -L /bin/ls
unload driver by bundlename
kextunload -b org.virtualbox.kext.VBoxNetAdp
list currently loaded drivers
kextstat
list the directories in the current directory
ls -d */
get or set kernel state
sysctl -a
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
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
git
gitk
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
man -k
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
cpu and memory info
hostinfo
list all installed packages (.pkg)
pkgutil --pkgs
list files installed by package
pkgutil --files PACKAGE
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 .

OS X (homebrew)

performance monitor
iperf
start macvim without gui
ln -s /usr/local/bin/mvim /usr/local/bin/vim
_enable autocd in osx
brew install bash
echo /usr/local/bin/bash >> /etc/shells
chsh
Shell: /usr/local/bin/bash start mysql
mysql.server start
network monitor
iftop (

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^ revert to previous, new commit
git revert HEAD

vim

rename files inside vim
:E
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
You can’t perform that action at this time.