Hands On Lab Introducing Linux Terminal
Hands On Lab Introducing Linux Terminal
Objectives
In this lab, you will:
In this exercise, you will explore directories on the cloud IDE Linux system using
the cd command.
cd ~
Copy the command above into the terminal and press Enter to run the command.
This will change your current working directory to the home directory ~.
Note: (In our lab environment, your user's home directory is ~ = /home/theia).
cd ..
This will change your current working directory to the parent of the current working
directory.
If your working directory was /home/theia, then it will become /home.
cd /
This will change your current working directory to the root directory /.
cd bin
This will change your current working directory to the /bin directory.
cd ../home/theia
This will change your current working directory back to your home directory.
cd ~
1.6. Changing working directory back to project directory
cd ../project
This will change your current working directory back to your project directory.
The project directory is a special empty directory we provide for your work.
In this exercise, you will explore browsing the content of directories using
the ls command.
ls is a special command that the shell knows by default. You will learn about many
more of these commands in the future.
ls
Typing ls by itself will show all files inside the current working directory.
If you know the path to a directory, you can view its contents by typing:
ls [PATH TO DIRECTORY]
For example:
ls /
This will show the contents of the root directory.
Director Contains
y
/bin System libraries
/sbin Binaries that require root privileges
/usr User programs and data
/home Home directory
/media Removable media device directories
ls /bin
This will show the contents of the /bin directory.
You might notice one of these files is called "ls". That's because the ls command
runs using the file /bin/ls.
nano is a simple command that enables you to use the terminal as a text editor.
To get the latest supported version of nano, type:
Type "n" and press Enter to continue. Updating nano will take time and will not affect
this lab.
Note: The capital Y in Y/n means it's the default - if you press enter without typing
anything it uses the default y.
Because vim doesn't come with your system, you will need to install it:
In this case, type "y" and press Enter to continue. You will be using vim in a later
exercise.
On the other hand, vim can be harder to learn - though it has many more features.
cd /home/project
Try auto-completing the path by typing cd /home/pr and pressing TAB.
nano myprogram.py
This will create a .py (Python) file called myprogram.py and enable you to begin
editing it using the nano text editor.
Type the following to the file:
ls
You should now see that the file myprogram.py was created in your current working
directory.
python3 myprogram.py
Try auto-completing the command by typing python3 my and pressing TAB.
Practice Exercises
1. Problem:
2. Problem:
3. Problem:
Navigate to the /home/project directory and display its contents.
4. Problem:
Using nano, edit myprogram.py to add a new line containing "print('My name
is ...')" (replace ... with your name)
Hint: To start, you can press the Up arrow until you get nano myprogram.py from your
command history.
5. Problem:
Using vi, create a file called "done.py" that prints "I am done with the lab!"