Tech Lounge

A Guide to Mac Terminal Commands

A Guide to Mac Terminal Commands. The Mac Terminal also called a “command line” or a “Terminal emulator,” is one of the most important programs on Mac and Linux. It’s a way to enter commands and get instant results, giving you direct access to your Mac’s real power.

There are several benefits to using terminal commands to get things done. Read on for a basic introduction to using Terminal commands and some useful essential commands to get you started.

How to Open a Mac Terminal

“Spotlight” is the fastest and best way to open a Terminal on a Mac. To extend a Terminal window, do the following:

  1. Connect on the magnifying glass button in the menu bar at the leading right of your screen. The movie “Spotlight” will open.
  2. Type “Terminal” and hit “Enter” in the search field.

It will open and be ready to be used.

Getting to Know the Terminal

The best method to comprehend how to use the Terminal app is to learn how the commands work. So, here are some rare tips to help you get started:

How to Execute a Command

First, to run a command, enter its syntax in the cursor and hit “Return” to run it.

Things to Remember About Commands

Two points to remember about command are:

  1. Every command has three components: the command name, arguments that tell the command what resources to work on, and an option that changes the output.
  2. Most commands are case sensitive. For example, if you want to move a file from one folder to another, you’d use the “move” command “mv” with a lowercase m and v. Here’s how to do just that:

% mv ~/Downloads/MyFile.txt ~/Documents/Work/MyFile.txt

List of Available Commands

Long-press the “Escape” key, then press “Y” when asked to see all the choices. This will show a checklist of all the available commands. Then hit “Return” to see more commands.

How to Flush DNS Cache

You should clear your Mac’s DNS cache from time to time for many reasons. For instance, it can help prevent problems with page loading and 404 errors. So here’s a command to flush the DNS on your Mac running macOS El Capitan and later:

udo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

How to Download a File Without a Browser?

You also can download a file from the internet without utilizing a computer if you have a terminal. When you have a straight download link, you can use this method. Type in the commands:

cd ~/Downloads/
curl -O [URL]

As an input (URL), the command needs a direct download link.

Change “downloads” to the name of the directory you want to save the file to.

How to Download and Delete your Entire Download History

Mac carefully keeps track of all the files you’ve ever received. To protect your privacy, it’s helpful to know how to delete the whole list. Enter the following command first to get the list:

sqlite3
~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*
'select LSQuarantineDataURLString from LSQuarantineEvent'

Then to delete it:

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'

Now, enter the first command again, and you’ll see that the list is empty.

How to Display Hidden Folders and Files

MacOS hides important files so they don’t get deleted by accident, which is generally a good idea. But this function gets in the way when you want to see a hidden file on an external drive. You can avoid this, though, if you use Terminal. Here’s the Terminal command that lets you see files that are normally hidden:

defaults write com.apple.finder appleshowallfiles -bool true

You can now see all files that were hidden.

How to Copy Contents From One Folder to Another

It’s easy to copy the data of a file from one folder to another using Terminal. Here is what you need to enter:

% cp-R ~/[original]/[folder name]/ ~/[new]/[folder name]/

And change “original” to the name of the existing directory and “new” to the directory where you want to copy the files.

How to Access iCloud Drive

Enter the following command to get straight access to your files through your iCloud drive:

cd ~/Library/Mobile Documents/com~apple~CloudDocs/

How to Mac Your Mac Talk

Using this command instead of Siri, you can make your Mac say whatever you want. You can get your Mac to repeat what you say by using the “say” command followed by the words you want it to say in quotes, for example:

Say “HELLO,

How to Keep Your Mac Awake

Many apps can stop your Mac from going to sleep. Instead, you can enter the following Terminal command if you want to lower the digit of apps you have installed:

caffeinated

This will prevent your Mac from going to sleep. To put it to sleep, press the “CTRL” and “C” keys at the same time.

How to Increase the Frequency of Checking for MacOS Updates?

You can request your Mac to check for important changes and updates more often to ensure you’re always on top of your computer’s security. Here’s how to tell it to check every day for updates:

defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

How to Play Tetris

Tetris is a game that everyone loves. So many of us can play it for hours. So if you like this old game, here’s how to find the hidden Tetris game on your Mac:

  1. Type “Emacs” and hit “Return” in the Terminal.

  2. Press the “Fn” key along with the “F10” key.
  3. Press “T” then “G” on your keyboard.
  4. You’ll eventually be told to “Select your game.” Tetris is beneath the “T” option (press “T” and “Return”).

You can also choose a classic game like Snake or Solitaire by following the directions on the screen.

How to Shut Down Mac

Enter the following command to shut down your Mac when it’s time for a break:

$ sudo shutdown -h now

To restart it, you can also enter the following:

$ sudo shutdown -r now

Taking Command With Mac Terminal Commands

The Mac Terminal, a command line system, gives you more power over your MacOS and lets you run tasks faster and better. You only need to learn rare simple commands and features to use it. Once you know how to use commands well, you can use command prompts to do more complicated and fun things.

What kinds of jobs do you like using the Mac Terminal for? Then, in the comments, tell us what you’ve learned using Mac Terminal commands.

Exit mobile version