Owners of Apple devices often disregard Terminal as something difficult to master. In fact, there's no need to be an advanced MacBook or iMac user to reap the benefits of this OS X command line. Like any other UNIX-based system, macOS comes packed with the Terminal app that works off a text editor interface. Users have to open the Terminal window and type the commands in, which may seem confusing after operating the cool graphical user interface (GUI) of macOS. Where is Terminal located on a Mac? How to access and use the command-line interface? Learn the best basic and advanced Mac terminal tricks & tips from this tutorial to boost your Mac user experience and quickly troubleshoot any problem from slow Mac internet to resource-hogging apps.
Using the command prompt can be fun. Before learning a few cool things to do in the Terminal, you need to know where to find it on your Mac. Accessing the Terminal is possible in two ways:
To launch Terminal via Spotlight, type in 'Terminal' in the Spotlight search bar.
It is important to clarify a few related terms:
Terminal commands consist of three elements: the program, the option, and the argument. Without going into details, view the next commands before proceeding with this tutorial:
Note: The sudo command provides root user privileges, so be careful using it. To execute this command, your OS will require the admin password.
Mac commands are powerful tools that can make a user's life easier. To understand how the parts of a command correlate, view the below example.
The ls command (short for "list") is the actual program to display the list of files in a particular Mac directory. To modify the way a program runs, you need to enter an option. For example, -l (short for "long"). The -l option displays the files supplied with detailed information. If the option is missing, the ls command will list the files contained in the current working directory. The command options are not obligatory. When options are missing, commands have certain default behavior.
In this example, the ~ (tilde sign) is the relevant argument. The tilde relates to the objects the ls command is executed on. Here, ~ is a shorthand name for your home folder. Altogether, the sequence ls -l ~ interprets as 'list all of the files in the home folder'. Some commands do not require arguments. Depending on the command, arguments may vary, but the order of the arguments is important. To abort the executed command, press Control-C.
Mac users can utilize the cd command to change the current working directory. To specify the directory, add a relevant argument. If the argument is missing, the command lands into home directory (~) by default.
The Terminal environment has a manual for learning specific commands. To access it, type in man and use the name of the needed command as its only argument. For instance, to learn more about ls, run man ls command.
Look up the following useful commands in the manual:
Mastering the Terminal is impossible without learning a few useful hacks. Terminal shortcuts are keyboard combinations, or codes used within the Terminal environment to work faster. These key combinations belong to four categories:
Marks apply to a particular Terminal window and execute specific commands within it. They "mark" the positions to return to later on. Bookmarks transcend from one Terminal window/tab to another one. Neither marks nor bookmarks last when you quit the Terminal.
Speaking of the Terminal shortcuts, there is a possibility to assign a particular key combination to launch Terminal fast. Please mind that this is a time-consuming process, which requires skill and effort.
Console.app is a log viewer included with macOS. With its help, users can extract system and application logs, status messages, and activities data to troubleshoot Mac issues. The Console app is handy when no other options are available to fix your Mac. To launch Console, go to Applications -> Utilities. Choose All Messages in the toolbar. It is possible to filter the messages by Errors and Faults to locate the line relevant to your problem. If you already know which app is causing the problem, you can use the search bar to look for the messages related to it. The Console displays an error code that users can Google to solve a problem on their own.
Despite being quite useful, the Mac Console has one serious pitfall. It only shows the data accurate at the time you open the application. Therefore, if your Mac crashed, opening the Console afterward won't provide any useful information. Users can look through Console's log archives. However, this tedious process requires making a system diagnostic report first.
Sudo is a Terminal command that allows running programs with a root user privileges. Very often, a root user (superuser) is mistaken for an administrator, so it is necessary to make a distinction between them.
In comparison, standard and managed user accounts have no exclusive privileges to make system-wide changes or sidestep access limitations.
To execute a sudo command, a user needs to type in the administrator password. A wrong or blank password will prevent the command from execution. In case your administrator account has no password, it is possible to set it in 'Users & Groups' preferences. Please mind that Terminal doesn't display the typed-in password. If you make a mistake, the Terminal will request the password again.
It is possible to search for files on your Mac using special Terminal commands.
When looking for a file, the find command enters any folder in the specified path. The folder may require a user access permission if it has restricted privileges. Often, the find command takes a long time to complete. If only the root folder is specified, it may recourse and never finish the search process.
Two other commands are offering indexed search results:
It is possible to open the present working directory in Finder using the open . command in Terminal. As long as you're located in a local path, you can open any type of system or user files, and launch them into the Finder. This can come in handy if a user needs to find and edit buried system files discovered through the command line. For instance, you are digging around /etc/, the directory containing configuration files for all the programs. If you want to open that directory in Finder, just type in open . to access it.
Terminal.app is a powerful instrument providing access to features that lie beyond Mac's standard graphical interface. The command-line interface offers an array of options that are safe to use for Mac users with little experience. However, Mac power users can access the hidden features through the Terminal to make necessary system-wide changes. Using Terminal commands will help you get the most of your Mac!