Return to site

Commands For The Mac Terminal

broken image


Apple's macOS platform includes Terminal, which is equivalent to Command Prompt in Windows OS. Since the macOS is based on UNIX, Terminal might give you a vibe of a dangerous tool where one wrong.

  1. To start the journey, learn how to open Terminal app on Mac: Click Launchpad and then type Terminal in the search bar. 1) Make your Mac talk to you. One of the simplest commands which can be very fun, especially when you are planning a prank on somebody. Just type any text in Terminal and your computer will speak it in your Mac's default voice.
  2. If you're working in Terminal on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands. Folders are called directories in UNIX. Commands that refer to filenames, as most do, assume that you're talking about files in the.

Apple's macOS platform includes Terminal, which is equivalent to Command Prompt in Windows OS. Since the macOS is based on UNIX, Terminal might give you a vibe of a dangerous tool where one wrong command can wreck your system. Sure, it is valid only to an extent. There are a bunch of harmless commands that are usable in customizing the interface and other settings of macOS.

The Terminal on macOS can be extremely useful in tweaking the performance of your Mac. Now it entirely depends on what you want to achieve. In case you have been dreading to use it, you can always get comfortable by using simpler tricks. Here are the top 11 terminal command tricks to try on your Mac.

Also on Guiding Tech How To Speed Up a Slow Mac Read MoreNote: While selecting/copying a command, make sure you scroll all the way towards right to select the complete command in the gray box. Otherwise partial commands will not work as intended.

1. Open Folders

One of the coolest ways to get familiar with the Terminal is to use it to open files and folders. I know that clicking on Finder will do the same. However, using Terminal, you can open a specific folder or a 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 hit Enter.


And that opens my Documents folder. There's a DOCX file in there. I can use Terminal to open that too. For that, you need to type out the command with some requirements — the path of the respective file:

Open -a 'Application Name' /Path/to/File

So for opening the DOCX file in the Documents folder of my Mac, I typed in the command below and then hit Enter:


That opens up the specific file using the predefined program. You can also use the wildcard character (*.extension) instead of the full filename. However, if you have more than one file in carrying the same extension, then it might freeze your Mac for a bit.

2. Change Default Save Screenshot Location

By default, the macOS Mojave stores the screenshots on the Mac's desktop. Now if you have iCloud sync enabled, which I am sure you do, then it keeps uploading to your account. Thankfully, you can change the save location for the screenshots instead of crowding your desktop.

Here's the command you need to type before hitting Enter:


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 in the following command.


Though it is not required, I would recommend restarting your Mac.

3. Change Screenshot Image Type

The macOS saves the screenshots in JPG format by default. You can change that to save them in PNG or PDF formats too. Here's how to do that quickly with this specific command:

Commands for mac os terminal


After that, you need to kill the SystemUIServer again.
Most commands which require some system changes shall mandate shutting down the SystemUIServer. So do that quickly.


Now, your new screenshots will save in the PNG format. Do note that PNG files are generally larger than JPG files. So keep an eye on how much storage space they consume.

4. Show Hidden Files

Have you tried looking for the option to let the Finder show hidden files? Well, it is tougher than picking the show hidden files on Windows. I always forget how to enable that. Thankfully there is a helpful command that makes it happen in a few seconds.


After that, you need to force shut the Finder.


Now you should see a lot of hidden files in the Finder. They would be greyed out but still visible. If you roll back this change, then you need to change TRUE to FALSE in the command.

5. Switch Off the Dashboard

Apple promoted the Dashboard view to access calculator and sticky notes quickly. I bet you rarely use that one for you can launch the Calculator app or Sticky Notes app using Mission Control of Spotlight. So you can switch it off and don't have to worry about opening it by mistake.

Here's the command to turn off the Dashboard.


Next, you must kill the Dock so that the changes are correctly applied.


Now I don't have to worry about accidentally opening the Dashboard. If you want to switch it on again, then change TRUE to FALSE in the command.

Also on Guiding Tech How to Install New Fonts in Mac OS X Read More

6. Download Files

