Best Terminal Command Tricks and Tips for Mac Users – Guide
When Terminal starts, it provides a line interface that you can use to control parts of the macOS interface – essentially providing access to UNIX functions that are outside the macOS skin. Here, we will see some projects that you can try in Terminal, using your new skills. If you are new to the Terminal or need to brush up about your commands, the best place to start is our introductory post, which you can read here: How to Use Terminal on a Mac.
1. Open the folders
One of the coolest ways to get started with Terminal is to use it to open files and folders. I know that clicking on the Finder will do the same. However, using Terminal, you can open a specific folder or file without exposing its file structure to anyone. Say you want to open your Documents folder. Then, you can type the following command and press Enter. Open ~ / Documents And that opens my Documents folder. There is a DOCX file there. I can use Terminal to open this too. To do this, you need to enter the command with some requirements – the path of the respective file: Open it “Application Name” / Path / to / File So, to open the DOCX file in the Documents folder on my Mac, I typed the command below and hit Enter: Open it “Microsoft Word” ~ / Documents / SoP_Prajith_New.docx This opens up the specific file using the predefined program. You can also use the wildcard character (* .extension) instead of the full file name. However, if you have more than one file carrying the same extension, it can freeze your Mac a little.
2. Change the default location for saving the screenshot
By default, macOS Mojave stores screenshots on the Mac desktop. Now, if you have enabled iCloud sync, which I am sure you have, the upload continues to your account. Fortunately, you can change the save location for screenshots instead of overloading your desktop. This is the command you need to type before pressing Enter: default write com.apple.screencapture location ~ / Downloads In the above command, you can provide any specific file location instead of ~ / Downloads, as shown. After pressing Enter, I need to reset the SystemUIServer for the changes to take effect immediately. Therefore, enter the following command. killall SystemUIServer Although it is not mandatory, I recommend restarting your Mac.
3. Change the image type of the screen capture
MacOS saves screenshots in JPG format by default. You can change this to save them in PNG or PDF formats as well. Here it is how to do it quickly with this specific command: patterns write com.apple.screencapture type PNG After that, you need to kill the SystemUIServer again. Most of the commands that require some changes in the system must shut down the SystemUIServer. So do it quickly. killall SystemUIServer Your new screenshots will now be saved in PNG format. Note that PNG files are generally larger than JPG files. So be aware of the amount of storage space they consume.
4. Show hidden files
Have you tried looking for the option to allow Finder to show hidden files? Well, it’s more difficult than choosing the show’s hidden files on Windows. I always forget how to enable this. Fortunately, there is a useful command that makes this happen in a few seconds. patterns write com.apple.finder AppleShowAllFiles -bool TRUE After that, you need to force the Finder to close. Finder killall You should now see many hidden files in the Finder. They would be faint, but still visible. If you reverse this change, you will need to change TRUE to FALSE on the command.
5. Unplug the panel
Apple promoted the Dashboard view to access the calculator and sticky notes quickly. I bet you rarely use this one so you can start the Calculator app or the Sticky Notes app using Spotlight’s Mission Control. So you can turn it off and you don’t have to worry about opening it by mistake. Here is the command to turn off the Dashboard. standards write com.apple.dashboard mcx-disabled -boolean TRUE Then, you must close the Dock for the changes to be applied correctly. Killall Dock Now I don’t have to worry about accidentally opening the Dashboard. If you want to turn it back on, change TRUE to FALSE on the remote.
6. Download files
Did you know that you can download files using Terminal? Yes, you don’t have to keep the browser running just for that file. The only requirement here is that you must have the file download link. Therefore, the command syntax is: curl -0 download link First, navigate to the folder where you want to download the file. To do this, you need to change to the Downloads directory. cd ~ / Downloads After that, you can feed the command to download VLC for macOS from the official website. It would be something like this: curl -O https://get.videolan.org/vlc/3.0.7.1/macosx/vlc-3.0.7.1.dmgObservation: There is a letter O in the command and not 0 (zero).
7. Ditto for backups
Copying files and making backups on macOS is quite fast – thanks to SSDs and flash storage. However, it takes a while to copy a large amount of data. Fortunately, Terminal offers a useful command for copying files. See How to do this while looking at the name of the files that the command copies. ditto -V / currentpath / / new / path / Therefore, I want to copy the DMG downloaded in the previous section to the desktop. idem -V ~ / Downloads / vlc-3.0.7.1.dmg ~ / Desktop This should do what is necessary. If you want to copy the files to an external drive, you need to supply the destination path correctly.
8. Always show the file path in the Finder
If you recently changed Windows, you may have noticed that the Finder in macOS does not show a file path like Windows Explorer. However, you can force the Finder to show the file path with this command: patterns write com.apple.finder _FXShowPosixPathInTitle -boolean true After pressing enter, you need to stop the Finder. Finder killall After pressing Enter, the Finder will restart. Next, you should see the file paths at the top of the Finder window.
9. Power signal when connecting the charger
Have you ever connected the MagSafe charger to your Mac, but forget to turn on the power button? I lost count. Fortunately, I came across this useful command that provides a chime of audio feedback whenever I connect the MagSafe charger. Feed this command to the Terminal and press Enter. write com.apple.PowerChime defaults ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app
10. Stop your Mac from hibernating
Often, you are downloading a huge file and don’t want your Mac to go to sleep. If it is a temporary requirement, a simple command can make this happen. Just type the following command, press Enter and exit the Mac. caffeine -u -t 600 In this command, the number 600 means seconds. Therefore, with this command, the Mac will not sleep until 10 minutes (600 seconds). You can enter a relevant number of seconds or just the word “caffeine” to prevent your Mac from sleeping. However, if you close the Terminal window, the command will stop running and the Mac will hibernate at a predefined time.
11. Check your Mac’s uptime
Want to know how much time has passed since you restarted your Mac? A simple restart can organize many things in order and increase your Mac’s performance. Here’s a command to check how long your Mac has been running without restarting or shutting down activity time This should provide all details with a timestamp.
Final note
I hope you like the guide Best Terminal Command Tricks and Tips for Mac Users. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.