Sure, but we'll also review them in the context of the workshop.
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
Sure. A command like drop cs204 myfile.tar
would drop the tarfile to the cs204
account (so I could see it).
Yes. It copies your file to the recipient, transferring ownership of the copy.
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).
So, SCP is a little more limited, since you can't run commands.
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.
I think of them as complementary: tar collects a bunch of files into one and gzip compresses a file, so sometimes we do both.
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.
Sure. We'll talk more about this on Tuesday, but here's a
preview. Suppose Gdome has an HTML file in
their public_html
that 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.
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.
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.
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.
"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.
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".
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.
Good idea. Meanwhile, you can search for "unix cheat sheet". There's also a list at the end of the Unix reading.