Top 5 useful Terminal tips for Mac users
The Mac's beautiful interface is a decades-old backbone, called UNIX, and you can use its old-fashioned Terminal to run commands that are simply inaccessible from applications or menus. These aren't just useful for developers and hackers - even if you've never dig into Terminal before, there are a few tweaks that will make your Mac better and boost your line confidence. your command.
The Terminal app is stored in Applications > Utilities , but you can launch it quickly at any time by pressing Command + Space to open Spotlight, searching for "Terminal", and pressing Enter.
Shutdown timer
This is one of those easy tasks. Sometimes you want to keep your computer on for the next 1 or 2 hours until a job is finished (like a large download) and shut it down when it's done. To set a shutdown timer, open a Terminal window and run:
sudo shutdown -h +60
The content of the command includes the following elements:
- sudo tells Terminal to run the following command as super user or admin. You'll need to enter your password, although it won't show an asterisk as you type it. Don't worry, it's still picking up your keystrokes.
- shutdown is the main command you are sending to the system.
- The -h flag indicates whether the system will pause or shut down. You can replace this flag with -r if you want to restart or -s if you want to put the computer to sleep instead.
- Finally, +60 is the timer in minutes. The above command tells the system to shut down after 60 minutes or 1 hour - but you can replace this number with any time period you want. You can also use specific dates and times in yymmddhhmm format if desired.
To cancel the timer before the timer runs out, just run:
sudo killall shutdown
The command will stop the shutdown process running in the background.
Prevent Mac from going to Sleep
On the other hand, you may want to prevent your Mac from going to sleep by using its automatic power-saving features. In this case, you can just use the caffeineate command to set a timer that prevents the machine from going to sleep:
caffeinate -u -t 3600
The -u flag tells the system to act as if the user is active (so the screen doesn't go to sleep either), while -t sets the timer in this case to 3600 seconds (or 1 hour) . Your usual energy-saving rules will then go into effect again.
Show hidden files and folders
In general, most people do not need to view or edit any hidden files. They are hidden for a reason: The system needs them, you don't. But if you find yourself needing to access a file for some reason - or you want to hide some secret files of your own - you can run the following command to show hidden files in Finder:
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
Then, for those changes to take effect, restart Finder by running:
killall Finder
You can also combine those two commands with some ampersand & :
defaults write com.apple.finder AppleShowAllFiles -bool TRUE && killall Finder
(For simplicity, the article will do that for the rest of the commands in this list that require restarting a service).
To hide your own folder or file, you can run:
chflags hidden ~/Dekstop/MySecrets && killall Finder
Replace ~/Dekstop/MySecrets with the path to your own secret folder or file. (The ~ sign indicates your home directory, also found at /home/[yourusername] ). To get hidden files and folders back, just run the above command with FALSE instead of TRUE .
Customize the Dock
The dock is an important part of the macOS interface: You store your most used shortcuts there, use it to switch between windows and hide minimized apps you don't need right now. And while you'll find some useful tweaks in macOS' Settings > Dock menu , you can customize it even further with a few Terminal commands.
For example, you might want to add a blank space to help organize apps into different groups. Let's run:
defaults write com.apple.Dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' && killall Dock
Or, if you want to keep the dock as minimal as possible, you can hide all apps that aren't currently running with:
defaults write com.apple.Dock static-only -bool TRUE && killall Dock
If you use Command + H to "hide" common apps, you can even dim their icons in the dock, so you know they're hidden:
defaults write com.apple.Dock showhidden -bool TRUE && killall Dock
Finally, if you want to automatically show and hide the Dock, you may notice a one-second delay for that animation - that is, when you hover over the bottom of the screen, it will take about a second before the Dock slide in. To remove this delay, run:
defaults write com.apple.Dock autohide-delay -float 0 && killall Dock
Alternatively you can change that zero to a higher number to increase the delay. To return to the default auto-hide settings, run:
defaults delete com.apple.Dock autohide-delay && killall Dock
Tweak how your Mac takes screenshots
Taking a screenshot on a Mac is super easy: Just press Command + Shift + 4 to capture a window or part of the screen. Unfortunately, you don't have much control over how these screenshots are stored - at least from the on-screen menus. However, you can customize everything from Terminal.
For example, if you wanted to change where the screenshots are stored, you could run:
defaults write com.apple.screencapture location ~/Pictures && killall SystemUIServer
Replace ~/Pictures with whatever directory you want to use. If you want to restore the default behavior, just replace that path with ~/Desktop.
Next, you can remove the drop shadow around the screenshot with:
defaults write com.apple.screencapture disable-shadow -bool TRUE && killall SystemUIServer
You can bring them back by running the command again with FALSE instead of TRUE.
Alternatively, you can change the file type of those screenshots - PNG by default - to something else with:
defaults write com.apple.screencapture type JPG && killall SystemUIServer
You can replace JPG with some file type, such as PDF, if you want.
Finally, you can change the default name of the screenshot files with:
defaults write com.apple.screencapture name "mycapture" && killall SystemUIServer
You can replace mycapture with whatever filename you want. With some of these commands, you'll be able to get your Mac to take a screenshot exactly the way you want it, without the need for an additional program.
Watch Star Wars
A long time ago, in Terminal, some enterprising people recreated the entire A New Hope in ASCII. It's still available in Terminals today, and on current versions of macOS you can run:
nc towel.blinkenlights.nl 23
… to see the story unfold as text. Just enjoy!
You should read it
- 6 interesting terminal commands on Mac
- How to use Terminal on a Mac
- 8 best free Terminal Emulator apps for Android
- Notable changes in Windows Terminal ver 0.11
- How to fix the problem of being unable to enter Terminal in Linux
- How to customize Windows Terminal application
- How to customize Terminal on Mac
- Top 7 best Linux terminal emulators
- Windows Terminal is about to have a retro version with a 'classic' interface.
- Windows Terminal can now automatically launch configurations as administrator
- How to make Windows Terminal the default Terminal application and its benefits
- Use commands and some tips for Mac OS X
Maybe you are interested
Why should you buy a USB-C dock that can stand your phone upright?
How to Hide App Icons in Mac Dock Even When Running on
5 best ASUS ROG Ally docks in 2024
10 Best Docker Alternatives 2023
How to create an effective Docker image for a Python project
How to Install Apache Guacamole via Docker on Ubuntu 22.04