Important:  I expect you to work in pairs for all in-class exercises.  Your partner is the first one to talk to with questions - discuss everything with them first! 

Then if you and your partner have a question together - the TA's or PG will be happy to work with your group to help solve it.  You may also communicate with students outside of your group.  Find yourself a partner, or PG will do it for you.  You don't have to stick with a partner all semester, but that has usually been the case in the past.  

Today's class is meant to give you a brief introduction to navigating around your directories on Linux, looking at text files, editing text, etc.  The first thing to do is to try and login to Rivanna using the OnDemand interface - follow the instructions below under (1).  After you login to Rivanna, work through the 5-minute Linux guide. 

Important: Refer to the getting_started page for instructions on connecting to your rivanna account. rivanna is the name of a cluster of PCs provided by UVA IT; we will use rivanna extensively throughout the semester.  We will learn much more about Rivanna next week.

Class exercise work is due by noon of the following day.  In-class exercises will be graded only based on participation.   In the next class, we will setup GitHub accounts for turning in work in this class.  For today, just show your Rivanna linux command-line window to a TA or PG after completing your work. 

Last thing: At the end of your class period, log out from rivanna, and close all browser and terminal windows.


1. Logging in with an On Demand virtual session

  • 1st time logging into Rivanna - Prof. Group should have made your account in advance of the first class (unless you just added the class this week - in that case talk to Prof. Group).  Note: if you have trouble logging in, you may need to reset your netbadge password - that is the most common issue.  See this link for information on how to reset your password.

  • We are basically following the instructions here - Use a web browser on your laptop or the lab computer to go to:https://rivanna-portal.hpc.virginia.edu/pun/sys/dashboard
  • Use your Netbadge username and password to login.

  • Once you follow the instructions here, a new tab should open in your browser that displays a remote desktop on the rivanna cluster.
  • In order to get the terminal, click the picture of the screen on the top toolbar.
  • In the terminal, Try the following commands:
    • ls
    • ls -al
    • pwd
    • history
    • More later…
  • Note that it may be easier to copy and post from this webpage into the OnDemand session if you open the webpage in the OnDemand window.  Try Firefox!  Make sure to close Firefox properly before you logout! 

2. Start working with the Linux shell

Note:  If you are not able to login to Rivanna yet, you may do some of the exercises below (explore basic linux commands), with this linux emulator in your browser window.

First, review the basic Linux Shell commands in the 5 minute guide

  • Log in to Rivanna if you are able to do so.  (If not make sure PG has you on the list)

  • When you log in you will be in your home directory. Follow these steps to create and navigate into some new directories.

  • Execute the command pwd to see the location of your home directory (your home directory is where each of your log-in sessions start).

  • Type mkdir phys1655 to create a new subdirectory named phys1655 in your home directory

  • Type cd phys1655 to enter into this new subdirectory called phys1655

  • Type mkdir class01 to create a new subdirectory named class01

  • Type ls to see the files in your current directory.

  • Type cd class01 to enter your the class01 directory.

  • Type ls again. You should see nothing, because we created the new directory, but did not populate it with files or other (sub)directories.

  • Now create the directories: test1, test2, and test3 under the class01 directory using mkdir.

  • Type ls to list the files in your directory. Next type ls -l to get a long listing of the files in your directory. ls -l lists the files size in bytes, the modification date, file owner, etc. Notice that the listings for all of your directories begin with “drwx”. “d” means the file is actually a directory, the “rwx” means the file owner (i.e. You) has read, write, and execute access.

  • You may now return to your top/home directory by typing either of these commands:
    cd (with no arguments returns to your home directory)
    cd ~ (~ is shorthand for your home directory)
    cd .. (“..” is shorthand for the parent directory)

  • Move into the directory named phys1655/class01/test1 using cd. Create a new file with the command touch file1.txt
    This command will create a file called file1.txt. Now we want to edit this file; do this via nano file1.txt – this command opens the text file editor program called nano and loads file1.txt as the file you are going to edit. You should see a screen resembling this one (but your screen colors may be different). Type some random text and refer to the editors page for instructions on using 'nano'. Make the text several lines (at least 20) long. Somewhere in your file include the word “python” in several random locations. Exit and save your text by typing control-x (also written as ^x) and following the on-screen prompts.

  • View your text file using the more command: more file1.txt Next, view your text file using the command less file1.txt Within the less command type: /python to search for the word “python”. Hint: to exit “less” just type “q”. Next observe how you can dump your file contents to the screen using the command: cat file1.txt

    Use the same commands to view a longer file already on the system, for example: less /etc/inittab. Don't worry about the file contents, this is just an example to get you familiar with the commands.

  • You can search your file for the word “python” using the grep command: grep python file1.txt

  • Make a copy of your original file called file2.txt: cp file1.txt file2.txt, and then do an ls to verify the result, ie, the new copy of the file. Do you see the new file called file2.txt?

  • Rename a file using the command: mv file2.txt file2b.txt
    Note: don't confuse the rename command with mv, rename is typically used to change the names of a group of similar filenames. Do an ls to verify the result of the mv command. Do you see the file called file2.txt any longer?

  • mv can also be used to move a file from one directory to another, if you include the new directory path in the new filename. Now move a file to a different directory: mv file2b.txt ../test2
    This command will move the file2b.txt into the test2 directory, which recall is a subdirectory of your parent directory class00. Verify the result of this command.
    (../test2 means move up one directory then down into test2)

  • Explore the other Linux shell commands described in the 5 minute guide. The best way to gain experience in using a computer system is to work with it and to try things out!  Make sure to learn to use the "tab" key for autocomplete and the "up arrow" key for using commands from your history (it can make you faster and much more efficient).  If you start typing a command, for example "ls file1" and then it tab, it will complete the command for you if unique.  If it is not unique you can hit tab twice and will list the possible option. 


 To get participation for today's in-class activity:  Introduce yourself to a TA, or PG, and show us your Linux command terminal.   In our next session, we will learn to use Git/GitHub and use that for all future assignments. 



Summary

This introductory exercise provided us with some foundational knowledge that will be essential going forward in this class. If you struggled with any of these concepts, I recommend return to it and doing them again on your own.  Also, consider going to office hours next week for more practice with someone who can explain things to you.  It is important not to fall behind in this class, as history promises it is very difficult for students to catch up!

All of the work for the class may be done with the OnDemand (and later with Jupyter Notebooks). However, it can be more convenient to setup a terminal on your own laptop. If you completed all of the items above try to establish connections to rivanna using your personal laptop during the remaining class time.  You should go to this link, follow the additional link there and complete the instructions that are appropriate for either Windows or Mac, depending on the kind of computer you own/are using. You may need to download some additional software to make this work – but this will be a helpful process to go through, preparing you to use your personal laptop/PC efficiently for the rest of the semester.



  • No labels