Assignment 2

This exercise is designed to give you practice with the terminal/command line environment. Given that the possibilities for the tools mentioned below have expanded quite a bit and can change over time, please let me know immediately if you run into trouble or something that seems to not fit (e.g. you don't seem to have a named program below) This will help me and the rest of the class. Also, know that this document might change slightly because of the above. Additionally, *different methods of using Linux and/or the command line may yield different answers*

(Specific questions are in bold, like this, and things to be typed or seen on screen are in monospace, like this.

  1. Precisely how are you getting to your Linux Command Line? (E.g. Virtualbox + name-of-distro, Raspberry Pi, Windows Subsystem for Linux, Docker, etc?)




  1. Regardless of method, you should have access to a terminal program. On your own, figure out how to open it and do so. Does this have its own special name; and if so, 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? What does this correspond with, exactly (e.g. your real user/ machine or something else?)




  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 and 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. While there are fancy options that have incited nerd holy wars, like vim vs. emacs, a good default that tends to be everywhere is "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. In nano, Do the following:

This is my local test file

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. There are two possibilities for this that I mentioned in class, "wget" and "curl."

First, lets explore them a bit.
First, simply try each of them by themselves, i.e. simply
wget
on a line by itself then
curl
on a line by itself.

  1. What did each of them respond with? As best as you can tell, do both of them exist on your machine? (If neither exists, definitely let me know immediately, and if you can get one installed on your own, great! Let know how you did it so we can help others)




  1. As best as you can tell,in your opinion, which is more powerful? You could use Google here — but you may be able to by simply using the "man" command. One short answer/reason is fine.


To ensure that everyone is getting some hands on experience here, for the next few questions, you will need to get your unique "book" file. Visit the "Assignment 2 - Booklist" page in Canvas, this will be found under the Pages link on the left. This will probably be easiest if you RIGHT CLICK the "book" link next to your name, and select "Copy Link" or similar. This will put the full url you will need in your clipboard, which then can be pasted into something like Notepad to be copied again, or perhaps pasted or simply typed directly into your terminal. Either way, use wget or curl to get a copy of the file into your Linux environment. Handy tip; for this assignment curl requires the "-o" flag, but wget does not. (And this is not officially a question — but by the end of this assignment you should fully understand a way to make curl do this WITHOUT the -o flag.)

Please rename the file to something more descriptive, and be sure it ends with .txt
The above is not necessary for this to work, but it is a good practice and may assist with completing the rest of the assignment.
I will be using yourbook.txt in the examples, of course you should change it to match what you have chosen.


9b. We mentioned two other commands for viewing a file, cat and less. Run them both on your new file and explain the difference between their operations.


QUESTION 9 and a half - Apologies for the weird verification questions: Please tell me a random fact about your book that I can easily verify, either in the book itself or an easy to find Wikipedia-esque fact. You could even copy a random line from the book. But make sure it's random enough such that if another student has the same book your answers are unlikely to be similar.


Let's try something else
Try typing:
sort yourbook.txt.

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




Now, type
less yourbook.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 yourbook.txt > sortedbook.txt

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

cp yourbook.txt yourbook.bak
cp sortedbook.txt sortedbook.bak

Okay. Now: do that first command AGAIN:
sort yourbook.txt > sortedbook.txt

  1. What happened?






Finally, do this slightly different command:
sort yourbook.txt >> sortedbook.txt

  1. Review your new file (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:LIS3353