3) Drag the file you wish to open and drop it into the Terminal window. This will append the file's location to the command you entered, but will not actually move the file. 4) Now click on the Terminal window to make it active, and press return. 5) Copy and post the complete output.
Nov 16, 2020 • Filed to: Solve Mac Problems • Proven solutions
How to Open Files with Terminal on a Mac - Duration: 0:39. Howtomac9319 50,377 views. How to right click and Open Command Line Terminal at folder on Mac from Finder - Duration: 1:15. How to Open and Edit a Text File on a Mac; How to Open and Edit a Text File on a Mac. Navigate to the desired text file and double-click the filename to load it. You can also open an existing text file by dragging its icon from the.
- Open Terminal using the Applications folder If you have a Finder window open, you can access Terminal from the Applications folder. 1) Select Applications from the left side. 2) Click the arrow to expand the Utilities folder.
- In the context menu, you will see the option to Open command window here. However, there is no such option to quickly open Terminal on Mac. When you open a terminal on Mac, it always opens in the home directory, but there are times when you may need to open them in a particular folder on your system.
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.
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.
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:
Mac Terminal Commands
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.