Week 5: Files, Directories, and Pointers Flashcards
What is a file?
A container for data which is persistent and accessible by name
What are UNIX files?
Unix file types: regular, directory, device, link and
etc.
Unix files are identified by a name in a directory
What is a “Regular” file?
essentially a sequence of bytes
can access these bytes in order
What is a “Directory” file?
a file containing name and pointer (inode number)
pairs for files and subdirectories in the directory
What is a “Device” file?
access a device (like a soundcard, mouse,
terminal, or …) like it is a file
What are “Links”
hard link: create another name for a file
soft link: a pointer to another file
What option can be used to get file information?
-F
What does the UNIX file system represent? What represents the root?
An upside-down tree
/ represents root
What is the difference between an absolute pathname and a relative pathname?
Absolute: to identify where a file is, concatenate the directories
together, can be anywhere in the UNIX file system
Relative: pathnames relative to the current working
directory
What pathways signify home?
$HOME
/user/home
~
or simply cd
What do the following represent in file locations?
/
~
.
..
/ means root
~ means home
. means current directory
.. means parent directory
What does mkdir dirname do?
Makes a new directory in the current directory with the name “dirname”
What does rmdir do? When does it work? Not work?
Removes a directory, only works if the directory exists and is empty
What does cp text1 text2 do if:
text1 is a file
text2 is a directory?
Copies text1 to directory text2
What does cp text1 text2 do if:
text1 is a directory
text2 is a directory?
Nothing, you need to add the
-r option to make it recursive:
cp -r text1 text2
What does cp -r text1 text2 do if:
text1 is a directory
text2 is a directory?
Copies directory text1 and all of its contents to directory text2
What is the command to create a link? Format?
ln readme.txt unix_is_easy
Creates a link to readme.txt called unix_is_easy
What is a hard link?
An indirect pointer to another file or directory
What command searches through directories for a file? Format?
find
find PATH EXPRESSION
e.g. Find all files and directories named README
starting from the current directory:
find . –name “README”
Note: the dot before -name
What does ls -a do?
list all files including those
beginning with a . (dot)
What does head do?
head displays the
top lines of a file
What command can you use within a “man” veiwer to go to the next page?
Spacebar