Вы находитесь на странице: 1из 174

bro

8/3/2016

Command
bro
tar

bro: just get to the point!

# install bro now


$ gem install bropages

Entry

# lookup an entry for the command 'bro' with bro


bro bro

# Create a tar archive


tar -cf archive.tar file1 file2 ... fileN

Votes
236 6
153 1

# Create a tar gzipp'd archive


tar -zcf archive.tar.gz file1 file2 ... fileN
# Create multi-part tar archives from a directory
tar cf - /path/to/directory|split -b<max_size_of_p
art>M - archive.tar
# Extract all files from a tar archive
tar -xf archive.tar
# Extract all files from a tar gzipped archive
tar -zxf archive.tar.gz
# Extract one file from a tar archive
tar -xf archive.tar the_one_file
# Lists all files in a tar archive
tar -tf archive.tar

ln

# Creates a soft link


ln -s /full/path/to/original/file /full/path/to/li
nk

130 0

# Creates a hard link


ln /full/path/ln/original/file /full/path/to/link

curl
bro

grep
http://bropages.org/browse

# get the contents of a web page


curl http://bropages.org

# Upvote the first entry of the last bropage you l


ooked at
bro thanks

104 5
61 0

57 0
1/174

8/3/2016

bro: just get to the point!

# Case insensitive search through all of the files


recusively starting from my current directory for
the string "computesSum" but does not search bina
ry files. When a match is found, print the line n
umber it was found.
grep -iIrn computesSum *

ls

# Lists all of the files in my current directory i


n ascending order based on last modification time.

59 3

# -l flag displays info like mode, owner, group, e


tc.
# -t flag sorts by time of last modification
# -r reverses the order of the sort, so that the m
ost recent entry is on bottom rather than top
ls -ltr

curl

man
curl

zip

find

chown
scp

http://bropages.org/browse

# download a file and write it to another file cal


led myfile.html
curl -o myfile.html http://bropages.org

# Shows the manual for using the command 'ls'


man ls

# Download a file using its original filename, fol


low all redirects, and continue where you left off
if the download previously failed
curl -LOC - http://foo.bar/file.ext

# Zips up everything in my current directory recur


sively into the file archive.zip
zip -r archive.zip *

# Executes a command on the files and folders matc


hing a given pattern, in this case, output the las
t lines of each .foo file in the current folder an
d subfolders.
find . -name "*.foo" -exec tail {} \;

# change owner of entire directory recursively


chown -R brouser:brogroup path/to/directory/

# Downloads a file from a remote location


scp user@remote_host:path/to/source path/to/destin
ation

54 0

53 2
47 0

46 0

46 0

45 0
38 0

2/174

8/3/2016

man

scp
curl

find

cp
ls

wget

bro

git log
http://bropages.org/browse

bro: just get to the point!

# Searches for all manual pages which mention "rub


y"
man -K "ruby"

# Transfer local copy to remote destination:


scp localfile remotehost:/path/to/destination

# send a header with curl


curl --header "X-BeerIsInteresting: 1" www.bropage
s.org

# Outputs all the file names/paths that start with


the name "Casey". Searches recursively starting
from my current directory (.)
# Throws out any error output by sending it to /de
v/null
find . -name "Casey*" 2>/dev/null

# Copy directories recursive using the option -r.


cp -r ~/videos/anime/ /media/backup/

# Displays your current directory how it ought to


be shown:
# -A : print all files except ./ and ../
# -l : show detailed file information
# -t : sort by time-last-modified
# -r : reverse the sort, to show most recent on bo
ttom
# -h : show file sizes in humna-readable format
# -G : colorize the output
ls -AltrhG

# Saves the HTML of a webpage to a particular fil


e.
wget -O bro.html http://bropages.org/

# How to thanks the 2nd or 3rd entry on bro when d


oing bro thanks
bro thanks 2
# will thank the 2nd person
bro thanks 3
# will thank the 3rd person and so on

# The ultimate graph display for your git log


git log --graph --abbrev-commit --decorate --date=

32 1

31 0
30 1

29 0

28 0
33 6

29 2

27 0

26 0
3/174

8/3/2016

bro: just get to the point!

relative --format=format:'%C(bold blue)%h%C(reset)


- %C(bold green)(%ar)%C(reset) %C(white)%s%C(rese
t) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C
(reset)' --all

curl
git
sed

grep
curl

curl -I http://google.com
gets the headers for a given page

# Delete last commit


git reset --hard HEAD~1

# Replaces all instances of FOO piped through stdi


n with BAR
sed 's/FOO/BAR/g'

# search for a string pattern in a file


grep "string pattern" "filename"

# Get my external IP address


curl ifconfig.me/ip

26 0
27 1
25 0

25 1
25 1

# Get my remote host


curl ifconfig.me/host
# Get my user agent
curl ifconfig.me/ua
# Get port
curl ifconfig.me/port

man
zip

find

mkdir

http://bropages.org/browse

# Show the ASCII table


man ascii

# put README.txt and test.c into the zip file name


d archive.zip
zip archive.zip README.txt test.c

# Finds all files in and under the current directo


ry that contain 'foo' in their name
find . -iname '*foo*'

# Creates the 'bar' directory, as well as 'foo' an


d 'baz' if they don't already exist
mkdir -p '~/foo/baz/bar'

24 2
22 0

22 1

22 1

4/174

8/3/2016

rsync

bro
tmux

bro: just get to the point!

# Makes the remote folder look *exactly* like the


source dir including file
# permissions, ownership, etc.
# -a Archive (sets a number of things).
# -v Versose
# --delete Dangerous! Will remove files on the re
mote which do not exist
#
in source.
# Be sure you have remotedir set properly and mayb
e run without --delete
# once to ensure that it does what you think it wi
ll do.
rsync -av --progress --delete sourcedir user@host:
remotedir

# Add an entry to bro for the curl command


bro add curl

# Creates a new tmux session named 'mysession'


tmux new -s mysession

21 0

23 2
21 0

# Lists the current sessions


tmux ls
# Attaches to an existing session
tmux attach -t mysession
# Kills a tmux session
tmux kill-session -t mysession

bro
sed
xargs

# Update your bropages


gem update bropages

# search and replace, inplace


sed -i 's/typo/what_you_meant/' list of files

# find all file name ending with .pdf and remove t


hem
find -name *.pdf | xargs rm -rf

21 0
21 1
20 0

#if file name contains spaces you shuold use this


instead
find -name *.pdf | xargs -I{} rm -rf {}

rsync

http://bropages.org/browse

# Sync 2 folders/destinations recursively, overwri


te, update, verbosely
rsync -ruv ~/source/dir ~/destination/dir

20 1

5/174

8/3/2016

touch

apt-get

bro: just get to the point!

# Updates the timestamp of the file 'temp' or crea


tes it if it doesn't exist
touch temp

# Install Packages: Ruby Gem & Nano.


sudo apt-get install gem nano

19 0

19 0

# Remove Packages(keep configuration files)


sudo apt-get remove gem nano
# Remove Packages(remove configuration files)
sudo apt-get purge gem nano
# Get Updated Package Index Files(Always Use Befor
e Upgrade)
sudo apt-get update
# Upgrade All Packages
sudo apt-get upgrade

ssh

chmod

awk
gcc

tar

# ssh port forwarding


# route all local requests to 8080 to remote port
80
ssh -L 8080:localhost:80 user@remoteserver

# Allow my user (u) to "execute" (x) the file bro.


rb
chmod u+x bro.rb

# Print only the first column of the input


awk '{print $1;}'

# gcc is used to compile C source code, for C++ (a


nd even C) use g++
# use -o to specify your own output filename
gcc ".c file here" -o "outfile name here"
# g++ uses virtually the same syntax
# to specifiy optimization levels, use -O
gcc -Os ".c file here" -o "outfile name here"

# Create a tar file:


tar cf archive.tar file1 [...]

18 0

18 0

18 0
18 0

18 0

# Create a compressed tar file:


tar cjf archive.tar.bz2 file1 [...]
# Create a older compressed tar file:
tar czf archive.tar.gz file [...]
# Extract a .tar, .tar.gz, .tgz, .tar.bz, or .tbz2
http://bropages.org/browse

6/174

8/3/2016

bro: just get to the point!

file:
tar xf archive.tbz2
# list the files inside the archive:
tar tf archive.tar

sudo

# Run previous command with sudo


sudo !!

17 0

# Run a command run X commands ago with sudo (X id


a number)
sudo !-X
sudo !-2

ps

tail

dd

grep

unzip
du

#Displays all of the running processes on a machin


e which contain the word "caseysProcess"
ps aux | grep caseysProcess

# View the end of a file and "follow" it. This is


especially useful for watching changes in a log f
ile.
tail -f logFile.txt

# write an image to the disk at sdb with a buffers


ize of 1 megabyte
dd if=/path/to/liveusb.img of=/dev/sdb bs=1M

# Filter out unwanted results. (This example will


show all files in a directory that are not ruby f
iles.)
ls | grep -v *.rb

# unzip a zip file, extract in current directory


unzip -e archive.zip

# File size in human-readable format(-h) of everyt


hing in that folder
du -sh *

16 0

16 0

16 0

17 1

15 0
15 0

# List human readable size of all sub folders from


current location
du -h --max-depth=1
# Sorted filesystem usage
du -s * | sort -nr

tar
http://bropages.org/browse

15 0
7/174

8/3/2016

bro: just get to the point!

# Unzip to target directory


tar -xvf file.zip -C target_directory_path

wc
clear
curl

gpg

# count the number of lines in a file


wc -l [file ...]

# Clears away your screen, bro


clear

# POST request
curl --data "param1=value1&param2=value2" http://w
ww.bropages.com

# Encrypt doc.txt for bob


gpg --output doc.gpg --encrypt --recipient bob@dom
ain.org doc.txt

14 0
14 0
14 0

14 0

# Decrypt doc.gpg
gpg --output doc.txt --decrypt doc.gpg
# Generate a new key pair
gpg --gen-key
# Search for a public key online
gpg --search-keys bob@domain.org
# Export a public key
gpg --armor --export bob@domain.org
# Import a public key
gpg --import keyfile
# Export a private key
gpg --export-secret-key bob@domain.org
# Import a private key
gpg --allow-secret-key-import --import private.key
# Mark a key as trusted. At prompt: trust, 5, save
gpg --edit-key bob@domain.org
# Validate a key by signing it with your own key.
At prompt: fpr, sign
gpg --edit-key bob@domain.org

crontab

http://bropages.org/browse

#Edit crontab for current user


#
#Allows bro to add cron job scheduled command
#Entries added in the following format:
# * * * * * command to execute
#|||||

14 0

8/174

8/3/2016

bro: just get to the point!

#|||||
# | | | | |------ day of week (0 - 6) (0 to 6 are
Sunday to Saturday, 7 is Sunday, the same as 0)
# | | | |------------- month (1 - 12)
# | | |--------------------- day of month (1 - 31)
# | |------------------------------ hour (0 - 23)
# |------------------------------------- min (0 59)
#
# e.g.
# 15 * * * * ~./brofist
# Would run the brofist command once an hour on th
e 15th minute of every hour
crontab -e

cd
yes
curl

dig

unzip
gem
ls

sl

# Change to the previous directory


cd -

# Repeatedly outputs "kitty"


yes kitty

# Post a file to a shiny enterprise webservice api


curl -d @invoice.pdf -X POST http://devnull-as-a-s
ervice.com/dev/null

# Scrub all extra information and get all record f


or domain
dig +nostats +nocomments +nocmd +noquestion +recur
se YOUR.DOMAIN any

# Extracts contents to specified directory


unzip archive.zip -d /path/to/other/directory/

# get the latest update of a certain gem


gem update bropages

# Prints all files, including "hidden" files/direc


tories (ones starting with '.')
ls -a

# Opens an advanced locomotive simulation.


sl

13 0
14 1
13 0

14 1

13 0
13 1
12 0

12 0

# Opens an advanced flying locomotive simulation


sl -F
# Opens an advanced runaway locomotive simulation
http://bropages.org/browse

9/174

8/3/2016

bro: just get to the point!

with screaming passengers


sl -a
# Opens a different advanced locomotive simulation
sl -l

rm

# used to remove (delete) files or directories


# delete the file or directory "foo"
rm foo

13 1

# recursively delete all subdirectories and files


in directory "foo"
rm -rf foo/

nmap

vim

# Scans the range 192.168.1.0-192.168.1.255 for po


rt 80
nmap -p80 192.168.1.0/24

# Vim open multiple files


vim -O file1 file2 # Vertical split
vim -o file1 file2 # Horizontal split
vim -p file1 file2 # Tabbed

12 0

13 1

# You can use wildecard too


vim -o *.txt

lsof
useradd

chmod

curl

# List all web processes


lsof -i :80

# Create a new user, set ahis shell, create his ho


me directory, set it to /home/john, and name the u
ser
useradd -s /bin/bash -m -d /home/john john

# allow only root access to a particular folder.


Useful for hiding your pr0n and any other files y
ou don't want anyone else to see.
sudo chmod -R 700 secret_folder

# POST the JSON encoded object


#{
#
"command": "sup",
#
"chill": true
#}
# with header 'X-BRO-HEADER' and value 91384934 to
api.bro.com
curl -X POST api.bro.com -d '{"command": "sup", "c

12 0
13 1

12 0

12 0

hill": true}' -H "X-BRO-HEADER: 91384934"

http://bropages.org/browse

10/174

8/3/2016

find

say

pbcopy

df

echo

bro: just get to the point!

# Searches entire computer starting at root for th


e file "hashClass.java". Throws out error output
by sending it to /dev/null.
# If we didn't throw out the error output, we'd ge
t a bunch of "User doesn't have permissions to vie
w directory" errors
find / -name "hashClass.java" 2>/dev/null

# [MAC-ONLY]
# Frighten your coworkers
say -v "Deranged" "Your soul...belongs to me"

# Represents the clipboard (pasteboard?) on a Mac.


This command sends a file (myfile.txt) to pbcop
y, so now I can paste it onto another
# window
cat myfile.txt | pbcopy

# Display free and used disk space in human readab


le format
df -h

#the echo command outputs the result of what it re


ceive as input
echo "hello bro!"
> hello bro!

11 0

11 0

11 0

11 0

12 1

#this output can be a command be the result of a c


ommand, for example 'pwd' to output the Present Wo
rking Directory
echo $(pwd)
> /path/to/the/present/working/directory
#this could be useful to log stuff in a document,
using '>' or '>>' : hereafter, the commands add t
he pwd to a document
echo $(pwd) >> ~/logs/logingmypwd
#it can also have colors!! using the -e option and
colors codes
echo -e "\e[0;32mHello This Text is Green!![0mBut
This Text Isn't"

ifconfig

## Show or configure network interfaces:

12 1

# Show all network interfaces:


ifconfig -a
# Show a network interface:
ifconfig eth0
ifconfig wlan0
http://bropages.org/browse

11/174

8/3/2016

bro: just get to the point!

# Assign an address to an interface (may need root


or sudo privileges):
ifconfig eth0 192.168.108.24
# Create a virtual interface linked to a real one
and assign an address:
ifconfig eth0:1 10.0.0.53
# Enable or disable an interface:
ifconfig eth0 down
ifconfig wlan1 up

7z

# Unzip a 7z archive: x for extract


7z x archive.7z

11 0

# Unzip without directory structure: e for extract


7z e archive.7z
# Create a 7z archive: a for add
7z a archive.7z foo.c bar.h baz.h
# See what's in an archive: l for list
7z l archive.7z
# Update archive if files in current directory hav
e changed: u for update
7z u archive.7z
# Remove files from archive: d for delete:
7z d archive.7z foo.c

wget

mv
cut

grep

rvm
http://bropages.org/browse

# Download a file from a webserver and save to har


d drive.
wget http://www.openss7.org/repos/tarballs/strx250.9.2.1.tar.bz2

# move a file
mv source_file.txt ~/new/location.txt

# To parse the word sir (using the ' ' as a delime


ter, the choosing the second word)
echo "hello sir" | cut -d' ' -f2

# grep recursively through files of a certain typ


e, such as .py files
grep -R --include="*.py" "pattern" /path/to/dir

# Switches RVM to use Ruby version 1.9.2 and sets


it as the default

11 0

11 0
11 0

11 0

10 0
12/174

8/3/2016

bro: just get to the point!

rvm --default use 1.9.2

history

alias
ps
mount

ruby
python

ack
wget

ipconfig
git
http://bropages.org/browse

# Displays all previous commands run from this use


r containing the phrase "execute". Numbers each c
ommand. You can then run one of the commands by t
yping !number
$ history | grep -i execute
675 ./executeShellCommand
678 ./transferFiles -o LARGE
$ !678
#runs ./transferFiles -o LARGE

# make 'sis' equivalent to 'bro'


alias sis=bro

# Show all processes running by a specific user


ps -u username

# Mount a shared folder on another computer on you


r network (requires cifs-utils)
mount -t cifs //192.168.1.2/path/to/share /my/moun
t/point

# run ruby program "program.rb"


ruby program.rb

# Serve the current directory over HTTP on port 80


00
python -m SimpleHTTPServer

# search for 'foo' on .rb files, recursively


ack --ruby -R 'foo'

# Download an entire website (more robust than wge


t -m)
wget --random-wait -r -p -e robots=off -U mozilla
http://www.example.com

# This isn't Windows.


ifconfig

# Setup git global configuration


git config --global user.name "John Doe"

10 0

11 1
10 0
10 0

10 0
10 0

10 0
10 0

10 0
10 0
13/174

8/3/2016

bro: just get to the point!

git config --global user.email johndoe@example.com


git config --global core.editor vim

date
ls
cat

screen

# Prints today's date in YYMMDD (eg 131021)


date "+%y%m%d"

# List only directories.


ls -d */

# random hex-calculation to let your terminal look


busy
cat /dev/urandom | hexdump -C | grep "ca fe"

# Detach from screen


<ctrl>+<a>, <ctrl>+<d>

10 0
10 0
10 0

10 0

# Connect to named screen (creates session if it d


oesn't exist)
screen -R SomeScreen
# Reconnect to existing screen session
screen -r SomeScreen

gzip
cat
awk
ag

# Compresses a file into a .gz file


gzip file # creates file.gz

#cat is used to read text files.


cat file.txt

# Print only the last column of the input


awk '{print $NF}'

# Recursively search for text 'foo'


ag foo

9 0
13 4
9 0
9 0

# Recursively search for filename 'file'


ag -g file

nc

# netcat-traditional (natcat-openbsd may differ)


# (Listens on/connects to) a port and communicate
on STDIN/STDOUT

9 0

# listening
$ nc -l -p 8888
# connecting
http://bropages.org/browse

14/174

8/3/2016

bro: just get to the point!

$ nc example.com 80
HEAD / HTTP/1.1<enter>
<enter>

vim

du

shutdown
awk

# Vim edit remote file (Works with FTP and SFTP to


o)
vim scp://user@host/path/file.name

# File size in human-readable format(-h) of everyt


hing in that folder
du -sh *

# restart machine in 30 minutes


shutdown -r +30

# print first 10 lines of file (emulates behavior


of "head")
awk 'NR < 11'

9 0

9 0

9 0
9 0

# print first line of file (emulates "head -1")


awk 'NR>1{exit};1'
# print the last 2 lines of a file (emulates "tail
-2")
awk '{y=x "\n" $0; x=$0};END{print y}'
# print the last line of a file (emulates "tail 1")
awk 'END{print}'
# print only lines which match regular expression
(emulates "grep")
awk '/regex/'
# print only lines which do NOT match regex (emula
tes "grep -v")
awk '!/regex/'
# print the line immediately before a regex, but n
ot the line
# containing the regex
awk '/regex/{print x};{x=$0}'
awk '/regex/{print (x=="" ? "match on line 1" :
x)};{x=$0}'
# print the line immediately after a regex, but no
t the line
# containing the regex
awk '/regex/{getline;print}'
# grep for AAA and BBB and CCC (in any order)
awk '/AAA/; /BBB/; /CCC/'

http://bropages.org/browse

15/174

8/3/2016

bro: just get to the point!

# grep for AAA and BBB and CCC (in that order)
awk '/AAA.*BBB.*CCC/'
# print only lines of 65 characters or longer
awk 'length > 64'
# print only lines of less than 65 characters
awk 'length < 64'
# print section of file from regular expression to
end of file
awk '/regex/,0'
awk '/regex/,EOF'
# print section of file based on line numbers (lin
es 8-12, inclusive)
awk 'NR==8,NR==12'
# delete leading whitespace (spaces, tabs) from fr
ont of each line
# aligns all text flush left
awk '{sub(/^[ \t]+/, ""); print}'
# delete trailing whitespace (spaces, tabs) from e
nd of each line
awk '{sub(/[ \t]+$/, "");print}'
# delete BOTH leading and trailing whitespace from
each line
awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'
awk '{$1=$1;print}'
# insert 5 blank spaces at beginning of each line
(make page offset)
awk '{sub(/^/, "
");print}'
# align all text flush right on a 79-column width
awk '{printf "%79s\n", $0}' file*
# center all text on a 79-character width
awk '{l=length();s=int((79-l)/2); printf "%"(s+
l)"s\n",$0}' file*
# substitute "foo" with "bar" ONLY for lines which
contain "baz"
awk '/baz/{gsub(/foo/, "bar")};{print}'
# substitute "foo" with "bar" EXCEPT for lines whi
ch contain "baz"
awk '!/baz/{gsub(/foo/, "bar")};{print}'
# change "scarlet" or "ruby" or "puce" to "red"
awk '{gsub(/scarlet|ruby|puce/, "red"); print}'
# reverse order of lines (emulates "tac")
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j
--] }' file*
# if a line ends with a backslash, append the next
http://bropages.org/browse

16/174

8/3/2016

bro: just get to the point!

line to it
# (fails if there are multiple lines ending with b
ackslash...)
awk '/\\$/ {sub(/\\$/,""); getline t; print $0 t;
next}; 1' file*
# print and sort the login names of all users
awk -F ":" '{ print $1 | "sort" }' /etc/passwd
# print the first 2 fields, in opposite order, of
every line
awk '{print $2, $1}' file
# switch the first 2 fields of every line
awk '{temp = $1; $1 = $2; $2 = temp}' file
# print every line, deleting the second field of t
hat line
awk '{ $2 = ""; print }'
# print in reverse order the fields of every line
awk '{for (i=NF; i>0; i--) printf("%s ",i);printf
("\n")}' file
# remove duplicate, consecutive lines (emulates "u
niq")
awk 'a !~ $0; {a=$0}'
# remove duplicate, nonconsecutive lines
awk '! a[$0]++'
# most concise
script
awk '!($0 in a) {a[$0];print}'
# most efficie
nt script
# concatenate every 5 lines of input, using a comm
a separator
# between fields
awk 'ORS=%NR%5?",":"\n"' file

scp

kill

ssh

http://bropages.org/browse

# Download a file from a remote location with port


specified
scp -P port-number user@remote_host:path/to/source
path/to/destination

# Sends a "SIGKILL" signal to process with id 925.


The -9 option sends the kill signal. The 925 id
was found by using 'ps'.
kill -9 925

# Create ssh tunnel with SOCKS interface on localh


ost:1234
ssh -D 1234 user@remotemachine

9 0

8 0

8 0

17/174

8/3/2016

g++

netstat

brew

bro: just get to the point!

# Compiles a C++ programm with output as output


# So you can run ./output
g++ input.cpp -o output

# show the TCP/UDP listening sockets and their pro


grams
netstat -tulp

# Install the package "git"


brew install git

8 0

10 2

8 0

# Remove the package "git"


brew uninstall git
# Search for packages with "fish" in the name
brew search fish

cp

df

diff

rm

nmap

head
gzip
usermod
http://bropages.org/browse

# Copy /home/el/file1.txt to /home/el/file1copy.tx


t
cp /home/el/file1.txt /home/el/file1copy.txt

# display used disk space for each mount point wit


h sizes nicely formatted
df -alh

# Show the difference between two files without cr


eating temporary files
diff <(sort file1) <(sort file2)

# Delete all files in a folder that are NOT .foo,


.bar or .baz
rm !(*.foo|*.bar|*.baz)

# Stealth (slowest) TCP/UDP scan of 192.168.1.0/24


for first 1024 ports
nmap -sT -sU -T5 192.168.1.0/24 -p 1-1024

# Print the first 10 lines of sample.txt


head -n 10 sample.txt

# gzip a file and keep the original


gzip < file > file.gz

9 1

8 0

8 0

8 0

8 0

8 0
8 0
8 0
18/174

8/3/2016

bro: just get to the point!

# Add existing user to existing group


usermod -a -G group_name user_name

grep

zip

telnet

dc

date
tar

scp

# grep for IP addresses


grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]
|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][09]|[01]?[0-9][0-9]?)' input.txt > output.txt

# Recursively zip all files in the directory foo i


nto foo.zip
zip -r foo foo

# Connects to a telnet server or TCP socket on por


t 3030 of 192.168.1.10
telnet 192.168.1.10 3030

#
# 'dc' can be used as reverse polish notation calc
ulator
# Here we set set the decimal precision to 3 (1.00
1) via the command '3 k',
# then we calculate '3 / 2'. Lastly we print the r
esult with 'n'
dc -e '3 k 3 2 / n'

# Print the current Unix Timestamp.


date +%s

# package up a folder and ignore a subfolder:


tar --exclude="project/.git" -czvf ~/Downloads/pro
ject.tgz project/

# Transfer folder and its content to remote comput


eR

8 0

12 4

8 0

8 0

8 0
9 1

8 0

scp -r folder/ user@host:/path/to/destination

tr

mysql
http://bropages.org/browse

# Replaces all newlines with spaces in the file 'f


oo'
tr '\n' ' ' < foo > foo

# Run a sql file


mysql -u <user> -p<password> -h host -P port < fil
e.sql

8 1

7 0
19/174

8/3/2016

awk
git

sed
pacman

bc
alias
less

vi
lynx
ping

ffmpeg

http://bropages.org/browse

bro: just get to the point!

# Print each line of input, with line numbers


awk '{print NR":",$0;}'

# git init creates a .git directory in the current


folder.
git init

# strip trailing whitespace from a file


sed -i 's/\s\+$//' [file]

# Update all the system's packages


# Note: This command synchronizes the repository d
atabase before updating packages.
pacman -Syu

# use bc to do simple calculations


echo "(1+1+2)/3" |bc

# Make grep colorize its output


alias grep='grep --color=auto'

# Opens up a file in a read-only editor. AFter lau


nch, use F (Shift+f) to tail a running file.
less somefile.txt

# run the vi editor against filename foobar.txt


vi foobar.txt

# run the lynx browser and load www.google.com


lynx www.google.com

# Beep when a machine starts responding to ping ag


ain
ping -i 60 -a IP_address

# Converts a FLAC file to an MP3 at 320 kbs


#
# ffmpeg should automatically use the proper encod
er based off of extension
# ffmpeg should also convert metadata automaticall
y
ffmpeg -i input_file.flac -ab output_file.mp3

7 0
9 2

7 0
7 0

7 0
7 0
7 0

8 1
7 0
7 0

7 0

20/174

8/3/2016

brew

bro: just get to the point!

# your_comment_here
# Search for packages with "fish" in the name
brew search fish

8 1

# Get info including a URL about the package "fis


h"
brew info fish
# Install the package "fish"
brew install fish
# Remove the package "fish"
brew uninstall fish
# List installed packages
brew list
# Update packages including brew itself (dosen't u
pgrade)
brew update
# Upgrade packages (after you updated)
brew upgrade
# Troubleshoot
brew doctor
your_command_here

rename

# strip extension from all files matching *.bak


rename -x *.bak

8 1

# strip the .bak extension from all files (by rege


x)
rename 's/\.bak\z//' *

make

find

http://bropages.org/browse

# Parallelize your make. Utilise your cores to the


ir full potential! Substitute the number for howev
er many physical cores your machine has.
make -j4

# directory -> chmod 700


# file executable -> chmod 700
# file -> chmod 600
# You can apply this to directory that needs more
secure permission
# recursively. Like `~/.ssh`. `+` means run at onc
e, not one by one. Like
# `xargs`.
find .private -type d -execdir chmod 700 '{}' + \
-or -type f -executable -execdir chmod 777 '{}' +
\
-or -type f -execdir chmod 600 '{}' +

7 0

7 0

21/174

8/3/2016

grep

bro
man

tmux

sudo

dig

bro: just get to the point!

# Searches for the exact string "jdk1.7.0", treati


ng '.' as a period rather than as any character
grep -F "jdk1.7.0"

# get bro for <smth> without thanks/...no lines


bro <smth> | grep -B1 <smth>

# Search man page names and short descriptions for


STRING
man -k STRING

# remember that most things you want to do in tmux


are not calling tmux from the cli
# but, rather, Control-b then some other keystroke
while running the multipane tmux
C-b, c #new window
C-b, [ #copy
C-b, = #paste from recent
C-b, ] #paste most recent
C-b, % #split panes
C-b, w #switch to another window
C-b, q #switch to another pane
C-b, x #kill this pane
C-b, :quit
#kill this pain

# Allows you to execute sudo commands for 5 minute


s without repeatedly entering a password for 5 min
utes. Each successive call to 'sudo -v' extends th
e lease by +5 minutes
sudo -v

# Find IP where domain resolves and TTL


dig EXAMPLE.COM

7 0

11 4
7 0

7 0

7 0

7 0

# Find IP where domain resolves and TTL using a sp


