Seven essential commands for our Mac: battery cycles, internet connectivity, and much more

Siete comandos esenciales para nuestro Mac: ciclos de batería, conectividad en internet y mucho más

From monitoring battery health to managing internet connections or verifying the integrity of files we download from the net, our Mac's Terminal app offers many options. All of them linked with the corresponding command. Let's see, then, seven commands that, once we know them, will be essential for our Mac.

Very useful tools through the Terminal

  1. Let's start with a command to change the format of the screenshots we take. It's enough to change the last "jpg" to PNG or TIFF for it to be reflected in the captures:

defaults write com.apple.screencapture type jpg

  1. To ensure that files downloaded from the internet have not been altered or damaged, many websites offer us hashes in MD5, SHA1, or even SHA256. What do we have to compare them with? Easy, with the hash that the following commands generate:
  • MD5: md5 path/to/file.extension
  • SHA1: shasum -a 1 path/to/file.extension
  • SHA256: shasum -a 256 path/to/file.extension
  1. The Terminal also allows us to monitor internet connections of applications. The nettop command is indispensable in this regard, allowing us to view all active connections and possible irregularities in them.
  2. In older Macs, it is through the Terminal that we will show the Finder's hidden files. Although in the most current operating systems we will do it by pressing Shift (⇧) + Command (⌘) + Dot (.), in other machines we will use the following command with "true" to show them and "false" to hide them:

defaults write com.apple.finder AppleShowAllFiles true

  1. The longevity of the battery is crucial to keep our Mac running optimally. To check the health of the battery, and see the count of charge cycles it has, we use this command:

ioreg -rn AppleSmartBattery | grep Capacity

  1. Similarly, the sudo powermetrics command gives us access to real-time battery consumption data, a valuable tool to better manage our Mac's energy.
  2. Finally, a command with which we can remove from our Mac the residues of uninstalled applications. A command that we have to use with certain caution, because everything we put inside the two *, in the following example the word "search", enters as a search and the file or files that contain it in their name are deleted:

sudo find / -iname "*search*" -exec rm -rf {} +

As we have just seen, the versatility of our Mac's Terminal app is huge. The truth is that the list of commands we discuss here is just the tip of the iceberg. And, even so, more than one can be really useful in various circumstances.

On Hanaringo | How to Set the Number of Recent Apps in Our Mac's Dock