- What does open source mean? How is that different from free-to-use?
Open source: Source code is freely available (eg Firefox). Free to use: you can use it for free, but you can't have the
source code (eg. google search).
- What are the two meanings of
/ in the file path /lab/week2/thing.txt?
The first / means "root", the top level directory of the unix file structure. The other /s are separators
which separate the directories and file in the path.
- What is the absolute path of the home directory of the user
stud?
/home/stud
- What is the file called
.? How is this different to a file called .stuff?
. is the current directory. .stuff is a hidden file.
- Create a directory called
week2 in the mounted directory if you haven't already. Then create a file
in week2 using the following command:
/usr/games/cowsay "MOO" > lol.txt
To create and move to the directory:
cd ~/perm
mkdir week2
cd week2
- Print the first 3 lines of
lol.txt using a command ("print" means "display in the terminal", not
"send to a printer").
head -n3 lol.txt
- Print the last line of
lol.txt using a command
tail -n1 lol.txt
- How many lines are in
lol.txt?
wc -l lol.txt
- What is the difference between
cat lol.txt and head lol.txt? Would this change on a larger file?
No difference because lol.txt is only 8 lines long and head prints 10 lines by default. If lol.txt was longer or
if head -n was used with n of less than 8, the output of head would be shorter than that of cat.
- How many files are in
/lab/week2? Don't count . or .. (why are we ignoring these?).
6 files. Don't forget to list hidden files with ls -a. We are ignoring . or .. because
they are the current and parent directory, not files "in" the directory.
- What does the
-p option mean for ls?
ls -p puts a / at the end of directory names. You can find this out using man ls.
- List the contents of
/lab/week2 in size order. Which is largest?
ls -S will sort files by size. Use ls -alS to include hidden files and show the file sizes.
Alice_in_Wonderland.txt is the largest.
- What command would you use to copy
Alice_in_Wonderland.txt from /lab/week2 to your mounted directory?
cp /lab/week2/Alice_in_Wonderland.txt ~/perm/week2
or
cp /lab/week2/Alice_in_Wonderland.txt ~/perm/week2/Alice_in_Wonderland.txt
- How many words are in
Alice_in_Wonderland.txt?
wc -w Alice_in_Wonderland.txt
- Open
Alice_in_Wonderland.txt using the less.
Using less, answer the following:
- What chapter begins on line 1252?
Pig and Pepper
- What food is described as rich and green?
soup
- How many times does the word "verdict" appear?
4
- You've decided you don't want to keep a whole book in your mounted directory. How can you remove
Alice_in_Wonderland.txt from your mounted directory?
rm Alice_in_Wonderland.txt