Command Line Assignment One
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.
- Which Linux system or distribution are you using?
- 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?
- 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 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.)
- 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:
- 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.
- 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 I have not yet mentioned.
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."
- What are you "missing" according to the error wget just produced?
Next type
man wget
- What is "man" short for, here? In a sentence or two, tell me what "wget" is/does.
Okay, next, type the following:
wget https://gutenberg.org/files/23/23-0.txt
Once it's finished, first try
cat 23-0.txt
Next, try
less 23-0.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 23-0.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
- Before doing anything else, describe what just happened.
Now, type
less fd.txt
- 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
- What happened?
Finally, do this slightly different command:
sort fd.txt >> fdweird.txt
- 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
- What happened? Does this look right? If not, give me the command in the format that does this "correctly."
Backlinks: FSU Courses:LIS5364 FSU Courses:LIS5364:Previous Readings