Command Line Assignment One

Created Wednesday 22 January 2020

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 Linux system or distribution are you using? Is this using a Virtual Environment?

  1. Regardless of distribution, you should have access to a terminal program. On your own, figure out how to open it and do so. What is the name of this program in the menu? Once open, see if there is something like an "about" or "help" menu, that may reveal a different name. If different, what is it?

  1. Okay, time to type stuff. You probably aren't seeing a *completely* blank screen, there is likely information about "who" you are and "where" you are next to a flashing cursor. Specifically, what is it telling you?

  1. What is the command to "list" files? Run it, and list the files and folders you see. (if this is not a "fresh" install, i.e. you've used it before, feel free to describe, instead.)

  1. Next, run the listing command, but with the "-a" flag. You don't need to relist all the files, but you are probably seeing "more stuff." In your own words, try to figure out explain the purpose and result of the difference.

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)

This opens the "nano" program. Do the following:

List the directory again, but this time with the “-al” option.

  1. 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 another powerful command I showed
First just try typing
wget
on a line by itself. That will not actually "do" anything, but it will tell you what it went "wrong."

  1. What are you "missing" according to the error wget just produced?

Next type
man wget

  1. What is "man" short for, here? 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

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

Next, try
less pg23.txt

9. What is the difference between less and cat, based on what you've seen here?

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

Next, 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

  1. Before doing anything else, describe what just happened.

Now, type
less fd.txt

  1. BIG IMPORTANT CONCEPT HERE: Did the file itself change? Try to 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

  1. What happened?

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

  1. 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

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




Backlinks: FSU Courses:LIS5364