CS 279 - Week 2 Lecture 1 - 2022-08-29]
=====
TODAY WE WILL
=====
* announcements...
* continuing our discussion of the UNIX/Linux filesystem
and file-related commands
* prep for next class
=====
reminder: mkdir, make directory
=====
* ...lets you make a new directory
* can give as an argument the pathname of a desired
new directory
=====
BUT let's now talk more about the UNIX/Linux filesystem
=====
* hierarchical!
* consists of a set of files
* every file has one or more file names
* starts at a special directory named /
which is called the root
* 3 kinds of files:
* regular files
* directories - each contains information
about a set of files, and are used to locate
a file by its name
* special files of several kinds:
* device files - provide access to printers,
terminals, etc.
* FIFO files - named pipes
* some UNIX/Linux implementation-specific kinds
of special files
* files have names;
* most Linux/UNIX systems allow up to 255 characters
* a filename can include any character other
than '/' or the null character
* are case sensitive!
* letters (uppercase or lowercase), digits, underscores
are usually safe
* hyphens are safe EXCEPT for as the first character
(would make your file look like a set of command
options...!)
* CONVENTION: a DOT the beginning of a file name
identifies an initialization or supporting file
for some program
* these are sometimes called "invisible" files,
because by default ls (with no arguments) does
not display their names (probably to keep users
from messing with them)
* these so-called "dot files" are also treated
specially during so-called wildcard expansion
(more on that in the nearish future)
=====
pathnames
=====
* a pathname is a name that designates a file
...consists of a sequence of filenames separated
by slashes /
* that is, filenames are components of a pathname
* the LAST filename in a pathname is sometimes called
the basename
* the portion of the pathname PRECEDING the last
filename is sometimes called the path prefix
* there are ABSOLUTE and RELATIVE pathnames
* absolute is the most complete pathname for
a file -- and will be the same regardless
of what your current directory is
It always starts with the root, /
* relative is relative to some directory;
(usually the current directory);
it MUST NOT start with a slash
=====
reminder: cd - change directory
=====
* with no arguments: always takes you home!
(changes the current directory to your special
home directory)
* with an argument, it tries to change the current
working directory TO the given directory
* (if a relative pathname is the argument,
it is considered relative to the present working
directory)
======
OOPS, did we mention? Re: ls
======
* ls by itself (no arguments) lists the files in
the current directory
...if given the name of a directory,
it lists the contents of that directory
=====
CONVENIENT provided nicknames:
=====
* .. is always a nickname for a directory's parent
directory
* . is always a nickname for a directory itself
* ~ in most modern shells ia nickname for your home
directory
~ followed by a username is a nickname for that
user's home directory
=====
filename completion
=====
* typically UNIX/Linux shells support! (but not
sftp, more's the pity!!!)
...if you start typing a filename in a command,
and you type the Tab key,
the shell will TRY to complete that filename (well,
the next level...) if the start you've typed
uniquely identifies it
(if not unique, typing tab twice LISTS all the
files it matches)
=====
cat - short for canCATenate
=====
* a way to quickly see a file's contents,
if called with ONE argument
* a way to see a concatenated version of multiple
file's contents, if called with multiple arguments
=====
output file redirection
=====
* desired_command > desired_outfile
...and desired_outfile now contains the standard
output for that command
BUT if redone, OVERWRITES desired_outfile's current
contents!!!!!
* desired_command >> desired_outfile
...APPENDS the results of desired_command's standard
output to desired_outfile
=====
more (and most and less, if installed on your system)
=====
...let you see a file's contents one screen at a time
(and other fun options)