ecific name server
dig EXAMPLE.COM @EG.NAMESERVER.COM
# List mail servers
dig example.com MX +noall +answer
# Reverse DNS lookup for a specific IP address
dig -x 127.0.0.1

unrar

http://bropages.org/browse

# Extract an archive to specified directory. It is


important to have a / at the end of the path.
unrar e <archive name> <path to extract>
~

7 0

22/174

8/3/2016

cowsay

cat

bro: just get to the point!

# Shows an ASCII cow saying "Let's eat, Grandma!"


in the terminal.
cowsay "Let's eat, Grandma!"

# cat concatenates a list of files


cat file1 file2

7 0

7 0

# abusing cat to read a single file is considered


bad practice
cat onefile | foo # DON'T DO THIS
# instead use the following
< onefile foo

date

http://bropages.org/browse

# date +FORMAT
%%
a literal %
%a
locale's abbreviated weekday name (e.
g., Sun)
%A
locale's full weekday name (e.g., Sunda
y)
%b
locale's abbreviated month name (e.g.,
Jan)
%B
locale's full month name (e.g., Januar
y)
%c
locale's date and time (e.g., Thu Mar 3
23:05:25 2005)
%C
century; like %Y, except omit last two
digits (e.g., 21)
%d
day of month (e.g, 01)
%D
date; same as %m/%d/%y
%e
day of month, space padded; same as %_d
%F
full date; same as %Y-%m-%d
%g
last two digits of year of ISO week num
ber (see %G)
%G
year of ISO week number (see %V); norma
lly useful only with %V
%h
same as %b
%H
hour (00..23)
%I
hour (01..12)
%j
day of year (001..366)
%k
hour ( 0..23)
%l
hour ( 1..12)
%m
month (01..12)
%M
minute (00..59)
%n
a newline
%N
nanoseconds (000000000..999999999)
%p
locale's equivalent of either AM or PM;
blank if not known
%P
like %p, but lower case
%r
locale's 12-hour clock time (e.g., 11:1
1:04 PM)
%R
24-hour hour and minute; same as %H:%M
%s
seconds since 1970-01-01 00:00:00 UTC
%S
second (00..60)
%t
a tab
%T
time; same as %H:%M:%S
%u
day of week (1..7); 1 is Monday

11 4

23/174

8/3/2016

bro: just get to the point!

%U
week number of year, with Sunday as fir
st day of week (00..53)
%V
ISO week number, with Monday as first d
ay of week (01..53)
%w
day of week (0..6); 0 is Sunday
%W
week number of year, with Monday as fir
st day of week (00..53)
%x
locale's date representation (e.g., 12/
31/99)
%X
locale's time representation (e.g., 23:
13:48)
%y
last two digits of year (00..99)
%Y
year
%z
+hhmm numeric timezone (e.g., -0400)
%:z
+hh:mm numeric timezone (e.g., -04:00)
%::z
+hh:mm:ss numeric time zone (e.g., -04:0
0:00)
%:::z
numeric time zone with : to necessary pre
cision (e.g., -04, +05:30)
%Z
alphabetic time zone abbreviation (e.
g., EDT)

tail

source

emacs

cd

php

# To show the last [n] lines of an logfile. Here 2


0 lines:
tail -n20 logfile.log

