These questions are included to facilitate question during our scheduled class time on Tuesdays. They are not graded and you don’t need to submit your answers anywhere - they’re just here to help you get practice with the material.
-
We won’t have time to cover all the commands we want to in this class. Lots of useful commands will be included in the lecture slides. You’ll need this for your homework - try finding the commands that do the following:
- Move a file from one location to another
- Delete a file
- Copy a file
Solution
mv src destrm filecp src dest
-
Do you know the difference between the terminal and the shell? If not, do you have any educated guesses?
Solutions
A terminal is your way of interacting with your computer in a text-based environment. For example, Macs come with the “Terminal” program or you can install “iTerm” that has more customizations. A shell is a program someone wrote run in a terminal that interprets the commands you type and presents output. There are different types of shells written by different people (e.g.,
bash,zsh,fish, etc.). -
What is the command to list all files in the current directory, and recursively list the files in all subdirectories?
Solutions
ls -RWe found this by using
man lsto see thelsdocumentation. Then by typing/we were able to start searching the page for the term “recursive”. -
What is the flag we would pass to
lsto sort files by size? (try searching themanpage instead of just scrolling!)Solutions
ls -S -
Using
ssh, can you print out the contents of your home directory onattuwithout logging intoattu? (You’ll still need your password, but you can do this without opening a login shell onattu).Solutions
ssh <username>@attu.cs.washington.edu lsThe important part of this problem is not the
sshcommand itself, but to look at the format ofman sshto see it’s something likessh destination [command]. Things in square brackets are optional while things without square brackets are required. The way of reading this is to say thatsshrequires a parameterdestinationand optionally, you can pass acommandto run on thedestination. -
findis a command that we will learn about more in this class that allows you to search through your file system. Suppose that we are in thelecture1directory from the videos (i.e. we have adir1anddir2subdirectory). Without actually running the command, do you think we could runfind dir1 dir2(i.e. give it two directories are arguments)? Why or why not?Solutions
Yes! If you look at
man find, you see the synopsis saySYNOPSIS find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]The pertinent part is
[starting-point...]. The square brackets mean this argument is optional and the...means it can accept one or more of them.