Quiz

  1. Going over the commands again would be really helpful, as I have not quite memorized them yet, especially the drop and copy commands

    Sure, but we'll also review them in the context of the workshop.

  2. Just to clarify, does ~/ mean home directory? I got confused when the reading started talking about passwords. / maybe more on the tilde

    Yes. It might be less confusing to talk about an "account database" rather than a "password database", but the standard unix terminology is "password database".

    • ~ is my home directory, where "my" means the person who is logged in.
    • ~fred is Fred's home directory, which is looked up in a "account database" (historically, /etc/passwd but nowadays could be some networked database, like the Active Directory database that LTS uses for your domain passwords.

    Example:

    • ~/cs204 is your cs204 folder, the one in your home directory.
    • ~cs204 is the CS 204 course account, where this web page lives.

    The following copies a file from the course account to your account:

    cp ~cs204/path/to/source/file ~/cs204/path/to/destination/file
  3. I also would like to talk more about/practice how to drop files.

    Sure. A command like drop cs204 myfile.tar would drop the tarfile to the cs204 account (so I could see it).

  4. Also, I'm a bit confused about how drop works. Every time you want to drop stuff, are you creating a new file just for that? 

    Yes. It copies your file to the recipient, transferring ownership of the copy.

  5. ssh and scp / I don't really get what the shell and ssh are, and how the server works. / I am still a bit confused scp and ssh. / I'm a little bit confused with the part regarding ssh and scp.

    The two commands are similar in that they provide a secure interaction with the server (a separate machine across the network on which you have an account).

    • SSH allows you to login to that remote server, where you can run commands, etc.
    • SCP allows you to copy files to/from the remote server

    So, SCP is a little more limited, since you can't run commands.

  6. I was wondering if we could talk more about tar files: How are they opened? How are they used? Also, what are the pros and cons of using tar/gzip vs. zip/unzip? / I would like to learn more about the tarfiles. / I'd like to go over the tarfile concepts in more depth to further understand how they work and how to utilize them.

    Tar copies a bunch of files into a "suitcase" for easy transport. The result is often called a "tarfile". Gzip scrunches a file down so it takes less space. So it's common to pack a tarfile and then gzip it.

    We can also gzip other kinds of files, and we can decide to skip the compression if we want.

    If you've used zip files, it's the same idea.

    There are other compression methods as well. XZ is one, and it almost got the world in trouble.

  7. Also, can I understand tar and gzip as doing the opposite functions?

    I think of them as complementary: tar collects a bunch of files into one and gzip compresses a file, so sometimes we do both.

  8. What exactly distinguishes a relative pathname from an absolute one? Why is the relative one called so?

    An absolute pathname starts at the root of the computer system and specifies a path of directories all the way down:

    /home/cs304flask/public_html/top/syllabus.html

    A relative pathname has an ambiguous or flexible starting point. It starts from "where you are", whatever that is. So

    top/syllabus.html

    from the CS 304 Flask public_html, that means the same thing. But from the public_html of the CS204 course, it means the syllabus of a different course.

    So, the pathname is relative to the starting location. This is actually really useful. I can tell each of you to find a file in your account by giving you a pathname relative to your home directory.

  9. I would like to talk more about when to use relative and absolute paths when linking something onto a webpage.

    Sure. We'll talk more about this on Tuesday, but here's a preview. Suppose Gdome has an HTML file in their public_htmlthat wants to load a CSS file. They might load it with an absolute URL like this:

    <link src="~gdome/static/style.css">

    Or with a relative URL like this:

    <link src="static/style.css">

    Both would work fine. But if the file moves, along with the static folder and the style.css file in it, the relative URL still works, but the absolute one doesn't.

  10. How wildcards work

    We can use them to operate on a specific set of files. Suppose I have a directory with 50 HTML files and 50 CSS files, and I want to delete all the CSS files and copy all the HTML files to another folder. I can do:

                rm *.css
                cp *.html /path/to/other/folder
            

    Or, I could type 100 separate commands.

  11. i'm not sure how to save any work i've done or how to properly close/log out of unix

    Great question. VS Code will remind you about unsaved work. You can logout by using the "logout" command or "^d" if you're lazy like I am.

  12. still slightly unsure of the difference/functions of code and cat

    cat just prints the contents of a file to the screen. Simple, useful occasionally but not very often.

    code opens the file for editing within VS Code. You'll use this all the time.

  13. I am still unfamiliar with the idea of remote and whose database we are working on. Do different databases mean different trees? Or different subtrees within the same tree? Pretty confusing to visualize for me!

    "remote" means "not the machine you are typing on". So, not your laptop, but the CS server.

    We're not working with databases in CS 204.

  14. I would like to get more practice with working in the terminal overall, however I think I especially would like to talk about the different deletion methods and possible safeguards/things to look out for when using them. / I am confused about the difference between rm, rm -r, and rmdir. Specifically, does rmdir remove only the directories that are empty? / commands about removing files & directories (other than "drop" only works on the CS server). Thank you!

    rm deletes the files listed on the command line. You can use wildcards or list multiple files.

    rm foo.html *.py *.css

    But they can't be directories. To delete a directory, use rmdir:

    rmdir project1

    But the directory has to be empty. To delete a directory and its contents, recursively, use rm -r

    rm -r project1

    To safeguard, I often use ls first, and if the listed files are the ones I want to delete, I edit the command to replace the "ls" with "rm".

  15. What rm* does and what 'mv' means?

    The rm * (the space is essential) means to delete all files in the current folder. Terrifying.

    The mv command moves a file to another folder or another name.

  16. none. I think it would be nice to have a clearer list, perhaps, of all of the commands that we have learned thus far + an example of their notation, just so we can see exactly how they are used right next to it.

    Good idea. Meanwhile, you can search for "unix cheat sheet". There's also a list at the end of the Unix reading.