# your_comment_here
WTF does source do?
When a script is run using `source' it runs within
the existing shell, any variables created or modi
fied by the script will remain available after the
script completes

# Use emacs to open my-file within the terminal (n


ot in a separate window)
emacs -nw my-file

# Changes the current working directory to two dir


ectories back.
cd ../..

# Start the builtin webserver on port 8000


# serving the specified directory "/foo"

7 0

7 0

7 0

6 0

6 0

php -S localhost:8000 -t /foo

mutt

# open the default inbox


mutt

6 0

# start writing an email to me@example.com


http://bropages.org/browse

24/174

8/3/2016

bro: just get to the point!

mutt me@example.com
# send an email with the body "hello" and subject
"test" to me@example.com
echo "hello" | mutt me@example.com -s

firefox

# open firefox profile manager


firefox -P

7 1

# open a given profile


firefox -P nameofmyprofile
# open another profile without shutting down the f
irst one
firefox -P nameofmyotherprofile -no-remote

pacman
pacman

ps
alias
node
pip
git
bc
du
http://bropages.org/browse

# install package "foo"


pacman -S foo

# [Arch Linux based distros only]


# Remove orphan packages and their configuration f
iles
# Note: be sure you want to do this!
pacman -Rns $(pacman -Qtdq)

# display info about a given process


ps -ef | grep my_shitty_script.pl

# Show all defined aliases


alias

# Launches interactive node.js shell


node

# pip update all packages


pip install -U

# Create and check out a new branch


git checkout -b mybranch

# Make calculations with floating point


bc -l

6 0
6 0

7 1
6 0
6 0
8 2
6 0
6 0
6 0
25/174

8/3/2016

bro: just get to the point!

# List human readable size of all sub folders from


current location
du -h --max-depth=1

shutdown
sort

# shutdown machine immediately


shutdown -h now

# Sort a file alphabetically:


sort filename

6 0
6 0

# Sort your command history alphabetically, skippi


ng the command number:
history | sort -k 2
# Lines look like this:
#
23 anothercommand
#
22 somecommand
#
24 stillanothercommand
# Sort files by number of matches in grep results:
grep -c searchterm * | sort -t: -n -k 2
# Lines look like this:
#
filename:2
#
anotherfile:3
# Sort files by human readable size in a director
y:
du -h --max-depth=1 | sort -h
# Lines look like this:
#
4.0K
./SomeDirectory
#
12K
./AnotherDirectory
#
2.4M
./SomeFile
#
1.5G
./LargeFile

tee
tail

nmap

ls

http://bropages.org/browse

# echo the text "hi" to STDOUT and to file.txt


echo "hi" | tee -a file.txt

# View the end of a file, and "follow" it. If the


file is replaced or truncated, follow the new fil
e that is now pointed to by the filename
tail -F logFile.txt

# Shows all active IP adresses on the local networ


k (replace 192.168.178. with your LAN IP)
nmap -sP 192.168.178.0/24

# Show result in one colomn


ls -1

6 0
6 0

6 0

6 0

26/174

8/3/2016

aria2

bro: just get to the point!

# Download from WEB


$ aria2c http://example.org/mylinux.iso

6 0

# Download from 2 sources


$ aria2c http://a/f.iso ftp://b/f.iso
# Download using 2 connections per host:
$ aria2c -x2 http://a/f.iso
#BitTorrent
$ aria2c http://example.org/mylinux.torrent
#BitTorrent Magnent URL:
$ aria2c 'magnet:?xt=urn:btih:248D0A1CD08284299DE7
8D5C1ED359BB46717D8C'
# Metalink:
$ aria2c http://example.org/mylinux.metalink
# Download URIs found in text file:
$ aria2c -i uris.txt

chsh

mysqldump

unzip
javac
telnet

http://bropages.org/browse

# use option -s to set the shell of the current us


er (yourself ; )
# use which to find the full path of the shell
# $ which zsh
# => /usr/bin/zsh
# then set your new shell
#
# note:
# some apps have an explicit shell path
# GNUShell expects something like
# shell "/usr/bin/zsh" in its .screenrc
#
chsh -s /usr/bin/zsh

# Backup data and the structure from a database to


a .sql file
mysqldump -u [user] -p[password] [database_name] >
file.sql

# use unzip -l to see the contents of an archive


unzip -l archive.zip

# Compile JavaFile.java into a Java class file.


javac JavaFile.java

# Watch Star Wars over commandline


telnet towel.blinkenlights.nl

6 0

6 0

6 0
6 0
6 0

27/174

8/3/2016

curl

gunzip

bro: just get to the point!

# POST the contents of a file (data.json in this e


xample)
curl -X POST -d @data.json http://httpbin.org/post

# Decompress a Gzip file (removing/replacing the o


riginal compressed file)
gunzip file.gz

6 0

6 0

# Decompress a Gzip file (keep the original compre


ssed file)
gunzip -c file.gz > file.out

cut
lolcat

# get the first 5 character of a string


echo 'do you even cut bro?' | cut -c1-5

# adds rainbow color to the input text


lolcat example.txt

6 0
6 0

# animates with rainbow color to any input text


lolcat -a example.txt

youtube-dl

grep

perl

openssl

pacman
pacman
http://bropages.org/browse

# Download just audio (mp3) from youtube


youtube-dl -x --audio-format="mp3" "https://www.y
outube.com/watch?v=d-diB65scQU"

# Case insensitve search through all of the files


recursively starting from my current directory fo
r the string "computesSum".
grep -ir computesSum *

# replace hamburgers with hotdogs in place in a fi


le
perl -p -i -e 's/hamburgers/hotdogs/g' juice_stan
d.txt

# get certiface from remote server


openssl s_client -connect www.domain.com:443 -show
certs

# look for a package in the repositories


pacman -Ss foo

# [Arch Linux based distros only]


# See how may packages are installed
pacman -Qsq | wc -l

6 0

7 2

5 0

5 0

5 0
5 0
28/174

8/3/2016

ping
yes
curl

sshfs

nano

seq
convert
tree
git

open

history

http://bropages.org/browse

bro: just get to the point!

# Pings a domain.
ping www.google.com

# Repeatedly outputs "y"


yes

# Get the header of a page. Very handy for checkin


g HTTP status, such as redirects. Also, check out
httpstatus.es as a quick reference.
curl -I http://somapage.com

# mount foobar from remote host to existing local


mountpoint, show Foobar as
# volume name in Finder and automatically reconnec
t upon loss of connection.
sshfs user@host:/foobar /Volumes/foobar -ovolname=
Foobar,reconnect

# open the file called file1.txt for editing in th


e nano editor
nano file1.txt

# Print 000,001,002, ... ,100


seq -s , -w 0 100

# convert all jepeg's in a directory into a PDF


convert *.jpg output.pdf

# display all files and folders in a 'tree' layout


tree ~

# allows you to commit your changes with a message


detailing what you have changed
git commit -m "Fixed unit test"

# Opens file or directory using the specified app


lication (OS X)
open myfile.pdf -a Safari

# Show most used commands


history | awk '{a[$2]++}END{for(i in a){print a[i]
" " i}}' | sort -rn | head

5 0
5 0
6 1

5 0

6 1

5 0
5 0
6 1
5 0

5 0

5 0

29/174

8/3/2016

man

vim

git
htop

bro: just get to the point!

# Search the section 3 of the manual for entry "pr


intf"
man 3 printf

# Starts vim with a blank vimrc. (Effectively star


ting vim in "safe" mode)
vim -u NONE

# pick range commits


git cherry-pick [commit id]

# To launch (you can interact with it using shortc


uts)
htop

5 0

5 0

5 0
6 1

# Change the Output Refresh Interval


htop -d 10

npm
passwd

git stash

# Reduce duplication of dependencies


npm dedupe

# Change the password for user called el, (press c


trl+d to cancel)
passwd el

# Save unfinished work onto a stack - you can get


it back later
git stash

5 0
5 0

5 0

# List your stashes


git stash list
# Get back the most recent stash
git stash apply
# Get back an earlier stash (third from top in thi
s case)
git stash apply stash@{3}

md5

nmap
http://bropages.org/browse

# print the md5 sum of a given file


md5 -q filename
# print the md5 sum of a given string
md5 -qs 'string'

# ping scan of the 192.168.1.0 network


nmap -sP 192.168.1.0/24

5 0

5 0
30/174

8/3/2016

rpm

bro: just get to the point!

# RPM Package Manager


# install a package
rpm -Uvh package.rpm

5 0

# install a package that doesn't have needed depen


dencies (never do this)
rpm -Uvh --nodeps --force package.rpm
# List information about an installed package
rpm -qi package
# List information about a package file
rpm -qip package.rpm
# Remove a package
rpm -e package
# Remove a package without checking dependencies
(never do this)
rpm -e --nodeps package
# Search for a package
rpm -qa |grep package
# Output package information based on package vari
ables
rpm -q package --qf %{name}-%{version}%{arch}
# List known variables
rpm --showrc
# What packages does this package require
rpm -q package --requires
# What capabilities does this package provide
rpm -q package --provides
# What packages require this package/capability
rpm -q package --whatrequires
# Install package into another base directory
rpm --root /some/path -Uvh package.rpm
# Show the scripts (postun,preun,post,pre) in the
package
rpm -q package --scripts
# Rebuild rpm database
rpm --rebuilddb

for
cd
http://bropages.org/browse

# Do stuff 10 times
for i in $(seq 10); do echo $i; done

5 0
6 1
31/174

8/3/2016

bro: just get to the point!

# Changes to the directory you were in before the


current directory
cd -

git
submodule

# Add a submodule as "name"


git submodule add ssh://url name

5 0

# Update all submodules (after git clone)


git submodule update --init --recursive

mv

tr
wget

gdb

cp

perl

# Move multiple files into a directory


mv file1.txt file2.txt file3.txt destination_folde
r/

# Convert FOO to lowercase


echo FOO | tr '[:upper:]' '[:lower:]'

# Save file into directory


# (set prefix for downloads)
wget -P path/to/directory http://bropages.org/bro.
html

# Starts GDB and breaks into the progress with the


given process ID
gdb program 4242

# copy all file but skip existing files (do not ov


erwrite)
cp -vrn ../source/* ./dest/

# Double space a file


perl -pe '$\="\n"'
perl -pe 'BEGIN { $\="\n" }'
perl -pe '$_ .= "\n"'
perl -pe 's/$/\n/'

5 0

5 0
5 0

5 0

5 0

5 0

# Double space a file, except the blank lines


perl -pe '$_ .= "\n" unless /^$/'
perl -pe '$_ .= "\n" if /\S/'
# Triple space a file
perl -pe '$\="\n\n"'
perl -pe '$_.="\n\n"'
# N-space a file
perl -pe '$_.="\n"x7'
# Add a blank line before every line
http://bropages.org/browse

32/174

8/3/2016

bro: just get to the point!

perl -pe 's//\n/'


# Remove all blank lines
perl -ne 'print unless /^$/'
perl -lne 'print if length'
perl -ne 'print if /\S/'
# Remove all consecutive blank lines, leaving just
one
perl -00 -pe ''
perl -00pe0
# Compress/expand all blank lines into N consecuti
ve ones
perl -00 -pe '$_.="\n"x4'
# Fold a file so that every set of 10 lines become
s one tab-separated line
perl -lpe '$\ = $. % 10 ? "\t" : "\n"'
# Number all lines in a file
perl -pe '$_ = "$. $_"'
# Number only non-empty lines in a file
perl -pe '$_ = ++$a." $_" if /./'
# Number and print only non-empty lines in a file
(drop empty lines)
perl -ne 'print ++$a." $_" if /./'
# Number all lines but print line numbers only non
-empty lines
perl -pe '$_ = "$. $_" if /./'
# Number only lines that match a pattern, print ot
hers unmodified
perl -pe '$_ = ++$a." $_" if /regex/'
# Number and print only lines that match a pattern
perl -ne 'print ++$a." $_" if /regex/'
# Number all lines, but print line numbers only fo
r lines that match a pattern
perl -pe '$_ = "$. $_" if /regex/'
# Number all lines in a file using a custom format
(emulate cat -n)
perl -ne 'printf "%-5d %s", $., $_'
# Print the total number of lines in a file (emula
te wc -l)
perl -lne 'END { print $. }'
perl -le 'print $n=()=<>'
perl -le 'print scalar(()=<>)'
perl -le 'print scalar(@foo=<>)'
perl -ne '}{print $.'
perl -nE '}{say $.'
# Print the number of non-empty lines in a file
http://bropages.org/browse

33/174

8/3/2016

bro: just get to the point!

perl -le 'print scalar(grep{/./}<>)'


perl -le 'print ~~grep{/./}<>'
perl -le 'print~~grep/./,<>'
perl -E 'say~~grep/./,<>'
# Print the number of empty lines in a file
perl -lne '$a++ if /^$/; END {print $a+0}'
perl -le 'print scalar(grep{/^$/}<>)'
perl -le 'print ~~grep{/^$/}<>'
perl -E 'say~~grep{/^$/}<>'
# Print the number of lines in a file that match a
pattern (emulate grep -c)
perl -lne '$a++ if /regex/; END {print $a+0}'
perl -nE '$a++ if /regex/; END {say $a+0}'
# Convert an IP address to unsigned integer
perl -le '$i=3; $u += ($_<<8*$i--) for "127.0.0.1"
=~ /(\d+)/g; print $u'
perl -le '$ip="127.0.0.1"; $ip =~ s/(\d+)\.?/sprin
tf("%02x", $1)/ge; print hex($ip)'
perl -le 'print unpack("N", 127.0.0.1)'
perl -MSocket -le 'print unpack("N", inet_aton("12
7.0.0.1"))'
# Convert an unsigned integer to an IP address
perl -MSocket -le 'print inet_ntoa(pack("N", 21307
06433))'
perl -le '$ip = 2130706433; print join ".", map {
(($ip>>8*($_))&0xFF) } reverse 0..3'
perl -le '$ip = 2130706433; $, = "."; print map {
(($ip>>8*($_))&0xFF) } reverse 0..3'
# Generate and print the alphabet
perl -le 'print a..z'
perl -le 'print ("a".."z")'
perl -le '$, = ","; print ("a".."z")'
perl -le 'print join ",", ("a".."z")'
# Generate and print all the strings from "a" to
"zz"
perl -le 'print ("a".."zz")'
perl -le 'print "aa".."zz"'
# Create a hex lookup table
@hex = (0..9, "a".."f")
# Convert a decimal number to hex using @hex looku
p table
perl -le '$num = 255; @hex = (0..9, "a".."f"); whi
le ($num) { $s = $hex[($num%16)&15].$s; $num = int
$num/16 } print $s'
perl -le '$hex = sprintf("%x", 255); print $hex'
perl -le '$num = "ff"; print hex $num'
# Generate a random 8 character password
perl -le 'print map { ("a".."z")[rand 26] } 1..8'
perl -le 'print map { ("a".."z", 0..9)[rand 36] }
1..8'
http://bropages.org/browse

34/174

8/3/2016

bro: just get to the point!

# Create a string of specific length


perl -le 'print "a"x50'
# Create a repeated list of elements
perl -le '@list = (1,2)x20; print "@list"'
# Create an array from a string
@months = split ' ', "Jan Feb Mar Apr May Jun Jul
Aug Sep Oct Nov Dec"
@months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep O
ct Nov Dec/
# Create a string from an array
@stuff = ("hello", 0..9, "world"); $string = join
'-', @stuff
# Find the numeric values for characters in the st
ring
perl -le 'print join ", ", map { ord } split //,
"hello world"'
# Convert a list of numeric ASCII values into a st
ring
perl -le '@ascii = (99, 111, 100, 105, 110, 103);
print pack("C*", @ascii)'
perl -le '@ascii = (99, 111, 100, 105, 110, 103);
print map { chr } @ascii'
# Generate an array with odd numbers from 1 to 100
perl -le '@odd = grep {$_ % 2 == 1} 1..100; print
"@odd"'
perl -le '@odd = grep { $_ & 1 } 1..100; print "@o
dd"'
# Generate an array with even numbers from 1 to 10
0
perl -le '@even = grep {$_ % 2 == 0} 1..100; print
"@even"'
# Find the length of the string
perl -le 'print length "one-liners are great"'
# Find the number of elements in an array
perl -le '@array = ("a".."z"); print scalar @arra
y'
perl -le '@array = ("a".."z"); print $#array + 1'
# ROT13 a string
'y/A-Za-z/N-ZA-Mn-za-m/'
# ROT 13 a file
perl -lpe 'y/A-Za-z/N-ZA-Mn-za-m/' file
# Base64 encode a string
perl -MMIME::Base64 -e 'print encode_base64("strin
g")'
perl -MMIME::Base64 -0777 -ne 'print encode_base64
($_)' file
http://bropages.org/browse

35/174

8/3/2016

bro: just get to the point!

# Base64 decode a string


perl -MMIME::Base64 -le 'print decode_base64("base
64string")'
perl -MMIME::Base64 -ne 'print decode_base64($_)'
file
# URL-escape a string
perl -MURI::Escape -le 'print uri_escape($string)'
# URL-unescape a string
perl -MURI::Escape -le 'print uri_unescape($strin
g)'
# HTML-encode a string
perl -MHTML::Entities -le 'print encode_entities
($string)'
# HTML-decode a string
perl -MHTML::Entities -le 'print decode_entities
($string)'
# Convert all text to uppercase
perl -nle 'print uc'
perl -ple '$_=uc'
perl -nle 'print "\U$_"'
# Convert all text to lowercase
perl -nle 'print lc'
perl -ple '$_=lc'
perl -nle 'print "\L$_"'
# Uppercase only the first word of each line
perl -nle 'print ucfirst lc'
perl -nle 'print "\u\L$_"'
# Invert the letter case
perl -ple 'y/A-Za-z/a-zA-Z/'
# Camel case each line
perl -ple 's/(\w+)/\u$1/g'
perl -ple 's/(?<!['])(\w+)/\u\1/g'
# Strip leading whitespace (spaces, tabs) from the
beginning of each line
perl -ple 's/^[ \t]+//'
perl -ple 's/^\s+//'
# Strip trailing whitespace (space, tabs) from the
end of each line
perl -ple 's/[ \t]+$//'
# Strip whitespace from the beginning and end of e
ach line
perl -ple 's/^[ \t]+|[ \t]+$//g'
# Convert UNIX newlines to DOS/Windows newlines
perl -pe 's|\n|\r\n|'

http://bropages.org/browse

36/174

8/3/2016

bro: just get to the point!

# Convert DOS/Windows newlines to UNIX newlines


perl -pe 's|\r\n|\n|'
# Convert UNIX newlines to Mac newlines
perl -pe 's|\n|\r|'
# Substitute (find and replace) "foo" with "bar" o
n each line
perl -pe 's/foo/bar/'
# Substitute (find and replace) all "foo"s with "b
ar" on each line
perl -pe 's/foo/bar/g'
# Substitute (find and replace) "foo" with "bar" o
n lines that match "baz"
perl -pe '/baz/ && s/foo/bar/'
# Binary patch a file (find and replace a given ar
ray of bytes as hex numbers)
perl -pi -e 's/\x89\xD8\x48\x8B/\x90\x90\x48\x8B/
g' file
# Print the first line of a file (emulate head -1)
perl -ne 'print; exit'
# Print the first 10 lines of a file (emulate head
-10)
perl -ne 'print if $. <= 10'
perl -ne '$. <= 10 && print'
perl -ne 'print if 1..10'
# Print the last line of a file (emulate tail -1)
perl -ne '$last = $_; END { print $last }'
perl -ne 'print if eof'
# Print the last 10 lines of a file (emulate tail
-10)
perl -ne 'push @a, $_; @a = @a[@a-10..$#a]; END {
print @a }'
# Print only lines that match a regular expression
perl -ne '/regex/ && print'
# Print only lines that do not match a regular exp
ression
perl -ne '!/regex/ && print'
# Print the line before a line that matches a regu
lar expression
perl -ne '/regex/ && $last && print $last; $last =
$_'
# Print the line after a line that matches a regul
ar expression
perl -ne 'if ($p) { print; $p = 0 } $p++ if /rege
x/'
# Print lines that match regex AAA and regex BBB i
http://bropages.org/browse

37/174

8/3/2016

bro: just get to the point!

n any order
perl -ne '/AAA/ && /BBB/ && print'
# Print lines that don't match match regexes AAA a
nd BBB
perl -ne '!/AAA/ && !/BBB/ && print'
# Print lines that match regex AAA followed by reg
ex BBB followed by CCC
perl -ne '/AAA.*BBB.*CCC/ && print'
# Print lines that are 80 chars or longer
perl -ne 'print if length >= 80'
# Print lines that are less than 80 chars in lengt
h
perl -ne 'print if length < 80'
# Print only line 13
perl -ne '$. == 13 && print && exit'
# Print all lines except line 27
perl -ne '$. != 27 && print'
perl -ne 'print if $. != 27'
# Print only lines 13, 19 and 67
perl -ne 'print if $. == 13 || $. == 19 || $. == 6
7'
perl -ne 'print if int($.) ~~ (13, 19, 67)'
# Print all lines between two regexes (including l
ines that match regex)
perl -ne 'print if /regex1/../regex2/'
# Print all lines from line 17 to line 30
perl -ne 'print if $. >= 17 && $. <= 30'
perl -ne 'print if int($.) ~~ (17..30)'
perl -ne 'print if grep { $_ == $. } 17..30'
# Print the longest line
perl -ne '$l = $_ if length($_) > length($l); END
{ print $l }'
# Print the shortest line
perl -ne '$s = $_ if $. == 1; $s = $_ if length
($_) < length($s); END { print $s }'
# Print all lines that contain a number
perl -ne 'print if /\d/'
# Find all lines that contain only a number
perl -ne 'print if /^\d+$/'
# Print all lines that contain only characters
perl -ne 'print if /^[[:alpha:]]+$/
# Print every second line
perl -ne 'print if $. % 2'

http://bropages.org/browse

38/174

8/3/2016

bro: just get to the point!

# Print every second line, starting the second lin


e
perl -ne 'print if $. % 2 == 0'
# Print all lines that repeat
perl -ne 'print if ++$a{$_} == 2'
# Print all unique lines
perl -ne 'print unless $a{$_}++'
# Print the first field (word) of every line (emul
ate cut -f 1 -d ' ')
perl -alne 'print $F[0]'
# Match something that looks like an IP address
/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
/^(\d{1,3}\.){3}\d{1,3}$/
# Test if a number is in range 0-255
/^([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[05])$/
# Match an IP address
my $ip_part = qr|([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0
-4][0-9]|25[0-5])|;
if ($ip =~ /^($ip_part\.){3}$ip_part$/) {
say "valid ip";
}
# Check if the string looks like an email address
/\S+@\S+\.\S+/
# Check if the string is a decimal number
/^\d+$/
/^[+-]?\d+$/
/^[+-]?\d+\.?\d*$/
# Check if the string is a hexadecimal number
/^0x[0-9a-f]+$/i
# Check if the string is an octal number
/^0[0-7]+$/
# Check if the string is binary
/^[01]+$/
# Check if a word appears twice in the string
/(word).*\1/
# Increase all numbers by one in the string
$str =~ s/(\d+)/$1+1/ge
# Extract HTTP User-Agent string from the HTTP hea
ders
/^User-Agent: (.+)$/
# Match printable ASCII characters
/[ -~]/

http://bropages.org/browse

39/174

8/3/2016

bro: just get to the point!

# Match unprintable ASCII characters


/[^ -~]/
# Match text between two HTML tags
m|<strong>([^<]*)</strong>|
m|<strong>(.*?)</strong>|
# Replace all <b> tags with <strong>
$html =~ s|<(/)?b>|<$1strong>|g
# Extract all matches from a regular expression
my @matches = $text =~ /regex/g;
# Print the version of a Perl module
perl -MModule -le 'print $Module::VERSION'
perl -MLWP::UserAgent -le 'print $LWP::UserAgent::
VERSION'

tr

rsync

# Squeeze whitespace (space, tab, and unicode whit


estuff) into a single blank
tr -s '[:blank:]' ' '

# Download a remote file from an ssh-compatable se


rver.
# Reverse the arguments to upload.

5 0

6 1

rsync -vP user@my_server:remote_dir/remote_file lo


cal_dir/local_filename
# -v gives a bit more information
# -P shows progress and allows transfer to be resu
med with the same
#
command after killing rsync

mail

sqlite3
tree
ed

# Sends email to multiple addresses with custom fr


om address
echo -e "Hello!\nThis is email body" | mail -s "Pl
ace for subject" -r "from@domain.com" "to.first@do
main.com,to.second@domain.com"

# Generate a dump .sql file


sqlite3 database.sqlite3 .dump > db_dump.sql

# Display only the directories in tree format


tree -d

# ed - a line editor

5 0

5 0
5 0
5 0

# launch ed
ed
http://bropages.org/browse

40/174

8/3/2016

bro: just get to the point!

# launch ed with a prompt (":")


ed -p:
# ed takes commands within the actual editor
# these are some of the more essential ones
# the prompt from earlier is included to distingui
sh betwen commands and text
# quit ed
:q
# write a file
:w
# see error description
:h
# globally make errors verbose (lasts until quit)
:H
# edit text
:a
# stop editing text
.
# example of writing one line and going back to co
mmand mode
:a
Hello, world!
.
:

grep

man

mv
screen

# grep for a word and get the lines before and aft
er the occurance
# in this case 3 lines before and after
grep -C 3 "word" ./file.txt

# Shows the manual for the conditional operator,


'['
man [

# move a directory
mv sourceDir destDir

# list all screen sessions for current user


screen -ls

5 0

5 0

5 0
5 0

# list all screen sessions on current host


ls -laR /var/run/screen/

http://bropages.org/browse

41/174

8/3/2016

ln
pwd

ssh

whereis

pwd
git branch

gem
adb

bro: just get to the point!

# Creates a soft link from relative path


ln -sr somefile.txt /path/to/link

# Displays the path of the current working directo


ry.
# In other words, displays the folder you are in
pwd

# see your path on a remote machine from a non-log


in shell
ssh you@remotemachine echo \$PATH

# Searches through all my binary directories in my


root folder for the executable "ls". Tells me wh
ere the program is located.
whereis ls

# Prints path to current working directory.


pwd

# List all branches, both locally and on remotes


# NOTE: If you haven't used `git fetch` first, you
won't see newly-created remote branches
git branch -a

# yo specific version
gem install -v=0.0.15 bropages

# list all connected devices


adb devices

7 2
5 0

6 2

4 0

4 0
4 0

4 0
4 0

# send command to a specific connected device by I


D
adb -s emulator-5554 <command>
# install an APK, overwriting any existing install
ation
adb install -r path/to/MyApp.apk
# uninstall an APK
adb uninstall com.mycompany.myapp
# enable debug logs for specific log tag
adb shell setprop log.tag.MyLogTag DEBUG
# uninstall an APK, keeping any app data (useful f
or testing new app code on top of old preferences

http://bropages.org/browse

42/174

8/3/2016

bro: just get to the point!

or databases)
adb shell pm uninstall -k com.mycompany.myapp

lsof

# List all IP sockets, and the process using them.

4 0

lsof -i

ffmpeg
tr
ls

chmod

vim

git

gem

npm
watch

http://bropages.org/browse

# Remove sound from a video


ffmpeg -i in.avi -vcodec copy -an out.avi

# change all non-alphanumeric characters to spaces


tr -c '[:alnum:]' ' '

# -F append indicator (one of */=>@|) to entries


# -h Human readable file sizes
# -l long list format
# -A "almost" all - excludes . and ..
ls -FhlA

# Give everyone read, write and execute access to


folder 'foo' and all its contents
chmod -R 777 foo

# Vim has an intricate system of splits and tabs.


# A full session can be saved with the command
# :mksession file.vim
# the command below restores every split and tab
vim -S file.vim

# Paginate - useful for creating commits of specif


ic changes
git add -p

# Uninstall all gems


gem list | cut -d" " -f1 | xargs gem uninstall -aI
x

# install a node package globally


npm install -g <package_name>

# run the free command (show amount of free memor


y) every one second.
watch -n1 free

4 0
4 0
5 1

4 0

4 0

7 3

4 0

4 0
4 0

43/174

8/3/2016

for

bro: just get to the point!

# loop over a list of files in bash


for f in file1 file2 file3
do
echo "doing stuff to $f"
# your commands here
done

4 0

# loop over all PDF files in the working directory


for f in *.pdf
do
echo "doing stuff to $f"
# your commands here
done
# do it in one line
for f in *.pdf; do command; done

ghc

# compile foobar.hs
# creates "foobar" executable in .
ghc foobar.hs

4 0

# high optimization
ghc -O2 foobar.hs
# no optimization, good for debugging
ghc -O0 foobar.hs
# profiling
ghc -prof -caf-all -auto-all foobar.hs
# create a profile report! (foobar.prof)
./foobar +RTS -p -RTS
# show all exception stack traces!
./foobar +RTS -xc -RTS
# force recompilation (even if foobar.o exists alr
eady)
ghc -fforce-recomp foobar.hs

irb

# irb and load a file


irb -r./file.rb

4 0

# run irb like a repl


cd my_gem
irb -Ilib -rmy_gem_name

echo
dd

http://bropages.org/browse

# Execute command at give time


echo "ls -l" | at midnight

# Output your microphone to a remote computer's sp


eaker.
dd if=/dev/dsp | ssh -c arcfour -C username@host d
d of=/dev/dsp

4 0
4 0

44/174

8/3/2016

ip

curl
pdftk

free
mkdir

uptime

java
uname

bro: just get to the point!

# Displays the IP information for the given interf


ace
ip addr show eth0

# get public ip address using curl


curl ipecho.net/plain ; echo

# Split Select Pages from Multiple PDFs into a New


Document
pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output
combined.pdf

# show the amount of free memory in megabytes


free -m

# create a directory in the current directory call


ed penguin
mkdir penguin

# uptime - Tell how long the system has been runni


ng.
uptime

# Run an executable jar file


java -jar my_jar_file.jar

# Print system information


uname

4 0

4 0
4 0

4 0
4 0

4 0

4 0
4 0

# Print all system information it can find


uname -a

sed
python

shuf
http://bropages.org/browse

# remove blank lines from from a text file


sed '/^[[:space:]]*$/d' input.txt > output.txt

# This is the python3 version of SimpleHTTPServer,


the command to easily serve
# any directory over http. Use if you run Arch or
a derivative. Alternatively,
# use on any distribution with python3 by replacin
g `python` with `python3`
python -m http.server

4 0
5 1

4 0
45/174

8/3/2016

bro: just get to the point!

# print 5 random lines from datafile.csv


shuf -n 5 datafile.csv
# inspect datafile.csv
(head -1; shuf -n 7; tail -1) < datafile.csv
# roll a 20-sided die
shuf -i 1-20 | head -1
# choose where to go for lunch
shuf -e moes joes golden_corral taqueria | head -1

mount

# Mount an ext4 partition /dev/sda1 to folder /med


ia/omg
sudo mount -t ext4 -v /dev/sda1 /media/omg

4 0

# Then unmount it
sudo umount /media/omg
# In case you don't remember exactly your partitio
n is
# /dev/sda1 or /dev/sda2 or /dev/sda3 or ...
# you can use this command to figure it out:
sudo blkid

nslookup

# to lookup a domain
nslookup www.slashdot.og

4 0

# to lookup a domain from googles public dns serve


r
nslookup www.slashdot.org 8.8.8.8

traceroute

# Traceroute show the packet path from your comput


er to a specified IP address or hostname
traceroute IP_ADDR\HOSTNAME

4 0

# -n : Disable DNS lookup to speed up queries.


# -w seconds : Set the time (in seconds) to wait f
or a response to a probe (default 5.0 sec).
# -q NUMBER : Sets the number of probe packets per
hop. The default is 3.
# The following example will wait 3 seconds (inste
ad of 5), only send out 1 query to each hop (inead
er of 3):
traceroute -n -w 3 -q 1 www.cyberciti.biz

clang

# Check for correctness


clang -fsyntax-only source.c

4 0

# Emit LLVM Intermediate Representation


clang -S -emit-llvm source.c -o output.ll
# Emit LLVM IR bitcode
http://bropages.org/browse

46/174

8/3/2016

bro: just get to the point!

clang -c -emit-llvm source.c -o output.bc


# Compile to native machine code
clang -S source.c -o assembly.s

jar
updatealternatives

# see what's inside a .jar archive


jar tf archive.jar

# Installing java alternatives.


# Arguments are update-alternatives link name path
priority
# link = the generic link which should be managed
by alternatives.
# name = the name of the alternative same as the l
ink in created in the alternatives folder(/etc/alt
ernatives/)
# path = the alternative path the alternative shou
ld point to
sudo update-alternatives --install "/usr/bin/java"
"java" "/usr/local/java/jdk1.7.0_45/jre/bin/java"

4 0
4 0

curl

coffee
git branch

git push

# Curl without progress bar, so you can pipe outpu


t
curl -s http://path.to/resource | less
curl -s http://path.to/resource | vim --

# Basic usage
coffee -c filename

# delete a local branch (to delete a remote branch


refer to 'bro git push')
git branch -D feature/cool-thing

# delete a remote branch


git push origin :feature/cool-thing

4 0

4 0
4 0

4 0

# alternatively
git push origin --delete feature/cool-thing

ab

shasum
http://bropages.org/browse

# performs 1000 requests at 100 concurrency on loc


al port 3000
ab -n 1000 -c 100 http://localhost:3000/

# Gets the sha256 sum of a file


shasum -a 256 filename.txt

4 0

4 0
47/174

8/3/2016

ping

find

bro: just get to the point!

# Limit the number of times an address is pinged


(4, in this case).
ping -c4 www.example.com

# Find and remove empty directories


find . -type d -empty -delete

4 0

4 0

# Find and remove empty files


find . -type f -empty -delete

at
psql
ld

# send a command to at
echo "say 'time to go'" | at 16:30

# open a remote database


psql -h hostname dbname username

# ld - a linker

4 0
4 0
4 0

# link two object files with a specified output na


me
ld -o hello-world ./hello.o ./world.o
# instruct ld to use name all input files as they
are processed
ld -o hello-world ./hello.o ./world.o -t
ld -o hello-world ./hello.o ./world.o --trace

nasm

# nasm - the netwide assembler

4 0

# specific output name for input 'hello.asm'


nasm -o assembled-hello ./hello.asm

patch

touch
http://bropages.org/browse

# Applies the .patch file path/file.patch to the c


urrent directory.
#
# Note: The p1 flag is for compatibility with patc
hes created with git, and stands
# for the number of leading prefixes to strip. If
that doesn't work, try using
# just p0.
#
# See https://drupal.org/patch/apply for some more
detailed information.
patch -p1 < path/file.patch

# Change the unix timestamp of a file to an arbita


ry date
touch -d '12 Jun 2005 10:05' /path/to/target_file

4 0

4 0
48/174

8/3/2016

http

export
git merge
git checkout
sed

dcfldd

bro: just get to the point!

# prints colorful version of the response headers


and body,
# with formatted JSON, of a request
http "httpbin.org/get?foo=bar"

# How to add (for example) ~/opt/bin to $PATH


export PATH=$PATH:~/opt/bin

# Merges the 'foo' branch into your current branch


git merge foo

# Create and switch to the branch 'foo'


git checkout -b foo

# print all lines from production.log matching the


word "error", plus 1 additional line
sed -n '/error/,+1p' production.log

# copy over contents


dcfldd if=/path/to/file of=/path/to/output

4 0

4 0
3 0
3 0
3 0

3 0

# copy over contents with custom block size and st


atus
# status is updated every time block_nums blocks a
re read from the input file.
dcfldd sizeprobe=if statusinterval=<block_nums> bs
=<block_size> if=/path/to/some.iso of=/path/to/out
put
# copy over contents of input file (if) to output
(of) with ~real time status update
dcfldd sizeprobe=if statusinterval=1 bs=4M if=/pat
h/to/some.iso of=/dev/sda

man bro

# look for bro manual. Unfortunatly there is none


man bro

3 0

# look for useful bro examples using man bro. Unfo


rtunatly there is none
bro man bro
# keeps the sillyness going by looking for example
s of meaningful uses of bro man bro
bro bro man bro
# this can really go for a while bro

http://bropages.org/browse

49/174

8/3/2016

scp

bro: just get to the point!

Tool used to transfer files over the network.


Send a file to another machine:
scp file_to_transfer.txt machine_name_or_ip:/path/
to/destination

4 1

Transfer a file to current machine:


scp machine_name_or_ip:/path/to/source /path/to/de
stination
# your_comment_here

python

jq
grep

vim
vim
vim

open

php
ffmpeg

http://bropages.org/browse

# Runs the line `print 'hello'` in Python and then


returns.
python -c "print 'hello'"

# Pipe JSON file to less but keep colored output


jq --color-output . file.json | less -R

# Filter lines not containing a match for "my proc


ess" from a text stream
tail -f "my_server.log" | grep "my process"

# Open file.txt placing the cursor at line 123


vim file.txt +123

# Pipe to the Vim


echo 'some stuff' | vim -

# Run Vim command(s) right after start


vim +'h motion | only | tabe +h text-object | only
| tabe +h leader | only'

# Open a file using the same default application a


s Finder (OS X)
open myfile.pdf

# Execute PHP file via command-line with `php -f`


php -f my_file.php

# Cuts a clip from a video or sound.


# Give it a minute to decode the video to accurate
ly get the timestamp.
ffmpeg -i in.avi -ss startseconds -t lengthofclip
out.avi

3 0

3 0
4 1

3 0
3 0
3 0

3 0

3 0
3 0

50/174

8/3/2016

sed

rake

bro: just get to the point!

# print the lines from somefile.txt matching the w


ord "fromText" to the first line that matches "toT
ext"
sed -n '/fromText/ , /toText/p' somefile.txt

# your_comment_here

3 0

3 0

# SHOW AVAILABLE RAKE COMMANDS


rake -P

wc

brew

test

# Find the length of the longest line in a file, g


ood for <80 char checks
wc -L code.txt

# Get some info including a URL about the package


git
brew info git

# test if a file exists


test -f somefile

4 1

3 0

3 0

# test is a directory exists


test -d somedirectory
# test if two strings are equal
STRING1 = STRING2
# test if two integers are qual
INTEGER1 -eq INTEGER2

rsync

# Remotely SYNC two directories, smarter than scp


and easier than creating a tar

5 2

rsync -rtvP --bwlimit=65 [source] [destination]


# Where
#
# -r is recursive
# -t retains the files' modification time
# -v to show what is going on
# -P shows the progress
# --bwlimit=65 limits the upload to 65Kb/sec

npm
mosh
http://bropages.org/browse

# install a node package into local node project


npm install <package_name>

# You can run remote command


mosh user@host -- your_command with arguments

3 0
3 0
51/174

8/3/2016

bro: just get to the point!

# It's handy for direct tmux session


mosh user@host -- tmux attach -t your_session_name

pip
pip
pip
git add

pandoc

mplayer
ssh

sudo

ssh

nc
git rebase
http://bropages.org/browse

# install django
pip install django

# install django version 1.5.1


pip install django==1.5.1

# update django
pip install --upgrade django

# Stages only the modified files. Great if you've


moved some files into a subfolder and you want to
keep their git history.
git add -u

# Converts a Markdown file foo.md to a HTML file f


oo.hml
pandoc -s foo.md -o foo.html

# Plays any media file from the command line


mplayer my_video.mkv

# SSH-VPN create a tun interface with ssh (use as


root on both sides) add ip's to both sides and ch
ange your default route
ssh root@server -vNTw any:any

# Forgot to sudo? Run the previous command as roo


t.
sudo !!

#Open a tunnel from 192.168.1.10's port 80 to your


local port 2001
ssh -N -L2001:localhost:80 192.168.1.10

# Share file through port 80


nc -v -l 80 < file.ext

# Rebase the current branch on top of some_branch


git rebase some_branch

3 0
3 0
3 0
3 0

3 0

3 0
3 0

5 2

3 0

3 0
3 0
52/174

8/3/2016

bro: just get to the point!

# Rebase the current branch on top of some_branch,


in 'interactive' mode,
# choosing what to do for each rebased commit
git rebase -i some_branch

sed

whois
git

rand

top
env
exit
ssh-keygen
git checkout

# Replace all 'dog' with 'cat' in file.txt, and ke


ep the original in file.txt.orig
sed -i.orig s/dog/cat/g file.txt

# Display WHOIS information of given website.


whois http://example.com

# Checkout Subversion repository in standard layou


t (branches, tags, trunk) using Git
git svn clone svn://example.org/path/to/repo targe
tdir -s --prefix=origin/ [--no-minimize-url] [--au
thors-file=/path/to/authors.txt]

# generate 100 pseudo-random numbers from the seed


2342, separated by comma and space
rand -N 100 -s 2342 -d ", "

# monitor the process with pid 1, 2, and 3


top -p 1, 2, 3

# print the environment variables to the screen.


env

# exit the shell


exit

# generate a key without any keyboard interaction


ssh-keygen -t dsa -N '' -f path/to/keyfile -y

# Check out a file from an earlier commit

3 0

3 0
3 0

3 0

5 2
3 0
3 0
4 1
3 0

git checkout c27cbab Gemfile

ack
yum
http://bropages.org/browse

# search a subdirectory
ack bart lib/simpsons/

3 0
3 0
53/174

8/3/2016

bro: just get to the point!

# Lists the installed packages


yum list installed

killall
convert

# No, really.. kill the process


killall -KILL java

# Clean up a whiteboard image.


# (via lelandbatey on www.reddit.com/r/commandlin
e)

3 0
3 0

convert inputfile -resize %50 -morphology Convolve


DoG:15,100,0 -negate -normalize -blur 0x1 -channe
l RBG -level 60%,91%,0.1 outputfile

date
ddrescue

mailx

less

# Display date for a specific timezone.


TZ="Africa/Casablanca" date

# Basic copy from partition sdb2 to img file with


2 retries max, no split of blocks, and verbose
ddrescue -v -r2 -n /dev/sdb2 filename.img logfile.
log

# Send a mail:
echo '<mail_body>' | mailx -s '<mail_subject>' <ma
il_address>

# Open a file for reading:


less file.txt

3 0
3 0

3 0

3 0

# Open a file with ANSI color codes for reading.


Note you can also type '-r' or
# '-R' in the less window to do the same:
less -R file.txt

openssl

unzip

http://bropages.org/browse

# Check whether a private key matches a certificat


e (do this before installing the cert) (courtesy s
slshopper tools page)
openssl x509 -noout -modulus -in certificate.crt |
openssl md5
openssl rsa -noout -modulus -in privateKey.key | o
penssl md5

# unzip many files in one command: must add \ befo


re wildchar
# otherwise command will extract first zip and sea
rch other files in it
unzip -e \*.zip

3 0

3 0

54/174

8/3/2016

lsof

sleep

bro: just get to the point!

# Show which PIDs have the most files open


sudo lsof | awk '{print $2}' | sort | uniq -c | so
rt -n

# sleep (wait) for 1 second


sleep 1
sleep 1s

3 0

3 0

# sleep (wait) for 1 minute


sleep 1m

netstat

pg_dump
gem
bro

vim

# Show socket connections on a port (specified in


the grep portion). In this case, ssh (port 22).
netstat -an | grep '\:22\ '

# Dumps database into a file


pg_dump your_database_name -f filename.dump

# show installed gems


gem list

# automatically thanks the first 5 brohelps in a


# bropage after exiting bro in a bash shell
for i in {1..5}; do bro thanks $i; done

# Encrypt files using vim


vim -x my-secret-file

3 0

3 0
3 0
4 1

3 0

# Remember the password :-)


vim my-secret-file

xargs

# problem: my conversations with my friend Ahmed a


re split up across
# irc logs across different folders

3 0

# want to find: a conversation where we were talki


ng about "apple butter"
find ~/chatlogs -name *ahmed* | xargs grep 'apple
butter'
#faster than finding a bunch of filenames, retypin
g them and cat * | grep apple butter

cp
http://bropages.org/browse

# Copy many files to a single target location


cp file_1 file_2 ... file_n target_directory

3 0
55/174

8/3/2016

scp

tsort

tshark

bro: just get to the point!

# copy multiple files from remote to current local


directory:
scp user@example.com:"file1 file2 file3" .

# topo-sort a DAG specified by i -> j edge pairs


# https://en.wikipedia.org/wiki/File:Directed_acyc
lic_graph_2.svg
tsort <<EOF
>38
> 3 10
> 5 11
>78
> 7 11
>89
> 11 2
> 11 9
> 11 10
> EOF

# Show hosts of IP traffic


tshark -r $FILE -q -z hosts,ipv4

3 0

3 0

3 0

# Show hierarchy stats using tshark


tshark -r $FILE -q -z io,phs
# Show all traffic and dest port info
tshark -o column.format:'"Source", "%s", "Destinat
ion", "%d", "dstport", "%uD"' -r $FILE |sort|uniq
# Show all conversations and port detail using tsh
ark filters
tshark -o column.format:'"Source", "%s", "Destinat
ion", "%d", "dstport", "%uD"' -r $FILE |sort|uniq
# Show all TCP streams
tshark -r $FILE -q -z conv,tcp

bzip2

find

# Unzip file.bz2, creating file, removing file.bz


2. (See also bunzip2)
bzip2 -d file.bz2

# Find and remove files recursively starting in th


e current directory.
find . -name "FILE_TO_FIND" - exec rm -rf {} \;

3 0

3 0

# Especially useful for finding and removing tempo


rary files.
# e.g. To remove compiled python files:
find . -name '*.pyc' -exec rm -rf {} \;

http://bropages.org/browse

56/174

8/3/2016

grep

pkill
diff
tar
lsof
watch

bro: just get to the point!

# recursively search all files of a specified type


for a search string (case insensitive)
# E.g. seach all python files in a directory (and
its sub-directories) for the expression "fixme"
grep -ri --include="*.py" -e "fixme" .

# Kills a process named 'chromium'


pkill chromium

# show the difference between two directories


diff -r DIRECTORY1 DIRECTORY2

# extract a tarball
bro -xjf package.tar.bz2

# Lists all open files under '/some/path'


lsof /some/path

# watch changes in ifconfig live


watch ifconfig

3 0

3 0
3 0
7 4
3 0
4 1

#watch for mail, you might do


watch -n 60 from
#To watch the contents of a directory change, you
could use
watch -d ls -l
#If you're only interested in files owned by user
joe, you might use
watch -d 'ls -l | fgrep joe'
#To see the effects of quoting, try these out
watch echo $$
watch echo '$$'
watch echo "'"'$$'"'"
#To see the effect of precision time keeping, try
adding -p to
watch -n 10 sleep 1
#You can watch for your administrator to install t
he latest kernel with
#watch uname -r

http://bropages.org/browse

57/174

8/3/2016

smartctl
gz

service
git stash
less

find

dd

w3m
xrandr
hexdump

tmux

http://bropages.org/browse

bro: just get to the point!

# Runs a short test on /dev/sda


smartctl -t short /dev/sda

# .gz extentions can be


# uncompressed with gunzip
gunzip file.gz

# Shows statuses of all services


service --status-all

# Save unfinished to a stash named "foo".


git stash save "foo"

# Use 'less' as a better tail -F, to follow outup


to files for eg. monitoring
# logs
less +f /var/log/apache

# Find files modified within a specific date rang


e.
touch --date "2007-01-01" /tmp/start
touch --date "2008-01-01" /tmp/end
find /data/images -type f -newer /tmp/start -not newer /tmp/end

# Create a random 3MB file on your desktop


dd if=/dev/urandom of=~/Desktop/test.txt bs=1M cou
nt=3

# Open shell based web browser to target url


w3m google.com

# change resolution of display eDP1 to fullHD


xrandr --output eDP1 --mode 1920x1080

# Display a file in a hex view using 16 bytes per


row, and print the corresponding ASCII characters
next to each row.
hexdump -C < myfile

# Attach to a running session, or create a new ses


sion if there isnt one
tmux attach || tmux

3 0
3 0

3 0
3 0
3 0

3 0

3 0

3 0
3 0
3 0

3 0

58/174

8/3/2016

pushd

lsof
grep
chsh
docker

docker

sudo

ip

tar

http://bropages.org/browse

bro: just get to the point!

# Pushes a directory into a stack of directories f


or easy switching
pushd ~/example/dir

# list all files open by the process [PID]


lsof +p [PID]

# Show file name in output


grep -H search_string file_name

# Change shell to zsh for user jake


chsh -s /bin/zsh jake

# list all docker containers


# - assumes the following alias exists
# alias docker="sudo docker -H tcp://localhost:2
375"
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
docker ps -a

# list all docker images


# - assumes the following alias exists
# alias docker="sudo docker -H tcp://localhost:2
375"
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
docker images -a

# Switches you to root user allowing you to execut


e
# commands at sudo level without having to use sud
o
# for every execution
# USE WITH CAUTION!!!
sudo su

# set default route (for example when connected to


both wifi and lan)
sudo ip route change default via 192.168.1.1

# exclude a file/directory from your tar archive


tar cvf archive.tar --exclude=.svn *

3 0

3 0
3 0
3 0
3 0

3 0

3 0

3 0

3 0

59/174

8/3/2016

cut

journalctl
octave

ss

ls
git
rsync

git branch
youtube-dl

youtube-dl

openssl

bro: just get to the point!

# use `col` to format an output so you can select


the third string using the default tab as a delim
eter
who | col | cut -f3

# Show messages from the current boot


journalctl -b -0

# GNU Octave is a free, open-source language prima


rily targeted toward numerical calculations. It's
mostly compatible with Matlab. But free.
octave
octave foo.m

# Display listening sockets, tcp and ports. Altern


ative netstat -nltp
ss -nltp

# Show the inodes


ls -i

# cleaning up old remote git branches


git remote prune origin

# ssh on a different port, with progress


rsync -P -rsh='ssh -p9001' user@remote.box:source.
file destination.file

# Rename a branch
git branch -m lolbranch featurebranch

# Download a specific video with youtube-dl


youtube-dl https://www.youtube.com/watch?v=q6EoRBv
dVPQ

# Download all the videos in a playlist from youtu


be with youtube-dl
youtube-dl "http://www.youtube.com/playlist?list=P
L24AF31F5D9CB3F2A"

# Quickly encrypt a file

3 0

3 0
3 0

3 0

3 0
3 0
3 0

3 0
3 0

3 0

3 0

# Lock:
openssl aes-256-cbc -a -salt -in file -out fil
http://bropages.org/browse

60/174

8/3/2016

bro: just get to the point!

e.enc
# Unlock:
openssl aes-256-cbc -d -a -in file.enc -out fi
le
# For directories, create a tarball first
tar -czvf directory.tar.gz directory
# Then lock it
openssl aes-256-cbc -a -salt -in directory.ta
r.gz -out directory.tar.gz.enc
# Unlock it
openssl aes-256-cbc -d -a -in directory.tar.g
z.enc -out directory.tar.gz
# And extract it
tar -xzvf directory.tar.gz

stow

Ag

# Create symlinks for the .vim and foo folders in


# the current dir into ~.
stow -v -t ~ .vim foo
-v verbose
-t the target directory where symlinks should go:
~
-D add this flag to remove the symlinks (unlink)

# search for app.txt


Ag app.txt

3 0

3 0

# search for special characters and only list file


names
Ag 'foo\(' -l
# search and ignore a directory
Ag foo --ignore dir
# search case insensitive
Ag foo -i

xclip

# Copy the text "foo" to primary selection.


echo "foo" | xclip

3 0

# Copy the text "bar" to clipboard selection.


echo "bar" | xclip -selection clipboard
# Copy the text "yo" to primary AND clipboard sele
ction for pasting EVERYWHERE!
# (Psst, "alias xclip='xclip -i -sel c -f | xclip
-i -sel p'")
echo "yo" | xclip -i -sel c -f | xclip -i -sel p

http://bropages.org/browse

61/174

8/3/2016

cloc

at

bro: just get to the point!

# Count lines of code recursive in a given directo


ry 'dir'
# http://cloc.sourceforge.net
cloc dir

# add new job to queue


at now +5 minutes <enter>

3 0

3 0

# specify command and exit menu


at>echo "foobar"
at>[Ctrl]-[D] <EOT>
# see all pending commands
atq
# remove command #21 from queue
atrm 21

dpkg

# Print info of installed application e.g. Chrome


dpkg -s google-chrome-stable

3 0

# List installed applications


dpkg --get-selections
# Install a deb file
sudo dpkg -i chefdk_0.4.0-1_amd64.deb

git
git
ulimit

zsh

# Show diff of staged changed


git diff --cached

# Delete remote branch (git v1.7.0 and up)


git push origin --delete feature_branch

# Set maximum limit of file descriptors open at on


ce to 10000
ulimit -n 10000

# start z shell (much better than bash!)


zsh

3 0
3 0
3 0

3 0

# execute a command
zsh -c <command>

cal

# display calendar for current month


cal

3 0

# display calendar for some year


cal <year>
http://bropages.org/browse

62/174

8/3/2016

paste

pod

while

tar
cd

cd

git pull

git commit

git pull

http://bropages.org/browse

bro: just get to the point!

# file1 is | file2 is
#1
| a
#2
| b
# will output
#1a
#2b
paste file1 file2

# Update outdated project dependencies and create


new Podfile.lock
pod update

# Ping a list of servers


while read i; do ping -c1 $i; done < listofserver
s.txt

# List contents of a tar.gz file


tar -tvf filename.tar.gz

# Enters my Documents folder (Documents directory


is inside my current working directory).
cd Documents

# Enters Documents directory by using an absolute


file path.
cd ~/Documents

# Pulls the most recent version of the current bra


nch
git pull

# Adds all currently-tracked, modified files to st


aging and commits them with the message 'some git
commit message'
# -a : includes all modified files in the commit
# -m : specifies the commit message following the
flag, instead of using the editor
git commit -am 'some git commit message'

# Applies your commits on top of the branch you ar


e pulling
# Helpful for dealing with merge conflicts when yo
u know that they are going to happen
git pull --rebase

3 0

3 0

3 0

3 0
2 0

2 0

2 0

2 0

2 0

63/174

8/3/2016

git reset

curl
php

php

axel

true
cat
exiftool
rm

mount
nmap
http://bropages.org/browse

bro: just get to the point!

# make your current branch point to HEAD, throws a


way all uncommitted changes
git reset --hard HEAD

# Use curl and ignore certificate errors


curl --insecure http://my.homespun.website.com

# Start the builtin webserver on port 8000


# serving the current directory
php -S localhost:8000

# Start the builtin webserver on port 8000


# serving the current directory
# using a specified .ini file for configuration
php -S localhost:8000 -c custom_php.ini

axel -a -n8 http://site.com/large.file.iso


Downloads the file at site.com/large.file.iso usin
g 8 threads and the new alternitive progress bar f
or axel

# Always returns true (exits with status code 0).


true

# Show tabs in a file


cat -T file.txt

# Remove all exif data from an image


exiftool -all=image.jpg

Remove specified file


ex: rm somefile
To remove directory and it's contents, use the -r
(recursive) flag
ex: rm -r someDirectory
Other quick tip, adding f to -r (-rf) will prevent
prompting for deletion

# mounts all filesystems that are in fstab


mount -a

# Stealth SYN Scan for all ports on 192.168.1.0


nmap -sS -P0 -p- 192.168.1.0

2 0

3 1
2 0

2 0

2 0

2 0
4 2
2 0
3 1

2 0
2 0
64/174

8/3/2016

clang
wget

which
locate

pip
hg

killall

pdftk

pv
packer
wget
http://bropages.org/browse

bro: just get to the point!

# Compiles prog.c into executable 'prog'


clang -o prog program.c

# wget example useful for automating a web call an


d appending results to a log
wget -q --no-check-certificate -O - "http://bropag
es.org" >> ~/bropages.log

# locates executable
which bro

# search the filesystem for a file containing wat


in the filename
locate filename

# list outdated packages


pip list --outdated

# pull the Mercurial source


hg clone http://selenic.com/repo/hello
# add a file to the repository
hg add new_file.txt
# commit the changes
hg commit -m 'commit message'
# push the changes back to the servec
hg push

# Kills (stops) all running 'java' processes. It o


nly kills processes you have permission to kill.
killall java

# Extracts page 10 from 'bigdocument.pdf' into sep


arate (one-page) file 'pageten.pdf'
pdftk bigdocument.pdf cat 10 output pageten.pdf

# View progress of the dd command


dd if=/dev/urandom | pv | dd of=/dev/null

# Searches for gimp in both repositories and AUR


packer -Ss gimp

# When downloading a huge file, it may become prac


tical to pause and resume a download. Adding the o

3 1
3 1

2 0
4 2

3 1
2 0

3 1

2 0

2 0
2 0
3 1
65/174

8/3/2016

bro: just get to the point!

ption -c or --continue will resume an interrupted


download.
wget -c https://scans.io/data/umich/https/certific
ates/raw_certificates.csv.gz

mplayer
curl

curl

awk

wget

node
pgrep

pgrep

sqlite

ffmpeg
http://bropages.org/browse

# Play media from compressed rar files


unrar p -inul file.rar | mplayer -

# Update Twitter
curl -u user:pass -d status="Tweeting from the she
ll" http://twitter.com/statuses/update.xml

# Check Gmail
curl -u username --silent "https://mail.google.co
m/mail/feed/atom" | perl -ne 'print "\t" if /<name
>/; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'

# Remove duplicate line entries in a file without


sorting
awk '!x[$0]++' <file>

# Open tarball without downloading


wget -qO - "http://www.tarball.com/tarball.gz" | t
ar zxvf -

# Run a JavaScript file with node.js


node /path/to/file.js

# Find the pids of all python processes on your sy


stem.
pgrep python

# Find the pids of processes with 'test.py' as an


argument, like 'python test.py'
pgrep -f test.py

# Convert sqlite2 database to sqlite3


# you need both versions installed for this
# attention! on some systems sqlite2 is just calle
d sqlite
sqlite2 path/to/olddb .dump > backupfile
sqlite3 path/to/newdb < backupfile

2 0
3 1

3 1

2 0

3 1

2 0
2 0

2 0

2 0

2 0
66/174

8/3/2016

bro: just get to the point!

# Rip the DVD's Video file nr. 1 to an x264 (flash


compatible) AAC converted AVI file to your home d
irectory)
# With a constant framerate of 630kbit/s ( see htt
p://www.3ivx.com/support/calculator/ ) (see ffmpeg
wiki for codecs)
ffmpeg -i /mnt/cdrom/VIDEO_TS/VTS1-01.VOB -strict
-2 -c:v libx264 -b:v 630k -c:a libfaac -b:a 128k
~/Videos/MySuperDvdRip.x264.aac.avi

ffmpeg

emerge
du
drush

# list all available codecs which are built in to


ffmpeg
# D..... = Decoding supported
# .E.... = Encoding supported
#
..V... = Video codec
#
..A... = Audio codec
#
..S... = Subtitle codec
#
...I.. = Intra frame-only codec
#
....L. = Lossy compression
#
.....S = Lossless compression
ffmpeg -codecs

# Synchronize your Gentoo Portage tree.


emerge --sync

# Sorted filesystem usage


du -s * | sort -nr

# Clear all the Drupal cache


drush cc all

2 0

2 0
2 0
2 0

# Perform the database update (executes the hook_u


pdate)
drush updb

scrot

pdftk

# Take a screenshot with the name YYYY-MM-DD_HH:m


m:ss.png and move it to ~/screenshots
scrot '%F_%T.png' -e 'mv $f ~/screenshots/'

# Merge Two or More PDFs into a New Document


pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

2 0

2 0

# or (Using Handles):
pdftk A=1.pdf B=2.pdf cat A B output 12.pdf
# or (Using Wildcards):
pdftk *.pdf cat output combined.pdf

http://bropages.org/browse

67/174

8/3/2016

more

type

su
kill
halt
fsck

systemctl

bro: just get to the point!

# Print the contents of the current directory only


one screen at a time
ls | more

# show the command that is run if you type a comma


nd
# displays the kind of command the shell will exec
ute, given a particular command name
type ls

# change the current user to el


su el

# Kill a running processID


kill 1000

# shutdown the computer immediately


halt

# check /dev/sda1 for errors and try to fix them a


utomatically
fsck -y /dev/sda1

# enable a service called bro to start automatical


ly (as root)
systemctl enable bro.service

2 0

2 0

2 0
3 1
2 0
2 0

2 0

# or (as a sudoer)
sudo systemctl enable bro.service

systemctl

# start listening on port 6600 and start mpd (as a


normal user) upon a connection
systemctl --user start mpd.socket

2 0

# start listening on automatically on user session


start
systemctl --user enable mpd.socket

htpasswd

ipython
http://bropages.org/browse

# generate a password hash for the user 'danny' an


d print it to stdout for future use
htpasswd -n danny

# Opens IPython Notebook with loaded PyLab library


and inline plots
ipython notebook --pylab inline

2 0

2 0
68/174

8/3/2016

git alias

bro: just get to the point!

# Add an alias called "foo" that runs "git log -n


3"
git config --global alias.foo "log -n 3"

2 0

# Modify an existing alias "foo"


git config --global --replace-all alias.foo "log 3 --graph --abbrev-commit"
# Delete an alias "foo"
git config --global --unset alias.foo

yum

yum
java

chflags
git

kill

tee
cal

# your_comment_here
yum search <name> : searches for <name> in package
s

# searches for <name> in the packages


yum search <name>

# Run a main class


# (Must be in the same directory as the MainClass.
class file)
java MainClass [arg0 arg1 arg2 ...]

# Unhide a file marked with the hidden flag.


chflags nohidden BaseServer.dmg

# Initiates an bare repository in current director


y.
git --bare init .

# kill -0 PID determines if PID is running (withou


t locking the kernel process table or forking new
shell)
kill -0 $(cat $PIDFILE) || breakLockRestart "Daemo
n died; restarting."
kill -0 $(cat $PIDFILE) && die "$0 already runnin
g. Exiting."

# save your ruby irb session as you go


irb | tee -a save-todays-ruby-session.hist

# print how the weeks were arrayed this month, las


t month, and next month
cal -3

2 0

2 0
2 0

2 0
2 0

2 0

2 0
4 2

# print how the weeks were arrayed last two month


http://bropages.org/browse

69/174

8/3/2016

bro: just get to the point!

s, this month, and next three months


cal -B 2 -A 3
# remind yourself of important dates of Middle Ear
th
grep Gandalf /usr/share/calendar/calendar.lotr

ls
java
cd
which

kill

find

virsh

# find the file you just downloaded


pushd ~/Downloads; ls -toh | head; popd

# What version of java


java -version

# Change directory to your home folder


cd

# Shows all install locations of an executable (in


this case ruby)
which -a ruby

# Kill a process by grepping its process name, rep


lace [p]rocessname with your own process, surround
first char with []
ps aufx | grep [p]rocessname | awk -v N=2 '{print
$N}' | sudo xargs kill -9

# Find all files in home directory that does not m


atch my user/group.
# Then change owner:group to my user/group.
find ~/ \( -not -group $(id -g) -or -not -user $US
ER \) -execdir chown $USER: '{}' +

## snapshotting:
# creates a snapshot:
virsh snapshot-create-as "$vmname" "$snapshotname"
"$descripton" --atomic

2 0
2 0
2 0
2 0

2 0

2 0

2 0

# lists snapshots:
virsh snapshot-list "$vmname" [--tree]
# restores snapshot:
virsh snapshot-revert "$vmname" "$snapshotname"
# deletes a snapshot:
virsh snapshot-delete "$vmname" "$snapshotname"

apt-key
http://bropages.org/browse

2 0
70/174

8/3/2016

bro: just get to the point!

# your_comment_here
# downloads a key via port 80 in case you're firew
alled restrictively:
sudo apt-key adv --keyserver hkp://keyserver.ubunt
u.com:80 --recv-keys $KEYID

laravel

livestreamer

# Lightning fast alernative to 'composer create-pr


oject laravel/laravel'. Simply replace ProjectName
with your ... well, project name
# and you are good to go. Execution time is seriou
sly less than 15 seconds. Just do it.
laravel new ProjectName

# your_comment_here
Opens flash streams in vlc (default).

2 0

2 0

Example:
livestreamer youtube.com/random-movie best
livestreamer twitch.tv/random-stream medium
livestreamer justin.tv/random-stream worst
Format:
livestreamer link quality.

hdiutil
zip

write
lsb_release

# Resize a sparse disk image to be 1200 MB large


hdiutil resize -size 1200m mydisk.sparseimage

# Recursively zip everything, starting from the cu


rrent directory, that matches the given pattern in
to archive.zip
# Note: the `R` flag is case sensitive!
zip -R archive "*.png"
zip --recurse-patterns archive "*.png"

# Start a conversation with another user


write john

# Determine the OS version you are running


lsb_release -d

2 0
2 0

2 0
2 0

# Figure out what crazy name Ubuntu is using for y


our version
lsb_release -c

tcpdump

http://bropages.org/browse

# Begin a capture on eth0


# -e print the ethernet address
# -n Dont convert host addresses to names

2 0

71/174

8/3/2016

bro: just get to the point!

# -i specify an interface
tcpdump -eni eth0

mysqldump

date

xclip
date

tmux

# Backup data and the structure from many tables i


n a database to a .sql file
mysqldump -u user -p database_name table_1 table_2
table_3 > file_name.sql

# Set the date to Fri Feb 14 09:18 with current ye


ar as default
# date mmddhhmi
# where mm = month
#
dd = day of month
#
hh = hour
#
mi = minute
date 02140918

# Put the text "Hi." into the primary selection.


echo "Hi." | xclip

# Last day of current month.


date --date="$(date --date="next month" +%Y-%m-01)
-1 day" +%Y-%m-%d

# more pane splitting


C-b, % #split pane vertically
C-b, " #split pane horizontally

2 0

2 0

2 0
2 0

2 0

# pane switching
C-b, o #go to another/next pane
C-b, q #print ids of panes, or jump to one by ent
ering it's number, ie C-b, q2

pandoc

tcpdump

tcpdump
http://bropages.org/browse

# Process markdown file foo.md using standard pand


oc markdown with multiline_tables extension (simil
ar for any other extesions), produces tex file rea
dy for LaTeX.
pandoc -o foo.tex -r markdown+multiline_tables fo
o.md

# Dump all traffic destined for TCP port 80. (show


numeric IP addresses -n)
tcpdump -n dst port 80

# Splitting a large pcap


tcpdump -r network.pcap -C 100 -w output

2 0

2 0

2 0
72/174

8/3/2016

ngrep

bro: just get to the point!

# Search for any word with user


ngrep -q -I $FILE|grep -i user

2 0

# Search for emails


ngrep -q -I $FILE '[a-zA-Z0-9.]+\.?@[a-zA-Z0-9.]+
\.[a-zA-Z0-9]+' |grep -Eo '[a-zA-Z0-9.]+\.?@[a-zAZ0-9.]+\.[a-zA-Z0-9]+'|sort|uniq

renice

# Reduce the execution importance (niceness) of PI


D 1938

2 0

renice 10 -p 1938

nice

# Runs the 'gcc' command at a lower priority

2 0

nice -n 15 make gcc -o test test.c

stat

wget
du
time

mtr

mlabel

# Display the file type and permissions of a file/


folder in octal format
stat -f %p filename

# Download a list of urls from a file


wget -i urls.txt

# list subfolders with size (mac)


du -h -d 1

# time - run programs and summarize system resourc


e usage
time [program]

# Runs a basic traceroute using MyTraceRoute with


domains and IP addresses and outputs a basic repo
rt
mtr --show-ips --report google.com

# Check the current label of /dev/sdb1


sudo mlabel -i /dev/sdb1 -s ::

2 0

2 0
2 0
3 1

2 0

2 0

# Set the label of /dev/sdb1 to MY_LABEL


sudo mlabel -i /dev/sdb1 ::MY_LABEL

snmpwalk
http://bropages.org/browse

# Retrive a subtree of managment values using veri


son 2
snmpwalk -v2c -cpublic <snmp_agent_IP>

2 0
73/174

8/3/2016

umount

pry
unrar

bro: just get to the point!

# Unmount (rather than eject) a volume (like a CD


or a second hard drive)
umount /media/[your_username]/[volume_name]

# Load the gem you are developing into pry


pry -Ilib -rgem_name

# Unrar an archive to the current directory

2 0

2 0
2 0

unrar e <archive name>

git revert

if

# Reverts the last commit made by creating another


commit
git revert HEAD

# echos "found" if a file contains the word you're


looking for
if grep myword myfile.txt ; then echo "found" ; fi

2 0

2 0

# same thing on multiple lines


if grep myword myfile.txt
then echo "found"
fi

wall

tac

subl

ntpdate
badblocks

http://bropages.org/browse

# Show the message "hello" on all the terminals of


all logged-in users.
echo "hello" | wall

# Output a file (temp in this case) with lines in


reversed order
tac temp

# open the folder ~/cat-tales/ in the existing win


dow
subl -a ~/cat-tales/

# sync your time with da server


sudo ntpdate pool.ntp.org

# Check a device for bad blocks in a non destructi


ble way
#Change /dev/sdX with the path to the device
badblocks -nsv /dev/sdX

2 0

2 0

2 0

2 0
2 0

74/174

8/3/2016

caffeinate

bro: just get to the point!

# Disable sleep on Mac from the command line tempo


rarily:
caffeinate

2 0

# Run for 4 hours:


caffeinate -t 144000 &
# Attach to other commands to prevent Mac from sle
eping:
caffeinate [command_to_run] -arguments

qemu-img

mkvirtualenv

unalias
git

git checkout

npm

git log

# create disk image called "four-gigs.img" and is


4000 megabytes in size
qemu-img create four-gigs.img 4000m

# Create a virtualenv named virtual_env_name. It w


ill be created in WORKON_HOME.
mkvirtualenv virtual_env_name

# Remove an alias named alias_name.


unalias alias_name

# a better alternative to git pull, won't commit m


erge conflicts
!git remote update -p; git merge --ff-only @{u}

# The following command will create a local branch


named foo, tracking the remote branch origin/foo.
When you push your
# changes the remote branch will be updated.
git checkout --track origin/foo

# Install node package into local node project and


save the package and version into package.json
npm install --save <package_name>

# Search the commit history for changes including


the string 'something', showing the diff of each
commit. Useful for
# finding when the a particular string was added o
r used in your commit history.
git log -p -Ssomething

2 0

2 0

2 0
2 0

2 0

2 0

2 0

# Same as above, but only search for the string 's


omething' being used in the commit history of the
file foo.py.
git log -p -Ssomething -- foo.py

http://bropages.org/browse

75/174

8/3/2016

set

find

feh

bro: just get to the point!

# stop script execution if error happen ( exitcode


!= 0 ) http://tldp.org/LDP/abs/html/exitcodes.htm
l
set -e

# Find files that were modified less than 4 days a


go and more than two days. Notice that `find -ctim
e +3 -ctime -4` would give no results.
find -ctime +2 -ctime -4

# Show thumbnails of your pictures in a folder


feh -t folder

2 0

2 0

2 0

# Show a picture in auto zoom mode


feh -Z picture.jpg

compare

apt-cache
eject
svn

svn

gpasswd

ssh

http://bropages.org/browse

# compare two images and create a visual diff outp


ut (as png in this case)
compare image1 image2 -compose src diff.png

# See the description of the Apache package


apt-cache show apache2

# Close the removable disk tray


eject -t

# Performs a complete merge of a branch (relative


URL from repository root) into your working copy
svn merge ^/path/to/branch /path/to/working/copy

# Merges revision 420 from /main to current workin


g copy
svn merge -c 420 ^/main /path/to/working/copy

# add user to group without removing from other gr


oups
gpasswd -a user grup

# To enable the ability to forward X11 windows to


a machine logged in using SSH. This is great if y
ou would like to run a graphical program from a re
mote computer on your local machine logged in with
SSH.
ssh -X user@remote-server

2 0

2 0
2 0
2 0

2 0

2 0

2 0

76/174

8/3/2016

xclip
mv
lame

hdparm

route

netstat

wget

nslookup
hydra

i3

http://bropages.org/browse

bro: just get to the point!

# Copy in clipboard
xclip -sel clip < foo.txt

# Rename a file
mv old_name.txt new_name.txt

# The only way to use lame for [.mp3/.ogg/.aac/.wa


v/.aif/.aiff/.au/.voc/.wma/.flac]
lame --preset insane <infile.whatever> <outfile.mp
3>

# Set spin-down timeout on drive; value is zero (d


isabled), between
# 1 and 240 inclusive (multiples of 5 seconds) or
vendor-specific
hdparm -S60 /dev/sdd # 5 minutes

# Set a default gateway


# route add default gateway [ip address] [eth devi
ce]
route add default gateway 172.19.0.1 eth0

# List pid /programs name linked to port 3000, dis


playing adress in a numerical format.
netstat -lpn |grep :3000
# will output something like that :
# tcp 0
0 0.0.0.0:3000 0.0.0.0:* LISTEN
14016/ruby

# Get your external ip address from icanhazip.com


and echo to STDOUT
wget -O - http://icanhazip.com/ | tail

# get all DNS entry types for www.slashdot.org


nslookup -q=any www.slashdot.org

# attack your own server at http://127.0.0.1/test/


authtest with user admin and a 4-digit password:
hydra -l admin -x 4:4:1 -t 1 -f -vV 127.0.0.1 http
-get /test/authtest

# spawn a new terminal


$mod+[enter]

2 0
2 0
2 0

2 0

2 0

2 0

2 0

2 0
2 0

2 0

77/174

8/3/2016

nmap

autojump

bro: just get to the point!

# Check a specific port (in this case, 8080) on a


remote host
nmap -p8080 www.google.com

# jump to previously visited directory containing


'foo'
autojump foo

2 0

2 0

# list top directories and their weights


autojump -s
# decrease weight of current directory
autojump -d
# increase weight of current directory
autojump -i

ip
mongorestore

mkdir

# inspect routing table


ip route

# restores dump to specific database


mongorestore -d destinationDatabaseName ./path/to/
dump/database

rsync -a ./from ./to --include \*/ --exclude \*

2 0
2 0

2 0

# your_comment_here
Copy directory structure without files

sed

git diff

expr
journalctl
lsof
http://bropages.org/browse

# Find and replace all instances of FOO with BAR i


n all matching files.
find . -type f -print | xargs sed -i 's/FOO/BAR/g'

# Show the changed filenames between HEAD and orig


in/develop.
git diff --stat origin/develop

echo $((2+2))
#4

# Show all messages from the previous boot


journalctl -b -1

# Show connections to specified host


lsof -i@192.168.0.1

2 0

2 0

2 0
2 0
2 0
78/174

8/3/2016

ldd

lsblk

grep
mpv
ssh

bro: just get to the point!

# The ldd command list the shared library dependen


cies of a file. You must supply the full path to t
he file. The following will display the shared lib
rary dependencies of the 'zip' file.
ldd /usr/bin/zip

# List information about available block devices i


ncl. labels attached to them.
lsblk -f

# Find files without pattern


grep -L pattern *

# Disable on screen controller


mpv --no-osc video.mkv

# Just connect to a remote server and get a shell


# -p is needed, if remote SSH is not listining on
# standard port (22)

2 0

2 0

2 0
2 0
2 0

ssh -p 1234 user@remoteserver.com

updatealternatives

# Add a new alternative for an already installed p


rogram. Identical syntax to adding a new one,
# just provide the path to the other alternative a
s the second-to-last argument, with a different pr
iority number.
sudo update-alternatives --install "/usr/bin/java"

2 0

"java" "/usr/local/my-other-jdk/java" 2

lsof

uniq

sed
yum
http://bropages.org/browse

# Show what files or filehandles are open in the /


tmp directory (if its not a seperate partition). T
his can be slow.
lsof +D /tmp

# This will show a count of all lines that have mo


re than 1 copy. So only show the duplicates. (-d)
uniq -cd

# Remove bad ssh-rsa key


sed -i 19d .ssh/known_hosts

# Search for a command or binary inside any packag


e

2 0

2 0

2 0
2 0
79/174

8/3/2016

bro: just get to the point!

yum provides */<your_command>

yum

date
pigz

lpass

macchanger
mvn
fortune

# Lists all the groups of software you can install


with yum
yum grouplist

# Previous month
date --date="$(date +%Y%m15) -1 month" +'%Y-%m'

# uncompress file with pigz (although standard gnu


gzip can be used also -pigz
# decompression may be slightly faster but not to
the extent of the compression)
gzip -d filename.gz

# Login with your email


lpass login example@example.com
# List all your accounts
lpass ls
# Find the account you want from the output and us
e the name or ID in the next command
# Copy password to clipboard (leave off -c to disp
lay the password)
lpass show -c --password "Google Mail"

# Changes to a random mac address


macchanger -r wlan0

# clean and install with maven but skip the tests


mvn clean install -Dmaven.test.skip=true

# presents a fortune
fortune

2 0

2 0
2 0

2 0

2 0
2 0
2 0

# presents an offensive fortune


fortune -o
# presents a long fortune
fortune -l
# presents a short fortune
fortune -s
# options can be combined
fortune -os

date
http://bropages.org/browse

2 0
80/174

8/3/2016

bro: just get to the point!

# Print file date in this format: 2014-12-27 13:18


date -r ".bashrc" "+%Y-%m-%d %H:%M"

crontab
apropos
tar

#List crontab for current user


crontab -l

# Search man pages for a keyword e.g. "socket"


apropos socket

# Extract all files from tar gzipped archive verbo


sely
tar xzvf archive.tar.gz

3 1
2 0
2 0

# Create a tar gzipp'd archive verbosely


tar czvf archive.tar.gz /path/to/directory fileN

git diff

# This is useful for sharing/saving a set of chang


es
# without having to commit anything.

2 0

# Create a patch file containing a diff.


git diff > diff.patch
# Apply the changes within the patch.
git apply diff.patch

plz
rvm

avconv
docker

banner

http://bropages.org/browse

# Ask for help from a bro.


plz

# remove your .rvm folder and obliterate everythin


g installed with rvm
rvm implode --force

# Convert mkv to mp4


avconv -i input.mkv -codec copy output.mp4

# Start bash in a new ubuntu container.


# This will download the ubuntu image if it's not
already installed.
docker run -i -t ubuntu /bin/bash

# Change width to 72 chars


banner -w 72 "YO BRO"

2 0
2 0

2 0
2 0

2 0

81/174

8/3/2016

nginx
ulimit

blkid

heroku
gzip
gpsd

diskutil

bro: just get to the point!

2 0

# reload nginx configuration (might need sudo)


nginx -s reload

# Show maximum number of file descriptors open at


once
ulimit -n

# Display block device attributes such as UUID and


filesystem type
blkid /dev/sdb1

2 0

2 0

2 0

# clone app to local directory


heroku git:clone -a <app_name>

2 0

# decompress gzip to file


gzip -dc < myfile.txt.gz > myfile.txt

# Run gpsd with some debug enabled on localhost:13


37
gpsd -b -N -D 2 /dev/ttyUSB0 -S 1337

# shows all available disks and their partitioning

2 0

2 0

diskutil list

update
cowsay

http://bropages.org/browse

2 0

# Record to a file in CD-quality


arecord -f cd -t wav file.wav

# ______
# < yum! >
# -----#
/^
#
// \
#
\// .\
#
|\\
#
| \ \
#
| \ \
#
|
\
\
#
|
\
\

2 0
\

/\

|\___/|

\ /O O \__ /

//

*----*
/
\

/ \/_/

//

|
@___@`

