Sudo is "Superuser Do"

I enjoy the etymology of technology words. Understanding it can be a handle into using the tool well. One example: sudo. sudo comes from “Superuser do”, allowing you to run a program with the security privileges of another user, usually the root superuser. Here’s an example from a terminal near you: $ <dangerous-command> dangerous-command: NOT super-user $ sudo <dangerous-command> Doing a dangerous thing... This is why programmers say “su DO” (pronouncing “do” like “do”) rather than the softer “sudo”. They aren’t (just) being pedantic; it’s the more correct way to pronounce the word. ...

October 22, 2026

Reloading Zsh

When I reconfigure my Zsh terminal, I want to see the changes immediately. A good way to do that on Mac is: exec zsh This uses the Zshbuiltin exec command to replace my login shell (Zsh) with another login shell (Zsh). Sourcing the Zsh config (source ~/.zshrc) is less reliable, as things like custom functions you’ve removed tend to stick around. Check out zshbuiltin for more.

October 21, 2026

Read lpr Configuration

I’ve written about lpr before; to me the ability to send a file to my printer from the command line is a magic trick. What if I want to know where the file is going to go before sending it? lpr’s docs say: The LPDEST and PRINTER environment variables are consulted first. If neither are set, the current default set using the lpoptions(1) command is used, followed by the default set using the lpadmin(8) command. ...

August 31, 2026

Overwrite vs. Append

I use the append >> and overwrite > redirection operators all the time. Today I’d like to share a simple mental model I’ve developed for remembering which is which. Append, >>, appends to its target with the redirected output. It’s two carets, because it “adds a second thing” to what already exists. Overwrite, >, replaces its target with the redirected output. It’s one caret, because it “becomes” its target. Hope this helps.

March 13, 2026

Who Owns This Program?

I’ve got a command docker on my machine. I need to upgrade it. So, who owns it? This is always a bit of a detective story. The question is type: $ type -a docker docker is /usr/local/bin/docker “If docker was a command, how would you interpret it?” -a means “List all occurrences.” I still don’t know who owns docker. Next, which: $ which -a docker /usr/local/bin/docker “Locate this program and list all answers.” Nothing new. ...

February 9, 2026

Calculating With Bc

Today I accidentally I found a calculator on my computer, bc. Let’s look at it! Here’s how I entered the bc REPL. bc Here’s me adding, a few different ways: # REPL! $ bc >>> 1 + 1 2 # Eval! $ bc -e "1 + 2" 3 # File! $ cat add 1 + 3 $ bc -f add 4 I’m reading the author’s website and may have some more tips and tricks next time!

January 7, 2026

pbcopy, no cat

My friend Josh recently wrote about a common mistake using pbcopy, Apple’s pasteboard utility. To paraphrase, the bad version creates a file called pbcopy: $ cat .envrc › pbcopy While the good version sends the file to your clipboard: cat .envrc | pbcopy There’s a third approach that avoids cat entirely, and may sidestep this mistake for some: pbcopy < .envrc

March 5, 2025

Read Zsh Builtin Manual Pages

In Zsh, if you type man cd, instead of a manual page, you’ll get this: See the built-in command description in the appropriate shell manual page. To see Zsh’s implementation of cd, we need to view Zsh’s built-in man page: man zshbuiltins What’s going on here? Here’s a summary: Builtin commands are contained within the shell itself. When the name of a builtin command is used as the first word of a simple command (see Simple Commands), the shell executes the command directly, without invoking another program. Builtin commands are necessary to implement functionality impossible or inconvenient to obtain with separate utilities. –“Shell Builtin Commands”, https://www.gnu.org/ ...

May 22, 2024

Append to a Write-Protected File

Suppose you want to append to a file that’s write-protected and can only be edited via sudo. Is that possible? It is! A technique I discovered today is to use tee with sudo: $ cat file.txt | sudo tee -a /etc/hosts This lets me append the contents of file.txt to the write-protected /etc/hosts file by entering my password.

February 22, 2024

Create a File With `cat`

When you combine cat (concatenate) with > (output redirection), you can create and write to a file from the command line. $ cat > test.txt Hit enter after the file name, and your terminal will wait for input. End the file with CTRL + D. $ cat > test.txt one two three $ cat test.txt one two three >> works, too; appending to the file as expected.

December 12, 2023