Useful System Binaries

This page provides the usage of some system commands. System commands are defined by those packages that are typically installed by default.


lsof means "list open files". It can provide information about disk files, named pipes, network sockets, and anything that currently being accessed.

>> checking if a file being accessed
$ lsof <file>
$ lsof -u <user> # list files access by user

>> show connections
$ lsof -i # all connections
$ lsof -i :80 # for port 80 only
$ lsof -iTCP # for all TCP connections
$ lsof -i -sTCP:ESTABLISHED # list connections for established connections

tar archive utility

>> archiving a folder
$ tar -czf output.tar path/

>> extracting an archive with verbose output
$ tar -xvzf file.tar


netstat is a utility for (insert more stuff here). I frequently use netstat to see how many ports are open and what packages are listening on those ports.

$ sudo netstat --plunt


find is one of the most useful command to locate files within any given path. On macOS, install gfind package via brew.

>> finding files in the current directory
$ find . -type f

>> find and execute (example: ffmpeg)
$ find . -name "*.flac" -exec ffmpeg -i {} -c:a libmp3lame -ab 256 {}.mp3 \;

>> upload something to BackBlaze B2
$ find * -type f -print -exec b2 upload_file b2-repo {} {} \;

Here are a few important things to know:


Sometimes I use type to see how many binaries of a package are in my system, e.g. if I installed python via apt and linuxbrew, I would run type command to know their full location, because which command only tells you the current binary in use.

$ type git

... which will return

git is /usr/local/bin/git
git is /usr/bin/git

... on my macOS, because I have git from xcode and git from homebrew. The which command tells me that I am running git from linuxbrew currently.


systemctl is the init daemon for almost all major operating systems, replacing the previous Upstart and SysVinit. It handles the services running in a system.

>> reloading systemctl
$ sudo systemctl daemon-reload

>> adjusting the state of any given service
$ sudo systemctl enable <service> # enable at startup
$ sudo systemctl start <service> # start the service
$ sudo systemctl stop <service> # stop the service
$ sudo systemctl disable <service> # disable at startup
$ sudo systemctl mask <service> # null the service
$ sudo systemctl unmask <service> # reverse the masking
$ sudo systemctl reload <service>

It is a great idea to create aliases for systemctl better productivity. This is my systemctl aliases.

alias ctl='sudo systemctl'

For example, running a service is done by issuing ctl start <service>. To me, this is a little less elegant because I want the subcommand comes after the service name. To do that, here is the bash function (which I have in my .zshrc).

function control() { sudo systemctl "$2" "$1" }

Running a service is done by issuing control <service> stop. It makes a little bit more sense.


GNU Privacy Guard (GnuPG or GPG) is an openPGP implementation of hybrid encryption software program.

>> symmetric encryption (not with keypair)
$ gpg --symmetric --cipher-algo AES256 file.tar.gz

>> decrypt
$ gpg --decrypt encrypted.gpg> decrypted.ext


If you think ssh is for connecting to a remote machine, that's one trick it can do. Another trick is to utilize ssh as network a tunnel, effectively making it a proxy on the application level.

>> Creating a proxy
$ ssh -D 8123 -f -C -q -N [email protected]

>> Tunneling a localhost service on VPS
$ ssh -N -f -L 8888:localhost:8888 [email protected]

>> Forwarding X
ssh -f -X -C [email protected] application

The second command listed above tunnels port running on 8888 on remote (e.g. VPS) to local machine's 8888. I run this command when I use Jupyter Lab on my VPS and accessing it with my local computer.