You’ll spend a lot of time in Terminal moving between directories using cd and examining their contents using ls. Use with caution! macOS Terminal Commands: Viewing & Navigating Directories f: force a command to run, disabling confirmation dialogs. Useful for applying per-file commands like chmod to whole folders. r: recursive mode, which causes the command to run itself repeatedly over the contents of a directory or other set of inputs. Useful for debugging problematic programs or monitoring long-running commands. v: verbose mode, which causes the command to narrate its actions. A few frequent flyer flags are featured further down: These flags change the way the command operates, adjusting functionality or toggling different features. Flagsįlags are options appended to commands and preceded by one or two dashes ( – ). It will send the output of one command, like ls, to another command, like rm.
#Command line for mac terminal iso
This symbol, called a pipe, is found above the Enter key on US keyboards or next to the left Shift key on ISO keyboards. If the file doesn’t exist yet, it will be created. For example, ls > filelist.txt will send the output of ls to a text file called filelist.txt located in your current working directory.
And get really excited about it! >Ĭalled a “redirect,” the caret sends the output of your command to a file (AKA “file output”) instead of the Terminal window (AKA “standard output”). Run the last command again, but this time with administrator privileges. Just press Enter when done to execute the command. When you do, the input cursor won’t move, but the keystrokes will be captured. It also gives you the power to break things very badly, so don’t use sudo unless you know what you’re doing.Īfter you use sudo, you’ll need to enter your administrator password. 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. Sudo stands for “super user do,” and it doesn’t do anything on its own. Modifiers adjust existing commands to make them do more things, or do things differently than they might normally. It’s a universal symbol for “command prompt,” but it’s not part of the command itself. Remember that the tilde ( ~ ) represents the current user’s home directory and the forward slash ( / ) alone represents your boot drive.Īlso note that, when using the commands below, you should omit the dollar sign ($).
You can see your current working directory to the right of the colon at command prompt. 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. Some commands are performed within the working directory, and other commands don’t care about it at all. 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. Hacking the Mainframe: Getting Acquaintedīefore we get started, let’s talk about the working directory.
#Command line for mac terminal how to
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.