\/_

//

\/\ \
0/0/|
\ \
0/0/0/0/|
| |

\/_ //
\///

82/174

8/3/2016

bro: just get to the point!

0/0/0/0/0/_|_ / ( //
| /
#
0/0/0/0/0/0/`/,_ _ _/ ) ; -.
|
_ _\.-~
/ /
#
,-}
_
*
-.|.-~-.
.~
~
#
\
\__/
`/\
/
~-. _ .-~
/
#
\____(oo)
*. }
{
/
#
(
(--)
.----~-.\
\-`
.~
#
//__\\ \__ Ack! ///.----..<
\
_ -~
#
//
\\
///-._ _ _ _
_ _ _{^ - - - - ~
#
cowsay -f dragon-and-cow "yum!"
|

elasticsearch
mreyes

_\

# Start ElasticSearch as daemon.


elasticsearch -d

# your_comment_here
You may think mreyes is a bit like Xeyes, but it i
s really not. mreyes is the MAN, and not even sud
o can execute mreyes.

2 0
2 0

chucknorrisdo -u mreyes write_engineer.sh

ldapsearch

setxkbmap

top
diff

screenfetch

http://bropages.org/browse

# Connect to a host using simple auth, with the ba


se tree "myhost", and return all objects
ldapsearch -H ldap://localhost:1389 -x -b "o=myhos
t" objectclass=*

# Remaps the capslock key to act like the super (w


indows) key
setxkbmap -option caps:super

# Order by cpu usage


top -o cpu

# Show the difference between two directories, ign


oring .DS_Store files
diff -rx .DS_Store DIR1 DIR2

# print system info with a fancy ascii logo


screenfetch

2 0

2 0

2 0
2 0

2 0

83/174

8/3/2016

bro: just get to the point!

# print info and take screenshot


screenfetch -s

info

ping

apt

modprobe

# read documentation for a command


# info is sometimes more detailed than man
info <command>

# Pings an address 10.0.0.150 in this example appe


nding a timestamp with an interval of 200 ms
ping -i 0.2 10.0.0.150 | while read pong; do echo
"$(date +%Y-%m-%d:%H:%M:%S:%N): $pong" ; done

# show various technical information about the 'fi


refox' package,
# as well as a short description
apt show firefox

# load a kernel module


modprobe <module>

2 0

2 0

2 0

2 0

# unload a kernel module


modprobe -r <module>

go
pushd

# Run tests in current folder and all sub-folders


go test ./...

# shows you all directions in the stack


dirs

2 0
2 0

# switches to last stacked direction (by pushd)


popd

diff

# diff remote files over SSH

2 0

ssh user@remote_host "cat remote_file.txt" | diff


- local_file.txt

sips

mv

# Resize image to width 500px, and saving to anoth


er file (respecting aspect ratio)
sips -Z 500 in.png --out out.png

# Rename a bunch of files all at once:


# (this uses bash for and sed commands as helper
s..)

2 0

2 0

for fname in *.png ; do mv "$fname" "$(echo "$fna


http://bropages.org/browse

84/174

8/3/2016

bro: just get to the point!

me" | sed 's/OldFilenameSubstring/NewFilenameSubs


tring/')" ; done;
# (replace *.png with whatever you want.)

nc
say
sdate

# A quick check for port information including NAT


nc -vz example.com 80

# Right syntax for speaking at a different rate


say -r 1 "I am speaking at a different rate"

# Prints the current "Eternal September" date


sdate

2 0
2 0
2 0

# Causes cal to print the calendar for eternal sep


tember
# You can wrap any program like this
sdate cal

pfctl

# Load the pf.conf file


pfctl -f /etc/pf.conf

2 0

# Parse the file, but don't load it


pfctl -nf /etc/pf.conf
# Load only the NAT rules from the file
pfctl -Nf /etc/pf.conf
# Load only the filter rules from the file
pfctl -Rf /etc/pf.conf
# Show the current NAT rules
pfctl -sn
# Show the current filter rules
pfctl -sr
# Show the current state table
pfctl -ss
# Show filter stats and counters
pfctl -si
# Show EVERYTHING it can show
pfctl -sa

entr

# Rebuild project if sources change


ls *.c *.c | entr make

2 0

# Rebuild project and run tests if the build was s


uccessful
ls *.c *.h | entr sh -c 'make && make test'
http://bropages.org/browse

85/174

8/3/2016

sed
tmux

yo
git remote

ssh-keygen

chmod
firefox
fg
fg
uptime
tcpdump

http://bropages.org/browse

bro: just get to the point!

# delete all lines that contain "foo" inplace


sed -i '/foo/d' $file

# Attach to a tmux session running on a remote hos


t
ssh <remote_host> -t tmux a
ssh <remote_host> -t tmux attach -t <session_name>

# useful tool to generate boilerplate code


yo <generator-name>

# shows a list of your remotes and where they are


pointing to
git remote -v

# Creates a new ssh key, using the provided email


as a label Generating public/private rsa key pai
r.
ssh-keygen -t rsa -b 4096 -C "your_email@example.c
om"

# Copy permissions from one file to another


chmod --reference=otherfile thisfile

# Launch Firefox in private browsing mode


firefox -private-window

# Open last suspended process


fg

# Open 2nd suspended process in buffer


fg %2

# print the prettier uptime without load averages


uptime -p

# Capturing with tcpdump for viewing with Wireshar


k
# Older versions of tcpdump truncate packets to 68
or 96 bytes. If this is the case, use -s to captu
re full-sized packets
tcpdump -i <interface> -s 65535 -w <some-file>

2 0
2 0

2 0
2 0

2 0

2 0
2 0
2 0
2 0
2 0
2 0

86/174

8/3/2016

find

git fetch

rsync

mysql
pear

pecl

git add
jq
nl
port

http://bropages.org/browse

bro: just get to the point!

# Searches through my user's "home" directory recu


rsively for the file "hashClass.java", throwing ou
t error output along the way.
# Passes the output to grep for case insensitive s
earch.
find ~/ 2>/dev/null | grep -i "hashclass.java"

# Updates your local copy of the 'foo' remote repo


sitory
# --prune : removes branches in your local copy of
the repository that don't exist/were deleted on t
he remote
git fetch --prune foo

# transfer a local file to a remote-server, with p


rogress
rsync --progress localFile.txt remote-server:/targ
etDirectory

# Connect to mysql
mysql -u <user> -p<password> -h host -P port

# Set PHP Version used for phpize etc.


# useful if several versions of PHP are installed
pear config-set php_ini /etc/php.ini

# Set PHP Version used for phpize etc.


# useful if several versions of PHP are installed
pear config-set php_suffix 5

# Add a folder to the index


git add ./folder

# Read a gzipped JSON file


gzip -d -c file.json.gz | jq .

# write a file to STDOUT with line numbers


nl filename

# Update MacPorts's ports list and internals


sudo port selfupdate

3 2

1 0

2 1

2 1
1 0

1 0

1 0
1 0
1 0
1 0

87/174

8/3/2016

xz
xz
php

setfacl

bro: just get to the point!

# Create a compressed archive


tar cf - linux-3.9.2 | xz > linux-3.9.2.tar.xz

# Extract a compressed archive


xz -d < linux-3.9.2.tar.xz | tar xvf -

# Execute PHP code via command-line with `php -r


''`
php -r '
$myName = "bob";
echo "hello, " . $myName;
echo "\n";
'

# Give a user rwx permissions on the current direc


tory using ACL
sudo setfacl -m u:username:rwx .

1 0
1 0
1 0

1 0

# Give a group rwx permissions on the current dire


ctory using ACL
sudo setfacl -m g:mygroup:rwx .
# Set default permissions (when a new file is crea
ted, it will
# have these permissions)
sudo setfacl -d -m u:username:rwx .
# Set ACL permissions recursively
sudo setfacl -R -m u:username:rwx .

# Run previous command but replacing, useful when


you have a typo
$ echo "I write currectly"
> I write currectly
$ ^u^o
> I write correctly

1 0

# Default is empty so...


vim file.txt
# Open an unwanted file, but then
^
# Opens the file you want (file.txt)

ngrok
sed

http://bropages.org/browse

# Pick a custom subdomain so your app appears on


ngrok -subdomain myapp 80

# Strip HTML
sed -e 's/<[^>]*>//g' index.html

1 0
3 2

88/174

8/3/2016

clang

ls

bro: just get to the point!

# Compiles program.c into program, with more warni


ngs than usual, and disabling extensions
clang -Werror -Wall -Wextra -pedantic program.c -o
program

# your_comment_here
#list the contents of a directory
ls .

2 1

5 4

#list the contents of a directory with attributes


ls -l .
#list the all contents of a directory including hi
dden files/direcotories
ls -a .
#recursively list the files and directories
ls -R .

readlink

ssh

# your_comment_here
#readlink prints out the contents of a symlink, re
turn EINVAL if its not a symlink
readlink file

# You can connect to the remote screen or tmux dir


ectly

1 0

1 0

ssh user@host -t 'tmux a -t session_name||tmux new


-s session_name'

service

cowsay
ssh
chmod

dmesg
http://bropages.org/browse

# restart the service called apache2, if you are l


ogged in as root:
service apache2 restart
sudo service apache2 restart

# make a sodomized sheep say hello


"hello" | cowsay -f sodomized-sheep

# ssh tunneling traffic to port 1080


ssh -C2ND 1080 user@host

# Give everyone read and execute access to folder


'foo' and all its contents
chmod -R 555 foo

1 0

3 2
1 0
2 1

1 0
89/174

8/3/2016

bro: just get to the point!

# Prints messages by the kernel


# dmesg

awk

debootstrap
git flow

git flow

git flow

git flow

# Prints one line for every second field in my_ser


ver.log
# 'Fields' are separated by whitespace.
cat my_server.log | awk '{ print $2 }'

# your_comment_here
debootstrap raring raring

# To initialize a new repo with the basic branch s


tructure
git flow init

# To list/start/finish feature branches, use:


git flow feature
git flow feature start <name> [<base>]
git flow feature finish <name>

# To push/pull a feature branch to the remote repo


sitory, use:
git flow feature publish <name>
git flow feature pull <remote> <name>

# To list/start/finish release branches, use:


git flow release
git flow release start <release> [<base>]
git flow release finish <release>

1 0

1 0
1 0

1 0

1 0

1 0

# For release branches, the <base> arg must be a c


ommit on develop.

VBoxManage
VBoxManage
VBoxManage
git config
http://bropages.org/browse

# start vm without gui in the background


VBoxManage startvm "vmName" --type headless

# power off the running vm vmName


VBoxManage controlvm "vmName" poweroff

# List running vms


VBoxManage list runningvms

# your_comment_here
You can set your custom configurations in system l

1 0
1 0
1 0
1 0
90/174

8/3/2016

bro: just get to the point!

evel (for all users in current machine) with this


command :
git config --system <YOUR_CUSTOM_CONFIG>

git config

git config

# This command will active color on files in each


tree levels of git (working tree, staging tree an
d repository tree)
git config color.ui true

# File permissions will sense by git. You can disa


ble this sense by using this command :
git config core.fileMode true

1 0

1 0

# You can also enable this sense by using this com


mand :
git config core.fileMode false

git config

# You can assign your custom color in each level o


f git tree (available colors are : normal, black,
red, green, yellow, blue, magenta, cyan and whit
e)

1 0

# For example, you can change the color of changed


files by using this command :
git color.status.changed YOUR_CUSTOM_COLOR
# Or, you can change the color of untracked files
by using this command :
git color.status.untracked YOUR_CUSTOM_COLOR

port
ifenslave

bonding

ghc-pkg

# Update installed but outdated packages


sudo port upgrade outdated

# Bond multiple interfaces into one bond


modprobe bonding mode=balance-rr miimon=100
ifenslave bond0 eth0 eth1

# Bond multiple interfaces into one bond


modprobe bonding mode=balance-rr miimon=100
ifenslave bond0 eth0 eth1

# list packages
ghc-pkg list
# global only
ghc-pkg list --global
# user only
ghc-pkg list --user

1 0
1 0

1 0

1 0

# delete a package
http://bropages.org/browse

91/174

8/3/2016

bro: just get to the point!

ghc-pkg unregister deepseq


# find broken packages
ghc-pkg check

orca

whence

# Orca is a screen reader for the Gnome Desktop.


# start orca with text-only setup.
orca -t

# List all the pythons accessible in your $PATH (z


sh only)
whence -a python

1 0

1 0

# Show the absolute path of MySQL even if it's ali


ased (zsh only)
whence -p mysql

echo

# print the shell environment variable 'home' to s


tandard output
echo $HOME

1 0

# apend 'bro' (newline) to the end of bro.txt, cre


ate the file if !exists
echo 'bro' >> bro.txt

tidy

ffmpeg

mount
rbenv

rbenv
uname
http://bropages.org/browse

# hide warnings and errors, ignore parsing errors,


no line-wrapping
tidy -quiet --force-output y -wrap 0 2>/dev/null

# Capture video of a linux desktop


ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tm
p/out.mpg

# Mount a temporary RAM partition


mount -t tmpfs tmpfs /mnt -o size=1024m

# Generate shims for gem executables (do this afte


r installing a new gem
# that has a command associated with it)
rbenv rehash

# List all the ruby versions rbenv can install


rbenv install --list

# Displays the machine's architecture


uname -m

1 0

1 0

1 0
1 0

1 0
1 0
92/174

8/3/2016

mmaker

bro: just get to the point!

# your_comment_here
your_command_here

1 0

# To_update_openbox_menu
mmaker -v OpenBox3
# To_update_openox_menu_by_overwrting_rc.xml
mmaker -vf OpenBox3

iotop

# Start iotop
sudo iotop

1 0

# Only show processes (not threads)


sudo iotop -P
# Show only processes with activity, update every
10th second
sudo iotop -o -d 10
# Turn on non-interactive mode that can e.g. be co
nsumed by scripts
sudo iotop -b

rails

# create a new project name 'myapp' with all defau


lt settings

1 0

rails new myapp

postfix
malloc

# check whether postfix is running


sudo postfix status

# What it does?
# allocate dynamic memory for the requesting proce
ss

1 0
1 0

# What is the Signature?


# void* malloc(size_t size);
# Which library to include?
# stdlib
# What is the parameter taken?
# Number of bytes that the programmer wants.
# What is returned?
# If there is enough memory to allocate, the call
will return a pointer to the allocated block, if
not NULL is returned. If size is 0, then malloc
returns either NULL, or a unique pointer value th
at can later be successfully passed to free.

http://bropages.org/browse

93/174

8/3/2016

bro: just get to the point!

# Others
# Returned memory can contain Junk values, access
ing them invokes undefined behavior.
# When you no longer need the memory, call free an
d pass the pointer which was returned by malloc.
# calloc does same thing as malloc expect that the
memory is initialized with 0.
# SAMPLE PROGRAM:
#include<stdio.h>
int main()
{
int *ptr_one;
//allocate
ptr_one = (int *)malloc(sizeof(int));
if (ptr_one == 0) {
printf("ERROR: Out of memory\n");
return -1;
}
//use
*ptr_one = 25;
printf("%d\n", *ptr_one);
//free
free(ptr_one);
return 0;
}
your_command_here

git merge

# Merge the branch 'some_branch' into the current


branch without actually touching anything
git merge some_branch -s ours

1 0

# Merge the branch 'some_branch' into the current


branch, forcing a merge commit
git merge --no-ff some_branch
# Merge the branch 'some_branch' into the current
branch, forcing a merge commit, and stopping befo
re actual commit
git merge --no-ff --no-commit some_branch

rkhunter

# Update Definitions
sudo rkhunter --update

1 0

# Update Stored Values of Commands For Future Comp


arison (Use after installing software that you tru
st.)
sudo rkhunter --propupd
# Scan System (with all prompts and alerts)
sudo rkhunter --check
http://bropages.org/browse

94/174

8/3/2016

bro: just get to the point!

# Scan System (with all prompts)


sudo rkhunter --check --rwo
# Scan System (with all alerts)
sudo rkhunter --check --sk
# Scan System (without prompts or alerts)
sudo rkhunter --check --rwo --sk

find

iptables

eix

eix

emerge

emerge

emerge

equery

emerge
http://bropages.org/browse

# Find all subdirectories that have been created i


n the last 5 days.
find . -type d -ctime -5

# basics of iptables
# switch -A INPUT/OUTPUT
# switch -p tcp/udp
# switch -j ACCEPT/DROP
# destination port as --dport 80

# Look for the libreoffice package in your local p


ortage-tree by name
eix libreoffice

# Look for all installed packages whose name start


with php using eix
eix -I php*

# List which list of packages would require you to


install libreoffice without actually installing t
hem:
emerge -pv app-office/libreoffice

# Remove the Gentoo Portage - package named dev-la


ng/ruby but not its dependencies:
emerge -C dev-lang/ruby

# Remove a Gentoo Portage - package along with its


post-install unrequired dependencies:
emerge -cav category/package-atom

# Which Portage packages do require media-libs/lib


vorbis-1.3.3 ?
equery d media-libs/libvorbis-1.3.3

1 0

1 0

1 0

1 0

1 0

1 0

1 0

1 0

1 0
95/174

8/3/2016

bro: just get to the point!

# Update your Gentoo system (might be neccessary a


fter use flag changes)
emerge -uDN @world

make
ctags
http-100

http-200

iptables

vim

kill
dos2unix

xinit
http://bropages.org/browse

# Make make verbose


make V=1

# generate tags recursively


ctags -R --tag-relative

100 Continue
101 Switching Protocols
102 Processing (WebDAV)

200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status (WebDAV)
208 Already Reported (WebDAV)
226 IM Used

# Add a rule to the top of the INPUT chain to drop


all incoming connections on all ports from the sp
ecified IP address
iptables -I INPUT 1 -s xxx.xxx.xxx.xxx -j DROP

# Type a file name after vim in order to open the


vim editior with that text file
vim <filename.extension>
vim pythonExample.py
vim README.txt
vim PerlExample.pl

# Kill all processes running on port 9001


kill `sudo lsof -t -i:9001`

# remove DOS/Mac control characters/line endings a


nd convert file to unix
dos2unix /home/el/yourdosfile.txt

1 0
2 1
1 0

1 0

1 0

2 1

1 0
1 0

1 0
96/174

8/3/2016

bro: just get to the point!

# start a default X session


xinit

xinit
systemctl
systemctl

# Start an X session with i3wm on display :1


xinit /usr/bin/i3 -- :1

# check the status of a service called bro


systemctl status bro.service

# start a service called bro (run as root)


systemctl start bro.service

1 0
1 0
1 0

# or (as a sudoer)
sudo systemctl start bro.service

systemctl

# stop a service called bro (as root)


systemctl stop bro.service

1 0

# or (as a sudoer)
sudo systemctl stop bro.service

systemctl
xev

mysqladmin

amixer

# start mpd to run as a normal user


systemctl --user mpd.service

# the xkb meymap manager for the X.org isn't easy


to navigate.
# fortunately, there is xev, which simply prints t
he keycode
# of whatever keypress is directed towards it's wi
ndow.
xev

# mysql processlist and statistics, with full (ver


bose) running queries
mysqladmin pr stat --verbose

# Use amixer to ajust your volume.


# "Master" reffers to master volume.
#
# tip: this is greate for keybinding.

1 0
1 0

1 0

1 0

amixer sset Master 5%+


-increace volume by 5%
amixer sset Master 5%-decrese volume by 5%

http://bropages.org/browse

97/174

8/3/2016

iperf

uuidgen
uuidgen
restorecon
ftp

pg_restore

bro: just get to the point!

# test network with iperf client mode using UDP pa


ckets, sending bandwidth at 1 M/sec, port 50000, 3
0 seconds, with 8 parallel client threads
iperf -u -c [ip_address] -p 50000 -b 1M -t 30 -P 8

# Create a time and ethernet mac based uuid


uuidgen -t

# Generate random (don't use for crypto!) uuid


uuidgen -r

# Re-apply the selinux context to the dir /var/www


restorecon -R -v /var/www

# Starts an ftp session with example.com, you'll u


sually be prompted for credential afterwards
ftp example.com

# Restore a PostgreSQL database from an archive fi


le created by pg_dump

1 0

1 0
1 0
1 0
3 2

1 0

# Detailed Version
pg_restore --verbose --clean --no-acl --no-owner h localhost -U your_user -d your_db_name path/to/a
rchive.dump
# Simple Version
pg_restore your_db_name path/to/archive.dump

minicom

awk
awk

ssh-keygen
http://bropages.org/browse

# Start minicom in startup mode, where you can se


t, among many other settings, which serial device
and baud rate to use. Be sure to save settings as
dfl after you're done.
minicom -s

# de-deplicate lines in a text file


awk '!x[$0]++' input.txt > output.txt

# removes lines that exist in file2 from file1


awk 'NR==FNR{a[$0]++;next} !a[$0]' file2.txt file
1.txt > output.txt

# remove host from known_hosts file


ssh-keygen -R hostname

1 0

1 0
1 0

1 0
98/174

8/3/2016

git diff

bro: just get to the point!

# Show the differences between your working direct


ory and the index
git diff
#
# Show the differences between most recent commit
and the index
git diff --cached

1 0

# Show the differences between the working directo


ry and the most recent commit
git diff HEAD

apt-cache
gprof

scrot

lsof

oneko
perf

cppcheck

git bundle

http://bropages.org/browse

# Search for php5 packages


apt-cache search php5

# Reading gprof output after commpiling with gprof


and running application:
gprof yourprogram gmon.out >output.txt

# screencap a part of the screen with your mouse


# the file will be titled like 2014-01-31-015810_2
28x295_scrot.png
scrot -s

# List open network connections without resolving


hostnames, userids, or ports (via '/etc/service
s'). Makes it faster.
lsof -i -nlP

# Renders a kitty to chase your mouse around


oneko

# Build with perf then run program under reporter:


# -g flag collects graph info on processor
perf record -g ./myprogram
# then view report:
perf report --stdio

# Recursively check ../myproject/ and don't print


progress
cppcheck --quiet ../myproject/

# create a file named repo.bundle


# contains all the data to recreate the repo
git bundle create repo.bundle master

1 0
1 0

1 0

1 0

1 0
1 0

1 0

1 0

99/174

8/3/2016

mytop

initctl

bro: just get to the point!

#Display top like information for MySQL


mytop -u<username> -p<password> -h<host> -P<port i
f non standard> -d<database>

# Restarts the ssh daemon


initctl restart ssh

1 0

1 0

# Emits an event called 'my-event'


initctl emit my-event
# Reloads Upstart configuration files
initctl reload-configuration

blueprint
dsh

# Create a blueprint
sudo blueprint create blueprint_name

# Lists the machine and filename in the root folde


r (concurrently) from each machine in machines.txt

1 0
1 0

dsh -f machines.txt -c -M 'ls /'

git rebase

du
rpm2cpio

git branch -merged

ffmpeg

qmod
http://bropages.org/browse

# prune and graft a branch. The resulting `topic`


will be based
# onto `new_base` instead of onto `old_base`.
git rebase --onto new_base old_base topic

# sorted by size (mac)


du -hs * | sort

# Extract the contents of an RPM


rpm2cpio mypackage.src.rpm | cpio -i --make-direct
ories

# your_comment_here
Shows all the branches which have been merged into
the current HEAD, e.g., master. To show all the b
ranches that have been merged into branch foo use
' git branch --merged foo'

# Converts an input-video file to a 256k 44100Hz m


p3 file.
ffmpeg -i input-video.wav -vn -ar 44100 -ac 2 -ab
256k -f mp3 output-file.mp3

1 0

2 1
1 0

1 0

1 0

1 0
100/174

8/3/2016

bro: just get to the point!

# clears errored job 41


qmod -cj 41

qalter

# place a user hold on job 41


qalter -h u 41

1 0

# clear a user hold on job 41


qalter -h U 41

apropos

# when you know what you're looking for, but not w


hat it's called

2 1

#something about video...


apropos video
#ahh, ffmpeg
#something about music...
apropos music
#ahh, rhythmbox
#continue on with which ffmpeg, which rhythmbox if
needed #man which
#bro which

locate
wget

md5sum

# where are those crazy java files kept?


locate libjvm.so

# (continue) downloading file from URL wich requir


es HTTP authentication
wget -c --http-user=username --http-password=passw
ord http://auth.example.com/file.dat

#Get the md5sum for a file


md5sum file.txt

3 2
1 0

1 0

#Get the md5sum for a text string


echo "mystring" | md5sum

mkpasswd

gem

mongo
http://bropages.org/browse

# Generate a new password using /dev/random and th


e word "hello"
mkpasswd hello

# Print out gem's internal environment variables,


# which tells you things like where gems are
# being installed:
gem env

# Connects to mongo server, running on local machi


ne
mongo

1 0

1 0

1 0
101/174

8/3/2016

bro: just get to the point!

# Connects to a particular database 'mydb' on mong


o server, running on local machine
mongo mydb

xset

composer
faac

faac

qstat

psql
mysqldump

tput
lpadmin

# xset can be used to adjust mouse speed


# with the xset m multiplier treshold syntax
# multiplier is how fast you want to go
# and nobody cares about treshold
xset m 4 1

# Dump autoload
composer dump-autoload

# Convert to AAC (MP4) with variable bitrate (cons


tant quality)
# "-q 100" is default, you can change it up and do
wn (higher is more quality, but larger file)
faac -w -q 100 <infile>.wav <outfile>.m4a

# Convert to AAC (MP4) with constant bitrate (vari


able quality)
# # "-b 192" is an example, you can change it up a
nd down (higher is more quality, but larger file)
faac -w -b 192 <infile>.wav <outfile>.m4a

# Gives statistics on cluster using the PBS queing


system
qstat -a

# connect to a database that already exists


psql -d database_name

# Backup data and the structure from a table in a


database to a .sql file
mysqldump -u username -p database_name table_name
> file_name.sql

# Return current terminal width


tput cols

# Unmaps all printers


lpadmin -x all

1 0

1 0
1 0

1 0

1 0

1 0
1 0

1 0
1 0

# Unmaps a specific printer foo


lpadmin -x foo
http://bropages.org/browse

102/174

8/3/2016

sina

bro: just get to the point!

# The creator of bropages


sina

1 0

# The way to pull an allnighter and write a lot of


code
sina --Dstraightdope=true -tallnight

youtubeviewer
find

mplayer

date
lsof

# Search for a video


youtube-viewer foo

# find last modified file in current directory rec


ursively except directory
find ./ -not -type d -printf "%T+ %p\n" | sort | t
ail -1

# To view a movie with the text based subtitles, u


se this command to start mplayer
mplayer movie.avi -sub subtitle.txt

# First day of current month.


date +%Y-%m-01

# Show local server listening port 80


lsof -i:80 -sTCP:LISTEN

1 0
1 0

1 0

1 0
1 0

# Show all local servers


lsof -sTCP:LISTEN

jot

#The command
jot - 1 10

1 0

#prints the integers from 1 to 10, while the comma


nd
jot 21 -1 1.00
#prints 21 evenly spaced numbers increasing from 1 to 1. The ASCII character set is generated with
jot -c 128 0
#and the strings xaa through xaz with
jot -w xa%c 26 a
#while 20 random 8-letter strings are produced wit
h
jot -r -c 160 a z | rs -g 0 8
#Infinitely many yes's may be obtained through
jot -b yes 0
http://bropages.org/browse

103/174

8/3/2016

bro: just get to the point!

#and thirty ed(1) substitution commands applying t


o lines 2, 7, 12, etc. is the result of
jot -w %ds/old/new/ 30 2 - 5
#The stuttering sequence 9, 9, 8, 8, 7, etc. can b
e produced by suitable choice of step size, as in
jot - 9 0 -.5
#and a file containing exactly 1024 bytes is creat
ed with
jot -b x 512 > block
#Finally, to set tabs four spaces apart starting f
rom column 10 and ending in column 132, use
expand -`jot -s, - 10 132 4`
#and to print all lines 80 characters or longer,
grep `jot -s "" -b . 80`

rpm
iftop
apt-cache
free

getenv
puts
strcpy
strlen

http://bropages.org/browse

# Lists all the files this package will install


rpm -ql package

#Monitor the wlan0 device in bytes


iftop -i wlan0 -B

# List the names of all packages


apt-cache pkgnames

# Free up dynamic memory allocated with malloc(),


with its only argument being a pointer returned b
y malloc()
free(pointer);

# get the user's home directory


getenv("HOME");

# output a string to the screen


puts("Hello, World.");

# copy a string to a variable


strcpy(dest, src);

# find the length of a string


strlen("Hello, World.");

1 0
1 0
1 0
2 1

1 0
1 0
1 0
1 0

104/174

8/3/2016

strcat

exit
for

bro: just get to the point!

# add a string to the end of a variable


strcat(greeting, ", World."); // greeting contain
s "Hello"

# exit the current process successfully


exit(EXIT_SUCCESS);

# WEB - Shows cookies, eTag and modules installed

1 0

1 0
1 0

for i in `cat 80.txt` ; do curl -iskXHEAD http://


$i/ > $i 2>&1 ; echo Scanned $i ; done
# Find the IP address for every subdomain in list.
txt.
for x in $(cat list.txt); do host $x | grep 'has a
ddress' | cut -d ' ' -f4; done
# DNS cache poisioning
for i in `53.txt`; do dig @"$i" +short porttest.dn
s-oarc.net TXT; done; > CachePoison.txt
# Non-recursive DNS queries
for i in `cat 53.txt`; do dig @"$i" www.google.com
A +norecurse; done > NonRecurive.txt

tcpick

# Look at TCP data in printable form


# Show Port 80 data
tcpick -r $FILE -yP "port 80"

1 0

# Show all TCP flows


tcpick -r $FILE -C

lighttpd

bzip2

bzip2

http://bropages.org/browse

# Start a new process of lighttpd with your own co


nfig file. This file can contain port definitions,
web locations, access permissions and stuff.
lighttpd -f lighttpd.conf

# add file1, file2 and file3 to a tar, then compre


ss them creating file4.tar.bz2
tar -cf file4.tar file1 file2 file3
bzip2 file4.tar

# Compress file, creating file.bz2, removing the o


ld file
bzip2 file

1 0

1 0

1 0

105/174

8/3/2016

git stash
u1sdtool

gksu

ffmpeg

ffmpeg

gist

hash

http://bropages.org/browse

bro: just get to the point!

# Pop the top item from the stash (apply + drop)


git stash pop

# Replace PATH with a folder you want to sync to U


buntu One
u1sdtool --create-folder=PATH

# Shows a user interface for sudo. Use gksudo [opt


ions] <command>
gksudo -m "Input Password" whoami

# Transcode any video into HQ x264 (MPEG4-AVC) wit


h AAC audio, in MP4 (M4V) container.
# This is the de facto standard for most current s
tandalone players, such as Apple and Android.
# It will transcode the video into SAME resolution
and framerate as the original.
# You can change the crf/qscale:a values to your n
eeds (lower/higher is better, respectively, but la
rger file).
# Check out https://trac.ffmpeg.org/wiki/x264Encod
ingGuide#Compatibility if you want to change profi
le:v and baseline.
ffmpeg -i <input_file.ext> -c:v libx264 -crf 20 -p
reset slow -profile:v baseline -level 3.0 -pix_fmt
yuv420p -c:a libfaac -q:a 150 -y <output_file>.m4
v

# Similar to above, just with a higher video profi


le and level, and better quality Ogg Vorbis audio.
# Appears to work on Android 2.2 (Froyo) and newer
devices flawlessly. Should definitely work on And
roid 4.
# Packed in a MKV (Matroska) format.
ffmpeg -i <input_file.ext> -c:v libx264 -crf 20 -p
reset slow -profile:v high -level 4.1 -pix_fmt yuv
420p -c:a libvorbis -q:a 5 -y <output_file>.mkv

# copies the contents of the clipboard and pastes


the gist link to your clipboard
gist -cP

# list all existing executables -> path entries in


the table ( none destructive )
hash -l
~
~
~

1 0
1 0

1 0

1 0

1 0

1 0

1 0

106/174

8/3/2016

hash
hash

hash

arch
iftop

qq

bro: just get to the point!

# list the save path for the given executable name


hash -t bro

# will delete a specific entry from the table ( de


structive )
hash -d bro

# will remove all entries from the table ( destruc


tive )
hash -r

# Displays CPU architecture (e.g. x86_64)


arch

# Monitor the traffic between your pc and IP 192.1


68.0.2:80 (Need root permission)
sudo iftop -BP -f 'host 192.168.0.2 and port 80'

# Stores the answer to a question to be retrieved


later
qq -a "Where did I leave my glasses" "On the kitch
en bench"

1 0
1 0

1 0

1 0
1 0

1 0

# Get the answer you're looking for using fragment


ed terms
qq where glasses

xmllint

mysql

unzip
cgminer

http://bropages.org/browse

# Outputs formatted XML if document is well-forme


d:
xmllint --format --encode utf-8 doc.xml

# Connect to database asking for password, use UTF


-8
mysql -u user database --default-character-set=utf
8 -p

# Unzip overwriting content of current directory


unzip -o archive.zip

# starts cgminer and begins mining with a worker e


stablished with Slush's bitcoin mining pool
# replacements [username] your pool account usern
ame
#
[workname] the nam
e of the worker you created on the pool mining sit

1 0

1 0

1 0
1 0

107/174

8/3/2016

bro: just get to the point!

e
#
[password] the pas
sword of the worker you created on the pool mining
site
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
cgminer --url stratum+tcp://stratum.bitcoin.cz:333
3 --user [username].[workername] --pass [password]

cgminer

cgminer

parallel

toilet
vim

# displays the available USB mining devices


# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
cgminer --ndevs

# starts cgminer and begins mining with a worker e


stablished with the provided pool
# replacements [pool] pool uri
#
[port] port number
provided by pool
#
[username] your po
ol account username
#
[workname] the nam
e of the worker you created on the pool mining sit
e
#
[password] the pas
sword of the worker you created on the pool mining
site
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
cgminer -o http://[pool]:[port] -u [username] -p
[password]

# Runs the gzip command on all the *.txt files in


the current directory, in parallel
parallel gzip ::: *.txt

# Create colourful ascii text


toilt --gay "Text here"

# Create a vim instance called SERV that can be re


motely controlled.
vim --servername SERV

1 0

1 0

1 0

2 1
1 0

# Send .vimrc for the instance to edit.


vim --servername SERV --remote ~/.vimrc
# Send keys to the remote server telling it to qui
t
vim --servername SERV --remote-send ":q<cr>"
# vim must be compiled with "clientserver".

http://bropages.org/browse

108/174

8/3/2016

bro: just get to the point!

# This can easily be provided on Arch by installin


g the gvim package.

sshuttle

yaourt
iwconfig

netstat

mplayer
lspci

subl
subl
find
mkvextract

http://bropages.org/browse

# Test connection to a remote server, with automat


ic hostname and subnet guessing:
sshuttle -vNHr example.org

# searches for program


yaourt program

# display wlan information about all interfaces


iwconfig
# display wlan information about a single interfac
e
iwconfig wlan0

# show IP-to-interface mapping table (aka kernel r


outing table)
netstat -nr

# infinitely play a list of tracks


mplayer -loop 0 a.mp3 b.mp3 c.mp3

# list PCI devices


lspci
# also print corresponding kernel modules/drivers
lspci -k
# output overly verbose information about every de
vice
lspci -v

# open the file called longcat.md for editing


subl longcat.md

# open the file called longcat.md at line 8


subl longcat.md:8

# Find broken symlinks


find -L . -type l

# Extracts track number 2 (zero based index) from


movie.mkv and stores it in movie.srt.
# In this case we extract subtitle track.

1 0

1 0
1 0

1 0

1 0
1 0

1 0
1 0
1 0
1 0

109/174

8/3/2016

bro: just get to the point!

# List of track can be shown by 'mkvinfo'


mkvextract tracks movie.mkv 2:movie.srt

ls

xdg-open

xdg-open

&

>

qemu

http://bropages.org/browse

# Prints the number of files in the directory (inc


luding other directories)
ls -1 | wc -l

# Opens specified file with the user's preferred a


pplication
xdg-open file.txt

# Opens specified URL with the user's preferred we


b browser
xdg-open http://www.google.com

# Concatenate multiple commands into one line and


execute each one.
# This will cd to home dir and list all files (UNI
X).
cd ~; ls -ag

# Run command in background until finished or kill


ed
# Note that you can pass output to any file includ
ing /dev/null
# This will run 'find -f * > ~/findlogs.txt' in th
e background
find -f * > ~/findlogs.txt &

# Routes output of command or program into file.


# Useful for logging and text manipulation
bro '>' > bro.log

# Passes/Pipes output to another command


# Useful for text manipulation, batch file manipul
ation etc.
# Searches syslog for invalid user and outputs IP
grep '.sshd.*Invalid user' /var/log/messages | awk
'{print $NF}' | sort -u

# launch a live session from an ISO file called "L


IVE.iso" and allocate 512 mb to the virtual machin
e
qemu -m 512 LIVE.iso
qemu-kvm -m 512 LIVE.iso
qemu-system-i386 -m 512 LIVE.iso

1 0

1 0

1 0

1 0

1 0

1 0

1 0

1 0

110/174

8/3/2016

ll

yaourt
git

git diff

git checkout

su
split
ack

git
submodule
foreach git
pull origin
master
sort

ogr2ogr
http://bropages.org/browse

bro: just get to the point!

#Lists my current directory in long listing forma


t. Alias of ls -l. Saves time, bro!
ll

# Sync and upgrade all Pakages from Repos and AUR


yaourt -Syyua

# create a git alias, now git ci "message" is a co


mmand
git config --global alias.ci 'commit -m'

# Compare the file foo.py in HEAD to the same file


in origin/develop.
git diff HEAD origin/develop foo.py

# Get the foo.py file from origin develop into the


current branch.
git checkout origin/develop foo.py

# run command "rm -rf bar" as user "tim"


su tim -c 'rm -rf bar'

# split a file by number of lines


split -l 5000 filename

# Ignore all files matching specified regex (ignor


ing css in this example)
ack "input" --ignore-file=match:/.+\.css/

# For each submodule, pull the latest changes from


the remote master branch.
git submodule foreach git pull origin master

# Sort the contents of all .csv files in a directo


ry
sort /path/to/directory/*.csv

# Convert an ESRI shapefile to GeoJSON


ogr2ogr -f GeoJSON output.geojson input.shp

1 0

1 0
1 0

1 0

1 0

1 0
1 0
1 0

1 0

1 0

1 0
111/174

8/3/2016

ogr2ogr

git commit
repoquery
rails

pyinstaller

git stash clear


git status

htop
lp
nmap

http://bropages.org/browse

bro: just get to the point!

# convert an ESRI shapefile to GeoJSON and reproje


ct
# to CRS EPSG:4326 (latitude and longitude).
# This will only work if there is an input.prj fil
e
# describing the coordinate reference system of th
e shapefile
ogr2ogr -f GeoJSON output.geojson -t_srs "EPSG:432
6" input.shp

# Update current commit with new timestamp


git commit --amend --reset-author

# List all the files added by a repo through yum


repoquery --list freeglut

# generate a new model Person with fields firstnam


e and lastname of type string
rails g model Person firstname:string lastname:str
ing

# creates binaries using a Python script with a va


lid entry point
pyinstaller <your-script-name.py>

# Deletes everything from your stash.


git stash clear

# Shows the current status of the working branch,


such as modified files and divergence from its tr
acking branch
git status

# Run 'htop'in monochrome.


htop -C

# prints pdf file


lp file.pdf

# Use nmap to check for an open DNS resolver (best


to run against external interface to protect agai
nst DNS amplification)
nmap -sU -p 53 -P0 --script "dns-recursion" 192.16
8.0.1

1 0

1 0
1 0
1 0

1 0

1 0
1 0

2 1
1 0
1 0

112/174

8/3/2016

cmus-remote
ffmpeg

pydoc
top

goaccess
forever
forever
curl

fossil

bro: just get to the point!

# Toggle play/pause
cmus-remote -u

# Remux video to embed non-UTF8 subtitle


ffmpeg -i video.mp4 -sub_charenc LATIN1 -i video.s
rt -c:a copy -c:v copy -c:s srt video_both.mkv

# List all available Python modules installed


pydoc modules

# Run the top command once, and only show the head
er and first 8 processes
# Can be further parsed with '| awk ...' in variou
s scripts
top -n 1 | head -n 15

# text-only log analysis


goaccess -f access.log

# List running forever-managed processes


forever list

# Start a new forever-managed process


forever start -c coffee coffeeScriptFile.coffee

# POST a raw binary file with absolutely no extra


processing
curl --data-binary @"image.png" http://an.imagepro
cessor.com

# Starting A New Project.


fossil init repository_name

1 0
1 0

1 0
2 1

1 0
1 0
1 0
1 0

1 0

# Cloning An Existing Repository


fossil clone url repository_name
# Checking Out A Local Tree
fossil open repository_name
# Checkout between different versions and branches
fossil update
fossil checkout
# Another commands
fossil info
fossil status
http://bropages.org/browse

113/174

8/3/2016

bro: just get to the point!

fossil changes
fossil diff
fossil timeline
fossil ls
fossil branch

split

gradle

lp
bar

# split a gz file into equal sized gz pieces from


stdin
zcat bigfile.gz | split -d --filter='gzip > $FILE.
gz' --number=r/32 - /output/dir

# Finds and executes gradle using the build.gradle


file in the git repo.
gradle --build-file $(find $(git rev-parse --showtoplevel) -name "build.gradle"

# print on a specified destination printer


lp -d <printer> file.pdf

#Example 1: Using bar to copy a 2.4gb file from a


device (in this case a tape drive) to a file, usi
ng a 64k buffer.
bar --in-file /dev/rmt/1cbn --out-file tape-restor
e.tar --size 2.4g --buffer-size 64k

1 0

1 0

1 0
1 0

#Example 2: Using bar to copy a 37tb file across t


he network using SSH.
ssh remote 'dd if=file' | bar --size 37t > file
#Example 3: Using bar inside a tar-pipe command:
# Normal tar-pipe command might be:
# (cd /some/dir/somewhere && tar -cf - *) | (cd /s
ome/other/dir && tar -xBpf -)
#3a: Using bar within the tar-pipe:
(cd /some/dir/somewhere && tar -cf - *) | bar | (c
d /some/other/dir && tar -xBpf -)
#3b: Using bar with the --size option in a tar-pip
e:
# $ du -sk /some/dir/somewhere
# 6281954 /some/dir/somewhere
(cd /some/dir/somewhere && tar -cf - *) | bar --si
ze 6281954k | (cd /some/other/dir && tar -xBpf -)
#Example 4: Using bar on a regular file. (Note th
at the --size option is not needed here, as bar wi
ll retrieve the file size itself.)
bar --in-file ./file | ssh remote 'cd /some/dir &&
dd of=file'
#Example 5: Generating a 512k file of random data.
dd if=/dev/random bs=1024 count=512 | bar -s 512k
-of ./random

http://bropages.org/browse

114/174

8/3/2016

wp

pyinstaller

bro: just get to the point!

# Adds a new user with user name "janesmith" to th


e Wordpress database as an
# admin.
wp user create janesmith jsmith@gmail.com --role=a
dministrator --user_pass=farglenuts --display_name
="Jane Smith"

# specify an icon to be used by the script after i


t's compiled
pyinstaller --icon=/path/to/icon ./script.py

1 0

1 0

# disable debug mode (hide terminal/command propmt


window at compiled program runtime)
pyinstaller -w ./script.py

mutt
sshd

convert

mv

ffmpeg

du

# open the mailbox located at ~/Maildir


mutt -f ~/Maildir

# Daemon program for ssh to provide encrypted conn


ectivity through insecure connection
sshd

# convert all PNGs in the current directory to a m


aximum dimension of 256x256 and name the copy acco
rdingly
for f in *.png; do convert -resize 256x256 "$f"
"${f%.png}_256x256.png"; done

# Rename a file that starts with '-' (avoids "ille


gal option --" error)
mv ./-file.txt file.txt

# Extract audio from a video and write to variable


-rate mp3 file
ffmpeg -i video-in.mp4 -q:a 0 -map a audio-out.mp3

# List the largest directories in reversed order


(useful alias)

1 0
1 0

1 0

1 0

1 0

1 0

du -kx | egrep -v "\./.+/" | sort -n

iwconfig

# control your wlan / ethernet speed


# ex wlancard @ 54MB:

1 0

iwconfig wlan0 rate 54M fixed

http://bropages.org/browse

115/174

8/3/2016

docker

wgetpaste

bro: just get to the point!

# minimum docker command


# - will display help
# - -H is the docker host daemon tcp endpoint, usu
ally tcp://localhost:2375
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
sudo docker -H tcp://localhost:2375

# wgetpaste a file as input


wgetpaste ~/somefile

1 0

1 0

# wgetpaste standard output


foo -xvjpf bar 2>&1 | wgetpaste

hot-babe

# so you found this old tool


# and bro'ed it
# congratz

1 0

hot-babe
# you won a washing machine

grep
chkconfig

git
qemu-img

wc

wget

http://bropages.org/browse

# Show only the first match in each file


grep -m 1 "needle" *.txt

# turn on a service in centos for runlevels 3, 4,


and 5
chkconfig --level 345 my_service_name on

# checkout a specific tag


git checkout tags/<tag_name>

# covert disk images from or to raw, qcow2, vdi,vm


dk, vpc (-p shows progress)
$ qemu-img convert -p -f raw -O qcow2 /some/input.
img /some/output.qcow2

# Count the number of lines of all files in a dire


ctory
find path/to/dir | xargs wc -l

# Recursively download only files with the pdf ext


ension upto two levels away
wget -r -l 2 -A "*.pdf" http://papers.xtremepaper
s.com/CIE/Cambridge%20Checkpoint/

1 0
1 0

1 0
1 0

1 0

1 0

116/174

8/3/2016

msgmerge

xsltproc

bro: just get to the point!

# Merge a translated file with an updated template


msgmerge englishtemplate.pot korean.po -o merged_k
orean.po

# explanation of xsltproc
Transform an XML file using an XSLT template file

1 0

1 0

xsltproc template.xsl data.xml > output.xml

patch

zip

nc

hping3

git show

mp3gain
jobs

jobs
http://bropages.org/browse

# Reverts a previously applied patch


#
# p1 flag is used by git. If your diff is in a
# different format try using p0
patch -R -p1 < patch/file.diff

# Use the `unzip` command to extract a zip file, u


nlike `tar` and `gzip` where you use a command lin
e argument to decompress
unzip file.zip # Extracts to current directory
unzup file.zip -d dir # Extracts to specified dire
ctory

# Scan all http default ports for a given ip block


(e.g 192.168.1.xxx)
for i in {1..255}; do nc -v -n -z -w 1 192.168.
1.$i 80; done

# Check if port is up, not using telnet, icmp-styl


e
hping3 -S -k -p443 www.google.com

# Shows the contents of the file Documentation/REA


DME in the branch my-branch.
git show my-branch:Documentation/README

#add 3 dB to every mp3 in current directory


mp3gain -g 3 *.mp3

# List background processes (eg. something you've


used <c-z> to hide)
jobs

# Print a comma-separated list of background jobs


echo ${$(echo `jobs | cut -d' ' -f6`)/[[:spac
e:]]/,}

1 0

1 0

1 0

1 0

1 0

1 0
1 0

1 0
117/174

8/3/2016

grep

parallel

factor

bro: just get to the point!

# show filenames of all files containing the patte


rn in this folder
# and all sub folders
grep -rl "pattern" .

# http://qbrc.swmed.edu/2013/03/gnu-parallel-speed
ing-up-unix-commands-and-scripts/
# search for all files that end with .txt and then
match a word within each file
find . -name *.txt | parallel grep matching wor
d

factor 23498719837
#23498719837: 293 80200409

1 0

1 0

1 0

time factor 23498719837


#real 0m0.003s
#user 0m0.000s
#sys
0m0.000s

SetFile

mogrify

xargs

# set creation timestamp (-d) and modification tim


estamp (-m) for a file in OSX
SetFile -d "08/09/2014 00:11:16" -m "08/09/2014 0
0:11:16" file.txt

#batch resize all .jpgs in current dir to 1024 hei


ght (keeps aspect ratio)
#install Imagemagick, files will be overwritten!
mogrify -resize x400 *.jpg

# find all UTF-8 encoded files


ls | xargs file | grep UTF-8

1 0

1 0

1 0

# find mbox unix-mail files


ls | xargs file | grep "very long lines"

xargs

gradle

git branch
http://bropages.org/browse

# backup all files under a certain size


ls -l | awk '$5<100000 { print $NF; }' | xargs gla
cier upload backupfoldername

# Exclude any task from execution, e.g. no tests d


uring build
gradle build -x test

1 0

1 0

1 0
118/174

8/3/2016

bro: just get to the point!

# Move (by force) a branch to another point in the


commit tree. This example moves the local develop
branch three
# commits back from HEAD.
#
# Note that you cannot move the branch you are cur
rently in.
git branch -f develop HEAD~3

ipcalc

mdadm
xrandr
curl

ack

journalctl
journalctl
journalctl
journalctl
nmap
http://bropages.org/browse

# Find the subnet mask (e.g 255.255.255.0) when yo


u have a the amount of bits (e.g 24)
ipcalc -m 10.0.10.0/24
# Find the amount of bits when you have a the subn
et mask
ipcalc -p 10.0.10.0 255.255.255.0

# Shows detailed information for RAID-device md0


sudo mdadm --detail /dev/md0

# Restore your previous resolution


xrandr -s 0

# Run a curl and output the response headers to ST


DOUT
curl -D - http://www.google.com -s -o /dev/null

# use word boundaries, i.e. search only for exact


word
ack -w pattern

# Show all messages by a specific unit


journalctl -u dbus

# Show all messages by a specific executable


journalctl /usr/lib/systemd/systemd

# Show all messages by a specific process


journalctl _PID=1

# Show kernel ring buffer


journalctl -k

# Check specific UDP port


nmap -sU -p65530 example.org

1 0

1 0
1 0
1 0

1 0

1 0
1 0
1 0
1 0
1 0
119/174

8/3/2016

lsof
lsof

lsof
lsof
lsof
lsof
lsof
lsof

lsof
pamtester
mv
lsblk

tune2fs
http://bropages.org/browse

bro: just get to the point!

# Show what files a user has open


lsof -u USER

# Show files open by users other than the specifie


d has open
lsof -u ^USER

# See files/connections open by binary


lsof -c firefox

# Files open by specified PID


lsof -p 101

# Find listening ports


lsof -i -sTCP:LISTEN

# Find established connections


lsof -i -sTCP:ESTABLISHED

# Return PID for a binary


lsof -t -c firefox

# Show everything USER is doing connected to 192.1


68.0.1
lsof -u USER -i @192.168.0.1

# Show open connections within a port range


lsof -i @192.168.1.2:6881=6887

# Test bob's password


pamtester auth bob authenticate

# move a directory to be a subdirectory


mv sourceDir destDir/sourceDir

# List available block devices incl. UUID identifi


er.
lsblk -o +UUID

1 0
1 0

1 0
1 0
1 0
1 0
1 0
1 0

1 0
1 0
1 0
1 0

1 0
120/174

8/3/2016

bro: just get to the point!

# Set filesystem label on ext2/ext3/ext4 filesyste


ms.
tune2fs -L label /dev/sda1

fatlabel
unzip
git

mdadm

date

# Set label on DOS/FAT/VFAT filesystems.


fatlabel /dev/sda2 label

# Unzip all *.zip files


unzip '*.zip'

# When the "assume unchanged" bit is on, Git stops


checking the working tree files for possible modi
fications, undo with --no-assume-unchanged
git update-index --assume-unchanged <file>

# Shows detailed information for drive in RAID-dev


ice
sudo mdadm --examine /dev/sda1

# Convert date to UNIX time:


date --date="2014-03-14 09:00:00 CET" +%s

1 0
2 1
1 0

1 0

1 0

# Convert UNIX time to date:


date -d @1394791500

cp
openssl
rdiff-backup
rdiff-backup

java

http://bropages.org/browse

# Do hardlinks instead of copying files


cp -al source/ target/

# Get certificate info


openssl x509 -text -noout -in cert.crt

# Backs up /foo to /media/bar


rdiff-backup /foo /media/bar

# Backs up /foo to /media/boo and does not cross f


ilesystem boundaries
rdiff-backup /foo /media/boo --exclude-other-files
ystems

# Execute a compiled Java class file


java foo.class

1 0
1 0
1 0
1 0

1 0

121/174

8/3/2016

gpg

bro: just get to the point!

# Encrypt a file with a password. Outputs file.tx


t.gpg
gpg --symmetric --cipher-algo AES256 file.txt

1 0

# Decrypt a file
gpg -d file.txt.gpg -o file.txt

maim

maim

zenity
iw

# Take screenshot using mouse, and save it to home


directory as png file
maim -s ~/screenshot.png

# take a screenshot using the mouse (-s) and save


it as a png file called screenshot_timestamp
maim -s ~/screenshot_$(date +%F_%H%M%S).png

# the manual already shows a lot of examples:


man zenity|cat

# General command to configure wireless interfaces

1 0

1 0

1 0
1 0

iw

setuid

# setuid/setgid makes a program start with the per


missions of the user that owns
# the file, regardless of the user running the pro
gram. This can be abused to
# take over a machine, so use this with care. Note
that on most systems, you
# cannot set this on interpreted programs (shell s
cripts, for example)
#
# Marking a program setuid is done with the 'chmo
d' command, using either the first
# digit of a 4 bit permission set, or using the
'u' flag when using letters.
#
# To set a program as setuid and setgid with lette
rs:
chmod ug+s /usr/bin/mybinary
# To set a program as setuid and setgid with regul
ar mode digits:

1 0

chmod 6744 /usr/bin/mybinary

wget

http://bropages.org/browse

# Download a web page or file, and name the result


ant file what the remote server says it should be.
# (Great for outfits like Sourceforge where the do
wnload link is a long, intractable string of chara
cters)
wget --content-disposition http://example.com/down

1 0

122/174

8/3/2016

bro: just get to the point!

load.php?id=12345&file=foobar.tgz&datetime=2014100
4

avconv

lpass

# Convert all files from current directory into mp


3
for f in *; do avconv -i "$f" "$f.mp3"; done

command line version of LastPass which is to remem


ber passwords

1 0

1 0

lpass login [--trust] [--plaintext-key [--force, f]] USERNAME


lpass logout [--force, -f]
lpass show [--sync=auto|now|no] [--clip, -c] [--al
l|--username|--password|--url|--notes|--field=FIEL
D|--id|--name] {UNIQUENAME|UNIQUEID}
lpass ls [--sync=auto|now|no] [GROUP]
lpass edit [--sync=auto|now|no] [--non-interactiv
e] {--name|--username|--password|--url|--notes|--f
ield=FIELD} {NAME|UNIQUEID}
lpass generate [--sync=auto|now|no] [--clip, -c]
[--username=USERNAME] [--url=URL] [--no-symbols]
{NAME|UNIQUEID} LENGTH
lpass duplicate [--sync=auto|now|no] {UNIQUENAME|U
NIQUEID}
lpass rm [--sync=auto|now|no] {UNIQUENAME|UNIQUEI
D}
lpass sync [--background, -b]

pwgen

whois

whois

whois

http://bropages.org/browse

# Generate a table with 10 character ambiguous ran


dom passwords which include at least one special c
haracter in in password
pwgen -B -y 10

# Make whois ip if you only know domain name via h


ost and awk
for i in `host bropages.org | head -1 | awk -F"[:
]+" '/has address/ {print $4}'`; do whois $i; don
e

# Make whois ip if you only know domain name via h


ost and sed
for i in `host bropages.org | head -1 | sed 's/^[^
0-9]*//g'`; do whois $i; done

# Make whois ip if you only know domain name via h


ost and grep
for i in `host bropages.org | head -1 | grep -Eo
'([0-9]{1,3}\.){1,3}[0-9]{1,3}'`; do whois $i; do
ne

1 0

1 0

1 0

1 0

123/174

8/3/2016

snapper

snapper
brew
wscat

bro: just get to the point!

# Create a pre and post snapshot with system updat


e (Arch Linux)
snapper create -d "system update" --command "pacma
n -Syu"

# Delete a snapshot
snapper rm number1

# make brew fix itself


brew doctor

# Connect to websocket server located at "ws://ech


o.websocket.org"
wscat -c ws://echo.websocket.org

1 0

1 0
1 0
1 0

# ... then echo "Hello World"


>Hello World

inkscape

# Convert SVG to PDF without starting GUI


# (echo a.svg --export-pdf=a.pdf;
# echo b.svg --export-pdf=b.pdf) |
# DISPLAY= inkscape --shell

1 0

# your_comment_here
In order to get a cropped PDF use -D option.

lvcreate

update-rc.d

# Create logical volume of 1TB on volume group 'sp


ace' (as root):
lvcreate -L1TB -nnewvol space

# Disable daemons during boot-up (Debian distros o


nly)
update-rc.d -f mydaemon_name remove

