On a Windows machine, launch Putty and type the following as the
Host Name:
cs##.cs.iusb.edu
where ## means a 2-digit number between 01 and 30. Make sure that the
connection type is SSH. Example
(putty1.png). You may be asked a security alert system the first time
you log on to a particular host, like in
this Example (putty2.png). Just answer yes. A
terminal window will open where you will be prompted on a second
screen to enter your username and password, like in
this Example (putty3.png). These should be
the ones you get from me. 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 is a name easy 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.
Ex. 2. Introduction to some shell commands.
A command is a small executable that perform some operation
involving the file system, processes, operating system. For example,
the command "ls" stands for "list" and will display a list of the
files contained in the working directory.
Commands can have arguments specifying what they apply to. For
example, for the command ls, we can provide a different directory that
the active one to display the contents of (/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" that
makes it display the list of files with a long list of arguments:
ls /var/log -l
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:
- ls - displays the list of files in a directory
- cd - changes the current working directory
- pwd - displays the path of the working directory
- less - displays the content of a file one page at a time
- mkdir - creates a directory
- pico - simple text editor
- cat - displays the entire content of a file
- cp - copy a file or directory
- rm - remove a file or directory
- man - manual pages (q to exit)
- alpine
Practical:
- If this is a new account for you, it is recommended to change your
password. Use the command "passwd" for this purpose. The rules for the
passwords are about the same as for any modern password system - it
should be at least 8 characters long, should contain at least 1
uppercase or digit or special character and should not be based on a
word that can be found in a dictionary.
- Try out the command ls with and without the option -l. Explore
the content of the directory /usr/ using this command.
- Use the cd command to go
to the /usr directory and move
around it (cd /usr). Descend in the include directory and inside one of its subdirectories
(your choice). To go back in the path you can use
cd ..
Find the path where you are using the pwd command.
- Use the less command to
view the content of one of the files in this folder (the file name
must be an argument for less). To move around inside the text, use the
space, Page Up, Page Down, and the up and down arrow keys. To quit the
viewer, type Q.
- Use the cd command with
no arguments to move back to your home directory.
- Create a directory named "c151" under your home directory. The
command for this looks like this:
mkdir c151
- Use the cd command to go inside this directory.
- Create a text file using the pico editor. You can do that with
the command
pico lab1pico.txt
- Write a few lines in this file, then save them with the command
Ctrl-o. When the program asks you for the file name, just press enter
to keep the same name. When you are done, exit the editor with the
command Ctrl-x. Note that most useful commands for pico are displayed
at the bottom of the window, where the "^" symbol means Ctrl.
- Display the content of this file with the command cat. You only need the filename as
its argument.
- Use the cp command to
make a copy of this file under a different name. First, find out how to
use the cp command using the Linux manual for it. For this, type the
command
man cp
The manual pages are displayed with the less commands, so you can use
its functionality to move around the text.
- Use this information to make a copy of your file under a
different name, like hw1_copy.txt.
- Use the rm command to
remove the file that you have copied.
- Explore the commands that you have just executed using the
right-hand-side slider of the terminal window.
- The Linux shell helps you type your commands faster. The tab can
be used to complete a command that you are about to type. To test this
feature, list the content of the /usr directory by typing
ls /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"
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.
Ex. 3 Saving the content of your terminal.
- On a Linux machine, open a gedit separate window by typing the
command (the ampersand is important)
gedit &
The using the mouse, select the entire content of the terminal (which
should copy it, but if that doesn't work, the Edit menu should let you
copy), then paste it into gedit with Ctrl-V. Save it under the name
lab1term.txt.
- On a MacOS system, locate the Shell menu at the top of the screen
(not of the terminal window) and then do Export Text As... Save the
file as lab1term.txt.
- On a Windows machine under Putty, click on the Putty icon in the
top left corner, and choose Chopy All To Clipboard. Then open a simple
text editor like Notepad and paste the content in a new file. Save the
file under lab1term.txt.
Ex. 4. Using alpine to send an email.
- You have an email related to your cs account, and your address is
username@cs.iusb.edu.
- Launch alpine by typing this command (and press enter). Note: some
computers might still be running the previous Fedora core. If the command
alpine doesn't work, use pine instead.
- If this is the first time you have used alpine, the program will
ask you if you want to be registered as a alpine user. Just press
enter.
- To find the content of your inbox, from the main menu (that you
can always find with m), press enter or l for list, and then enter
again. Your inbox is probably empty for the moment.
- Start composing a message by typing c. In the To field insert my email
address, danav@cs.iusb.edu. Move between the fields using the arrow
keys. In the subject area, type lab 1. The body of the message should
just state your name.
- Attach the file called lab1.txt that you have created before. For
this, move to the Attchmnt field and type Ctrl-t. This will take you to
a file browser that should open in your home directory. Move between
file names with the arrow keys. Locate the folder named c151 and when
its name is highlighted, press enter. This should take you inside that
directory. Select the file and press enter.
- Once your email is ready, type Ctrl-x to send it. Alpine will ask
for a confirmation and you can just press enter.
- Note that most useful commands under alpine can be found at the
bottom of the window, just as for pico. And just the same, "^" means
Ctrl.
Submission. Submit the file lab1term.txt containing the text
in the terminal for exercise 2 to Oncourse. Under Assignments 2 there
is a section called Lab 1 where you can submit it. The due date for
this lab is next Monday at 11:59pm.