Apple's macOS platform includes Terminal, which is equivalent to the command prompt in the Windows operating system. Since macOS is UNIX-based, Terminal can give you the impression of a dangerous tool where one wrong command can destroy your system. Of course, this is only valid to a certain extent. There are plenty of harmless commands you can use to customize the interface and other macOS settings.
Contents1. Open folders 2. Change the default screenshot recording location3. Change screenshot image type4. Show hidden files5. Switch off the dashboard6. Download files7. Ditto for backupsThe Terminal on macOS can be extremely useful for tweaking your Mac's performance. Now, it entirely depends on what you want to achieve. In case you are worried about using it, you can always make yourself comfortable using some simpler tricks. Here are the 11 best terminal command tricks to try on your Mac.
Note: When selecting/copying an order, be sure to scroll all the way to the right to select the entire order in the gray box. Otherwise, the partial commands will not work as expected.One of the coolest ways to get familiar with the terminal is to use it to open files and folders. I know clicking Finder will do the same thing. However, using Terminal, you can open a specific folder or file without exposing your file structure to anyone.
Let's say you want to open your Documents folder. Then you can type the following command and then press Enter.
Open ~/Documents
And this opens my Documents folder. There is a DOCX file in there. I can also use Terminal to open it. For this you need to type the command with some requirements – the respective file path:
Open -a "Application Name" /Path/to/File
So, to open the DOCX file in my Mac's Documents folder, I typed the command below, then hit Enter:
Open -a "Microsoft Word" ~/Documents/SoP_Prajith_New.docx
This opens the specific file using the preset program. You can also use the wildcard character (*.extension) instead of the full filename. However, if you have multiple files with the same extension, it may freeze your Mac a bit.
By default, macOS Mojave stores screenshots on the Mac desktop. Now, if you have iCloud sync enabled, which I'm sure you do, the download continues on your account. Luckily, you can change where screenshots are saved instead of cluttering your desktop.
Here is the command you need to type before hitting Enter:
defaults write com.apple.screencapture location ~/Downloads
In the above command you can provide any specific file location instead of ~/Downloads as shown.
After hitting enter, I need to reset the SystemUIServer for the changes to take effect immediately. So feed the following command.
killall SystemUIServer
Although not required, I recommend restarting your Mac.
The macOS saves screenshots in JPG format by default. You can change this to also save them in PNG or PDF format. Here's how to do it quickly with this specific command:
defaults write com.apple.screencapture type PNG
After that you have to kill the SystemUIServer again. Most commands that require system changes should force the SystemUIServer to shut down. So do it fast.
killall SystemUIServer
Now your new screenshots will be saved in PNG format. Note that PNG files are generally larger than JPG files. So keep an eye on the storage space they consume.
Have you tried looking for the option to allow Finder to show hidden files? Well, it is more difficult than choosing hidden files on Windows. I keep forgetting how to enable this. Luckily, there's a handy command that lets you do this in seconds.
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
After that, you need to force quit Finder.
killall Finder
You should now see lots of hidden files in Finder. They would be grayed out but still visible. If you undo this change, you must change TRUE to FALSE in the command.
Apple promoted the Dashboard view for quick access to the calculator and sticky notes. I bet you rarely use it because you can launch Calculator app or Sticky Notes app using Mission Control of Spotlight. So you can turn it off and not have to worry about opening it by mistake.
Here is the command to disable the dashboard.
defaults write com.apple.dashboard mcx-disabled -boolean TRUE
Then you need to kill the Dock for the changes to be properly applied.
killall Dock
Now I don't have to worry about accidentally opening the dashboard. If you want to turn it back on, replace TRUE with FALSE in the command.
Did you know you can download files using Terminal? Yes, you don't need to let the browser work just for this file. The only requirement here is that you must have the file download link. The command syntax is therefore:
curl -0 download link
First, navigate to the folder where you want to upload the file. To do this, you need to switch to the Downloads directory.
cd ~/Downloads
After that, you can feed the command to download the VLC for macOS from the official site. It would look something like this:
curl -O https://get.videolan.org/vlc/3.0.7.1/macosx/vlc-3.0.7.1.dmgNote: There is a letter O in the command and not the 0 (zero).
Copying files and making backups on macOS is quite fast, thanks to SSDs and flash storage. However, copying a large amount of data takes some time. Fortunately, Terminal offers a useful command for copying files. Here's how to do it while monitoring the names of the files the command copies.
same -V /currentpath/ /new/path/
So I want to copy the DMG downloaded in the previous section to the desktop.
ditto -V ~/Downloads/vlc-3.0.7.1.dmg ~/Desktop
That should do the needful. If you want to copy the files to an external drive, you must provide the destination path correctly.
If you recently switched from Windows, you would have noticed that the Finder on macOS does not display the file path like Windows Explorer. However, you can force Finder to show you the file path with this command:
defaults write com.apple.finder _FXShowPosixPathInTitle -boolean true
After pressing Enter, you must stop the Finder.
killall Finder
After pressing Enter, the Finder will relaunch. Then you should see the file paths at the top of the Finder window.
Have you ever connected the MagSafe charger to your Mac but forgot to turn on the power switch? I lost count. Luckily, I came across this useful command that provides an audio feedback chime whenever I connect the MagSafe charger.
Enter this command in the terminal and press Enter.
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app
Often you download a large file and you don't want your Mac to go to sleep. If it is a temporary requirement, a simple command can make it happen. Just type the following command, hit enter, and walk away from your Mac.
caffeinate -u -t 600
In this command, the number 600 means seconds. So, with this command, the Mac will not sleep for 10 minutes (600 seconds). You can enter a relevant number of seconds or just the word "caffeinate to prevent your Mac from sleeping.
However, if you close this terminal window, the command will stop running and the Mac will go to sleep at a preset time.
Wondering how long it's been since you restarted your Mac? A simple restart can sort a lot of things in order and improve your Mac's performance. Here is a command to check how long your Mac has been running without restarting or shutting down
uptime
This should give you all the details with a timestamp.
The Terminal is an absolute pleasure to use and tinker with in macOS. However, we strictly advise against using random commands provided by unverified sources or strangers. Other than that, these commands should run on the latest macOS Mojave update to the latest versions.
You should always double-check terminal commands that involve deleting, deleting, or disabling any service. If you stick to our list, you'll be sure to use Terminal like a pro.
Then: Tired of the same old lock screen on your Mac? Here is a nifty guide that will show how to customize the lock screen on your Mac OS Mojave running Mac.