How to access and delete saved system Mail (mbox) in Mac OS Big Sur terminal

If you are using crontab or some other terminal based system applications on Mac OS Big Sur, you may encounter a message saying “You have mail” after opening your Mac OS Terminal application. This is a system message telling you that you have system mail in your systems mail box, NOT, in the Mac Mail GUI application. To read your mail, you can type “mailx”, in your Terminal application. After you are done reading your mail, you may type “q” to quit the system mail application. After this, MacOS will tell you that it is “saving your messages to mbox”.

Once your mac has saved these messages, you can re-access these old messages by typing the following inside your terminal app:

mail -f ~/mbox

Mac OS will then show you all of your saved messages in mbox. It will also give you the number of saved mbox message like “71 messages”, in the top right corner of your terminal.

To delete these messages (all of them), you can issue the following command where “x” is the first message you want to delete, and “y” is the last message you want to delete.

d x-y

For example, I have 71 saved messages in my mbox. I want to delete all of them. So I would issue the following two commands.

mail -f ~/mbox

… to activate mbox, and…

d 1-71

to delete all of my 71 saved mbox messages.

Once deleted, you can exit out of mbox by typing q and then hitting “enter”.

There you go. This is just a quick tip on how to delete and manage your Mac OS System mail in mbox.

How to batch convert images to WebP with Imagemagick on MacOS

1 Install homebrew by opening up your terminal application and copying and pasting the following line of code in it. Then hit enter.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/.sh)"

2. Run the following command in your terminal application:

brew install imagemagick

3. Create an empty folder on your mac.

mkdir ~/Pictures/WebP

4. Navigate to the folder of png or jpg images you want to convert to WebP in your terminal.

cd ~/YourImages/

5. Issue the following command replacing “.png” with the file extension of the files you need converted (the source files).

magick mogrify -format webP -path ~/Pictures/WebP/ *.png

6. To change the quality of your images using lossless compression, you can use the “-quality” and “-define” arguements like so…

magick mogrify -format webP -quality 80 -define webp:lossless=true -path ~/Pictures/WebP/ *.png

where -quality 80 is to reduce the quality of your images by 20% (only 80% of the original quality is used).

7. To use lossy compresssion with reduced quality you can use the “-define webp:lossless=false” arguement like so…

magick mogrify -format webP -quality 60 -define webp:lossless=false -path ~/Pictures/WebP/ *.png

This will reduce your image quality to 60% of the original image, but shrink the filesize of your photos tremendously. This will also make your original image quality unrecoverable since it is lossy. So don’t delete your original photos unless you are absolutely sure you don’t need them scaled up to a larger size and better quality. For website use, it is recommended that you scale down your image quality anywhere from 60%-80%, to decrease page load times and image load times. However, if you already are using small images this may not be neccessary, and your image compression and filesize (lossy or lossless) is relatively subjective depending upon what you are trying to accomplish with your website. If you desire High quality UHD or 4K photos all the time with slower load times, then stick with lossless with less compression. If you desire faster load times with lesser quality images, the oposite extreme end is to use lossy compression with more compression, which should shrink your files pretty well and prep them for quick load times on a website.

7. Wait for the images to be converted. Your newly converted images can be found in your ~/Pictures/WebP folder after its complete.

How to secure copy (SCP) a file from a local machine to a remote server using a Yubikey 5

For anyone having difficulties with the scp command using yubikey, here is the proper syntax I used to copy a file from a local machine to a remote server:

SYNTAX:
scp -i ~/.ssh/id_rsa_yubikey.pub -P 22 local_file_to_be_transferred.txt remote_username@local_server_ip_address:/remote/directory_of_server

where -i = your yubikey identities file, -P = your ssh port, remote_username = your username that you use to log in to your server

In my case:
scp -i ~/.ssh/id_rsa_yubikey.pub -P 40001 /Users/Danrancan/Downloads/myfile.zip boopi@192.168.1.2:/home/Danrancan

Yubico Yubikey & SCP Command

How to SSH Secure copy (SCP) a file to a remote server, using a Yubikey

For anyone having difficulties with the scp command using yubikey, here is the proper syntax I used to copy a file from a local machine to a remote server:

SYNTAX:

scp -i ~/.ssh/id_rsa_yubikey.pub -P 22 local_file_to_be_transferred.txt remote_username@local_server_ip_address:/remote/directory_of_server

where -i = your yubikey identities file, -P = your ssh port, remote_username = your username that you use to log in to your server

In my case:

scp -i ~/.ssh/id_rsa_yubikey.pub -P 40001 /Users/Danrancan/Downloads/myfile.zip boopi@192.168.1.2:/home/Danrancan

This should successfully securely copy your file from your local machine to your remote machine or server.