1 0

1 0

# Enable daemons during boot-up (Debian distros on


ly)
update-rc.d mydaemon_name default

unp
docker rm

http://bropages.org/browse

# unpack the archive test.zip


unp test.zip

# Delete all containers.


docker rm $(docker ps -a -q)

1 0
1 0

124/174

8/3/2016

docker rmi
pigz

bro: just get to the point!

# Delete all images


docker rmi $(docker images -q)

# pigz parallel gzip implementation example - gzip


one file with 4 cpu cores
pigz -p 4 filename.txt

1 0
1 0

#to gzip entire folder must pass to gzip with tar


(and set variable for cores)
#gzip /dirtogzip into /directory/gzipfile.tar.gz u
sing 4 cores
export PIGZ="-p4"
tar cf /directory/gzipfile.tar.gz --use-compress-p
rogram=pigz /dirtogzip

adduser

# Agregar usuarios al sistema


adduser pepe

2 1

# Agrega usuario a un grupo


adduser -g pepe

dicks

Example command for 'dicks':


# Takes an argument n, for number of dicks
# Prints n dicks on the screen.

1 0

dicks 10

mp3info
ctorrent

MP4Box

# print bitrate of filename.mp3


mp3info -r m -p "%f %r\n" filename.mp3

# Create new torrent


