Assignment 2 - The Terminal

This exercise is designed to give you practice with the terminal/command line environment. Some of the below answers may change based on your particular distribution.

1) Which distribution are you using? Is this using Virtualbox?

2) Regardless of distribution, you should have access to a terminal program. On your own, figure out how to open it and do so. Briefly describe that (perhaps very simple) process.

For the following questions, it may be useful or necessary to refer to the following slides:
http://jrm4.com/FSU_Courses/LIS3353/05%20LIS3353%20-%20Lots%20of%20Linux%20(with%20command%20line%20info).pdf

3) What is the command to "list" files? Run it.

4) List the files and folders you see.

5) Next, run the listing command, but with the "-a" flag. You don't need to relist all the files, but please explain what is different now, and why?

With the -a flag, you should see a file called ".dmrc". Take a look at it. (note, some distros may not have this)

6) If you do have a ".dmrc" file, view it and tell me the name of your current session?

Let's make a new file, called test.txt, with a command-line editor. One command that you could use for this is the “touch” command. However, you can also simply type the name of the editor, then the name of the file. Let's use "nano" —
Type the following:
nano test.txt
then enter. (you may presume an "enter" at the end of all future commands)

Once inside, type "This is my local test file," no quotes. Save/Close the file. (You can get clues how to do this at the bottom. Here, the symbol "^" means the Control Key. So to save, first try Control-X for "Exit" then follow the prompts.

List the directory again, but this time with the “-al” option.
7) How many bytes is test.txt? (hint: the number you're looking for is close to the date)

Lets get a bigger file; we'll use a command I covered briefly - wget --.
First just try typing
wget
on a line by itself. That will not actually "do" anything.
Next type
man wget

8) In a sentence or two, tell me what "wget" is/does.

Okay, next, type the following:
wget "http://www.gutenberg.org/cache/epub/23/pg23.txt"

to get a file called pg23.txt.

Once it's finished, first try
cat pg23.txt

Next, try
less pg23.txt

9) What is the difference between less and cat?

Let's rename this file to something slightly more descriptive, but still short for us. How about fd.txt?
type:
mv pg23.txt fd.txt

Okay, lets use some basic commands to play around with this file a bit. A command we did see for a second in class is "sort"

Try typing:
sort fd.txt

10) Before doing anything else, describe what just happened.

Now, type

less fd.txt

11) Did the file itself change? Briefly explain why or why not?

What if we actually wanted to "keep" the weird thing that came out when we did the sort command? We have to use a "redirect," to redirect the output of a command to something other than stdout (Standard Output)? Try this:

sort fd.txt > fdweird.txt

Now we have two files. Lets make some backups of them. Do:

cp fd.txt fd.bak
cp fdweird.txt fdweird.bak

Okay. Now: do that first command AGAIN:
sort fd.txt > fdweird.txt

12) What happened?

Finally, do this slightly different command:
sort fd.txt >> fdweird.txt

13) Review fdweird.txt (or perhaps try another ls -a) — what happened here? What is the difference between > and >>?

Lets try something a little different: As above, make a file that looks like the following. Name it numbers.txt

34
78
1001
12
30
4084

(each of these numbers, on its own line, with nothing else)

Next type
sort numbers.txt

14) What happened? Does this look right? If not, give me the command in the format that does this "correctly."