Command Line Stuff I Use

Screenshot of command line stuff I use

This is a blog post where I share various commands for use in the terminal. Mostly, I add new commands here when I find them and when someone shares something useful with me. This blog post helps me keep all these commands in a single place.

Search Files and Folders for Code

When working with Kevin Cristiano of Tadpole Collective, I picked up a very useful command to search files and folders for a string of code.

grep -iRn ‘wp_searching_for_something’ .

To break that command down a bit, here’s an explanation as I understand it:

  • grep is a command-line utility for searching plain-text data sets for lines that match a regular expression;
  • -i tells the search to work in a case insensitive way – that is, search for the string regardless of uppercase or lowercase letters;
  • R makes the search recursive;
  • n tells the search to output the specific line number in any files where the string is found;
  • 'wp_searching_for_something' is the specific string for the search; it’s important to include the single quote marks; and
  • . at the end tells the search to run in the current directory.


This command is useful when troubleshooting DNS issues. This was shared with me by Daniel Olson.

dig A +short
dig A +short
dig CNAME +short
dig CNAME +short

Find Nameserver Details

These short commands were shared with me by the coffee-loving Jan Dembowski.

dig ns
dig ns +trace

Get TXT Records for a Domain

The following command is a clean way to get the basics on TXT records, which is helpful when looking to verify authorization over a domain.

dig -t txt +short

Curl -I

I can’t recall the value of this but I used it once and it was pretty helpful. I think Daniel Olson shared this with me as well. For what it’s worth, curl is short for “Client URL”.

curl -I

Mac OS Commands

Hide Desktop Icons

I found this wonderful technique in a blog post and copied it here for my own future reference.

Hiding the Icons

defaults write CreateDesktop false
killall Finder

Bringing the Icons Back

defaults write CreateDesktop true
killall Finder

Create Fake File

Thanks to Steven Grant and a newsletter from Delicious Brains, here’s a great little command to create a fake file to test file upload limits. You can adjust the size and format of the file by adjusting the command.

mkfile 10m testfile.pdf

Git Commands

Git Remote

In early 2022, Bitbucket changed the way that they allow people to access repositories remotely. As such, I had to change the URL of my remote repos. The following code will get that done.

git remote set-url origin [git@url stuff]

Then to confirm that the remote was set correctly, you can run the following command.

git remote -v

Git Diff

When looking to compare what has been changed in files, you can run a Git command to show you, as shared with me by Kevin Cristiano of Tadpole Collective.

git diff

Git Stash

Kevin also taught me about Git stash, which can be use to remove changes to a file.

git stash

Or bring those changes back …

git stash pop

Commands on Digital Ocean

To change from issuing commands as the root user to the www-data user in a Digital Ocean droplet, you can use the following command within the droplet console. Once you can run wp-cli commands. (As with so many commands on this page, this too was shared by Kevin Cristiano.)

sudo -u www-data

Last updated: 27-Apr-2022