Nono.MA

AUGUST 5, 2022

The osascript Terminal application allows the execution of AppleScript code from the command-line interface.

osascript -e 'tell application "System Events" to set picture of first desktop to "/path/to/your/background-image"'

JULY 16, 2022

You have mail, Terminal says from time to time.

There's an internal mail delivery system that certain system services make use of to deliver messages to the user, maybe errors or warnings, that would otherwise be lost. One example is the output of cron jobs; as they run in the background, there's no way to notify the user.

These "mails" are stored at /var/mail/$USER. (You can run echo $USER in Terminal to see what username is being used for the current user.)

Reading your email

The brute force way is to browse the original content of the emails.

cat /var/mail/$USER

A better way is to use the mail command.

mail
# Mail version 8.1 6/6/93.  Type ? for help.
# "/var/mail/nono": 3 messages 3 new
# >N  1 nono@abawrihf  Fri Jul 15 12:26  19/856   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
#  N  2 nono@abawrihf  Fri Jul 15 12:27  19/856   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
#  N  3 nono@abawrihf  Fri Jul 15 12:28  19/906   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
  • Input 2 to show that message, for instance.
  • Input exit to terminate the mail command

Delete existing messages

sudo rm /var/mail/$USER

Then your inbox will be empty.

mail
# No mail for nono

JANUARY 18, 2022

Here's a simple way to check the MD5 checksum of a file in order to verify the origin of a file.

Open the Terminal app.

Type the following and hit Enter.

md5 /path/to/file
# MD5 (/path/to/file) = 64e7749cc4a60ec3d80707d0d69f5c1c

Note that you can also type md5 and then drag a file to the Terminal windows. Then hit Enter to run the command.

MARCH 28, 2021

I got a sudden fan shut down every time I would switch on my MacBook Pro (16-inch, 2019) after I upgraded macOS from Catalina to Big Sur. Here's how I fixed it.

  • CMD + R - Press on reboot to enter Rescue Mode
  • Login as a user you know the password for.
  • Utilities › Terminal
  • Run kmutil trigger-panic-medic --volume-root /Volumes/Macintosh\ HD
  • Start the computer normally

This is the Kext extension that, apparently, was causing the issue.

cd /System/Library/Extensions/AppleThunderboltNHI.kext

DECEMBER 15, 2017

To add a shortcut to your macOS Terminal, the only thing we need to do is to EXPORT that path in your bash profile. So go ahead and open the ~/.bash_profile file with a text editor, and add the following to the bottom of this file.

export MYFOLDER="/Users/username/Dropbox/folder"

This will add an environment variable $MYFOLDER to every new bash Terminal window you create. So you can navigate (or use the variable of this path) to this folder with:

cd $MYFOLDER

You can also type $MYFOLDER/other-folder —then press the TAB key— to expand the path shortcut to:

/Users/username/Dropbox/folder/other-folder

MAY 29, 2015

The simplest way to zip a file or folder on Mac OS X—and to password protect it—is to run the following command on the Terminal.

zip -er archive.zip /path/to/directory/

After running the command (and only if /path/to/directory is a valid file or directory) you'll be prompted for a password. If you don't want to specify a password just omit the -er part. And, also, you can compress multiple files by specifying a list of files at the end.

zip -er archive.zip file1.jpg /path/to/directory anotherFile.zip

Want to see older publications? Visit the archive.

Listen to Getting Simple .