Sep 28, 2020 • Filed to: Solve Mac Problems • Proven solutions
When people heard the word Mac Terminal, they get scared thinking that using Terminal is very hard. But the truth is quite the opposite. Once you get a hold of Terminal commands, it will become easy for you to carry out even the complex task on Mac easily. So, in this article, you will learn how to open and use Terminal on Mac.
Cmd shortcuts are generally for GUI apps on Mac, Ctrl shortcuts for terminal apps. So, you can Cmd+Q to quit the Terminal completely, or Cmd+W to close the window, but Ctrl+D to quit Python while leaving the Terminal window alone. – abarnert May 23 '15 at 2:42. Basics of Mac Terminal: Just like the Windows command line, Mac Terminal is the command line system that helps the users to take control of the operating system and make changes in it. The best thing you can do to learn using Terminal is to start using. To get started with.NET Core development on macOS, see Install Visual Studio 2019 for Mac. For the latest release,.NET Core 3.1, you must use the Visual Studio for Mac 8.4. Install alongside Visual Studio Code. Visual Studio Code is a powerful and lightweight source code editor that runs on your desktop. The Terminal is an exceptionally powerful tool, providing a command line interface to the underpinnings of OS X. It's a topic we've covered at length before with our popular series Taming the Terminal. There's a great deal that Terminal can do, from moving large numbers of files to changing preferences that we didn't even know exist. Bash Profile Configuration. The profile file is run during boot-up to configure the terminal to define file path, shims, and autocompletion handlers. This is the single biggest frustration with people using Linux on Mac. One of the earliest articles on bash here shows shell variables, environment variables, and aliases. Each operating system has its own file name for its profile.
Part 1. Basics of Mac Terminal:
Just like the Windows command line, Mac Terminal is the command-line system that helps the users to take control of the operating system and make changes in it. The best thing you can do to learn using Terminal is to start using it. The most important thing you need to learn is commands.
All you need to do is to type the command and hit Return to execute it. Every command has three components, the command itself, an argument, and an option. The command is self-explanatory; the argument tells the command the source where it should operate and the options work as a modifier for the output.
For example, if you want to move a file from one folder to another, the command used will be- mv. Then type the location where the file exists and add file name and location where you want to move it.
While you are using the Mac Terminal, you should know about the basic rules too.
- Every single character matters in the terminal command, even spaces, and commas.
- You can't use a mouse or Trackpad inside the Terminal. Therefore, you'll have to navigate using the arrow keys, and Return key.
- Commands are executed inside a location, so if you don't specify a location in the command, it is automatically set to the recent or previously specified location.
Part 2. Basic Commands and Functions of Terminal:
The macOS terminal is a tool that requires skills and intelligence to learn. You will have to pay attention to even the smallest detail to ensure that you don't make mistakes. From learning how to open the file via Mac terminal to terminal deletion, every single command matters. Here are some basic commands that you need to understand if you want to improve your terminal knowledge.
- ls- list the contents of a particular directory
- cd-change to another directory
- sudo- authenticate yourself as a superuser to gain extra security privileges
- defaults write –g ApplePressAndHoldEnabled –bool false to disable the pop-up accent window
- defaults write com.apple.finder AppleShowAllFiles -bool TRUE to show hidden files.
- History to see the terminal command history
- defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 check for macOS updates.
If we start learning, the macOS terminal commands won't come to an end. So, in this article, we will only learn using some basic commands like deleting files, show hidden files, change folder permissions, etc.
Part 3. How to Open Terminal on Mac:
There is no doubt that Terminal is a handy tool for Mac users. Therefore, it is vital that you know all the ways there is on how to open a terminal on Mac. Here are all the ways that are used to open Terminal. Take a look and use the one which suits you best.
1: Using Spotlight Search:
It is one of the quickest and easiest ways to open Terminal on Mac. If you have the Spotlight search button in the menu bar, then click on it directly. Or use the keyboard shortcut by pressing the Command + Space keys. Type terminal in the space and you will see the Terminal utility in the result. Double-click on the option and the Terminal will open up.
2: Using Finder:
Another method to open the terminal is using the Finder. Click on the Go option from the Utilities and you will find the Terminal option in the Utilities folder. Simply double-click on the application and it will open.
3: Using Applications Folder:
You can also use the Finder to open the applications folder and access Terminal from there. Open Finder and click on the Application option from the left side panel. Expand the Utilities folder and there you will find the Terminal option. Double click on it and the Terminal will open up.
If you have a shortcut for the Applications folder on Mac, then you can directly locate the Terminal application from the list.
4: Using Launchpad:
You can also use Launchpad to open Terminal. It depends on whether you have organized the Launchpad or not. There are two ways to open the Terminal using Launchpad.
Sep 28, 2020 • Filed to: Solve Mac Problems • Proven solutions
When people heard the word Mac Terminal, they get scared thinking that using Terminal is very hard. But the truth is quite the opposite. Once you get a hold of Terminal commands, it will become easy for you to carry out even the complex task on Mac easily. So, in this article, you will learn how to open and use Terminal on Mac.
Cmd shortcuts are generally for GUI apps on Mac, Ctrl shortcuts for terminal apps. So, you can Cmd+Q to quit the Terminal completely, or Cmd+W to close the window, but Ctrl+D to quit Python while leaving the Terminal window alone. – abarnert May 23 '15 at 2:42. Basics of Mac Terminal: Just like the Windows command line, Mac Terminal is the command line system that helps the users to take control of the operating system and make changes in it. The best thing you can do to learn using Terminal is to start using. To get started with.NET Core development on macOS, see Install Visual Studio 2019 for Mac. For the latest release,.NET Core 3.1, you must use the Visual Studio for Mac 8.4. Install alongside Visual Studio Code. Visual Studio Code is a powerful and lightweight source code editor that runs on your desktop. The Terminal is an exceptionally powerful tool, providing a command line interface to the underpinnings of OS X. It's a topic we've covered at length before with our popular series Taming the Terminal. There's a great deal that Terminal can do, from moving large numbers of files to changing preferences that we didn't even know exist. Bash Profile Configuration. The profile file is run during boot-up to configure the terminal to define file path, shims, and autocompletion handlers. This is the single biggest frustration with people using Linux on Mac. One of the earliest articles on bash here shows shell variables, environment variables, and aliases. Each operating system has its own file name for its profile.
Part 1. Basics of Mac Terminal:
Just like the Windows command line, Mac Terminal is the command-line system that helps the users to take control of the operating system and make changes in it. The best thing you can do to learn using Terminal is to start using it. The most important thing you need to learn is commands.
All you need to do is to type the command and hit Return to execute it. Every command has three components, the command itself, an argument, and an option. The command is self-explanatory; the argument tells the command the source where it should operate and the options work as a modifier for the output.
For example, if you want to move a file from one folder to another, the command used will be- mv. Then type the location where the file exists and add file name and location where you want to move it.
While you are using the Mac Terminal, you should know about the basic rules too.
- Every single character matters in the terminal command, even spaces, and commas.
- You can't use a mouse or Trackpad inside the Terminal. Therefore, you'll have to navigate using the arrow keys, and Return key.
- Commands are executed inside a location, so if you don't specify a location in the command, it is automatically set to the recent or previously specified location.
Part 2. Basic Commands and Functions of Terminal:
The macOS terminal is a tool that requires skills and intelligence to learn. You will have to pay attention to even the smallest detail to ensure that you don't make mistakes. From learning how to open the file via Mac terminal to terminal deletion, every single command matters. Here are some basic commands that you need to understand if you want to improve your terminal knowledge.
- ls- list the contents of a particular directory
- cd-change to another directory
- sudo- authenticate yourself as a superuser to gain extra security privileges
- defaults write –g ApplePressAndHoldEnabled –bool false to disable the pop-up accent window
- defaults write com.apple.finder AppleShowAllFiles -bool TRUE to show hidden files.
- History to see the terminal command history
- defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 check for macOS updates.
If we start learning, the macOS terminal commands won't come to an end. So, in this article, we will only learn using some basic commands like deleting files, show hidden files, change folder permissions, etc.
Part 3. How to Open Terminal on Mac:
There is no doubt that Terminal is a handy tool for Mac users. Therefore, it is vital that you know all the ways there is on how to open a terminal on Mac. Here are all the ways that are used to open Terminal. Take a look and use the one which suits you best.
1: Using Spotlight Search:
It is one of the quickest and easiest ways to open Terminal on Mac. If you have the Spotlight search button in the menu bar, then click on it directly. Or use the keyboard shortcut by pressing the Command + Space keys. Type terminal in the space and you will see the Terminal utility in the result. Double-click on the option and the Terminal will open up.
2: Using Finder:
Another method to open the terminal is using the Finder. Click on the Go option from the Utilities and you will find the Terminal option in the Utilities folder. Simply double-click on the application and it will open.
3: Using Applications Folder:
You can also use the Finder to open the applications folder and access Terminal from there. Open Finder and click on the Application option from the left side panel. Expand the Utilities folder and there you will find the Terminal option. Double click on it and the Terminal will open up.
If you have a shortcut for the Applications folder on Mac, then you can directly locate the Terminal application from the list.
4: Using Launchpad:
You can also use Launchpad to open Terminal. It depends on whether you have organized the Launchpad or not. There are two ways to open the Terminal using Launchpad.
By default, the 'Other' folder of Launchpad contains the Terminal application. You can open Launchpad from Dock or by using a keyboard shortcut, i.e. Fn+ F4 keys. Find the other folder and you will find terminal inside the folder.
If you have arranged the Launchpad in a different way, then you will have to type Terminal in the search box. As soon as the terminal icon appears on the screen, click on it and it will open up.
5: Using Siri:
A big thanks to Apple Inc, now users can use Siri to find anything on their Mac too. All you need to do is to open Siri and say 'Open Terminal'. Siri will take care of the job and terminal will open up on your Mac. You can easily access Siri from the shortcut button or find Siri in the Applications folder.
6: Create a Terminal Shortcut:
If you use Terminal more often, then it will be better if you create a shortcut on the desktop or Dock for it. This way, opening a Terminal will be more convenient for you. Select the Terminal application from Utilities or from the 'Recent' applications in Dock and right-click on it. It will open some options in a small pop-up window. Scroll the mouse pointer over 'Options' and you will see few options. Pick whether you want to keep Terminal in Dock, show it in finder, or open it at login.
All of these methods are simple and easy. So, pick whichever is more comfortable and you will be able to access Terminal with just one click.
Part 4. How to Use Terminal Commands on Mac:
Here is a list of some common commands used in Terminal. These commands will provide you a short and precise method to carry out the task.
Terminal For Mac
1: Delete Files Using Terminal:
Removing files using the terminal is a much more convenient method to delete files and folders permanently. You can delete multiple files quickly and efficiently. The terminal can also be used to delete files from Trash.
To delete files from Mac, the rm command is used. As you launch the terminal and type cd ~/Desktop to get to the desktop directory, find the file that you want to delete and enter its name. For example, if you want to delete MyFile.rtf, then you will pass the command as- rm MyFile.rtf and the file will be gone forever. To delete multiple files, just leave space between the file names and hit the Return key and Terminal will take care of the rest.
2: Open Finder from Terminal:
Some people would say why they need to learn how to open a finder from the terminal. Well, it comes in handy when the OS is not working properly or you have to find the hidden files. For this, the command passed will contain the following components:
- Controls: Mac-Admin is the name of the system and is separated by the colon. The next section, ~ or / minas that you in the user's root or home folder. And admin$ is the username.
- PWD: It is the Print Working Directory that shows you the path to the folder in which you are currently located. When you pass this command, it will give results like /Users/admin. The /Users is the user folder present in the root folder of the disk and /Users/admin is the current user folder which is present inside the Users folder.
- CD: It means change directory or folder.
- OPEN: To open Finder using the Terminal, you will have to type this command.
Just type open. and press the Return key and a Finder window will open up.
3: Show Hidden Files with Terminal:
If you want to view hidden files and folder in the macOS, you'll have to use the show hidden files Mac terminal command. Write the command as-
$ defaults write com.apple.finderAppleShowAllFiles –bool TRUE
$ killall Finder
As you hit Enter, the command will execute and you will see a lot of files in the Finder window that you can't see because of privacy. To reverse the process, you just have to change TRUE into FALSE and the files will become hidden again.
4: Empty Trash Using Terminal:
As we discussed above, Terminal can be used to empty trash too. To empty trash using a Mac terminal, you will have to follow some different steps.
Step 1: Type the command as sudo rm –R without pressing the Enter key and control-click on the Trash icon to open it.
Step 2: This will open the Trash folder. Select all the files that you want to delete and drag them to the terminal window. Then press the Enter key and provide the admin password.
When you enter the password, you won't see any change in the Terminal screen. After that, press the Enter key again and the trash files will be deleted from your Mac.
5: Change Folder Permissions:
It is possible to change the file permission of a file and folder using the Finder, but Terminal gives you better control and flexibility. Permissions are assigned considering user, Group, or others and have attributes such as read, write, and execute. To change permissions, you will have to use the chmod command. It runs in two modes, i.e. absolute and symbolic. For beginners, it is better if they stick to the symbolic mode as Absolute mode is for advanced users. This is how you can change folder permissions using the Mac terminal.
For a file or folder, you will have to specify the category (user, group, others, or all three), type of operation (e.g. add permissions, delete permissions, clear permission, or use the default), and the permission itself, i.e. read, write, or execute. Suppose you have a folder which has permission like- drwxr-xr-x and it means:
- User- rwx(read, write, or execute)
- Group- r-x(read and execute)
- Others r-x (read and execute)
Type cd and drag the folder whose permissions you want to change. This way, you won't have to specify the location of the folder as it will copy the path.
Type the command ls –l in the terminal to reveal all the subfiles, sub-folders, and their permissions. Now to change the permission of any folder or file, type- chmod 01234567 and the path file folder such as type chmod 755/bin which gives the bin folder Read/Write/Execute permission to the folder.
6: Repair Disk:
To repair disk using a Mac terminal, you will have to follow a simple procedure. The command to repair disk is direct- diskutil repairvolume /. Before you get to this, it is important that you determine the repair your disk needs.
You simply have to type the command with the location of directed at other volumes such as- diskutil repairvolume /Volumes/ExternalBackups/ and hit the Return key to execute the command. The repair disk command will resolve all the issues on the disk.
Part 5. Tips for Opening and Using Terminal on Mac:
Here are some tips for opening and using a Mac terminal so that you can avoid common mishaps.
- To change the default format of an image screenshot, type - defaults write com.apple.screencapture type JPG and hit Return. You can change to format to any format like PNG, TIFF, etc.
- To create a recent applications folder on Mac, type- defaults write com.apple.dock persistent-others -array-add '{ 'tile-data' = { 'list-type' = 1; }; 'tile-type' = 'recents-tile'; }';killall Dock. As you control-click the Dock item, you'll see the recent application, documents, servers, and favorite items all in one place.
- To flush the Mac memory, type- sudo purge and you might be asked to enter a password. Enter the password and the Mac memory will be erased.
- To fix your Mac, you can use File System Consistency Check, i.e. fsck, and repair the file system on Mac. Type- fsck fy and hit the return key. A bunch of code will appear on the screen until the check finishes and you will see the results on the screen in a while.
- Use caffeinate to keep your Mac from falling asleep as- caffeinate and hit the return key. You can also specify the amount of time in seconds like –t 3600 or –t 24000 to keep your Mac awake for a limited time period.
If you somehow end up making a mistake while using the Terminal and end up losing your files, then you still have an option to get them back. If you use Recoverit data recovery software for Mac, you can retrieve all files that are lost or deleted from Mac with just one-click.
Closing Words:
In this article, we learned how to open and use Mac Terminal in detail. As the commands and use of Terminals extend to the limit of words of this article, you can always learn a new thing. All the things you have learned from this guide will surely come in handy. And if you happen to fall prey to data loss situations, then you will still have access to Recoverit Mac Data Recovery to get the important files back on the device. Recommend this Mac Data Recovery tool to your friends and family and help them to retrieve their lost or deleted files.
What's Wrong with Mac
- Recover Your Mac
- Fix Your Mac
- Delete Your Mac
- Learn Mac Hacks
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.
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
Terminal Code For Mac Os X
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:
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.
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:
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.
Terminal Commands For Mac Os
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.
Mac Os Terminal Programs
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.
Also on Guiding Tech #productivity Click here to see our productivity articles pageUsing 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.