Menu
To execute Terminal commands Mac users need first of all to invoke Terminal in Commander One by pressing simultaneously the combination CTRL + O, and after that follow the above Mac Terminal commands cheat sheet. Once everything is done, you can return to the previous mode of Commander One by pressing the mentioned above hotkey. With this quick guide, we’re going to try and at least take away some of the mystery that exists within the Terminal app on macOS by giving you the power that you need to list all 1,400+ terminal commands available across all versions of macOS and OS X. With this quick guide, we’re going to try and at least take away some of the mystery that exists within the Terminal app on macOS by giving you the power that you need to list all 1,400+ terminal commands available across all versions of macOS and OS X.
Hidden behind beautiful Mac screens is the world of Terminal Command lines. Knowing how to use these commands will help you increase your work efficiency in a great way.
Below is a list of the most basic commands divided by purpose of use:
CORE COMMANDS
CHAINING COMMANDS
PIPING COMMANDS
COMMAND HISTORY
FILE MANAGEMENT
DIRECTORY MANAGEMENT
SEARCH
HELP
Terminal, sometimes called the command line interface or CLI, is a text-based program for interacting with your computer’s deepest levels. But while it gives users more power, it also ditches the graphical interface we all know and love. This can make learning Terminal tricky, and not a little bit daunting. Fortunately there’s nothing to be anxious about: great power is at your fingertips, and you need only learn the right macOS Terminal commands.
If Terminal is brand new for you, start here. Once you know how to launch Terminal and input commands, you can come back here to expand your knowledge.
Hacking the Mainframe: Getting AcquaintedBefore we get started, let’s talk about the working directory. The working directory, as we covered previously, is the directory Terminal is currently using as “home base.” You change your working directory with cd , and it’s the point from which all file path references are calculated.
Some commands are performed within the working directory, and other commands don’t care about it at all. If a command does care about the working directory (like
ls , for example), you’ll need to run that command from within the appropriate working directory. You can see your current working directory to the right of the colon at command prompt. Remember that the tilde ( ~ ) represents the current user’s home directory and the forward slash ( / ) alone represents your boot drive.
Also note that, when using the commands below, you should omit the dollar sign ($). It’s a universal symbol for “command prompt,” but it’s not part of the command itself.
macOS Terminal Commands: Modifiers
Modifiers adjust existing commands to make them do more things, or do things differently than they might normally.
sudo stands for “super user do,” and it doesn’t do anything on its own. Instead, it gives the command it’s partnered with superpowers. When you type sudo before a command, the command will be run with administrator privileges, giving you the power to do things you won’t normally do. It also gives you the power to break things very badly, so don’t use sudo unless you know what you’re doing.
After you use
sudo , you’ll need to enter your administrator password. When you do, the input cursor won’t move, but the keystrokes will be captured. Just press Enter when done to execute the command.
Run the last command again, but this time with administrator privileges. And get really excited about it!
Called a “redirect,” the caret sends the output of your command to a file (AKA “file output”) instead of the Terminal window (AKA “standard output”). For example,
ls > filelist.txt will send the output of ls to a text file called filelist.txt located in your current working directory. If the file doesn’t exist yet, it will be created.
This symbol, called a pipe, is found above the Enter key on US keyboards or next to the left Shift key on ISO keyboards. It will send the output of one command, like
ls, to another command, like rm .
Flags are options appended to commands and preceded by one or two dashes ( – ). These flags change the way the command operates, adjusting functionality or toggling different features. A few frequent flyer flags are featured further down:
-v: verbose mode, which causes the command to narrate its actions. Useful for debugging problematic programs or monitoring long-running commands.
-r: recursive mode, which causes the command to run itself repeatedly over the contents of a directory or other set of inputs. Useful for applying per-file commands like chmod to whole folders.-f: force a command to run, disabling confirmation dialogs. Use with caution! macOS Terminal Commands: Viewing & Navigating Directories
You’ll spend a lot of time in Terminal moving between directories using
cd and examining their contents using ls .
ls , or list, reports information about the working directory’s contents. We’ve covered ls ‘s basic operation already, so here’s a few more advanced flags.
The -a flag lists all the contents of directory, including hidden files. The -l flag returns the results in “long format,” which includes crucial information like file size, modification date, permissions and so on.
The -S flag sorts long format output by file size. Like all the commands below, the -S flag needs to be run with the -l flag to work. To quickly run more than one flag at once, list them one after another, prepended by a single dash.
The -h flag shows file sizes in a “human readable” format, using units like kilobytes instead of block size.
The -e flag shows the Access Control Lists, or ACLs, associated with a file. macOS’s HFS+ file system uses ACLs to attach advanced file system attributes to files and folders.
The -t flag sorts files by the time they were modified, with the most recently modified file displayed first.
We also touched on the basics of
cd , so here’s a few tricks you can try out.
Free 3d exterior house design software for mac. Without any other arguments,
cd returns you to your home directory at /Users/[username]/ Rosetta stone software for mac.
Anno 1602 fur mac download. The two periods at the end of the command mean “parent folder,” and they will bump you up one directory level.
Changes the working directory to Brushes. Don’t forget that
cd for the specified path within the current working directory. If you want to navigate to a specific path using the root directory as your starting point, you’ll need to start your file path specification with a forward slash ( / ), like /Users/alexander/Documents/Adobe. The root directory starts from your computer’s boot disk (typically Macintosh HD), so the file paths will often be fairly lengthy.
macOS Terminal Commands: Copying, Moving and Deleting Files
Copies the contents of first directory into contents of second directory. The -V flag is for verbose, which will cause
ditto to report its progress as it copies files. Of course, you could also specify the current folder as the target destination by using the period ( . ) in place of new/folder/location.
Creates a copy of the file filename.doc in path/to/directory/newfilename.doc. If the filename already exists, the copy operation will not be completed.
Renames badname.txt to goodname.txt. Since renaming a file is essentially the same as “moving” the file’s bits to a new filename, we use the
mv , or move, command to accomplish this.
Moves badname.txt to path/to/directory and renames it goodname.txt. Deletes the original badname.txt file when moving.
Moves goodname.txt to a new directory location without renaming the file.
Removes the directory contents and all the files contained within it. The -r flag makes
rm , or remove, operate recursively, while the -f flag shuts off any confirmation dialogs. The more powerful version of this command, sudo rm -rf , should be used with extreme caution. It can erase your boot drive without warning or complaint, so handle with care.
macOS Terminal Commands: Permissions
Permissions affect which users can view, edit and execute specific files. Files and folders have an owner, which is normally the user that created it, and modes, which control the users that can access the file, as well as what they can do with it.
These commands are the first commands that we’ll use
sudo with. Remember that sudo elevates us to a superuser, giving us temporary administrator power. This is almost always necessary when dealing with file permissions, since not every file will be owned by your current user.
Change the owner of every file in the given directory to user af. The -R flag makes the command recursive. Of course, you could also run this in your working directory by using the period ( . ) in place of path/to/directory.
chmod stands for “change mode,” and adjust permissions for files and folders. In this example, the -R flag is again used to apply permissions recursively.
10 Fun And Useful Terminal Commands For Mac Os X
File permissions can be represented a few ways, but the “numeric mode” used above (775) is the most common. To learn about the different ways to represent permissions, check out chmod’s man page. Best free disk partition software for mac.
Conclusion
Now that you have these commands under your belt, you should be able to get a little more done with Terminal! However, I doubt you’ll be giving up Finder to start using mv instead. In our next post, we’ll look at expanding your understanding to accomplish more useful tasks.
You might also like:
Terminal Commands List5 Fun Terminal Commands To Try Right Now10 Fun And Useful Terminal Commands For Mac Os DownloadGetting Started with Terminal: An Introduction10 Tips for Using Terminal Like a Pro10 Fun And Useful Terminal Commands For Macos Download
Featured image by Thomas Schanz (Own work) [CC BY-SA 3.0], via Wikimedia Commons
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |