

Move works almost identically to copy as shown above, except that there’s no need to add a recursive flag when moving directories. For example: cp file1.txt file2.txt file3.txt /destination/. You can even include multiple files in a single copy command. For example: cp -R /folder/ /destination/. If you want to copy a directory, you’ll need to use the -R flag to indicate that all files and folders in the directory are to be included. If you’re copying a single file, you can use the cp command without a flag as per the example shown above. Use cp to initiate the copy command, add a flag where required, and then enter the target file or folder, followed by a space, and then add the destination folder. Remember, you can also use the same location shortcuts that you’d use with the cd command (e.g. For example, use -C to get a multi-column output, -S to sort by size, -lt to sort by date modified, -la for detailed contents including hidden files, or -lh to create a list with readable file sizes. You can add flags to the ls command to get different results. Append it with a location on the drive to specifically target that directory. List Files & Folders: lsĪlso useful in navigating your drive, ls can be used to list the contents of the current directory simply by executing the command. For example, running cd ~ will take you to the Home directory for the current user. You can also use cd/ to get to the root of the drive, cd. You can use shortcuts to quickly skip to certain directories. For example: cd /Volumes/Elements/ to access an external drive called “Elements.” Use the cd command to change directories. In this example, rm is the delete command, the -i flag instructs the process to ask for user confirmation, and would be replaced with the file or folder’s location on the drive. Flags are case-sensitive. The flag always appears after the command.

For example, the -R flag applies a command recursively so that it applies to a directory, all files and folders within that particular directory, all files and folders inside those folders, and so on. Most commands can be appended with a flag in the form of a hyphen and a letter to access different functions.
#Command prompt commands mac how to#
When we’re done, you might want to learn how to lock your Mac from the Terminal, or even how to shut it down with a simple command. These will be familiar to you if you’ve ever used the Linux command line, too. We’ll cover some of the most basic Mac terminal commands here. Cut, copy, and paste all work as expected, and you can drag any file or folder into the Terminal window to immediately skip to that directory. You can open multiple tabs with Command+T or a new Terminal window with Command+N.

Many of the shortcuts that you use in other apps will work here. Launch Terminal by finding it in the Utilities folder or by searching for it using Spotlight, and then familiarize yourself with the interface. This is how you execute commands on your Mac using the command line. Your Mac comes with an app called Terminal under Applications > Utilities. You might even discover that you enjoy working in a command-line environment! Use Terminal to Execute Commands Type ls and press the Return key, and you’ll see the folders (and/or files) in the current directory.Are you afraid of the Mac command line? Learning a few simple commands can help you build your confidence and shed that fear. To do that you use the ls (or list) command. While you’re there-or when you’re in any folder ( directory in Unix-speak)-you might want to know what’s in it. When you first get to the command line, you’re in your home folder.

Mac-Pro-8 is the name of the Mac (same as the Computer Name in the Sharing pane of System Preferences).In the prompt above romansempire is the user name.The second line is the prompt, and while it can change from system to system depending on configuration, by default it contains several bits of information:.The first line shows the last time you logged into your Mac via the command line that’s the current time, when you’re using Terminal.
