The Mac terminal offers thousands of options to interact with our computer. From checking the veracity of a file that we have downloaded from the internet to seeing the battery charge cycles. In this article we gather eight useful commands with which to achieve various objectives. Let us begin.
See the charge cycles of our battery
Battery charge cycles are one of the indicators of your health. It is not the only one, but it is a value that we should keep in mind in certain situations. We can use third-party apps to read this data or we can execute the following command in our terminal:
ioreg -rn AppleSmartBattery | grep Capacity
In the results, the number behind “Cycle Count” = is the count of the charging cycles that our battery has made.
Check the integrity of downloaded files
File hashes are an easy and simple way to verify that the file we just downloaded is exactly the one we want. Any modification of the file would change its hash, which we can check with the one recorded on the website where the file comes from. In the Terminal app we can generate the necessary hashes for comparison:
- Hash and MD5:
md5 ruta/del/archivo.algo
- Hash and SHA1:
shasum -a 1 ruta/del/archivo.algo
- Hash and SHA256:
shasum -a 256 ruta/del/archivo.algo
See the internet connections made by the applications
The applications of our Mac periodically make connections to different servers. A normal behavior, but one that we will probably want to monitor. We can do it using the following terminal command:
nettop
When we enter it we will see a list of all the connections of all the apps, ideal for locate irregularities in certain apps.
View battery consumption
Returning to the battery of our computer, other data that may interest us are those of the consumption in real time. With the following terminal command we can access this data.
sudo powermetrics
Remember that when executing the command as super user we will need enter the password of our computer to give the necessary permissions.
Disable tab preview
With macOS Big Sur the preview of the tabs that we have open in Safari came to the Mac. A most interesting resource that we may want to disable. The command in question is the following, but there are some steps that we must carry out previously and that we have seen in this article.
defaults write com.apple.Safari DebugDisableTabHoverPreview 1
Change the format of screenshots
By default the screenshots of our Mac are saved in png format, but there are other alternatives. Since a simple jpg to a tiff or a pdf, there are several options to save these captures. We can choose between formats using the following command:
defaults write com.apple.screencapture type jpg
The available options, which we will write to replace the “jpg” that appears in the command are: pdf, jpeg, tiff, gif, pict, bmp, sgi, tga and jp2.
Find and uninstall apps
We end up with a most useful command, but with which we must be a little careful. It serves for eliminate residues that some applications have left on our computer. We will execute it in two parts, first this one:
sudo find / -iname "*buscar*"
With this expression, substituting search for the word that interests us, we can locate all files named like this on our Mac. This command goes much further than the Spotlight level search, it searches the entire system.
Next we have two options, we can read the list manually, go to locate the files we want to delete using your path, which is the safest system, or automate the removal of all results found with the following command:
sudo find / -iname "*buscar*" -exec rm -rf {} +
If we choose this second option, please, I emphasize, extremely careful to have read the list of results previously to avoid disappointment.
And so far eight interesting and useful commands with which to perform certain actions on our Mac that otherwise require third-party apps or are simply not possible through the computer’s own interface.