Git - Basic Shell Commands
Git - Basic Shell Commands
As throughout this eBook, we will be using mainly Git via the command
line. It is important to know basic shell commands so that you could find
your way around the terminal.
The ls command
ls
The output will show you all of the files and folders that are located in
your current directory. In my case, the output is the following:
For more information about the ls command, make sure to check out
this page here.
21
The cd command
cd ebook
Let's take the example from above. If I run the pwd command, I would
get the full path to the folder that I'm currently in:
pwd
Output:
/home/bobby/introduction-to-git
Then I could use the cd command and access the ebook directory:
cd ebook
And finally, if I was to run the pwd command again, I would see the
22
following output:
/home/bobby/introduction-to-git/ebook
Essentially what happened was that thanks to the pwd command, I was
able to see that I'm at the /home/bobby/introduction-to-git
directory and then after accessing the ebook directory, again by using
pwd I was able to see that my new current directory is
/home/bobby/introduction-to-git/ebook.
The rm command
The rm command stands for remove and allows you to delete files and
folders. Let's say that I wanted to delete the README.md file, what I
would have to do is run the following command:
rm README.md
rm -r ebook
Note: keep in mind that the rm command would completely delete the
files and folders, and the action is irreversible, meaning that you can't
get them back.
The mkdir command stands for make directory and is used for
creating one or more new directories. All you need to do in order to
23
create a new directory using this command is to open a terminal, cd
into desired location and run the following:
mkdir My_New_Directory
You can also create serveral new directories by placing the names of
desired directories after each other:
touch README.md
The above will create a new, empty file with the name README.md
One thing that you need to keep in mind is that all shell commands are
case sensitive, so if you type LS it would not work.
With that, now you know some basic shell commands which will be
beneficial for your day-to-day activities.
24