Skip to main content


Command Collection

A collection of useful commands and Bash snippets that I tend to forget way too often. Many more to come.

Files & Directories

Count number of files in a directory recursively

$ find mydir -type f | wc -l


Get runtime of a process

$ ps -p <pid> -o etime=

Net stuff

Turn on an interface

# ip link set up dev eth0

Manual add/delete ip address

# ip addr add dev eth0
# ip addr del dev eth0

Add/delete static route

# ip route add via dev eth0
# ip route del

Add default route

# ip route add default via


Show remote origin url

$ git remote -v
$ git config --get remote.origin.url # for scripting

Add origin as remote

$ git remote add origin <url>

Change origin url

$ git remote set-url origin <url>


List public/private keys, shorthand

$ gpg -k
$ gpg -K

List keys with keyid, default is none for versions >= 2.1.13, short otherwise.

$ gpg -k --keyid-format <none|short|long>

Check if public key is in keyring

if gpg -k 0x1234ABCD > /dev/null 2>&1; then
    # key exists

Get info about keys cached by gpg-agent

$ gpg-connect-agent 'keyinfo --list' /bye


Install local package, e.g., from cache (/var/cache/pacman/pkg/)

# pacman -U mypackage.pkg.tar.xz

Get information about a package

$ pacman -Qi python2

List the files installed by a package

$ pacman -Ql python2

List explicitly installed packages

$ pacman -Qe
$ pacman -Qet # those that are not dependencies

List unneeded dependencies (orphaned packages)

$ pacman -Qdt

TeX Live

Update system-wide font map files

# updmap-sys

Run after adding new fonts

# texhash