ctorrent -t -u "http://tracker.example.com:6969/an
nounce" -s example.torrent file_or_dir_to_upload

# Install (Debian and derivatives)


sudo apt-get install gpac

1 0
1 0

1 0

# Losslessly concatenate MP4 videos from '0.mp4' t


o '3.mp4'. All of them must have the same resoluti
on.
MP4Box -cat "0.mp4" -cat "1.mp4" -cat "2.mp4" -cat
"3.mp4" losslessly-concatenated.mp4

xrandr

http://bropages.org/browse

# Change screen (eDP1) gamma level to simulate bri


ghtness (backlight) modification. Useful when back
light doesn't work.
xrandr --output eDP1 --brightness .3

1 0

125/174

8/3/2016

MP4Box

latexmk

timedog

for

conky

emerge

rfkill
rfkill
wc
netstat

macchanger
http://bropages.org/browse

bro: just get to the point!

# Losslessly split a playable MP4 video file speci


fying times in seconds. This creates a copy of the
minute 1'50" until 3'.
MP4Box example.mp4 -splitx 90:180

# Compiles targeted latex file whenever it detects


a change, and updates the pdf as you do so.
latexmk -pdf -pvc your_file

# your_comment_here
Comparing TM backup - Depth: 5 directories Omitti
ng if smaller than: 1MB
timedog -d 5 -m 1M -ls

# Bash 3.0+ has ranges {start..end..incr} builtin:


for i in {1..10}; do echo $i; done
for i in {0..8..2}

# This is a terribly inefficient way to display a


fortune in Conky
# This is for your .conkyrc
${execi 600 fortune -s > ~/fortune; sed '/^$/d' >
~/fortune > ~/fortune2; rm ~fortune; cat ~/fortun
e2}

# Clean up system from unneeded packages/dependenc


ies.
emerge --depclean

# Turn off all wireless devices.


rfkill block all

# Turn on all wireless devices.


rfkill unblock all

# count the words in a file


wc -w

# your_comment_here
#Open all open networking listening ports for tcp
netstat -atp tcp | grep -i "listen"

# Changes mac address to xx:xx:xx:xx:xx:xx on inte


rface eth0

1 0

1 0

1 0

1 0

1 0

1 0

1 0
1 0
1 0
1 0

1 0
126/174

8/3/2016

bro: just get to the point!

macchanger -m xx:xx:xx:xx:xx:xx eth0

ag

docker rmi

mvn
vagrant
install

smbclient

# search for GREP_OPTIONS= in all dirs except usua


l suspects (sys, tmp, var, etc.)
ag -Q "GREP_OPTIONS=" --ignore-dir=run --ignore-di
r=tmp --ignore-dir=sys --ignore-dir=lost+found --i
gnore-dir=var

# Remove all untagged docker images.


# - docker rmi - remove image
# - docker images -a - show all images
# - grep '^<none>' - filter the list down to tho
se entries with no
#
value in the Repository column
# - awk '{print $3}') - show only the image IDs
from the output,
#
feeding it back to `docker rmi`
docker rmi $(docker images -a | grep '^<none>' | a
wk '{print $3}')

# Redeploy maven war witout testing :)


mvn tomcat7:redeploy -Dmaven.test.skip=true

# provision vagrant with file and shell


vagrant provision --provision-with file,shell

#Copies a file into a directory and set the mode t


o executable (rwxr-xr-x)
install helloworld /usr/bin

# List shares on a system.

1 0

1 0

1 0
1 0
2 1

1 0

smbclient -L hostname

chef-solo
cocos
grep

http://bropages.org/browse

# Executes chef solo with a solo.rb file


chef-solo -c ./solo.rb

cocos new MyGame -p com.MyCompany.MyGame -l cpp -d


~/MyCompany

# Force line buffering


mysqladmin processlist | grep --line-buffered "Que
ry"

1 0
1 0
1 0

127/174

8/3/2016

truncate
hdparm
hdparm

pip

tar

bro: just get to the point!

# truncates a file to size 0 (empty)


truncate -s 0 bro.log

# Test sequential read from harddrive.


sudo hdparm -t /dev/sdb1

# Test the linux cache read speed without disk acc


ess.
sudo hdparm -T /dev/sda1

# cache downloaded packages locally


pip install --download-cache ~/.cache/pip <package
>

# Create tar.bz2 archive


tar -c file(s) | bzip2 > yourfilename.tar.bz2

1 0
1 0
1 0

1 0

1 0

# Extract all files from a tar.bz2 archive


tar jvxf yourcompressfile.tar.bz2 (only in modern
tar versions)

convert

cowsay

# Adds a large, yellow date/time stamp to the Sout


h-East corner of picture original.jpg
convert original.jpg -gravity SouthEast -font Aria
l -pointsize 72 -fill yellow -annotate +100+100 "%
[exif:DateTimeOriginal]" stamped.jpg

# < hello world! >


# -------------#
\ ^__^
#
\ (oo)\_______
#
(__)\
)\/\
#
||----w |
#
||
||

1 0

1 0

cowsay "hello world!"

fio

echo

http://bropages.org/browse

# run fio with 64mb random read/write with 4 concu


rrent jobs
fio --name=random-writers --ioengine=libaio --iode
pth=4 --rw=randwrite --bs=32k --direct=0 --size=64
m --numjobs=4

# print a sequence of numbers to the terminal


echo {2005..2015}

1 0

1 0

128/174

8/3/2016

swipl
git-add

test
git rev-parse
awk

sysctl
mount
git checkout

git revert
setterm

convert
redis-cli
http://bropages.org/browse

bro: just get to the point!

# Loads .pl file in current directory


swipl -s hello_world.pl

# Patch add -- interactively add only part of your


changes
git add -p

# test if empty string


test -z ""

# get the hash of the HEAD commit


git rev-parse HEAD

# Calculate the average of a file full of line-sep


arated numbers
awk '{ sum += $2; n++ } END { if (n > 0) print sum
/ n; }'

# Disable IPv6 on all interfaces


sysctl net.ipv6.conf.all.disable_ipv6=1

# Mount a partition in read-only mode


