krotrunner.blogg.se

How to use terminal mac
How to use terminal mac





how to use terminal mac

Similarly, you can use df -h to calculate disk space, or use the -H flag to display total disk space in “metric” storage units (e.g. For a far more useful readout, run du -sh /destination/ instead to provide a human-readable total of disk usage for a specified location. Use the du command to calculate disk usage in the location specified thereafter. For example: rm file1.txt file2.txt file3.txt.

how to use terminal mac

You can delete multiple files at once by appending more filenames to the end of the command. You can add the -i flag to require user confirmation whenever using it, which should help prevent mishaps. The rm command deletes files or folders immediately without asking you for confirmation first. If you want to create a folder with a space in the name, make sure that you put the folder name in quotations. For example: mkdir folder1 folder2 folder3. You can create multiple directories by separating the names with spaces. If you want to create a new directory, use the mkdir command, followed by the name of the directory that you want to create. For example: mv oldfilename.txt newfilename.txt. You can use mv to rename files too by “moving” a file to the same directory. You can add an -i flag to the command to require confirmation before moving since the mv command will overwrite any files in the destination by default. 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.

how to use terminal mac

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.

how to use terminal mac

Most commands can be appended with a flag in the form of a hyphen and a letter to access different functions.

#How to use terminal 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.







How to use terminal mac