1 - Dev Tools and command line

Table of Content

  1. 1.
    ​Operating systems​
  2. 2.
    ​The Command Line​
  3. 5.
    1. 1.
    2. 2.
    3. 3.
  4. 7.
    ​Development Tools​
  5. 9.
    ​More Resources​
  6. 10.
    ​Advanced Level - 1 { OPTIONAL }
  7. 11.
    ​Advanced Level - 2 { OPTIONAL }

Operating Systems

An Operating System (OS) is a powerful, and usually large, program that controls and manages the hardware and software on a computer. All computers and computer-like devices require operating systems, including laptops, tablets, desktops, and smartphones. The OS performs all the basic tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives and printers.
The most common operating systems for desktop and laptop computers are:
  • Microsoft Windows (Windows 95, Windows 7, Windows 10,...)
  • Linux (Debian, Red Hat, Ubuntu,..)
  • MacOS
  • Chrome OS
  • Android and iOS are operating systems for mobile devices.


Unix is ​​a family of operating systems. The first version was developed starting in 1969. Unix is ​​characterized by being portable and multitasking.
Unix operating systems are widely used in a multitude of devices that range from the most capable supercomputers to the mobile phones and computers that we use daily. The philosophy of Unix systems is characterized by:
  • a hierarchical file system,
  • a large collection of small programs that can work in series,
  • the use of text files to store the data,
  • treating devices as files.
Linux and MacOS are examples of Unix systems.


Linux is a family of Unix-like operating systems that use the Linux kernel. The name comes from the original programmer, a student named Linus Torvals, who in 1991, working with the GNU project of the Free Software Foundation, created the first version of this operating system.
Linux development is one of the clearest examples of free, open source software development by a diverse community of programmers all over the world. Anyone can use the operating system, study it and modify it. The open source nature of Linux is protected by the GPL (GNU General Public License).


Ubuntu is a Linux distribution. It is an open-source operating system aimed at desktop users, and its strengths are that it is easy to use and install. Although the desktop is somewhat different from Windows or Mac OS, a user who is accustomed to any of these operating systems will not have many problems becoming familiar with Ubuntu. Ubuntu is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: Desktop, Server, and Core for Internet of things devices and robots.
If you are using Ubuntu, you will see this sreen:
Demo of Ubuntu:
  • The friendly Desktop
  • The filesystem: navigate through folders and files using File Manager
  • Ubuntu software: a tool to install software easily

The Command Line

The Command Line, also knows as Bash, Terminal or Shell (LΓ­nea de Comandos Γ³ SΓ­mbolo de sistema in Spanish) is a way of controlling a computer, based on a text interface.
Why should I use the command line/terminal?
  • Once you know the basics, it helps you to interact with you computer faster
  • Some software for developers must always be used from a terminal
  • You have more control over the software
  • It allows you to create scripts (lists of commands) and automate manual tasks
  • It is what hackers use in movies.

How do I use the terminal on my computer?

