1 00:00:00,460 --> 00:00:03,930 Before I start, I'm gonna make sure that I'm in my workspace directory. 2 00:00:05,010 --> 00:00:08,500 In the shell there are a variety of symbols that have special meanings. 3 00:00:08,500 --> 00:00:12,020 We've already seen a couple special symbols, dot and dot-dot, 4 00:00:12,020 --> 00:00:15,670 which are used to indicate the current and parent directories. 5 00:00:15,670 --> 00:00:18,830 This video will look at those symbols a little closer. 6 00:00:18,830 --> 00:00:20,640 We'll also look at the tilde symbol, 7 00:00:20,640 --> 00:00:23,900 which represents the user account's home directory. 8 00:00:23,900 --> 00:00:26,450 Dot indicates the current directory. 9 00:00:26,450 --> 00:00:28,840 It may not seem that useful at first. 10 00:00:28,840 --> 00:00:32,480 Cd dot just changes to the same directory. 11 00:00:32,480 --> 00:00:37,135 You can use dot in the paths of files, like cat ./bird.txt. 12 00:00:38,500 --> 00:00:40,803 But cat bird.txt does the same thing. 13 00:00:40,803 --> 00:00:42,730 It takes two fewer keystrokes. 14 00:00:43,830 --> 00:00:47,870 There are a few situations in which dot is very useful, however. 15 00:00:47,870 --> 00:00:50,880 One is in running executable programs. 16 00:00:50,880 --> 00:00:54,776 Let me change to a directory where I have an executable stored, 17 00:00:54,776 --> 00:00:57,436 cd offices/web_agency/mcgavren/. 18 00:00:57,436 --> 00:01:01,470 Let me list the files that are here. 19 00:01:01,470 --> 00:01:04,830 Here I have an executable file named hello.sh. 20 00:01:04,830 --> 00:01:07,640 The sh is short for shell script. 21 00:01:07,640 --> 00:01:08,750 If you come from Windows, 22 00:01:08,750 --> 00:01:13,130 you're probably used to executable files all ending in .exe. 23 00:01:13,130 --> 00:01:15,220 But on a Linux system like this one, 24 00:01:15,220 --> 00:01:18,090 executable files can have any extension you want. 25 00:01:19,102 --> 00:01:21,780 On Unix-like systems, as a safety feature, 26 00:01:21,780 --> 00:01:25,960 you can't run an executable file just by typing its name. 27 00:01:25,960 --> 00:01:29,800 You have to provide the executable's name as part of a path. 28 00:01:29,800 --> 00:01:32,750 Using only what we've learned so far, that would mean you have to 29 00:01:32,750 --> 00:01:36,650 change to the parent directory and then type the name of the directory that 30 00:01:36,650 --> 00:01:41,550 contains the executable, a slash, and the name of the executable file. 31 00:01:41,550 --> 00:01:45,240 But that's a pain if you're already in the same directory as the executable. 32 00:01:46,480 --> 00:01:51,570 So you can form a path by using dot to represent the current directory, a slash, 33 00:01:51,570 --> 00:01:56,440 and the name of the executable, ./hello.sh. 34 00:01:56,440 --> 00:01:59,360 Executable files are outside the scope of this course, 35 00:01:59,360 --> 00:02:02,290 but if you'd like to know more about them, see the teacher's notes. 36 00:02:03,500 --> 00:02:06,120 Another special symbol we've seen is dot-dot, 37 00:02:06,120 --> 00:02:07,980 which represents the parent directory. 38 00:02:09,130 --> 00:02:13,330 We've already make extensive use of cd dot-dot to change up a directory. 39 00:02:14,560 --> 00:02:17,990 You can also use dot-dot as an argument for commands. 40 00:02:17,990 --> 00:02:18,750 For example, 41 00:02:18,750 --> 00:02:23,790 you can list then contents of the parent directory by running ls dot-dot. 42 00:02:23,790 --> 00:02:26,948 You can also use dot-dot as part of a path. 43 00:02:26,948 --> 00:02:30,810 Suppose we wanna change to the dentist directory that's within the parent 44 00:02:30,810 --> 00:02:32,210 directory. 45 00:02:32,210 --> 00:02:35,670 We don't have to cd dot-dot and then cd dentist. 46 00:02:35,670 --> 00:02:40,850 Instead, we can type cd ../dentist. 47 00:02:40,850 --> 00:02:44,598 The operating system will realize this means the parent directory's 48 00:02:44,598 --> 00:02:47,469 dentist's subdirectory and change directly to it. 49 00:02:49,682 --> 00:02:53,560 Now for a symbol we haven't looked at thoroughly, the tilde. 50 00:02:53,560 --> 00:02:57,184 Like dot and dot-dot, tilde is a reference to a directory, 51 00:02:57,184 --> 00:02:59,980 your user account's home directory. 52 00:02:59,980 --> 00:03:04,502 We can type cd ~ to go to that home directory from anywhere on our system. 53 00:03:05,850 --> 00:03:10,640 You can see that the directory path in the prompt changes to just a tilde character. 54 00:03:10,640 --> 00:03:13,120 That's not the real path of this directory. 55 00:03:13,120 --> 00:03:15,148 To see the real path we can run pwd. 56 00:03:15,148 --> 00:03:18,976 You can see we're actually in a directory named treehouse, 57 00:03:18,976 --> 00:03:24,170 which is in a directory called home, which is the root directory. 58 00:03:24,170 --> 00:03:27,700 The name of the treehouse directory matches the name of the user account we're 59 00:03:27,700 --> 00:03:28,830 logged in as. 60 00:03:28,830 --> 00:03:31,727 We can see that account name if we run the whoami command. 61 00:03:33,390 --> 00:03:38,000 Each user account has its own subdirectory under the home directory. 62 00:03:38,000 --> 00:03:42,610 Windows and Mac machines have equivalents to the home directory at different paths. 63 00:03:42,610 --> 00:03:45,790 See the teacher's notes if you'd like more info. 64 00:03:45,790 --> 00:03:50,360 If we run ls/home, we'll see there's only the treehouse directory. 65 00:03:50,360 --> 00:03:53,969 That's because the treehouse account is the only one that's been created on 66 00:03:53,969 --> 00:03:55,110 this system. 67 00:03:55,110 --> 00:03:57,830 If there were other users, they'd have directories here too. 68 00:03:59,030 --> 00:04:01,380 So what's so special about your home directory? 69 00:04:01,380 --> 00:04:04,010 Why is there a special shortcut for it? 70 00:04:04,010 --> 00:04:05,410 For ordinary users, 71 00:04:05,410 --> 00:04:09,390 the home directory is really the only one on the system you should make changes to. 72 00:04:10,660 --> 00:04:13,840 The root directory is filled with a dozen subdirectories or more. 73 00:04:15,060 --> 00:04:17,750 Each one of these directories is filled with files that 74 00:04:17,750 --> 00:04:19,890 the operating system relies on to run. 75 00:04:21,160 --> 00:04:23,940 If you went around making changes in these directories, 76 00:04:23,940 --> 00:04:26,748 you could render your operating system unusable. 77 00:04:26,748 --> 00:04:31,540 Don't worry, Unix-like machines are set up so that ordinary users simply get an error 78 00:04:31,540 --> 00:04:34,230 message if they try to make changes in the root directory. 79 00:04:35,420 --> 00:04:38,410 Your home directory is the only directory on your system that's 80 00:04:38,410 --> 00:04:42,430 specifically intended for you to work in and make changes. 81 00:04:42,430 --> 00:04:46,600 And that's why there's a convenient tilde shortcut to help you access it. 82 00:04:47,640 --> 00:04:53,380 Just like dot and dot-dot, you can use tilde as part of a file or directory path. 83 00:04:53,380 --> 00:04:56,420 To change of the workspace directory within your home folder, 84 00:04:56,420 --> 00:05:00,730 you can run cd ~/workspace/. 85 00:05:00,730 --> 00:05:03,580 This will work no matter where you are on your system. 86 00:05:03,580 --> 00:05:08,187 For example, I could change to the /etc directory within the root directory again. 87 00:05:08,187 --> 00:05:13,863 And if I run cd ~/workspace/, I'll be taken directly to the workspace directory. 88 00:05:15,840 --> 00:05:18,837 You don't have to type out the whole directory name. 89 00:05:18,837 --> 00:05:24,352 That's because tab completion works with paths that start with tilde too, so I 90 00:05:24,352 --> 00:05:30,210 can say cd ~/wo tab and it'll complete the name of the workspace directory for me. 91 00:05:32,040 --> 00:05:34,750 These are not absolute paths that I'm showing you 92 00:05:34,750 --> 00:05:39,000 because the home directory is in different places for different users. 93 00:05:39,000 --> 00:05:42,300 Still, using tilde does work like an absolute path 94 00:05:42,300 --> 00:05:44,080 because it lets you reference files and 95 00:05:44,080 --> 00:05:48,160 subdirectories in your home directory from anywhere on your system. 96 00:05:48,160 --> 00:05:53,323 Let's print out that Starbunks menu one more time using a path relative 97 00:05:53,323 --> 00:05:59,021 to the home directory, cat ~/workspace/mall/starbunks/menu.txt.