sudo mount -o ro /dev/sda1 /media/lollerskates

# Create a local named `foo` based on `origin/bar


`,
# but do not track `origin/bar`.
git checkout --no-track -b foo origin/bar

# Undo the changes made by a particular commit.


git revert SHA

# copy current contents of pseudo terminal #4 (as


root):
setterm -dump 4 -file /dev/stdout

# Get the filetype of any file


file the_godfather.avi

# your_comment_here
`redis-cli` opens a comand line interface for work

1 0
1 0

1 0
1 0
1 0

1 0
1 0
1 0

1 0
1 0

1 0
1 0
129/174

8/3/2016

bro: just get to the point!

ing with a running instance of a redis-server, def


aults to the default redis-server.

valgrind

g++

play
play

# Valgrind can be used to check a program for memo


ry leaks.
valgrind <program name> --leak-check=yes

# Compile a program executable to a file and displ


ay warnings.
# g++ may catch problems before they slap you
g++ <files to compile> -o <output executable name>
-Wall

# Play song with 1.5 faster tempo


play song.mpe tempo 1.5

# Play song in different pitch (transpose song 1 t


one up)
play song.mp3 pitch 200

1 0

1 0

1 0
1 0

# Transpose song half tone down


play song.mp3 pitch -100

sox

# Transpose input.mp3 1 tone lower and saves it a


s output.mp3
sox input.mp3 output.mp3 pitch -200

1 0

#Transpose input.mp3 1/2 tone higher and saves it


as output.mp3
sox input.mp3 output.mp3 pitch 100

git reflog

git reflog

open

http://bropages.org/browse

# your_comment_here
find the head commit of the branch as it was immed
iately before the rebase started in the reflog
git reflog

#Find the head commit of the branch as it was imme


diately before the rebase started in the reflog
git reflog

# Open the latest file named something like `repor