Here are the instructions for the three operating system:
  • MacOS: You can find the in your Applications, in the folder Utilities. An alternative way to open the Terminal is to search with Spotlight and type in β€œterminal”. Select the application called terminal and press the return key. This should open up an app with a black background. When you see your username followed by a dollar sign, you’re ready to start using the command line.
  • Linux: You can open the Terminal by directly pressing [ctrl+alt+T] or you can search for it by clicking the dash (#) icon, typing in β€œterminal” in the search box, and opening the Terminal application. This should open up an app with a black background. When you see your username followed by a dollar sign, you’re ready to start using the command line.
  • Windows: Windows has its own Command Prompt. It is very similar to the Unix command line, but some commands are not exactly the same. For the main differences go to this link. Because of these differences, and because we want to learn UNIX commands, we use the Git Bash. Go to the Windows "Start" button and search the program Git Bash. When you open it you will see a screen like this one:
After you have followed the instructions, open a terminal and write ls, then press the Enter key. What do you see?

Commonly used commands

These are the most used commands that you will quickly become comfortable with during the course. These commands allow you to effectively move around the filesystem and write software on your laptop. There are more commands in the tables with more commands and descriptions below.
  • cd - change directory. To move up one folder level and into the parent directory use: cd ..
  • ls - list the contents of a directory. Can also be used as ls [directory_name] to list the contents of a specific directory without actually moving (with cd) to it
  • pwd - print working directory: print the full location of the folder you are working in
  • mkdir [name] - make directory: create a new directory, with the given name after a space
  • touch [file_name] - create a new file, with the given name (don't forget to add the extension, like .css or .html)
  • rm [file_name] - remove a file
  • rm -r [directory_name] - remove a directory (and all files inside that directory)
Getting Help
When you're stuck and need help with a command, help is usually only a few keystrokes away. Help on most commands is built right into the commands themselves, available through online help programs (such as, and of course online.
Using a command's built-in help Many (but not all) commands have simple help screens that can be called with special command flags. These flags usually look like -h or --help. Example: grep --help.
Online manuals: the man pages The best source of information for most commands are the manual pages, also known as the man pages. To read a command's man page, type man plus a space and the command.
man ls
Get help on the ls command
man man
Get the manual for info on the manual!

Beginner Level



By the end of this chapter, you should be able to:
  • Define what Terminal is and how it is structured
  • Navigate through and list files on your machine
  • Define the following terms: shell, terminal, directory, absolute path, relative path
print working directory: shows current location
cd, chdir
change directory; returns to the home directory
cd directory
cd directory
change into the specified directory
cd ~
~ means home directory; shortcut to the home directory
cd ..
cd ..
move up one directory
cd -
returns to the directory of your previous location
dir /w
list all files in current directory
ls directory
dir directory
list all files in the specified directory
ls -l
list all files in long format: one file per line, with info about the file
ls -a
dir /a
list all files, including hidden files (= filenames that start with .)
ls -ld directory
show detailed information about the directory
ls /usr/bin/d*
dir d*.*
list all files starting with d in the /usr/bin directory

What is Terminal?

Terminal is an application that gives us a command line interface (or CLI) to interact with the computer. Everything you can do in Finder/Windows Explorer you can do in Terminal. Developers use Terminal because it is usually much faster to use Terminal than a graphical user interface (GUI) such as Finder/Windows Explorer. Although the Terminal interface can seem daunting at first, with a bit of practice, you'll be up to speed in no time!

What is a shell? Bash/ZSH

You will also hear the term "shell" when learning about Terminal so it is important to distinguish between these terms. From Stack Overflow:
The shell is the program which actually processes commands and returns output. Most shells also manage foreground and background processes, command history and command line editing. These features (and many more) are standard in bash, the most common shell in modern linux systems. (We are using zsh).
A terminal refers to a wrapper program which runs a shell. Decades ago, this was a physical device consisting of little more than a monitor and keyboard. As unix/linux systems added better multiprocessing and windowing systems, this terminal concept was abstracted into software.
If you are using Windows, there is a great tool called Babun, which is a shell that you can install and use the same commands as if you were on Mac or Linux. This is not essential, but using it will enable you to more easily follow along with the material.

How Terminal is Structured

In Terminal, all files and folders begin at the root directory. The root directory is noted by a /. Inside the root directory are essential files/folders that your machine needs, but we do not modify the files and folders in the root directory often. Inside of the root directory, we have a folder called Users which contains all of the user accounts on your computer. If you move into the directory for your user account, you will be in the home directory, which is denoted by ~. For example, if your user name on the computer is eschoppik, then your home directory would be /Users/eschoppik. A synonym for the /Users/eschoppik path is ~ when you are logged in as eschoppik.

Moving Around

The first thing you want to start to understand when using Terminal is how to navigate from folder to folder. One of the most common commands you will be using in Terminal is cd which is short for "change directory." In order to change a directory, type cd followed by the directory or a path to the directory. If we want to move up a directory we use cd .. and if we want to move into a directory we specify the name of the directory we are moving into. For example, if you are in your home directory and type cd Desktop, you should move into your Desktop directory.
We just mentioned that you can type cd followed by a directory or path. But what is a path? Let's learn some more vocabulary:

Absolute Paths vs Relative Paths

A path is simply the way to reach a file or folder; it's like an address for the file or folder you're trying to reach. When we specify a path starting from the root directory /, we call that an absolute path. For example, if I am currently in the ~ home directory and I would like to change directories into my Desktop folder, I can do that in two of the following ways:
  1. 1.
    cd Desktop - relative to where I am currently
  2. 2.
    cd /Users/eschoppik/Desktop - absolute, starting from the root (first /, then Users, then eschoppik, then Desktop)
Questions to Answer
  • What is the difference between / and ~? What do we call each of these directories?
  • What command do we use to change directories?
  • What is the difference between an absolute and relative path?

{ Working with Files and Folders. }


By the end of this chapter, you should be able to:
  • Create files and folders in Terminal using mkdir and touch
  • Move files and folders in Terminal using mv
  • Copy files and folders in Terminal using cp
  • Remove files and folders in Terminal using rm and rmdir
  • Explain what a flag is in Terminal
  • Explain what the following commands do: whoami, pwd, cat, echo, less, open
copy a file from one location to another
rename, ren, move
moves a file to a new location, or renames a file
remove (= delete) a file
create a new directory
rd, rmdir
remove a directory

Creating Files And Folders

Now that we have a good understanding of how to change directories and navigate in Terminal, let's see how we can create our own folders and files. To create a folder we use the mkdir command (short for "make directory"), followed by the name (or space-separated names) of the folder(s) that we would like to create. So let's head over to our Desktop and create a new folder called first_folder.
cd /Users/$USER/Desktop
mkdir first_folder should be asking yourself, what is that $USER thing? It is an environment variable in your shell that keeps track of the current user of the shell. You can also see who $USER by typing echo $USER or by using the command whoami. Try out both methods of checking who the current user is.
As another side note, this tutorial will use absolute paths to navigate, just to make it easier for you to follow along. However, don't feel like you MUST use absolute paths over relative ones.
Now that we made the first_folder, how do we change directories into it? If you are thinking of the cd command, you're right! So let's cd /Users/$USER/Desktop/first_folder. Or, if you are already in your Desktop, you can just cd first_folder.
We just mentioned "if you are already in your Desktop." How do you know which directory you are in if you forget? Thankfully, there is a handy command called pwd which will display the absolute path and let you know what current directory you are working in. So if you are ever unsure, just type in pwd (which is short for present working directory).
Now that we are inside our new folder, first_folder, let's create a new file. A simple way to create a file is with the touch command. The touch command simply creates an empty file. Let's create a file called first_file: touch /Users/$USER/Desktop/first_folder/first_file. Alternatively, if you are currently in the first_folder directory, you can simple type touch first_file. Now use the ls command to verify that your file was created. ls, which is short for "list," will list all of the files and folders in your current directory.

Displaying Contents Of A File

A very common command to display the contents of a file is the cat command. If you type cat NAME_OF_FILE you can see the contents of the file easily, right there in Terminal. Try it out on the file you just created, first_file. You should see no output after pressing enter. There is no output because first_file is empty.
Let's add some text to the file so that we can use cat. Type:
echo "Hello World" > first_file
The echo command simply writes text to the terminal. The > is called a redirect. The > redirects the output from the command on the left side into the file on the right hand side. We will see more redirects in the next chapter.
Now try using cat on the file again. Do you see Hello World?
There are other ways of seeing the contents of a file in the terminal. Try using the command less: less first_file. less is a program that displays the contents of a file and allows the user to navigate up and down through the file or search for text in the file. To exit less, just press q.

Opening up a file

If you would like to open up a file, you can use the open command. So if we want to see the contents of first_file we can do open first_file. The open command is also very useful if you want to open all the files and folders in a directory (using your operating system's user interface). Try typing in open . and see what happens! If you are on Windows, the command to do this is start NAME_OF_FILE

Moving Files And Folders

Now that you understand how to create files and folders, let's move onto another essential operation: moving and copying folders. To move files and folders we use the mv command. Let's try this out!
Head back to the Desktop by typing in cd ~/Desktop and let's make a new file called test.txt (remember that command? If not - stop reading and go through the previous section again). Now on your Desktop you should have a folder called first_folder and a file called test.txt. Our goal is to move test.txt inside of first_folder - let's do that using the mv command. First make sure you are in the Desktop (type pwd to be sure), type mv test.txt first_folder/test.txt, and press enter.
Did it work? You shouldn't see any kind of success message or confirmation from Terminal, but you also should not see an error. This is very common when working with Terminal: you will see error messages if a command is incorrect, but very rarely see a success message. In other words, no news is good news. In this case, to make sure we did the correct thing, let's cd into first_folder and type in ls. We should see test.txt inside of first_folder.

Copying Files and Folders

Sometimes you may want to make a copy of a file or a folder. To copy a file, we use the cp command (short for copy). The general syntax looks like this:
For example, if we wanted to create a copy of test.txt and call it test_copy.txt, we could enter the following command (assuming we're inside of first_folder:
cp test.txt test_copy.txt
If you list all of the files in first_folder, you should now see three text files.
What if you want to copy an entire directory of files? Try moving up a directory from first_folder, and then type cp first_folder first_folder_copy. Uh oh! You should see an error: cp: questions_copy is a directory (not copied).
In order to copy a directory, you need to modify the cp command as follows:
cp -r first_folder first_folder_copy
The -r is called a flag; you can think of a flag for a command as an option that can be passed to that command. To learn more about the flags that you can pass to cp, you can type man cp (man is short for manual, on Windows this command is --help) and use the arrow keys to move up and down. When you're finished, press q to quit.

Deleting Files And Folders

Alright, enough with all of these files and folders, let's get rid of them. Make sure you are inside the first_folder and type rm test.txt. Once again, you shouldn't see much of a response from the terminal, so run a quick ls to make sure that the file is removed. Now that it is gone... where did it go? The Trash? The answer is it is completely removed from your computer. There is no confirmation or undo so be VERY careful when using the rm command. After you have removed this file, go ahead and remove the copied file as well. Finally, remove first_file. Now that the first_folder is empty, let's move up a directory and remove the first_folder directory itself.
Here you may run into a problem. If you try to use rm on a directory, you will see this message: rm: first_folder: is a directory. It turns out that rm is for a file, while the command rmdir is used to remove (empty) directories. So, let's use the rmdir command to remove first_folder. Make sure that there is nothing else inside that folder, or else you will see a message that looks like this: rmdir: first_folder: Directory not empty.
If there is anything inside the folder, you will have to use rm -rf first_folder. Like we saw with cp, the r and f in -rf are examples of flags. How can you learn more about the flags for rm? Go ahead and remove the first_folder_copy directory using rm -rf.
  1. 1.
    Create a file called name.txt.
  2. 2.
    Try renaming the file to rename.txt using the mv command. What does this tell you about the command?
  3. 3.
    Using the cp command, make a copy of rename.txt and call it copy.txt.
  4. 4.
    Remove the file copy.txt.
  5. 5.
    Create a folder called questions.
  6. 6.
    Change directories to the questions folder.
  7. 7.
    Create a file called first.txt.
  8. 8.
    Create a file called second.txt.
  9. 9.
    Go back a directory and make a copy of the questions folder and call it questions_copy.
  10. 10.
    When using cp -r what is the -r called? What does it do?
  11. 11.
    Delete the original questions folder and the copy.

{ Listing Files and Flags. }


By the end of this chapter, you should be able to:
  • Understand what the ls command does
  • Define flags and describe how the syntax works
  • List files using flags

Listing Files

As you saw in the previous chapter, one of the most important commands you are going to be using is ls, which lists the contents of a directory. If you type ls in a directory you will see all sorts of content. For example, typing ls in your home directory will show you all of the files and folders inside of that directory. Typically your home directory contains folders such as Desktop, Documents, Downloads, Music, Pictures, etc.
Sometimes the default ls command does not give us all the information we want. In such cases, we'll need to add some flags to get more details.


In the previous chapter, we saw how flags could be used to modify the behavior of cp and rm. Flags can change and even enhance commands and are added using a - after the command. Flags are usually represented by single uppercase and lowercase letters. With the ls command, we can pass in the -a flag to list "all" files (including hidden files and folders). If we want the ls command to give us more information about each file, we can pass in the -l flag. To combine flags we can just use one - and pass in each flag. So the command to use ls and show all files and more detailed information about each one would be ls -la.
Using flags for ls will be essential when working with permissions as well as when you start working with git. We will also see many other terminal commands which accept flags later in this course.

{ Terminal Basics Exercises. }

Write the following terminal commands to perform the following tasks:

Part I

  1. 1.
    make a directory called first
  2. 2.
    change directory to the first folder
  3. 3.
    create a file called person.txt
  4. 4.
    change the name of person.txt to another.txt
  5. 5.
    make a copy of the another.txt file and call it copy.txt
  6. 6.
    remove the copy.txt file
  7. 7.
    make a copy of the first folder and call it second
  8. 8.
    delete the second folder

Part II

  1. 1.
    What does the man command do? Type in man rm. How do you scroll and get out?
  2. 2.
    Look at the man page for ls. What does the -l flag do? What does the -a flag do?
  3. 3.
    Type the following command to download and save the contents of curl > google.html
  4. 4.
    Use less to look at the contents of google.html.
  5. 5.
    Look at the man page for less. Read the section on /pattern. Search for the text hplogo in the google.html file.
  6. 6.
    How do you jump between words in the terminal?
  7. 7.
    How do you get to the end of a line in terminal?
  8. 8.
    How do you move your cursor to the beginning in terminal?
  9. 9.
    How do you delete a word (without pressing backspace multiple times) in terminal?
  10. 10.
    What is the difference between a terminal and shell?
  11. 11.
    What is an absolute path?
  12. 12.
    What is an relative path?
  13. 13.
    What is a flag? Give three examples of flags you have used.
  14. 14.
    What do the r and f flags do with the rm command?

Intermediate Level


{ Permissions and Links. }


By the end of this chapter, you should be able to:
  • Determine the permissions set for a file or a directory
  • Manage and change permissions using chmod
  • Manage and change users and groups using chown and chgrp
  • Explain what root is, and the relationship between root and sudo
  • Create links in the file system using the ln command
  • Explain the difference between a hard and a symbolic link


When you're working in Terminal, you may sometimes find that you're not allowed to do things you want to do. Maybe you're trying to install something, or move a file from one directory to another, and you get an error telling you something along the lines of "permission denied." These sorts of permissions errors are extremely common, so understanding how to deal with them is important. That's what we'll learn how to in this chapter.

Users and Groups

Before you learn about permissions, you first need to understand users and groups. Let's take a look at an example. Head to your home directory and list everything using the ls -lah command. (Not sure what the h flag does? Check the manual!)
The output you get might look something like this:
The details of these files aren't important. What you should see is a bunch of rows of output, one row for each file or directory. Let's figure out what all of this actually means. For instance, here is the line for the .bashrc file from the above screen shot:
-rwxr-xr-x 1 eschoppik staff 67B Aug 29 2014 .bashrc
The third column specifies the username of the user that owns the file. In this case, eschoppik is the owner of the file. The fourth column specifies the name of the group associated with the file. In this case the group staff is associated with the file.
In most Mac systems, users are also members of the staff group. To see which groups you are a member of, type the groups command in Terminal. The staff group will likely be one of the many groups you are in. As we will see next, permissions can be set for the owner of the file, a user that is in a group associated with the file, or a user that is neither the owner nor a member of the associated group.


Let's take a look at that .bashrc line again:
-rwxr-xr-x 1 eschoppik staff 67B Aug 29 2014 .bashrc
We've already talked about the third and fourth columns in this output. Now let's talk about the first column. The -rwxr-xr-x refers to permissions of the .bashrc file. Each character of the permissions string, -rwxr-xr-x describes something about the file's permisisons. But what are permissions? A file's permissions is a set of rules that describes which operations a user can or cannot perform on a file or folder. There are 3 types of operations that can be allowed or not allowed:
  • r - reading the file
  • w - writing to the file
  • x - executing the file (we will go into this in more detail soon)
You may be asking at this point, why is the permissions string so long if there are only 3 operations that can be specified? Well, a permissions string describes different types of users that can or cannot perform read, write and execute operations. You may be one of 3 different types of users:
  1. 1.
    The owner of the file.
  2. 2.
    Not the owner, but a member of a group associated with the file.
  3. 3.
    Other. Not an owner and not in a group that is associated with the file
So a permissions string specifies the permissions for all 3 types of users plus an extra character to specify the type (file, folder, etc).
Here is how the above permissions string breaks down:
In other words, this string says that .bashrc is a file, that the owner of the file can read, write, and execute, users in the group can only read and execute, and other users can only read and execute as well.

Changing Permissions

To change the permissions of a file we use the chmod command. For each set of permissions (owner, group, everyone) we can assign a number from 0 to 7. This is called octal (base-8) notation. Here's a table that illustrates what each number means.
rwx (display in terminal)
write only
write and execute
read only
read and execute
read and write
read, write and execute
So if we want to change a file so that only the owner and group can read, write, and execute, we would type chmod 770 somefile.txt.
If you'd like to be a bit more specific, you can also set permissions using what's called symbolic notation. Here's an example of what that looks like:
chmod ug+rwx,o-rwx hi.txt
This is saying "add read, write, and execute permissions to the user and the group, and remove read, write, and execute permissions from other." While a bit more verbose, it's also a little more descriptive. To see more examples of symbolic notation, check out this article.
If we want to change permissions for a folder, we need to add the -R flag: chmod -R 755 some_folder.
You can read more about chmod here.

Executable Files and Folders

Now let's talk a little bit more about what the x (executable) means for a file or a folder's permissions. If you have executable permissions on a folder, it means that you can cd into it. See what happens with the following commands:
mkdir test_folder
cd test_folder
cd ..
chmod 666 test_folder
cd test_folder
You should see an error saying permission denied. Add the execute permission back to the folder, and then remove the folder.
Now onto executable files. When a file is executable, it can be run from your shell as if it were a program. Let's first create our file. Type the following in your terminal:
echo ls >
echo pwd >>
echo pushd . >>
echo "cd ~" >>
echo "pwd" >>
echo popd >>
The file should look like the following now:
pushd .
cd ~
(Did you notice that our first echo command used a single arrow (>), while the other commands used two? We'll explore the difference between these two operators in the next chapter!)
Now let's make the file executable and run it. Use chmod to make it executable: chmod 755 Next, execute the file by providing a path to the file. In our case, the file is in the current directory, so to execute it, we do the following: ./ We just made our first executable shell script!

chown and chgrp

Now that we have a clearer understanding of users, groups and permissions, let's take a look at the line from ls -lah again:
-rwxr-xr-x 1 eschoppik staff 67B Aug 29 2014 .bashrc
  • The 1 refers to the number of files (this will always be 1 for files)
  • eschoppik is the "owner"
  • staff is the group
  • 67B is the size of the file
  • Aug 29 2014 is the last day the file was modified
  • .bashrc is the name of the file
So what if we don't want eschoppik as the owner of the file any longer? Or what if we want a different group to own that file? We can use one of the following commands:
chown anotheruser:anothergroup .bashrc
Or if we just want to change the group:
chgrp anothergroup .zshrc.
Now let's take a look at this line from the ls -lah command:
drwxr-xr-x 6 root admin 204B Oct 20 2015 ..
The other file said eschoppik for user and staff for group, but this one says root and admin. We can also see that this is a directory because it starts with a d before listing the permissions. So what is the root user?

root user and sudo

The root user is a special user on your computer that has the power to do anything it wants. It can change permissions on any file, delete anything it wants, etc. When you see root as the owner, and you want to make a change to that file, you have to use a command called sudo. The sudo command gives you the powers of the root user for just one command and will ask you for your password in order to preform the command. Try out commands with sudo. Create a file called somefile.txt. Then make the owner the root user:
sudo chown root somefile.txt
Now try to delete the file without using sudo. You are not allowed. Look at the permissions. Why is this not allowed?
Since we have files and folders located all over our file system, it becomes difficult to identify where many of these are located. Fortunately, we can create a link (also known as an alias) to a file or folder using the ln command. The structure looks like this:
ln path_to_link name_of_link
There are two kinds of links we can make, hard and symbolic links - let's see how they work!
Let's create a file called learn.txt in our Desktop folder (type in cd /Users/$USER/Desktop if you need to get there). We can open up our learn.txt file using open learn.txt and let's add the text "Learning about links!".
Now let's create a link to this file! We can call our link first_link. To do this we use the ln command and type ln learn.txt first_link. Now if we cat first_link we should see the output "Learning about links!".
If we decide to move our learn.txt file anywhere we still have a link to it through first_link! Pretty awesome!
If we decided to delete our learn.txt file, what happens to our hard link? Let's rm learn.txt and then cat first_link. We still see that we have a link! This might seem strange; shouldn't a link be broken if a file is removed? Not with hard links! You can think of a hard link like a direct copy of a file. If the file is removed, the link still exists.
We saw that when we remove the original file, any hard links still remain and contain the entire source file. This is usually not what we want, since we usually want a reference to some file and not a direct copy. To create a reference instead of a copy, let's make a symbolic link.
To create a symbolic link, we use the -s flag when creating a link. Let's create a new file called learn_again.txt and then create a symbolic link using ln -s learn_again.txt first_sym_link. If we cat first_sym_link we do not get any errors! But if we delete or move learn_again.txt, our first_sym_link will be broken!
We can also use symbolic links for folders as well, which makes it very useful if we need to access a folder but do not remember the path. However, if your original file/folder path changes or is removed , the symbolic link will break!

{ Redirection. }


By the end of this chapter, you should be able to:
  • Explain what redirection is
  • Explain the difference between >, >>, and <
  • Use redirection to work more effectively in Terminal


Sometimes instead of simply displaying the output from a command to the terminal, it's useful to take the result output of a command and send it somewhere else. We call this "redirection" and it is denoted by >> or >. Let's start with a simple example using the echo command.
The echo command is useful for displaying text to the terminal, but many times it is more useful to take that text and redirect it to a file. In Terminal, type the command echo Hello World > hello.txt. Then, using the cat command, let's see what we just did by typing cat hello.txt. All we did here is take the text "Hello World" and instead of displaying it to the terminal, we sent it to a file called hello.txt!
Run the same command again but with slightly different text: echo Hello Universe > hello.txt. Now cat the file again. Notice that your new text completely overwrote the old text: you should see that "Hello World" has been replaced by "Hello Universe." In other words, when you use >, whatever text you're echoing into the file will completely overwrite any text that might already be in the file.
Maybe this is what you want, but maybe not. What if you're trying to append some text to the end of the file, rather than overwriting the text? In this case, use >> instead. Try it out: echo Hello World >> hello.txt. Now cat the file. You should see the following:
Hello Universe
Hello World
One very common use case for redirection is to put small pieces of text in a file. Instead of opening a text editor, typing in some text, saving it and closing the file we can do this all in one step.

Redirection with Input

So far we have seen redirection using > and >>. These arrows indicate redirection with standard output (take something and output it to something else). However, we can also use redirection with input as well using the < arrow. Let's use a command called sort, which sorts a file alphabetically. Imagine we have a file called names.txt with the following names:
If we want to sort this file, we can type sort names.txt and it will output
Now what if we want to take the contents of names.txt, redirect that to the sort command, and then send that output to a file called sorted.txt? The redirection will look like this: sort < names.txt > sorted.txt. This will now create a new file called sorted.txt with the names sorted alphabetically!
This might seem a bit strange, but try typing these commands and see what information you can output and redirect. As we see right now, we are only using the sort command, but what would happen if we wanted to use other commands along with sort? We would somehow need to connect each of these commands together. We connect these commands together through something called "pipes."

{ Piping. }


By the end of this chapter, you should be able to:
  • Explain what the head, tail, sort, uniq, wc and grep commands do
  • Define what piping is
  • Understand use cases for piping
  • Use piping to better work in Terminal


At the end of the last chapter, we saw how we could use redirection to combine a couple of commands into one. In that case, in a single line we were able to both sort a text file and output the contents to a new file.
But what if we want to chain even more commands together? This is where piping comes into play. Before we learn about piping, though, let's learn/review a couple other terminal commands.
head - display the first lines of a file (using the -n flag we can specify the number of lines)
tail - display the last lines of a file (using the -n flag we can specify the number of lines)
sort - sort lines of a text file
uniq - removes duplicated lines (your data must be sorted for this to work)
wc - word, line, character and byte count
Now let's create two files - first.txt which contains the text
And second.txt which contains:
If we want to concatenate (join) these two files together, we use the cat command:
cat first.txt second.txt (make sure the files and commands are separated by a space).
But what happens if we want to concatenate these two files and then find the word count? What if we want to concatenate and then sort it? This is where we need piping! You can think of a pipe as a connection between the output of one command into the input of another command. So once we concatenate two files we then want to send (or pipe) the result of that to another command. We can even combine this with redirection!
To pipe a command we use the | character. So if we want to pipe cat into sort it would look like this:
cat first.txt second.txt | sort or cat first.txt second.txt | sort | head -n 2
Take a look at this command and try to figure out what it's doing. You'll find a step-by-step answer below.
cat first.txt second.txt | sort | tail -n 3 | head -n 1
  1. 1.
    Concatenate the two files first.txt and second.txt
  2. 2.
    Sort the results
  3. 3.
    Find the last 3 lines
  4. 4.
    Find the first line of those last 3 lines
This is how we can find the third from last line in a file (without knowing how many lines the file has).


Let's examine another useful command called grep which is extremely powerful for finding text. On its own it is helpful, but it is quite useful when piped with cat. Let's try a simple example with cat first.txt | grep First - what do you see?
You should see the word First output to the terminal. This is because grep searched the file for the text First and found a match!
Notice that if grep doesn't find a match, it won't output anything. If it finds multiple matches, it will print them all. Try out these commands and see what grep returns to you!
cat first.txt second.txt | grep Nope
cat first.txt second.txt | grep th
Let's look at another example. Imagine you have a file called petnames.txt, and inside you have the following list of names:
We see here there are quite a few duplicates, so let's try to use the uniq command to remove these duplicate names. The problem is, when we run uniq petnames.txt we get the following
If we look back at our definition of how the uniq command works, we see that our data must be sorted! So how can we first use sort on petnames.txt then attach the uniq command? Piping to the rescue!
sort petnames.txt | uniq gives us
This looks great! But this text is just being output to the terminal, what if we want to output this text to a new file called petnames_sorted.txt? We can combine piping with redirection and use sort petnames.txt | uniq > petnames_sorted.txt. Now if we cat petnames_sorted.txt we should see our four unique sorted names!

{ Permissions, Redirection, and Piping Exercise. }

Write terminal commands to do the following:
  1. 1.
    Create a file called restricted.txt.
  2. 2.
    Change the permissions on the restricted.txt file to allow the owner to read and write to the restricted.txt file. Do this using the Octal Notation.
  3. 3.
    Change the permissions on the restricted.txt file to only allow the owner, group and everyone to read and write and execute the restricted.txt file. Do this using the Symbolic notation.
  4. 4.
    Create a folder called secret_files. Inside the secret_files folder create a file called first_secret.txt and another folder called classified. Inside of the classified folder create a file called super_secret.txt.
  5. 5.
    Change the permissions on the secret_files to only allow the owner and group to read, write and execute in all the files and folders inside of secret_files. Do this using the Octal Notation.
  6. 6.
    Create a hard link for the restricted.txt called hard_link.
  7. 7.
    Create a symbolic link for the classified folder called classified_link.

Part II (Piping and Redirection)

For the following exercises, create a text file called vegetables.txt with the following text:
Write the following terminal commands to do the following
  1. 1.
    Sort vegetables.txt.
  2. 2.
    Count the number of lines in vegetables.txt.
  3. 3.
    Create a file called vegetables_sorted.txt which contains all the unique vegetables sorted in ascending order in vegetables.txt (do this without the touch command).
  4. 4.
    Create a file called last_three.txt which contains the last three vegetables in the vegetables.txt file (do this without the touch command).
  5. 5.
    Count the number of lines the word "Broccoli" appears on (using wc and grep).

Development Tools

Visual Studio Code

Visual Studio Code or VS Code is an IDE. IDE stands for Integrated Development Environment. It is the software that you will be using to write most of your code. It is designed to help you develop your apps quickly, focusing on the problems that you need to solve instead of having to search online for minor details.
One of the most important features of an IDE is that it provides auto-completion. This means that it will give you suggestions of what you can write next, while you are typing something.
For example, when writing a CSS property, VSC will tell you what values you can assign to this property.
File tree view
The reason why we call an IDE integrated is that you almost don't need to leave the window when you are write your code. For example, creating, renaming and moving files can be done directly from the IDE. This functionality can be achieved from something called a tree view. You can find this view on the left side of your IDE.
Finding files
When working with big projects, you will often need to find a file quickly, without having to go through the tree view manually.
Enable formatting on save
To automatically give your code the right format:

{ OPTIONAL } Visual Studio Code Extensions For Web Development

Visual studio code offers a wide range of extensions. Here is how to install the extension.
Press SHIFT+COMMAND (or Windows)+X or just click on the extension icon of visual studio code. Search for the extension and press install
Here are some visual studio code extensions for web development. The choices of the extension are ones personal opinion.

1: Javascript (ES6) Code Snippets

No need to mention that JavaScript is the core of web development. There are lots of code snippets that we used on a daily basis and this extension helps you by not writing that repetitive code again and again.
It provides JavaScript, TypeScript, Vue, React, and HTML code snippets. This is a must-have extension for web development.
You can install it by searching the name on the extension section of the visual studio code.

2: CSS Peek

As its name suggests, this extension lets you jump to the CSS code using classes and IDs.
You can install it by searching the name on the extension section of the visual studio code.

3: Auto Close Tag

This extension automatically adds the closing tag of HTML and XML.
You can install it by searching the name on the extension section of the visual studio code.

4: ESLint