Home / Mac / Master the command line: Navigate files and folders

Master the command line: Navigate files and folders



If you’ve been using a Mac for a long time, you know that it’s more than just a nice point-and-click window and icon interface. Beneath the surface of the operating system is a whole world that you can only access from the command line. Terminal (in the folder / Applications / Utilities) is the default port of that command line on a Mac. With that, instead of pointing and clicking, you enter your commands and your Mac bids.

Why do you want to do that? For almost all your data needs, the usual graphical user interface is enough. But the command line can be useful when it comes to troubleshooting your Mac, to turn on “hidden” settings and other advanced chores. It is a good idea for anyone who is not a complete beginner to be familiar with it.

If you are not already familiar with the Mac command line interface. First up: How to navigate the file system from the command prompt.

The prompt

By default, when you open Terminal, the first thing you see is something like this:

Last login: Tue Apr 23 1
3:40:35 on ttys000 walden:~ kirk$

The first line shows the last time you logged in to your Mac via the command line; it is the current time when you use Terminal. The second line is the command prompt, and although it may change from system to system depending on configuration, it contains several bits of information by default.

In my message, Walden is the name of my Mac (same as the name in the System Preferences sharing pane), and kirk is my username. The ~ shows where I am in the file system on my Mac; ~ is a shortcut that means the current user’s home directory. (In the Finder, there is the folder with the username and the house icon.) Finally, $ is a character that the bash shell (the default interface that Terminal uses) displays to indicate that it is ready to accept a command.

What’s in a folder

Once you get to the command line, you are in your home folder. While you are there – or when you are in any folder (catalog in Unix speech) – you may want to know what’s in it. To do that, use ls (or list) command. Type ls and press the Return key, and you will see the folders (and / or files) in the current directory.

The exit from the plain ls the command is quite sparse; it shows you the names of the files and folders found in the current directory (including some known ones like movies, music, pictures and so on). Fortunately, you can add a number of optional switches to ls command that allows you to see more information. So try writing, for example ls -l (there are lowercase letters L), and then press Enter. You see something like this:


Source link