t (123).xlsx` in /your/directory/ (OSX)
# Use sort to order the files numerically, startin
g at the `(` char.
# -t sets the separator
# -g to sort numerically
# -k to choose the column

1 0

1 0

1 0

130/174

8/3/2016

bro: just get to the point!

# Use tail to only select the last result after th


e sort
# Feed all of the above to the open command as an
expansion
open "$(find /your/directory/ -name 'report (*' |
sort -t \( -g -k 2 | tail -1)";

rsync

ln
cloc

apachectl
bundle

figlet
encfs

tree

avconv

sqlplus
http://bropages.org/browse

# Rsync to different port


rsync -e "ssh -p 9999" /path/to/local_file domain.
com:/path/to/remote_file

# Creates a soft link from a relative path


ln -s somefile.txt /path/to/link

# Count distinct lines of code for every file and


prints summary in the end
cloc <dir> --by-file-by-lang

# Restart the apache web server


apachectl restart

# Display full location of gems used, and avoid in


stalling gems declared in 'group :local do' block
bundle --verbose --without local

# Print an out of this world Hello World


figlet "Hello World"

# create an encrypted directory that you can sync


on dropbox, and mount it to your file system
# both the encrypted and mount_point directories m
ust exist, and be empty
encfs /home/jdoe/documents/encrypted /home/jdoe/do
cuments/mount_point

# Shows absolute filenames of all files in current


directory and subdirectories.
tree -i -f .

# Convert avi to mp4


avconv -i input.avi -c:v libx264 -c:a copy output.
mp4

1 0

2 1
1 0

1 0
1 0

2 1
1 0

1 0

1 0

1 0
131/174

8/3/2016

bro: just get to the point!

# Starts console with db with specified credential


s
sqlplus myusername/mypassword@ORCL

mongoimport

# import csv/tsv file into db 'users' collection


'contacts' on local MongoDB (default port)
mongoimport --db users --collection contacts --typ
e csv --headerline --file contacts.csv

1 0

# import csv/tsv file - short params version


mongoimport -d users -c contacts --type csv --head
erline --file contacts.csv
# import json file
mongoimport --db users --collection contacts --fil
e contacts.json
# specify server, port, credentials
mongoimport --host mongodb1.example.net --port 370
17 --username user --password pass -c contacts -d
marketing --file data.json

montage

git
addgroup
locate

# create a tiled montage that is three columns acr


oss, and two rows down, (scale down by 50% during
montage creation)
montage *.jpg -tile 3x2 -geometry 50% output_name.
jpg

# Delete local branch


git branch -D feature_branch

# Create a new group


addgroup new_group_name

# update database for 'locate' (requires root!)


updatedb

1 0

1 0
1 0
1 0

# update specific direction into new database


updatedb -o /path/to/database -U /direction/to/sca
n/through

locate
chage

http://bropages.org/browse

# search for 'brofile' in specific database


locate brofile -d /path/to/database

# your_comment_here
chage -m 0 -M 99999 -I -1 -E -1 username

1 0
1 0

132/174

8/3/2016

chage
bcrypt

pkg-config

bro: just get to the point!

# Configure a user's password not to expire


chage -m 0 -M 99999 -I -1 -E -1 username

# Encrypt a file. Asks you about a secret Passphra


se to decrypt it again.
bcrypt my_diary.txt

# Helps you get all -l and -I flags for compiler r


ight
# compile:
gcc -c -o main.o main.c `pkg-config --cflags PKGNA
ME`

1 0
1 0

1 0

# link:
gcc -o my_application main.o `pkg-config --libs PK
GNAME`
# compile + link in a single step:
gcc -o my_application main.c `pkg-config --cflags
--libs PKGNAME`
# check if library is installed
pkg-config --exists 'glib-2.0 >= 1.3.4 libxml = 1.
8.3' && echo yep || echo nope

atom

apm

# Start Atom in development mode.


atom -d
atom --dev

# Upgrade your Atom packages.


apm upgrade

1 0

1 0

# Upgrade without having to confirm each upgrade.


apm upgrade -c false

apm

bzip2

node

http://bropages.org/browse

# Clones an Atom package's git repository for deve


lopment.
apm dev <package_name>
apm develop <package_name>

# Create bzip2 archive from directory without inte


rmediate files
tar -cjf output.tar.bz2 path/to/directory/

# view node's config and environment


node -p -e "process"

1 0

1 0

1 0

133/174

8/3/2016

mkfifo

wc
find
xz

bro: just get to the point!

# mkfifo creates a named pipe as a file. You use i


t as the input for one
# program, and use it as the output for another, a
nd it's as if those two
# were piping to eachother
mkfifo /tmp/named_pipe && gzip -c < /tmp/named_pip
e > /tmp/out.gz &; cat /tmp/foo > /tmp/named_pipe

# Get the number of characters in a line


echo "hello world" | wc -m

# Find all symlinks to specific file (GNU find)


find -L /dev -samefile /dev/video0

# compress a file "foo" into "foo.xz"


xz foo

1 0

1 0
1 0
1 0

# compress a directory "foo" into "bar.tar.xz"


tar cf - foo/ | xz -c - > bar.tar.xz

gpsd
sshuttle
csplit

diskutil

add-aptrepository

# Run gpsd on device /dev/gps0


gpsd /dev/gps0

# Hide behind your SSH server (easy VPN)


sshuttle --dns -r ppctf.net 0/0

# break the whole file in a specific pattern into


several files with a prefix: out00, out01, out0
2,...
csplit inputfile.txt -f out /searchstring/ {*}

# Show detailed information on a particular disk o


r partition
diskutil info disk-or-partition

# Add a PPA to your apt repositories:


sudo add-apt-repository ppa:user/ppa-name

1 0
1 0
1 0

1 0

1 0

# Remove the PPA from your apt repositories


sudo add-apt-repository -r ppa:user/ppa-name
# Remember to update your cache for these changes
to take effect:
sudo apt-get update

http://bropages.org/browse

134/174

8/3/2016

ccze
iptables

iptables
traceroute
ip

ip
TextWrangler

fold

bro: just get to the point!

# output and follow the colorized output of syslog


tail -f -n 50 /var/log/syslog | ccze

# print out ip tables with verbose, numeric listin


gs
iptables -vnL

# Flush iptables until restart


iptables -F

# trace with TCP packets on port 80


traceroute -P TCP -p 80 heise.de

# Use ip to create vlan on adapter when nmcli is n


ot available.
ip link add link eth1 name eth1.10 type vlan id 10

# Use ip to show vlan information.


ip -d link show eth1.10

# You can install the textwrangler command line to


ols from their website to have 'edit' send any fil
e to the GUI app.
edit mytextfile.txt

fold -w 80 -s

1 0
1 0

1 0
1 0
1 0

1 0
1 0

1 0

# your_comment_here
add a line breaks so that your text doesn't reach
more than 80 characters per line, breaks on space
if possible

uniq
git
bc
chmod
http://bropages.org/browse

# Precede each line with number of occurrences


uniq -c

# Look for occurrences of word 'foo' in diffs


git log -Gfoo

# Do simple subtraction
bc <<< "2 - 1"

1 0
1 0
2 1
1 0
135/174

8/3/2016

bro: just get to the point!

# Let rvm install gems without sudo.


# allow your (u)ser to (w)rite and e(x)ecute thing
s in the /Library/Ruby directory, and (-R)ecursive
ly below it
chmod -R u+wx /Library/Ruby

par
serveradmin

# Get rid of hanging lines in an email


xsel -bo | par -w 400 | xsel -bi

#! Provide a useful example for how to use 'server


admin'

1 0
1 0

#This command is present in OS X when the Server.a


pp is installed.
# Stores settings from all services into a file.
serveradmin settings all > outfile
# Will take any settings file and set the values.
serveradmin settings < outfile

virtualenv

# Create a virtualenv
virtualenv <name>

1 0

# Create a virtualenv with Python 3


virtualenv <name> -p /usr/bin/python3
# Create a virtualenv that inherits system package
s
virtualenv <name> --system-site-packages

lrzip

# lrzip a file (use lrztar for directories)


lrzip <file>

1 0

# lrzip a file with maximum compression


lrzip -L 9 <file>

lrztar

# tar and lrzip a directory


lrztar <dir>

1 0

# tar&lrzip with maximum compression into a certai


n directory
lrztar -L 9 -o /dir/output.tar.lrz <dir>

updatealternatives
wc
http://bropages.org/browse

# Select default browser interactively from list o


f possibilities
update-alternatives --config x-www-browser

1 0

1 0
136/174

8/3/2016

bro: just get to the point!

# count the number of words in a file


wc -w my_file.txt

tail
sass

testparm

testparm

feh

git branch -a
python
uname
strings

privoxy

http://bropages.org/browse

# tail multiple log files


tail -f /var/log/messages /var/log/*/*.log

# Watch and compile SASS files from .scss to .css


in current directory
sass --watch .:.

# Tests /etc/samba/smb.conf.master for correctnes


s, and copies it to /etc/samba/smb.conf, ready for
use.
sudo testparm -s /etc/samba/smb.conf.master > /et
c/samba/smb.conf

# Tests the default samba config for correctness.


/etc/samba/smb.conf
testparm

# Set a background image for Xorg


feh --bg-scale file.png
feh --bg-fill file.jpg

# List all your branches


git branch -a

# use python as a powerfull calculator


python -qi -c "from math import *"

# print current kernel version


uname -rs

# print out strings of printable characters in a f


ile
strings <file>

# the basic command structure


privoxy [--config-test] [--chroot] [--help] [--nodaemon] [--pidfile pidfile] [--pre-chroot-nslookup
hostname] [--user user[.group]] [--version] [conf
igfile]

1 0
1 0

1 0

1 0

1 0

1 0
1 0
1 0
1 0

1 0

137/174

8/3/2016

sbcl
sbcl
sbcl

bro: just get to the point!

# Start the sbcl REPL


sbcl

# Run a lisp script


sbcl --script hello.lisp

# Load one or more lisp files before starting REPL


sbcl --load file1.lisp --load file2.lisp

1 0
1 0
1 0

# Can also be used with --eval


sbcl --load file1.lisp --eval '(hello)'

sbcl
sbcl

git checkout
hub

arp

sudo
vim

# evaluate expression before starting REPL


sbcl --eval '(format t "Hello World~%")'

# Quit after loading and evalling command line opt


ions
sbcl --noinform --quit --load file1.lisp --eval
'(main)'

# Go back two versions


git checkout HEAD~2

# Use GitHub's Hub to create a pull request of the


# current branch into the develop branch.
hub pull-request -b develop

list all known devices on local network


# your_comment_here
arp -a

# Logs in as root
sudo -i

# Opens FILE in binary mode, so you can edit binar


y files with Vim
vim -b FILE

1 0
1 0

1 0
1 0

1 0

1 0
1 0

# Once you've opened it, you can type :%!xxd to ru


n it through the xxd program,
# giving you a hexedit like interface. :%!xxd -r w
ill convert it back to binary

seq
http://bropages.org/browse

1 0
138/174

8/3/2016

bro: just get to the point!

# print numbers 1 through 10 (fish shell only)


seq 10

sed

notify-send

# search and replace, inplace ** forward slashes *


*
sed -i 's|~|/home/user|' list of files

# Display "Your fly is open" in a graphical notifi


cation
notify-send 'Your fly is open'

1 0

1 0

# Display "Do not pass go, do not collect 200 doll


ers." in a graphical
# notification, with "Go Directly To Jail" as the
title
notify-send 'Go Directly To Jail' 'Do not pass go,
do not collect 200 dollers.'

pdfnup

# merges every two pages to one (cols x rows)


pdfnup --nup 1x2 --suffix '1x2' --batch FILE.pdf

1 0

# merges FILE.pdf to FILE-2x1.pdf


pdfnup --nup 2x1 --suffix '2x1' --batch FILE.pdf

which
conda

git checkout

zgrab

zgrab

yum
http://bropages.org/browse

# return 0 or 1 instead of file path


which -s some_file

# your_comment_here
Create a python virtual environment and install an
aconda scientific distribution.
conda create -n virtualenv_name anaconda

# Selectively checkout part of a file from a diffe


rent branch
git checkout --patch branch_name -- file_name

# output serial JSON data for each ip in ips.csv w


ith SSH metadata (banners, etc)
cat ips.csv | zgrab -port=22 -ssh=true

# Output JSON metadata for zgrab HTTP scan of ips


in ips.csv
cat ips.csv | zgrab

1 0
1 0

1 0

1 0

1 0

1 0
139/174

8/3/2016

bro: just get to the point!

# yum security patch only (add to cron) - requires


yum-security plugin
yum --security update >/dev/null 2>$1

yum

popd

dirs

lftp

# Install kernel-devel specific to your current ke


rnel.
yum install "kernel-devel-uname-r == $(uname -r)"

# switches to last direction in stack (refer also:


bro pushd)
popd

# shows all directions in stack (refer also: bro p


ushd)
dirs

# lftp is a great utility that wraps multiple tran


sports. It is hugely useful as a replacement
# for scp/rsync on servers that don't give you ful
l ssh access.
#
# You can use it to quickly upload/download entire
directory trees.

1 0

1 0

1 0

1 0

# Opens a CLI on the server where you can `ls`, `c


d`, etc
lftp sftp://user@sub.domain.com
# The prompt is open. Download everything recursiv
ely with 20 threads (fast!)
lftp user@sub.domain.com:/a/folder/to/download> mi
rror --parallel=20
# Or, upload your local directory to this folder r
ecursively with 20 threads
# The -R is "reverse"
lftp user@sub.domain.com:/a/folder/to/upload/to> c
d /a/folder/to/download
lftp user@sub.domain.com:/a/folder/to/download> mi
rror --parallel=20

compgen

# compgen: {gen}erate possible {comp}letion matche


s
# usage: compgen [-abcdefgjksuv] [(optional) word]
# see also: man complete
#
#
# bro.. I don't have time for this
# all I want is just see a list of...

1 0

# all shell variables


compgen -v

http://bropages.org/browse

140/174

8/3/2016

bro: just get to the point!

# my aliases that begin with "l"


compgen -a l
# my functions
compgen -A function
# jobs
compgen -j
# shell built-ins
compgen -b
# shell reserved words
compgen -k
# directories that begin with .
compgen -d .
# every single command
compgen -c

gti
identify
find

# shows a VW Golf GTI driving by


gti

# Write image width and height to stdout


identify -format "Width: %w, Height: %h" test.jpg

# Find all images in and under current directory u


sing regular expression.
# Regex should start with .* because find displays
full path.

1 0
1 0
1 0

find . -regextype awk -regex ".*(jpg|jpeg|png)$"

git tag

# List tags:
git tag

1 0

# Create an annotated tag:


git tag -a mytag

pip

sam2p

remind
http://bropages.org/browse

# Upgrade outdated packages - for when "pip instal


l -U" doesn't work
pip list --outdated | sed 's/(.*//g' | xargs pip i
nstall -U

# convert PNG image to PDF and scale image to fit


page (-e)
sam2p -e in.png out.pdf

1 0

1 0

1 0
141/174

8/3/2016

bro: just get to the point!

# From manpages: Suppose you get paid every second


Wednesday, and your last payday was Wednesday, 28
October, 1992. You can use:
# (the star means repeat).
REM 28 Oct 1992 *14 MSG Payday

split

pidstat

iostat

storcli

# Split a file whenever it matches a pattern (empt


y line, here)
split -p'^$' file_to_split

# pidstat is useful for tracing tasks managed by t


he kernel.
# -d for disk IO, the integer is the sleep time be
tween reporting.
pidstat -d 1

# Show the current disk IO in human readable forma


t
# Also see pidstat
iostat -d -h

# Information on the Controller and Configuration


sudo storcli /cX show all
# Information on the existing hard drives and thei
r status (IDs,...)
sudo storcli /cX /eall /sall show (all)
# Information on the existing virtual drives and t
heir status
sudo storcli /cX /vall show (all)
# View current status of all rebuilds

1 0

1 0

1 0

1 0

sudo storcli /cX /eall /sall show rebuild

iconv

iconv
scp

http://bropages.org/browse

# Converts in.txt from UTF-8 to ISO-8859-1 and pri


nts it to stdout
iconv -f UTF-8 -t ISO-8859-1 in.txt

# Lists all available character encodings


iconv -l

# to send a file whose name includes a colon (:) t


o a remote host, use ./ before filename
scp ./some_file_includes_colon_:in_it user@remot
e:/dir
# or use absolute path
scp /absolute/path/some_file_includes_colon_:_in_i
t user@remote:/dir

1 0

1 0
1 0

142/174

8/3/2016

unrar

tree

du

bro: just get to the point!

# Extract an archive to the current directory, mir


roring the archive hierarchy in a directory of the
same name.
unrar x <archive name>

# List files and folders in the current directory


in 'tree' format
tree -a

# Disk usage of all files and folders in this dire


ctory, on this filesystem, human-readable:
du -d1 -x -h

1 0

1 0

1 0

# Now sorted:
du -d1 -x -h | sort -h

readline
http-server

# reads lines in a file


readline

# To serve current directory as static web


http-server

1 0
1 0

# To server from a different port


http-server -p 9090
# to server from different host
http-server -a 127.0.0.1

git
sshbook
sshbook

# Rename current branch branch


git branch -m <newname>

# Connect to an alias host


sshbook host

# Run a command on the host


sshbook host command

1 0
1 0
1 0

# Transfer a file to host


sshbook -t file host:/dest-dir
# Transfer a file from the host
sshbook -t host:/path/to/file .
# Transfer a folder to the home directory on the h
ost
sshbook -t -r folder host

http://bropages.org/browse

143/174

8/3/2016

sshbook-add

bro: just get to the point!

# Add an host alias


sshbook-add alias user@host

1 0

# Add an alias with the -Y X11 forward option


sshbook-add -o "-Y" local user@localhost
# Add a connection to an host that can be found in
the HOSTNAME var
sshbook-add -s ENV['HOSTNAME'] local user
# Add a connection that by default executes ls
sshbook-add -c ls local user@localhost

sshbook

# Delete the "local" connection alias


sshbook -d local

dockermachine

# List the machines


docker-machine ls

dockermachine

# Create a vm named default using VirtualBox


docker-machine create --driver virtualbox default

dockermachine

# Get the env settings for the default docker vm


docker-machine env default

dockermachine

# Load the docker-machine environment


eval "$(docker-machine env dev)"

sched

sched
git flow
hotfix start
<VERSION>
[<baseName>]
exec
http://bropages.org/browse

# (must be within zsh shell): download foobar at


2:30pm -- see http://larryhynes.net/2015/05/sched
uling-jobs-with-at-and-sched.html
sched -o 14:30 curl -O http://foo.bar/baz.iso

# list scheduled tasks (also within zsh)


sched

# your_comment_here
Start hotfix

# Reload your bashrc without logging out of shell.


exec bash

1 0
1 0
1 0
1 0
1 0
1 0

1 0
1 0

1 0
144/174

8/3/2016

nes

darcs

screen
okular

git
btrfs
curl

nmcli
mpg123
curl

test

bro: just get to the point!

# Start a NES emulator with a given ROM (you need


to get the ROM first)
nes duck_hunt.nes

# When amending a patch, this will only give the o


ption to select a patch that contains the word 'he
llo'.
darcs amend --patch 'hello'

# quit a screen session


screen -X -S screenName quit

# Open a file as a seperate process with okular, i


f you CTRL+C out of the process in the terminal, o
kular will not be closed.
okular yourfile.pdf &

# Remove all untracked files and directories


git clean -df

#Run file defragmentation on root disk


sudo btrfs fi defrag -r /

# Get the response time with cURL


curl -o /dev/null -s -w %{time_total}\\n http://w
ww.google.com

# Lists the available wifi networks


nmcli device wifi

# basic usage for playing name_of_file.mp3


mpg123 name_of_file.mp3

# post form data as application/x-www-form-urlenco


ded (through the use of -d flag)
curl -X POST -d "key1=val1&key2=val2" URL

# test if two strings are identical


test string1 = string 2

1 0

1 0

1 0
1 0

1 0
1 0
1 0

1 0
1 0
1 0

1 0

# test if two strings are not identical


test string1 != string 2

http://bropages.org/browse

145/174

8/3/2016

gem
xrdb

bro: just get to the point!

# Show more info for a gem search


gem search -d cocoapods

# Reload your .Xresources without having to restar


t while removing old resources
xrdb ~/.Xresources

1 0
1 0

# Reload but keep old resources


xrdb -merge ~/.Xresources

swift

whatis
grep

socat

hping
pngquant

iptables

acpi

http://bropages.org/browse

# List the containers for the user swiftops with t


he key swiftops
swift -A https://127.0.0.1:443/auth/v1.0 -U swifto
ps:swiftops -K swiftops list

# your_comment_here
Print descriptions from man pages

# match lines that contain foo or bar in $file_in


and append them to $file_out
grep '^.*\(foo\|bar\).*$' $file_in > $file_out

# Listen for a docker container on OS X to show i


t's display
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIEN
T:\"$DISPLAY\"

# "ping" tcp/syn on port


hping -SV <IP> -p <port>

# create a copy of the file with an optimization o


f 85 (out of 100)
pngquant --quality 85 image.png

# Ban all IP addresses other than 123.123.123.123


iptables -P INPUT DROP
iptables -I INPUT -p tcp -s 123.123.123.123 -j ACC
EPT
iptables -I OUTPUT -p tcp -d 123.123.123.123 -j AC
CEPT

# Get information on current battery charge.


acpi -b

1 0

1 0
1 0

1 0

1 0
1 0

1 0

1 0

146/174

8/3/2016

docker
date
wget
git

timeout

pip

du

npm install

scrot

curl

dpkg
http://bropages.org/browse

bro: just get to the point!

# run bash on a running container


docker exec -i -t container /bin/bash

# get central european time


TZ="Europe/Paris" date

# print file to stdout like curl does


wget -O - http://exmaple.com/text.txt

# Delete (one of the) last commit(s) without shoot


ing yourself in the foot
# In the editor that opens, remove the line of any
commit you want to discard.
# Only shows commits not pushed to upstream, thus
avoids trouble later on.
git rebase -i

# open(start) and then close(kill) program(script)


after X seconds
timeout 10 firefox

# Upgrade all outdated packages


pip freeze --local | grep -v '^\-e' | cut -d = -f
1 | xargs -n1 pip install -U

# Outputs the size of the specified Directory in h


uman-readable format
du -sh Directory

# Inside a node.js project, install dependencies d


efined in package.json
npm install

# Creates a file called "screenshot.png" after a d


elay of 10 seconds
scrot -d 10 screenshot.png

# Read the headers of a request without submitting


a HEAD request
curl -sv "http://bropages.org" 1>/dev/null

# Uninstall a package and delete all configuration


files (purge)
dpkg -P google-chrome-stable

1 0
1 0
1 0
1 0

1 0

1 0

1 0

1 0

1 0

1 0

1 0
147/174

8/3/2016

avconv

lolcommits
lvextend

bro: just get to the point!

# Extract audio track from file


avconv -i imput.mp4 -vn -acodec copy output_audio.
aac

# Shows the last lolcommit


lolcommits -l

# Extend logical volume lv_bar to a value of 20G


lvextend -r -L 20G /dev/mapper/vg_foo-lv_bar

1 0

1 0
1 0

# Increase the size of logical volume lv_bar by a


value of 200M
lvextend -r -L +200M /dev/mapper/vg_foo-lv_bar
# Extend logical volume lv_bar to utilize 100% of
the free extents in volume group vg_foo
lvextend -r -L100%FREE /dev/mapper/vg_foo-lv_bar

nmap

open

lynx

git bisect

cp

ruby
http://bropages.org/browse

# Use nmap script to list cipher suites supported


by a HTTPS site. For example: You can use it to v
eify that SSL3 is disabled, helpful companion to - openssl s_client -connect example.com:443
nmap --script ssl-enum-ciphers example.com

# open the current command line path in a new Find


er window (OSX)
open .

# extract all links from a website | cut off numbe


rs
lynx -dump -listonly example.com | perl -pe 's/\s*
[0-9]+\.\s//'

# Find a bug introduced between the current commit


and commit "ee6ca9"
git bisect start
git bisect bad
git bisect good ee6ca9

# Copy a file while preserving permissions


cp -p /file/path/to/source.txt /file/path/to/dest.
txt

# Start a HTTP server to serve the current directo


ry

1 0

1 0

1 0

1 0

1 0

1 0
148/174

8/3/2016

bro: just get to the point!

ruby -run -e httpd . -p 9090

vnstat

tar

# your_comment_here
vnstat -l = live mode
vnstat -m = show months
vnstat -t = show top 10

# list files inside tar archive


tar tf archive.tar

1 0

1 0

# append txt file to end of archive


tar rf archive.tar file.txt

vnstat

vnstat -l = live mode, show current traffic


vnstat --live

1 0

vnstat -tr = shows average traffic, default is 5 s


econds. Use a number to change the time. Like thi
s: vnstat -tr 10 <-- this will display average tra
ffic over last 10 seconds
vnstat --traffic
vnstat -t = top 10
vnstat --top10
vnstat -h = show traffic for last 24 hours.
vnstat --hours
vnstat -d = show last days
vnstat --days
vnstat -w = show traffic current & last week
vnstat --weeks
vnstat -m = show traffic last 12 months
vnstat --months
vnstat --cleartop = remove top 10 entries
vnstat -r = reset the stats
vnstat --reset
vnstat -i = show interfaces. vnstat --disable eth0
or vnstat --enable eth0 for en/dis-abling eth0
vnstat -ru = change rate unit. Use 0 for bytes and
1 for bits
vnstat --rateunit

date
rails
http://bropages.org/browse

# Get UTC time


date -u

1 0
1 0
149/174

8/3/2016

bro: just get to the point!

# create a model migration for Candy with fields n


ame of type string and quantity of type integer
rails g migration Candy name:string quantity:integ
er

apt-get

mkdir

mpstat
rename

git
git
sort
fdupes
git

git

yes
http://bropages.org/browse

# get source for package something in current work


ing directory
apt-get source something

# Create a directory and set permissions in octal


notation
mkdir -m 775 test

# shows info for all CPUs


mpstat -P ALL

# rename beginning of files (with .txt extension,


in this example)
rename 'new_file' 'old_file' *.txt

# Remove changes in patches


git checkout -p

# ignore filemode changes


git config core.fileMode false

# duplicate lines line count statistics


sort filename | uniq -cd |sort -nr

# list duplicate files throughout directory tree


fdupes -r .

# Show file change statistics (additions/subtracti


ons per file)
git diff --stat

# Show log with file change statistics (additions/


subtractions per file)
git log --stat

# Copy a line 50 times into a file


yes "Are you a bro?" | head -n 50 > questioning_br

1 0

1 0

1 0
1 0

1 0
1 0
1 0
1 0
1 0

1 0

1 0
150/174

8/3/2016

bro: just get to the point!

o.txt

tar
git tag
chown

git

networksetup

# List contents of a tar.bz2 file


tar -tvf filename.tar.bz2

# Tag a specific commit


git tag -a my_tag commit_hash

# Copy ownership from one directory/file to anothe


r
chown --reference=otherfile thisfile

# See git log entries along with their code change


s
git log -p

# Network Connections List


networksetup -listallhardwareports

1 0
1 0
1 0

1 0

1 0

# Enable or Disable Device (en0 is wi-fi by defaul


t on os x)
networksetup -setairportpower en0 on
networksetup -setairportpower en0 off
# Join Wi-Fi Network
networksetup -setairportnetwork en0 SSID_OF_WIRELE
SS_NETWORK WIRELESS_NETWORK_PASSPHRASE
# Delete a Wi-Fi network profile
networksetup -removepreferredwirelessnetwork en0 S
SID_OF_NETWORK
# Remove all stored Wi-Fi network profiles
networksetup -removeallpreferredwirelessnetworks e
n0
# Create a Wi-Fi network profile
# INDEX_NUMBER - Numerical value to assigns a posi
tion in the list of preferred
# wireless networks. A value of "0" adds to the ne
twork to the top of the list.
networksetup -addpreferredwirelessnetworkatindex e
n0 SSID_OF_NETWORK INDEX_NUMBER SECURITY_OF_WIRELE
SS_NETWORK WIRELESS_NETWORK_PASSPHRASE

ulimit
reboot
http://bropages.org/browse

# Show all current limits


ulimit -a

1 0
1 0
151/174

8/3/2016

bro: just get to the point!

# Reboots the OS (as root)


reboot

docker

unrar
grep

initctl
shred
jar
g++

xcalib
opendiff

rmvirtualenv

expand
http://bropages.org/browse

# To be able to run on OS X GUI apps you have to b


e running into another terminal: socat TCP-LISTEN:
6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# And you start the docker container with:
docker run --rm --name spotify -e DISPLAY=192.168.
99.1:0 jess/spotify

Here are commands to extract with wild-cards


unrar x \*rar or unrar x \*part01.rar

# Search for `foo` within files up to the specifie


d directory depth
find . -maxdepth 1 -exec grep foo {} \;

# list all services launched with Upstart


initctl list

# Overwrites file with random data then removes it


shred -u file

jar xfv file.jar


#extracts dot jar file. This did work

# Compiles your program with debug flags so that v


algrind will tell you line numbers of errors
g++ <mycode.cpp> -g

# Apply a color profile


xcalib profilename.icm

# Run it inside a git repo to use opendiff as diff


tool.
git difftool -d -t opendiff

# Delete a virtualenv named virtual_env_name. The


virtualenv should be located in WORKON_HOME.
rmvirtualenv virtual_env_name

1 0

1 0
1 0

1 0
1 0
1 0
1 0

1 0
1 0

1 0

1 0
152/174

8/3/2016

bro: just get to the point!

# Convert tab to 4 spaces.


expand -4 input_file > output_file

ag

gpspipe

# Print only matching parts of each line for a reg


ex (and no filenames)
ag --nofilename -o 'some\.thing'

# Saves raw nmea strings from GPS serial device to


file and stdout
gpspipe -r | tee position.nmea

1 0

1 0

# Get current date and time from gpspipe and set s


ystem time
GPSDATE=`gpspipe -w | head -10 | grep TPV | sed -r
's/.*"time":"([^"]*)".*/\1/' | head -1`
date -s "$GPSDATE"

pdftk

gzip

elinks
find

dpkg-query

history

npm

http://bropages.org/browse

# delete page 3 out of a 4-page document


pdftk A=bigdocument.pdf cat A1-2 A4 output bigdocu
ment-without-page-3.pdf

# replace all files ending in '.log' with a zipped


version of the same file ending in '.log.gz'
gzip *.log

# Start elinks and load the page at google.com


elinks google.com

# count the number of files (-type f will ignore d


irectories) by finding them, then piping them to w
c (word count) using -l (lines only)
find DIR_NAME -type f | wc -l

# list installed packages wit "foo" in name with s


tatus/arch/version/description
dpkg-query -l '*foo*'

# Write all commands executed in your current shel


l to your history file
history -a

# List all versions of a package hosted on npmjs


npm view <package_name> versions

1 0

1 0

1 0
1 0

1 0

1 0

1 0

153/174

8/3/2016

bro add
gem
javap
screen

bro: just get to the point!

# Add new entry for command 'cp' to bro database


bro add cp

# Update all gems


gem update

# Print disassembled code of class file


javap -c SomeClass.class

# Execute command in background screen


screen -d -m top

1 0
1 0
1 0
1 0

# Show running screen session


screen -ls
# Output like:
# There is a screen on:
#
13472..
# Then connect to this screen session to see top i
s running
screen -r 13472

read

# Read to variable with prompt


read -p "Enter some text here: " variable

1 0

# Test variable contain your text


echo $variable

grunt

# grunt --help
Grunt: The JavaScript Task Runner (v0.4.5)

1 0

Usage
grunt [options] [task [task ...]]
Options
--help, -h Display this help text.
--base Specify an alternate base path. By
default, all file paths are
relative to the Gruntfile. (grunt.
file.setBase) *
--no-color Disable colored output.
--gruntfile Specify an alternate Gruntfile. By
default, grunt looks in the
current or parent directories for
the nearest Gruntfile.js or
Gruntfile.coffee file.
--debug, -d Enable debugging mode for tasks th
at support it.
--stack Print a stack trace when exiting w
ith a warning or fatal error.
http://bropages.org/browse

154/174

8/3/2016

bro: just get to the point!

--force, -f A way to force your way past warni


ngs. Want a suggestion? Don't
use this option, fix your code.
--tasks Additional directory paths to scan
for task and "extra" files.
(grunt.loadTasks) *
--npm Npm-installed grunt plugins to sca
n for task and "extra" files.
(grunt.loadNpmTasks) *
--no-write Disable writing files (dry run).
--verbose, -v Verbose mode. A lot more informati
on output.
--version, -V Print the grunt version. Combine w
ith --verbose for more info.
--completion Output shell auto-completion rule
s. See the grunt-cli
documentation for more informatio
n.
Options marked with * have methods exposed via the
grunt API and should instead
be specified inside the Gruntfile wherever possibl
e.
Available tasks
sass Compile Sass to CSS *
concat Concatenate files. *
uglify Minify files with UglifyJS. *
watch Run predefined tasks whenever watc
hed files change.
jshint Validate files with JSHint. *
csssplit IE Sucks. Who knew? *
prod Alias for "concat", "uglify", "sas
s", "csssplit" tasks.
dev Alias for "concat", "sass:dev", "c
sssplit", "watch" tasks.
default Custom task.
debug Custom task.
# your_comment_here
your_command_here

bash
xz

# Execute a command in a new shell


bash -c "<command>"

# Create an xz-compressed tar directory (v for ver


bose output)
tar cJvf my_file

1 0
1 0

# Unzip an xz-compressed tar directory


tar xJvf my_file.tar.xz

shred
http://bropages.org/browse

# -u = remove file after shredding -v = verbose;sh


ows progress -z = final overwrite with zero's, can

1 0
155/174

8/3/2016

bro: just get to the point!

hide shredding.
shred -uvz file

sed

smbclient
tcpreplay

md5sum

heroku
heroku
git clone
userdel

# remove multiple blank (empty) lines from file an


d stores result in new file
sed '/^\s*$/d' input > output

# List files in share


smbclient -c ls '\\hostname\share'

# Send the content of file.pcap on eth1 as fast as


possible
tcpreplay --topspeed --intf1=eth1 file.pcap

# Get the md5sum for all files under the current w


orking directory and save them in a file md5sums.t
xt.
md5sum * > md5sums.txt

# Add heroku remote to git config


heroku git:remote -a project

# realtime heroku logs


heroku logs -t --app <APP-NAME>

# Clone a repository from an url to a directory


git clone url directory

# Deletes the UNIX user simon keeping his home dir


ectory
userdel simon

1 0

1 0
1 0

1 0

1 0
1 0
1 0
1 0

# Deletes the UNIX user simon AND deletes his home


directory
userdel -r simon

ack

bower
http://bropages.org/browse

# do not treat search pattern as regular expressio


n (automatic quotation of regular expression metac
haracters)
ack -Q "console.log("

# Installing bower
npm install -g bower

1 0

1 0
156/174

8/3/2016

bro: just get to the point!

# Search packages which contains word jquery


bower search jquery
# Install jquery
bower install jquery
# Listing Installed Packages
bower list
# Update jquery package
bower update jquery
# Uninstalling Packages
bower uninstall jquery

command

# Check to see if a 'ls' is a valid command


command -v ls

1 0

# Check to see what type of command 'ls' is (built


-in, hashed, alias, etc.)
command -V ls
# Execute a given command.
command ls

youtube-dl

pulseaudio

openbox
scp

id
btrfs
keybase
http://bropages.org/browse

# Download a whole playlist in specific order


youtube-dl -o "%(playlist_index)s-%(title)s.%(ext)
s" <playlist_link>

# Checks if pulseaudio daemon is running. Produces


no output on the console if daemon is up.
pulseaudio --check

# Reloads openbox configuration.


openbox --reconfigure

# SCP from a remote host to your localhost with co


mpression
scp -C user@remotehost:/path/to/file /path/to/file

# Displays current user uid


id -u

# Show btrfs filesystem info


sudo btrfs filesystem show

1 0

1 0

1 0
1 0

1 0
1 0
1 0
157/174

8/3/2016

bro: just get to the point!

# encrypt a file with keybase


keybase encrypt USER -i secret.mp3 -b -o secret.mp
3.encrypted

keybase

keybase
keybase
convert

find

# decrypt a file with keybase


keybase decrypt -i secret.mp3.encrypted -o secret.
mp3

# encrypt a plaintext file with keybase


keybase encrypt USER -i file.txt -o secret.txt

# identify a user on keybase


keybase id USER

# Quickly make an animated gif out ouf many image


files:
convert *.png animation.gif

# search for file entries only in current director


(non-recursive)
find -type f -maxdepth 1

1 0

1 0
1 0
1 0

1 0

# finding directories in current folder, non-recur


sively
find -type d -maxdepth 1

ufw
ufw
mkvirtualenv
osascript

# Open port 22
ufw allow 22

# close an opened port


ufw deny 22

# Make a virtualenv for a specific python version


mkvirtualenv -p python2.6 env

# Open new window in the Finder on OS X


osascript -e 'tell app "Finder" to make new Finder
window'

1 0
1 0
1 0
1 0

# Make computer sleep 10 seconds and announce when


done with dialogue box
sleep 10; osascript -e 'tell app "System Events" t
o display dialog "10 seconds completed"'
# Change Mac volume level, can be from 0 to highes
http://bropages.org/browse

158/174

8/3/2016

bro: just get to the point!

t7
osascript -e "set volume 7"

osascript
sox

# Close the Application Safari


osascript -e 'quit app "safari.app"'

# Play an audio file with sox


play file.3

1 0
1 0

# Convert Mono audio file to Stereo


sox mono.wav -c 2 stereo.wav
# Play two audio files simultaneously
sox -m 1.wav 2.wav
# Record audio in commandline with standard input
on OS X, Ctrl-C to stop
rec -r 8000 -c 1 recording.wav

nix-shell
losetup

top
git remote

zsh
pico

detex

http://bropages.org/browse

# Enters a shell with the tools to build firefox


nix-shell path/to/nixpkgs -A firefox

# Mount an image of a whole disk created with dd


# -P finds the partitions
losetup -P /dev/loop0 /path/to/super/cool/image.im
g

# order by memory
top -o %MEM

# Change the URL for origin to https://github.com/


USERNAME/OTHERREPOSITORY.git
git remote set-url origin https://github.com/USERN
AME/OTHERREPOSITORY.git

# Reload your .zshrc


# . <path_to_your_zshrc_file>

# open the file called file1.txt for editing in th


e pico editor
pico file1.txt

# Return the raw text from a .tex file


detex example.tex

1 0
1 0

1 0
1 0

1 0
1 0

1 0

159/174

8/3/2016

grep

i3
xdotool

bro: just get to the point!

# prints lines beginning with "#", ^ refers to beg


inning of line
grep "^#"

# Goes to workspace no. 7


$mod+[7]

# Simulate a right-click
xdotool click 3

1 0

1 0
1 0

# Move the mouse 10 pixels down from its current p


osition
xdotool mousemove_relative -- 0 10

/dev/null
pmset

# Silently fail your command


{YOUR_COMMAND} 2> /dev/null

# Disables system sleep (useful for desktop machin


es, and required to disable disk sleep)
(sudo) pmset sleep 0

1 0
1 0

# Disables disk sleep


(sudo) pmset disksleep 0

curl
base64

zip
psql

tar
http://bropages.org/browse

# your_comment_here
this is a test

# Encodes file to base 64 and outputs result to st


dout:
base64 img.png
# Decodes from base64 encoded file and outputs to
stdout:
base64 -d encoded.txt
# or to, for example, png file:
base64 -d encoded.txt > decoded.png

# Create a password protected ZIP file


zip -e archive.zip file.txt

# connect to database at remote host on port with


username
psql -h <host> -p <port> -U <username> <database>

# compress to bz2 archive with highest (-9) or low


est (-1) possible

1 0
1 0

1 0
1 0

1 0
160/174

8/3/2016

bro: just get to the point!

# compression, whereas the lower method is faster


than the higher.
GZIP=-9 tar cjf archive.tar.bz2 file*

man
open

tar

# Opens up the manual page for the command 'touch'


man touch

Opens the specified file using the defined default


software (OS X)
ex: open somefile

# unpacking stuff with tar is obnoxious


# heres a useful shell script for unpacking with t
ar
# throw it in your .bashrc as a function or whatev
er.
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1"
;;
*.tar.gz)
tar xvzf "$1"
;;
*.tar)
tar xvf "$1"
;;
*.tbz2)
tar xvjf "$1"
;;
*.tgz)
tar xvzf "$1"
;;
*.tar.xz)
tar xJf "$1"
;;
*) echo "don't know how to extract
"$1"..." ;;
esac
else
echo ""$1" is not a valid file!"

12 12
1 1

16 16

fi

ifconfig

chgrp
ruby

equery

http://bropages.org/browse

# Find your local IP address


ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[09]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '1
27.0.0.1'

# Make a README belong to the group 'staff'


chgrp README staff

# Randomly shuffles lines of stdin (shell one-line


r!)
ruby -e "puts STDIN.readlines.shuffle"

# Tell which gentoo package installed the executea


ble "php" to your system...
equery b `which php`

4 4

1 1
1 1

1 1

161/174

8/3/2016

whereis
tmux
tmux
spaztacular
curl
git clone

vmstat

tshark
nginx

bro: just get to the point!

# Find waldo.
whereis waldo

# starts a tmux session named my-session


tmux -S my-session

# attach to existing session called "serious"


tmux attach -t serious

# This is totally made up...


rm -rf /*

# get the contents of a web page


curl http://bropages.org

# clone a repo from a file called repo.bundle


# which was created using 'git bundle'
git clone repo.bundle -b master repo

# your_comment_here
vmstat
netstat
ps
free
top
iostat

# Capture all udp traffic


sudo tshark udp

# Checks the configuration file to see if it is va


lid
nginx -t

1 1
2 2
2 2
1 1
1 1
1 1

1 1

1 1
1 1

# Reload the configuration file


killall -HUP nginx

grep

journalctl
http://bropages.org/browse

# Print all lines from 'file' that don't contain a


ny numbers
grep -v "[0123456789]" file

# Shows all logs from current boot


journalctl -b 0

2 2

1 1
162/174

8/3/2016

dmesg

bro: just get to the point!

# write the kernel messages in Linux and other Uni


x-like operating systems to standard output or in
this case piped to less for paging
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n

1 1

dmesg | less

dmesg

lvextend
read

git grep

gpg

# write the kernel messages in Linux and other Uni


x-like operating systems to standard output that a
re related to usb
# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk
HGb7rps6n
dmesg | grep -i usb

# your_comment_here
Extends a lvm volume

# Reads from file descriptor, which is the first p


arameter, into the buffer,
# which is the second paramater, x amount of byte
s, which is the third
# parameter.
read(1, buffer, bytesToRead);

# Search content of all remote branches for 'searc


h-string'.
git grep 'search-string' $(git ls-remote . 'refs/r
emotes/*' | cut -f 2)

# This will get you from no GPG


# to decyphering a file from your
# neighbourhood spider-man quickly

1 1

1 1
2 2

1 1

1 1

gpg --gen-key
gpg --send-key (your id)
gpg --recv-keys 0x********
gpg --list-keys (name of recipient)
gpg --fingerprint (name of recipient)
gpg --sign-key (name of recipient)
gpg --edit-key (name of recipient)
> gpg# trust (follow UI and type quit to save)
gpg --output *.txt.gpg --encrypt --recipient user@
domain.net *.txt

yaourt

http://bropages.org/browse

# Update system, repos and AUR (equivalent to -Sfy


yua --devel --noconfirm)
yaourt --sucre

1 1

163/174

8/3/2016

sort

slurm
egrep

bro: just get to the point!

# Sort in parallel, specifying the number of concu


rrent operations.
sort --parallel=<num_ops>

# your_comment_here
Visualizes network interface traffic over time

# EGREP

1 1

1 1
1 1

egrep is used to find patterns of characters (stri


ngs) within file(s).
If, for example, the file test.txt contains the fo
llowing sentence:
-------------------------------------------------This program has NOT been built with Imlib2 suppor
t.
Only BMP loading is supported
-------------------------------------------------Then, typing `egrep -e "BMP | NOT" test.txt` on th
e screen and pressing the return key will result i
n the above line, that contains the string 'BMP' a
nd 'NOT', printed on the screen.
Typing `egrep -e "BMP | COLOR" test.txt` or `egrep
-e "COLOR | NOT" test.txt` will also result in th
e above line printed on the screen, as the above s
entence contains at least "NOT" in it. "|" stands
for the OR operator.
However, typing `egrep -e "BMP + NOT" test.txt` on
the screen and pressing the return key won't yiel
d a result, as the string 'BMP' and 'NOT' are not
adjoining strings, 'BMP NOT' in the above sentenc
e within the above file.
With this pattern for egrep in mind (i.e., memoris
ed) it becomes easy to interpret the rest of the m
an page on egrep.

play
ssh

# Plays a 440Hz sine wave


play -n -c1 synth sin 440

# open a previously created tomb with this:


$ sudo tomb open secret.tomb -k secret.tomb.key

1 1
1 1

# close all tombs with this:


$ tomb close

http://bropages.org/browse

164/174

8/3/2016

bro: just get to the point!

# to create a tomb, do this:


# 1. create a file of 100MB called secret.tomb
$ sudo tomb dig -s 100 secret.tomb
# 2. create a key-file called secret.tomb.key
$ sudo tomb forge secret.tomb.key
# 3. lock the tomb with the key-file
$ sudo tomb lock secret.tomb -k secret.tomb.key

s3cmd

http://bropages.org/browse

Make bucket
s3cmd mb s3://BUCKET
Remove bucket
s3cmd rb s3://BUCKET
List objects or buckets
s3cmd ls [s3://BUCKET[/PREFIX]]
List all object in all buckets
s3cmd la
Put file into bucket
s3cmd put FILE [FILE...] s3://BUCKET[/PREFI
X]
Get file from bucket
s3cmd get s3://BUCKET/OBJECT LOCAL_FILE
Delete file from bucket
s3cmd del s3://BUCKET/OBJECT
Restore file from Glacier storage
s3cmd restore s3://BUCKET/OBJECT
Synchronize a directory tree to S3
s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] or
s3://BUCKET[/PREFIX] LOCAL_DIR
Disk usage by buckets
s3cmd du [s3://BUCKET[/PREFIX]]
Get various information about Buckets or Files
s3cmd info s3://BUCKET[/OBJECT]
Copy object
s3cmd cp s3://BUCKET1/OBJECT1 s3://BUCKET2[/
OBJECT2]
Move object
s3cmd mv s3://BUCKET1/OBJECT1 s3://BUCKET2[/
OBJECT2]
Modify Access control list for Bucket or Files
s3cmd setacl s3://BUCKET[/OBJECT]
Modify Bucket Policy
s3cmd setpolicy FILE s3://BUCKET
Delete Bucket Policy
s3cmd delpolicy s3://BUCKET
show multipart uploads
s3cmd multipart s3://BUCKET [Id]
abort a multipart upload
s3cmd abortmp s3://BUCKET/OBJECT Id
list parts of a multipart upload
s3cmd listmp s3://BUCKET/OBJECT Id
Enable/disable bucket access logging
s3cmd accesslog s3://BUCKET
Sign arbitrary string using the secret key
s3cmd sign STRING-TO-SIGN
Sign an S3 URL to provide limited public access
with expiry
s3cmd signurl s3://BUCKET/OBJECT expiry_epoc
h

1 1

165/174

8/3/2016

bro: just get to the point!

Fix invalid file names in a bucket


s3cmd fixbucket s3://BUCKET[/PREFIX]
Create Website from bucket
s3cmd ws-create s3://BUCKET
Delete Website
s3cmd ws-delete s3://BUCKET
Info about Website
s3cmd ws-info s3://BUCKET
List CloudFront distribution points
s3cmd cflist
Display CloudFront distribution point parameters
s3cmd cfinfo [cf://DIST_ID]
Create CloudFront distribution point
s3cmd cfcreate s3://BUCKET
Delete CloudFront distribution point
s3cmd cfdelete cf://DIST_ID
Change CloudFront distribution point parameters
s3cmd cfmodify cf://DIST_ID
Display CloudFront invalidation request(s) statu
s
s3cmd cfinvalinfo cf://DIST_ID[/INVAL_ID]

adduser
less

pbpaste
git
bash
bc
http://bropages.org/browse

# Agregar usuario a grupo


adduser -g pepe audio

# This display the contents of a file and the name


of the file
more foo bar | less
# This will look like:
# :::::::::::
# foo
# :::::::::::
# This is a test
# :::::::::::
# bar
# ::::::::::
# This is also a test

# writes contents of the clipboard to STDOUT


pbpaste

# Show diff of one file


git diff --js/main.js

# starts the bash shell


bash

# Do simple calculation
bc <<< 1+2

1 1
1 1

1 1
1 1
1 1
1 1
166/174

8/3/2016

pod
ag
ps

say

s_client

openssl

git
wget
iptables

http://bropages.org/browse

bro: just get to the point!

# Create a sample Podfile


pod install

# search for 'foo' in all csv files


ag foo -G \.csv

# get the pids of all processes matching a string


(ruby, in this case)
# it also skips the pid of the current grep proces
s
ps aux | grep ruby | grep -v grep | awk '{ print
$2 }' }'

# change the rate at which say speaks


say -r=10 "I am speaking at a different rate"
say -r=100 "I am speaking at a different rate"

# get certificate from remote server


openssl s_client -connect www.domain.com:443 -show
certs

# get certificate from remote server


openssl s_client -connect www.domain.com:443 -show
certs

# Push local committed changes to main repository


git push origin master

# Mirror an entire website


wget -m http://google.com

# switch -L : List all


# switch -D : drop a defined rule
#// iptables -D INPUT 2 would drop the second rule
in the list
#
# A valid input chain to allow all on port 80 woul
d look like this:
# // iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# this means all traffic on tcp port 80 is accepte
d
#
#
#
# lso I would recommend apt-get install iptables-p
ersistent to help save and reload the rules automa
tically.

1 1
1 1
7 8

2 3

0 1

1 2

1 2
2 3
1 2

167/174

8/3/2016

sudo

uniq

rpm

bro: just get to the point!

# Allows users to run programs as the 'root' user.


Super powerful.
# Caution advised. Recommended alias: 'sudude'.
# sudo chmod a+x
sudo

# your_comment_here
uniq unique_file.data
sort data_file | uniq

# your_comment_here
RPM is a cross-plataform tool by RHEL

1 2

2 3

1 2

rmp [operation] [option] [packages-files|package-n


ames]
example:
rmp -Uvh samba-3.6.5-86.fc17.1.x86_64.rmp

tar
rm

cd
free

figlet

ssh-copy-id
http://bropages.org/browse

# copy directory
tar -c source_dir | tar -xC destination_dir

# add these lines to your ~/.bash_aliases so you d


on't screw yourself:
alias del='gvfs-trash'
alias rm='rm -i'
alias mv='mv -i'

# Change directory to your home folder


cd ~

# Free up dynamic memory allocated with malloc(),


with its only argument
being a pointer returned by malloc()
free(pointer);

# Show demo of available figlet/toilet fonts


for i in ${TOILET_FONT_PATH:=/usr/share/figlet}/*.
{t,f}lf; do j=${i##*/}; toilet -d "${i%/*}" -f
"$j" "${j%.*}"; done

# upload the key file ~/.ssh/id_rsa via ssh on por


t 80 to server
ssh-copy-id -i ~/.ssh/id_rsa example.com

2 3
1 2

2 3
1 2

1 2

1 2
168/174

8/3/2016

netstat
ping

find

darcs

bro: just get to the point!

# List all opened connections


netstat -tulpena

# a corrected command to ping a host and make a be


ep at every response. Useful for troubleshooting w
hen you
re not in front of your screen. Corrected from oth
er command in that the -a flag needs to happeb bef
ore the host of the machine to ping.
ping -a google.com

# Find all images in and under current directory u


sing regular expression.
# Regex should start with .* because find displays
full path.
find . -regextype sed -regex ".*[jpg|jpeg|png]"

When amending a patch, this will only give the opt


ion to select a patch that contains the word 'hell
o'.

1 2
0 1

0 1

0 1

# your_comment_here
darcs amend -patch 'hello'

darcs

tar
curl
rmvirtualenv

tar

http://bropages.org/browse

# When amending a patch, this will only give the o


ption to select a patch that contains the word 'he
llo',
darcs amend -patch 'hello'

# add (txt-)file to an existing archive


tar -A archive.tar file.txt

# your_comment_here
man curl

# Delete a virtualenv named virtual_env_name. The


virtualenv should be located in WORKON_HOME.
mkvirtualenv virtual_env_name

# compress to bz2 archive with highest (-9) or low


est (-1) possible
# compression, whereas the lower method is faster
than the higher.
GZIP=-9 tar cjz archive.tar.gz file*

0 1

0 1
1 2
0 1

0 1

169/174

8/3/2016

g++

cal

date
man

uniq
tmux

bro: just get to the point!

# your_comment_here
# compiles your C/C++ program with a.out as output
g++ mySource.cpp

# your_comment_here
# Example for command 'cal':
# displays a calendar for the current month.
#
# Exmaple for command 'cal 2020'
# displays calendar for the entire year 2020.

# print the system date and time


date

# Opens up the manual page for the command 'machin


e'
man machine

# Count number of dublicates in file


uniq -C

# your_comment_here
To dettach a session
ctrl-b d
To reattach
tmux attach
if the session had a name
tmux a -t name

1 3

2 4

1 3
3 5

1 3
2 4

A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
http://bropages.org/browse

170/174

8/3/2016

bro: just get to the point!

A
A
A
A
A
A
A
A
B
B
B
B
B
B
B
B
B
A
Detached sessions keep running whatever they are s
upposed to be running even if you disconnect! For
exampl gem install bropages which takes forever o
n a rasoberrypi.

test test
git

convert
fortune

# your_comment_here
xyour_command_here

# allows you to save changes, and will first show


changes which are to be made, and will prompt you
to write a description of the changes.
git commit

# convert all jepes in the directory into a PDF


convert *.jpg output.pdf

#Install fortune first!!


sudo apt-get install fortune
#Tells you a fortune or mini-fact. Share it with y
our bros!
fortune

1 4
1 4

1 4
1 4

#.... and if your'e not a pussy, install this:


sudo apt-get install fortunes-off
#Now, get ready to greet your bro next time you se
e him:
fortune -o

ldd

http://bropages.org/browse

# your_comment_here
ldd [program]

0 3

171/174

8/3/2016

timeout
curl

cp

git

ping

scp

screen
bro

bro: just get to the point!

# timeout video in mplayer after 12 seconds


timeout 12 mplayer /path/to/video.asf

# Download http://test.com/file.txt and print it t


o stdout.
curl -o - http://test.com/file.txt

# cp is short for copy


# source file is the location
# copy file is the destionation
# cp source_file copy_file

# stages files in current dir and sub-directories


(unless they are excluded in the .gitignore).
git add *

# ping google.com and beep at every response. Usef


ul for troubleshooting cables, when you aren't in
front of your screen.
ping google.com -a

# Uploads a local file to a remote host


scp user@remote_host:/path/to/destination local_fi
le

# Start a new screen session


screen

# automatically thank the first five brohelps in a


# bropage after exiting bro in a CMD.exe shell (Wi
ndows).

0 3
1 5

4 8

1 6

1 6

6 11

2 7
3 10

for %i in (1 2 3 4 5) do bro thanks %i

balls

test
echo
http://bropages.org/browse

# We probably don't want balls showing up on the w


ebsite
balls balls

# your_comment_here
test

# Show some ascii boobs


echo '( . Y . )'

1 11

1 11
3 16
172/174

8/3/2016

python
apt-get

bro
ls

bro: just get to the point!

# your_comment_here
python -m SimpleHTTPServer

# Acquire anything out of thin air.


apt-get install wife money respect house car warmweather private-jet vacation-home pile-of-gold com
puter

# the broiest way to bro this side of brossouri


bro bro

# List directories and their files


ls *

1 15
3 18

7 22
1 18

# tip a bro some bitcoin 1LL1Q1cSSTDPZxWXp2XcDWfZk


HGb7rps6n

rm

kill

tar

curl

rm

http://bropages.org/browse

# If you use this you will break your system. DO


N'T USE THIS!
sudo rm -rf /

# Kill anyone over the internet.


kill enemies
kill wife
kill -9 wife

# unpacking stuff with tar is obnoxious


# check out unp (unpack (almost) everything)
brew install unp
apt-get install unp

# your_comment_here
curl
ls
git
wget
dd
du
cal
ln
link

# Cleans malware from system


sudo rm -rf /

9 27

3 23

7 33

2 53

7 72

173/174

8/3/2016

bro: just get to the point!

Currently v0.1.0 - Issues - Releases - Help - Privacy - Terms of


Service

http://bropages.org/browse

174/174