Did you know that you can download files using the Terminal? Yes, you don't need to keep the browser running just for that file. The only requirement here is that you must have the file's download link. So the command syntax is:

curl -0 downloadlink

First, navigate to the folder where you want to download the file. For that, you need to switch to the Downloads directory.


After that, you can feed the command to download the VLC for macOS from the official site. It would appear something like this:

Note: There is a letter O in the command and not the 0 (zero).

7. Ditto for Backups

Commands For The Mac Terminal

Copying files and taking backups on macOS is quite swift — thanks to the SSDs and the flash storage. However, it does take a while to copy a large amount of data. Thankfully, Terminal offers a useful command to copy files. Here's how you can do it while watching the name of files that the command copies.

ditto -V /currentpath/ /new/path/

So I want to copy the DMG downloaded in the previous section to the desktop.

That should do the needful. If you want to copy the files to an external drive, then you need to provide the destination path correctly.

8. Always Show File Path in the Finder

If you have switched from Windows recently, you would have noticed that the Finder on macOS doesn't show file path like the Explorer in Windows. However, you can force Finder to show you the file path with this command:

After hitting enter, you need to stop the Finder.

After you hit Enter, the Finder will relaunch. Then you should see the file paths at the top of the Finder window.

9. Power Chime on Connecting the Charger

Has it ever happened that you've connected the MagSafe charger to your Mac but forgot to flip on the power switch? I have lost the count. Thankfully, I stumbled upon this useful command that provides an audio feedback chime whenever I connect the MagSafe charger.

Feed this command in the Terminal and hit Enter.

10. Stop Your Mac from Sleeping

Often you are downloading a massive file, and you don't want your Mac go to sleep. If it is a temporary requirement, then a simple command can make it happen. Just type the following command, hit Enter and walk away from your Mac.

In this command, the number 600 signifies seconds. So with this command, the Mac won't sleep until 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 that Terminal window, then the command will stop executing and the Mac will go to sleep on a predefined time.

11. Check Your Mac's Uptime

Terminal

Wondering how long it has been since you've restarted your Mac? A simple restart can sort a lot of things in order and boost your Mac's performance. Here's a command to check your how long your Mac has been running without a Restart or a Shutdown

That should give you all the details with a timestamp.

Mac Terminal Commands Pdf

Also on Guiding Tech #productivity Click here to see our productivity articles page

Using Terminal Is Fun

The Terminal is an absolute delight to use and tinker around in the macOS. However, we would strictly advise against using random commands provided by unverified sources or strangers. Other than that, these commands should run on latest macOS Mojave update till last few versions.

You should always double-check the Terminal commands that involve removing, deleting or disabling any service. If you stick to our list, then you would be confident of using Terminal like a pro.

Next up: Are you bored 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 macOS Mojave running Mac.


The above article may contain affiliate links which help support Guiding Tech. However, it does not affect our editorial integrity. The content remains unbiased and authentic.Read Next
Mac terminal commands cheat sheet pdf


After that, you need to kill the SystemUIServer again.
Most commands which require some system changes shall mandate shutting down the SystemUIServer. So do that quickly.


Now, your new screenshots will save in the PNG format. Do note that PNG files are generally larger than JPG files. So keep an eye on how much storage space they consume.

4. Show Hidden Files

Have you tried looking for the option to let the Finder show hidden files? Well, it is tougher than picking the show hidden files on Windows. I always forget how to enable that. Thankfully there is a helpful command that makes it happen in a few seconds.


After that, you need to force shut the Finder.


Now you should see a lot of hidden files in the Finder. They would be greyed out but still visible. If you roll back this change, then you need to change TRUE to FALSE in the command.

5. Switch Off the Dashboard

Apple promoted the Dashboard view to access calculator and sticky notes quickly. I bet you rarely use that one for you can launch the Calculator app or Sticky Notes app using Mission Control of Spotlight. So you can switch it off and don't have to worry about opening it by mistake.

Here's the command to turn off the Dashboard.


Next, you must kill the Dock so that the changes are correctly applied.


