You can reach any location using a relative path as long as it is formed correctly by moving up or down the directory hierarchy, but in some cases, it’s easier to use the absolute path. Remember that relative is relative to where you currently are in the structure. separated by / which would result in the command shown below. This means I would need to use two sets of. I will need to move up two levels in order to get to the decomm directory. If I wanted to move to the decomm directory from this location I would either need to use an absolute path or I could specify upper level directories using the. Once in the newdevelopment directory, if you wanted to move to the App1 directory, you would only need to typeīut typing the absolute path will also work.Ĭd /Applications/newdevelopment/App1 (the absolute path) If you wanted to move to the newdevelopment directory from anywhere on the file system, you could type: You would move to the root directory with the following command. Mac Terminal uses a UNIX/LINUX-based style of commands so paths are formed by putting the names of directories together with a / in between each directory name, with the root directory always being denoted as just the / by itself. This is because the absolute path always starts from the root directory which is defined as /. This path is relative to /Applications/newdevelopmentĪn easy way to tell the difference between an absolute path and a relative path is that an absolute path begins with a / and a relative one does not. Keep reading, and I will explain a bit further how to use it and give you some tips to make it a little easier to use.įrom our example above, an absolute path might beĪn example of a relative path would be if we are already sitting in the /Applications/newdevelopment directory.Īpp1/Logs (notice there is no / before the path specification) While this command can be very simple, there are some things to know and look out for. I have used command-line interfaces like Mac Terminal for much of that time and commands like cd are ingrained in my head so they come naturally to me. I’m Eric, I have been around computers for over 40 years and I have worked as a software engineer for over 20. It’s a simple two-letter command followed by the directory name or path (shown below) but things can get a little complicated. Don’t worry, once you begin using it on a regular basis, things like changing directories will become second nature to you, and typing them in will be a breeze.Ĭhanging directories is probably one of the most frequently used commands when working in a command-line environment such as Mac Terminal. For example, the pathname My Disk is “My Disk” or My\ Disk.If you are new to Mac Terminal and just learning some of the basic commands, it’s possible you may be feeling overwhelmed. Although some file systems permit the use of these other characters, including spaces, you might need to add single or double quotation marks around pathnames that contain them.įor individual characters, you can also use an escape character-that is, put a backslash character immediately before the character in your string. Avoid most other characters, including space characters. Most of these users aren’t traditional user accounts with home directories, but you should be able to find the short name of known users on the computer.įile and folder names can include letters, numbers, a period, or the underscore character. In macOS, this folder is in the local /Users folder or on a network server.įor a list of short names on your server, enter dscl. To specify another user’s Document folder, use the short name preceded by the tilde (~) character-for example, ~jsmith/Documents. For example, to specify the Documents folder of the current user, enter ~/Documents. The tilde character represents the home folder of the logged-in user. For example, the string “./Test” represents a sibling folder (named Test) of the current folder. Two periods represent the parent folder of the current folder. For example, the string “./Test.c” represents the Test.c file in the current folder. A single period represents the current folder.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |