Due Date: Tuesday, January 26, 2021.
In this lab we will do an introduction to Linux, make sure that you can log into our system, and see some of the operations that can be done through a terminal.
Most of this lab will be done in a terminal-type session. If you work directly on one of the Linux machines in our labs, then all you have to do is open a terminal. If you are working from a Windows or Mac machine, you will need an application (putty or terminal) that connects remotely to one of our Linux computers in the labs with a terminal-type session. Instructions for each situation are found below in the section Tools. Note that only one of the paragraphs of that section applies to you (you must choose it based on your computer type).
Your IU username and password, that you use to access the IU sites and log on to the campus computers, should now also be working to login on Linux. If not, contact me or our lab administrator Will Keeler (NS #203, wkeeler at iusb dot edu).
Note. The login prompt is setup not to echo anything when you type in the password. Whatever you type is still input normally, you just don't see anything. Also, if you attempt to login and fail for 5 times within 5 or 10 minutes, your home computer will be blacklisted, so if you fail to login 4 times, take a break of a few minutes before you try again.
Tools
Starting up. Follow the instructions for the type of system that you are working on.
ssh cs##.cs.iusb.edu -l username -XY
where ## means a 2-digit number between 01 and 03. You may have to
try several numbers to find one that works because some of these
computers may be booted in Windows or MacOS, in which case they will
not respond to this command. Replace "username" with the name of your
account. This opens a remote secure session on the machine that you
specified. You will be prompted for a password.
Here is an example of a connection being established.
cs##.cs.iusb.edu
where ## means a 2-digit number between 01 and 03. Make sure that
the connection type is SSH, like in this example.
You may be asked to confirm that you want to connect to this machine
by a security alert system the first time you log on to a particular
host, like in this example.
Just answer yes. A terminal window will open where you will be
prompted to enter your username and password, like in this
example.
These should be your usual IT information. You may have to try several
computer numbers until one works (see Mac section above).
On your home computer, you may want to bookmark the session information for easy access. You can enter the username and remote host name, then give it an easy name to remember in the Saved Sessions box, and click Save. After that you'll be able to launch the session again by double-clicking on the bookmark name in the list. It is not recommended to save the password.
To make it easier to save the terminal, you can click on the little icon in the top-left corner of your putty window, and from the pop-up menu, choose "Change Settings". There you can click on Logging, and check the "Printable output" option or the "All session output". Then hit the Browse button to choose where to save the session under the name "putty.log" or whatever name you choose for it. That file, that you can rename later as "lab0term.txt" or "hw1.txt" or whatever name is appropriate for your session, will be part of what you turn in for this lab and for most of the labs and homework assignments.
Your working (or current) directory when you login is called your home directory. It is a folder named after your username and located in a folder called /home. Most commands will apply by default to files in your working directory, and a little later you'll learn how to change it. To see the path of the working directory, type the command pwd, then hit the Enter key. It stands for Path of the Working Directory.
A command is a small executable that performs some operation involving the file system, the processes, or the operating system. For example, the command ls stands for "list" and will display a list of the files residing in the current working directory. Try it.
Commands can have arguments specifying what they apply to. For example, for the command ls, we can ask it to list the files in a different directory than the current one by providing this other directory as an argument (/var/log/ in the following case):
ls /var/log
Commands can also have options that modify the way they are executed. For example, an option for the command ls would be "-l" (lowercase El) that makes it display the list of files with a long list of properties or attributes:
ls /var/log -l
Arguments and options are usually flexible. Try the previous command again while swapping the places of the option and the argument. The result should be the same.
Options can be provided separate, or grouped together. For example,
the option -a for the command ls will also display hidden files. If we
want to run this command with both the options -a
and -l, we can have them both separated by a space, or use
-al instead. Thus, the following three commands should be
equivalent (make sure they are):
ls -a -l
ls -l -a
ls -al
If you are not sure about what a command does and what options can
be used with it, the easiest way to find out is with the command
"man", which is short for manual (q to exit):
man ls
Commands we'll use below:
Practical:
cd /usr
and check its content with the command ls. Note: this directory is found at the root (top level) of the entire filesystem on that computer (identified by the slash /). Since it is not a subdirectory of the current working directory, we identify its name starting with the slash. This is called an absolute path.
Descend into the include subdirectory with the command
cd include
Note that this directory is directly inside /usr (which should be your current working directory) and for that reason, we do not start its name with a slash. This is called a relative path.
Repeat the operation to go to one of its subdirectories (your choice). Start again with the directory /lib (absolute path again) and then another subdirectory. To go back up in the path of the current directory you can use
cd ..
where the ".." identifies the parent directory (one up) from wherever you are at the moment. A single dot identifies the directory itself.
Find the path of the directory where you are using the pwd command.
mkdir c151
pico lab0pico.txt
ls /u
without any space after "u", and then without completing the word "usr", type a tab. Note that the shell has completed your command. Without pressing enter, type an "l" (lowercase "el") as if you were going to list the files or folders starting with l, and then press a tab again (you may have to press it twice). Since there are several folders starting with l, the shell will display all the possibilities instead of completing the command. As soon as the command can be completed uniquely, the shell will do it. For example, type an "o" and press a tab again. Since "local" is the only possible completion, the shell will complete it for you. Finish the command by pressing enter.
mv lab0pico.txt week0/
Submit the file lab0term.txt containing the text in the
terminal for exercise 2 to Canvas. Under Assignments there is a
section called Lab 0 where you can submit it. The lab is due
next Tuesday at 11:59pm.