Now I don't have to worry about accidentally opening the Dashboard. If you want to switch it on again, then change TRUE to FALSE in the command.

Also on Guiding Tech How to Install New Fonts in Mac OS X Read More

6. Download Files

Did you know that you can download files using the Terminal? Yes, you don't need to keep the browser running just for that file. The only requirement here is that you must have the file's download link. So the command syntax is:

curl -0 downloadlink

First, navigate to the folder where you want to download the file. For that, you need to switch to the Downloads directory.


After that, you can feed the command to download the VLC for macOS from the official site. It would appear something like this:

Note: There is a letter O in the command and not the 0 (zero).

7. Ditto for Backups

Copying files and taking backups on macOS is quite swift — thanks to the SSDs and the flash storage. However, it does take a while to copy a large amount of data. Thankfully, Terminal offers a useful command to copy files. Here's how you can do it while watching the name of files that the command copies.

ditto -V /currentpath/ /new/path/

So I want to copy the DMG downloaded in the previous section to the desktop.

That should do the needful. If you want to copy the files to an external drive, then you need to provide the destination path correctly.

8. Always Show File Path in the Finder

If you have switched from Windows recently, you would have noticed that the Finder on macOS doesn't show file path like the Explorer in Windows. However, you can force Finder to show you the file path with this command:

After hitting enter, you need to stop the Finder.

After you hit Enter, the Finder will relaunch. Then you should see the file paths at the top of the Finder window.

9. Power Chime on Connecting the Charger

Has it ever happened that you've connected the MagSafe charger to your Mac but forgot to flip on the power switch? I have lost the count. Thankfully, I stumbled upon this useful command that provides an audio feedback chime whenever I connect the MagSafe charger.

Feed this command in the Terminal and hit Enter.

10. Stop Your Mac from Sleeping

Often you are downloading a massive file, and you don't want your Mac go to sleep. If it is a temporary requirement, then a simple command can make it happen. Just type the following command, hit Enter and walk away from your Mac.

In this command, the number 600 signifies seconds. So with this command, the Mac won't sleep until 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 that Terminal window, then the command will stop executing and the Mac will go to sleep on a predefined time.

11. Check Your Mac's Uptime

Wondering how long it has been since you've restarted your Mac? A simple restart can sort a lot of things in order and boost your Mac's performance. Here's a command to check your how long your Mac has been running without a Restart or a Shutdown

That should give you all the details with a timestamp.

Mac Terminal Commands Pdf

Also on Guiding Tech #productivity Click here to see our productivity articles page

Using Terminal Is Fun

The Terminal is an absolute delight to use and tinker around in the macOS. However, we would strictly advise against using random commands provided by unverified sources or strangers. Other than that, these commands should run on latest macOS Mojave update till last few versions.

You should always double-check the Terminal commands that involve removing, deleting or disabling any service. If you stick to our list, then you would be confident of using Terminal like a pro.

Next up: Are you bored 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 macOS Mojave running Mac.


The above article may contain affiliate links which help support Guiding Tech. However, it does not affect our editorial integrity. The content remains unbiased and authentic.Read NextHow to Customize the Lock Screen on macOS 10.14 MojaveAlso See#terminal #macos

Did You Know

Thunderbolt 3 is a data and video transfer protocol and is developed by Intel.

More in Mac

Top 4 Ways to Fix Mac Desktop Icons Missing or Not Showing

Terminal is one of the most powerful macOS apps, which allows you to perform actions with different commands. Although Terminal Commands are seemingly difficult to carry out, believe me, they aren't. Once you know the commands, you can quickly perform tasks like shutting down your Mac or copying contents from one place to another right from your terminal

As the terminal is a CLI (Command Line Interface), the language we type in which interacts with the Mac, is known as bash, and commands are called bash commands. This tool is often overlooked because it is completely different from the GUI (Graphical User Interface ), which provides a rich interface. But today I've come up with a useful list of macOS Terminal Commands that you can learn easily and will help you do things instantly. So let's start.

11 Cool Terminal Commands for macOS – Mac User Should Try

