Linux Fundamentals


In the EECS department at the University of Tennessee, we use Linux operating systems.

Navigating the File System

There are two main ways to navigate the Linux file system. You can use the File Browser, accessible by clicking on Places and then Home Folder.

File Browser Navigation

Otherwise, you can use the terminal and the following commands to navigate the file system. To access the terminal, click on Applications, then Accessories, then Terminal. A terminal window will open and you will be in your home area. The following sequence of commands will allow you to view the files that are currently in your file system:

The following commands allow you to change the structure of the file system:

Text Editors

We will primarily use text editors to create and edit our code. There are two main text editors: vi and emacs. Most in our department use vi to create and edit their code, but emacs is also very popular. We will start using vi. Emacs will be introduced later in the semester. If you are already comfortable using a particular editor, feel free to continue using that editor.

Real Programmers

Link to xkcd comic on text editors

To open vi, simply open a terminal and type vi filename where filename is the name of the file you want to open.

To enter insert mode, type I. -- INSERT -- will appear at the bottom of your page. If you are copying and pasting into Vi, Vi must be in insert mode.

To exit insert mode, click ESC, which will return you to command mode.

To save a file in Vi, return to command mode and type :w. W is this instance stands for write. In this instance, write and save are synonyms.

To exit Vi, return to command mode and type :q. You can also save and quit at the same time by typing :wq.

Though Vi's commands may seem difficult to learn initially, the goal of using Vi is to minimize the transfer of hands from keyboard to mouse. The more Vi commands you learn, the faster you will be able to type in Vi.

A few of the more handy commands in Vi (all of which are used in command mode) are:

For more information about vi, you can visit one of the following tutorials:

Tar

Tar is an archiving program designed to store and extract files into an archive file. We will use tar to create a tar file in our lab submissions. For our purposes there are two types tar commands we will use:

Exercise

In this exercise you will a directory, several files, and a tar file. You will email me the completed tar file.
  1. Open a terminal and navigate to your home directory by typing:
  2. Make a directory called cs594csf using the following command:
  3. Navigate to your new directory:
  4. Make a new directory called lab1, where you will do all of your work for lab1:
  5. Make a new directory called test, where you will complete the remainder of this test:
  6. Navigate to the test directory:
  7. Create a new file called f1.txt using vi:
  8. In f1.txt, enter insert mode and type your name, what you preferred to be called, and what you are interested in learning in this course.
  9. Save and exit when you are finished by re-entering command mode and typing :wq.
  10. Copy f1.txt to f2.txt:
  11. Move f1.txt to intro.txt.
  12. List the files in the directory and note that f1.txt is no longer there.
  13. Open f2.txt in vi:
  14. Delete all of the lines in f2.txt using dd and enter your current degree information (where you received your undergrad, in what, and when, and what year and degree you are pursuing at UT).
  15. Save and exit when you are finished.
  16. Move f2.txt to edu.txt:
  17. Create a tar file called username_test.tar where username is replaced by your username. This tar file should contain intro.txt and edu.txt.
  18. Email me the tar file at cdschuman@gmail.com. Make the subject of the email CS 594 -- Linux Basics.
  19. Navigate to the lab1 directory you created earlier:
  20. Make a directory in lab1 called submit.
  21. When you complete Lab 1, copy all of the relevant files to the submit directory, navigate to that directory and follow the submission instructions on the class main page.
  22. If you are unfamiliar with C++, let me know and check out the following sites:
  23. Get started on Lab 1.
  24. If you are interested in learning how to log into our lab machines from home, please let me know.