#1. Hide/Unhide and View Files/Folders in Finder

macOS Terminal provides you an easy way to Hide, Unhide or View hidden files in the Finder via Terminal.

Open up the terminal from /Applications/finder or alternatively launch it from Spotlight.

To Hide any File/Folder:

Type in the following command :

Now, drag the file which you want to hide in the terminal and click Enter.

To View Hidden File/Folder:

Type defaults write com.apple.finder AppleShowAllFiles -bool TRUE in the Terminal.

Once done you need to restart the Finder, it can be done by this command.

If you ever wish to hide the sensitive files again, repeat all the commands by replacing TRUE with FALSE.

To Unhide any File/Folder:

Unhiding the file/folder is fairly easy, just replace 'hidden' with 'nohidden'.

All Terminal Commands For Mac

Now, drag the file/folder which you want to unhide.

#2. Download Files Using Terminal

If you've a direct link of the file which you want to download, you can use the following commands to download the file using the Terminal on Mac.

Note: If you want to download the contents to any other directory replace 'downloads' with the directory name.

#3. Keep your Mac Awake

To prevent the mac from sleep, or showing screensaver after some inactivity use

If you want this command to get auto-disabled after a certain period of time, put the -t flag and specify the time in seconds as shown below.

Here, after 150000 seconds the command will get disabled, and the settings will be restored. Meanwhile, you can also use Cmd + C to terminate the command.

#4. Change Default Screenshot Format Type

By default, the screenshots are saved in .PNG format, but you can gain full control over the screenshots behavior.

To change default screenshot format type, use defaults write com.apple.screencapture type followed by type for e.g. : ( PNG, JPG, GIF, or PDF), then press Enter.

#5. Access iCloud Drive Using Terminal

To access the data from your iCloud Drive use the following command.

However, we already have a detailed guide on how you can access, copy, or move data to your iCloud Drive, which you can check out anytime.

#6. Shut Down or Restart Mac using Terminal

To shut down your mac with CLI (Command Line Interface) aka Terminal, use

Just as shut down, you can restart your Mac by

#7. View File Contents

To access the contents of any damaged or corrupted file, you can force the terminal to open it with this command.

Note: If you try to open an image file in the terminal, it will show some gibberish text.

#8. Speed Up Time Machine Backup

Whenever you're updating the Mac to the new version, backup's are assurity of your data and the easiest way to take a backup is to use Time Machine. But do you know? You can speed up time machine backup using the terminal by this command

#9. Add Spaces to your Dock

If you feel, your dock is crowded with a lot of apps. You can add up a little space between each app icon, here's how.

Type:

Best Terminal Commands Mac

and hit Return.

Once done, type:

and press Return again

#10. Copy Contents from One Folder to Another

Copying contents from one place to another is fairly easy with Terminal, Type in the following command

Replace original with the current directory, and new with the name of the directory to which you want to copy the contents.

#11. Make your Mac Say Anything you want

This is the coolest command that macOS provides, you can make your Mac say anything you want, by using the say command followed by the words.

say 'hello, iGeeksblog'

Wrapping Up…

There are lots of bash commands available for macOS. However, these were some of them. Do give them a try, and make more out of your Mac.

You might also like to read:

Which command did you like the most? Share your views in the comment section.

Nikhil runs iGB's official YouTube channel. He is the official lensman of iGB and GB's small studio is Nikhil's playground, where he does all wonders with his remarkable signature. When Nikhil is not in his studio, you may spot him in a gourmet restaurant, chomping his way through some delicious food. He is a great traveler, who can go for long drives in search of good food.

  • https://www.igeeksblog.com/author/nikhil/
    How to Manage Website Settings in iOS 13 Safari on iPhone and iPad
  • https://www.igeeksblog.com/author/nikhil/
    How to Fix 'iMessage Needs to Be Enabled to Send This Message' Issue
  • https://www.igeeksblog.com/author/nikhil/
  • https://www.igeeksblog.com/author/nikhil/
    How to Enable and Use Taptic Time on Apple Watch in watchOS 6




broken image