Topic 4 - Unix Files and Directories Flashcards

1
Q

What is a computer file?

A

A container for a sequence of bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 4 types of files?

A

1) Regular normal file
2) Directory
3) Link
4) Device (Unix treats a device like a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Does the shell remember the current directory for you or do you have to remember the current directory on your own.

A

The shell remembers the current directory for you

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the cmd for determining the current directory?

A

pwd (print working directory)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

cmd for changing directories?

A

cd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The cmd “ls” does what?

A

listing the contents of a directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How is the Unix filesystem organized?

A

As un upside-down tree; top of the filesystem is the root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Whats the symbol for the root directory?

A

/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you change from the current directory to the root directory?

A

cd /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Examples of file names in unix:
a.out(
data@
readme.txt
tmp/
Are the letters *,@, and / part of the file name?
A

No, just indicators to give more information about the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A typical Unix file system spans _____ disks?

A

Many

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

As a user, do you need to know which physical disk is used to store your things?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the cmd for reporting on all mounted file system?

A

df.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Definition of Absolute Pathnames?

A
  • start from the root directory ie. /
  • string together all directory names that are in your path to the file
  • separate each directory name by a single slash
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does ~ mean?

A

Refers to the $HOME directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does “cd” with no arguments do?

A

Changes the working directory to your home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Define Relative Pathnames

A

Specifying pathnames relative to the current working directory using . and ..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what does “ .. “ mean?

A

Start from parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does “ . “ mean?

A

Start from the current directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you create a new directory?

A

mkdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you remove a directory? (as long as it exists and is EMPTY)

A

rmdir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you move a file or directory?

A

mv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do you copy a file from one directory to another?

A

cp [filename]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do you copy a directory?

A

Use a recursive copy: “cp -r” to copy the directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Changes the current working directory, and also remembers the previous one by pushing it on to ta stack
pushd
26
Popd does what?
change the current working directory back to the last directory placed on the stack by pushd
27
Keeps track of what you have so far in the stack
dirs
28
How do you reveal hidden files?
ls -a
29
How you display the first few lines of a file? (Default 10)
head
30
How do you display the last few lines of a file (default 10)
tail
31
What is the only invalid character in a Unix file name?
the Slash ( / ) - used for pathnames
32
Which ones are not legal Unix file names? a a. .a a.b.c
None, they're all legal - Unix does not enforce file name extensions. Just remember: any name beginning with a dot is hidden where "ls" command cannot see them but the "ls -a" command can. (Note: the . and .. are reserved for current and parent directories)
33
Give an example of an extension for executable files.
Executable files usually have no extensions. This does make distinguishing executable files from data files a bit difficult.
34
How can you determine if a file is executable?
using the "file" command --> file filename
35
Give 3 examples of Wildcard Characters:
1) * 2) ? 3) [...]
36
What does the wildcard * do?
matches a sequence of zero or more characters: | a*.c --> matches abbb.c, aaaa.c, aldkfjaklf.c
37
What does the wildcard ? do?
matches any single characters
38
What does the wildcard [...] do?
Matches any single character between the braces: b[aei]t --> matches bat, bet, or bit, not baet, or bt You can use a hyphen: [A-Z] to match a range. in this example, it'll match the alphabet of capital letters
39
What acts as a boundary for wildcards to ensure matching does not go beyond filenames into the file path?
the slash ( / ) in the pathnames
40
Using * or ?, can you match a dot (.) at the beginning of a filename? Anywhere else in the filename? Comment on your answer.
No. Yes. A dot ( . ) at the beginning of a filename must be matched explicitly i.e. with a literal "."
41
What do double quotation marks do?
- Stops the interpretation of some shell special characters (whitecaps and wild cards) - Forces the shell to deal with whatever between the two quotes as one token
42
What do single quotation marks do?
Does everything double quotation marks do plus stops variable expansion ($HOME, etc.)
43
What do Back Quotes do?
Text between back quotes leads to executing the text as a command and returning the results instead
44
What is the name of the single control structure Unix creates for each file?
Index Node (ie. inode) for each file
45
Wha happens when a file is created in terms of its inode?
When the file is created, there is one link to the file's inode.
46
Ls -i displays ____?
The inode number of each file.
47
Ls -l displays _____?
Displays permissions AND the number of existing links per file.
48
Each hard link acts like a _______?
a pointer to the actual file.
49
Whats a symbolic link?
"ln -s" is an indirect pointer to another file or directory
50
Removing any one of a file's hard links except one ______ [will or will not] remove the contents of the file?
will not
51
Removing all of a file's hard links ______ [will or will not] remove the contents of the file?
Will
52
Removing a file's symbolic link ______ [will or will not] affects the file
will not
53
Removing the symbolic link ________ [will or will not] remove the contents of the file.
will not
54
What happens when you remove the original file that has a symbolic pointer?
The symbolic pointer will point to an unknown file
55
Who can do what when it comes to these 3 actions: 1) Creating a symbolic link to directories or files 2) Creating hard links to files 3) Creating hard links to directories
1) Any user 2) Any user 3) Only the super user / root user
56
File Permissions: How does Unix divide up users in terms of who has what permissions with files?
3 Divison --> Owner User, Group User, Other users 1) Owner user: owner of the file 2) Group user: each file is assigned to one and only one group (superuser sets up groups) 3) Other users: everyone else
57
How do you view Permissions?
the command ls -l
58
what does "r" mean?
read permission
59
what does "w' mean?
write permission
60
what does "x" mean?
execute permission
61
How do you change / assign permissions?
Command: chmod
62
What are the 2 syntaxes / methods you can use with the chmod command?
2 syntaxes / methods you can use: 1) numeric method 2) symbolic method.
63
Describe the numeric method for chmod command.
Numeric method: chmood DDD file [file..] | 1 2 4 = --x -w- r--
64
Describe the symbolic method for chmod command.
Symbolic method; chmod [ugoa][+-=}[wrx] file[ [...] Relative: chmod u+rwx file -- gives owner user R,W,X Absolute: chmod g=r file --> gives group users R, makes sure it has nothing else Relative and Absolute permission assignment can be appended with commas: chmod u=rwx, g-w,o-rwx file
65
How do you set default permissions for any file you will create?
command: umask
66
Describe the umask command:
value is opposite to that of the chmod command: tells which permissions will not be given - umask 077 means do not let anyone but the owner user to do anything with my files by default Generally, set umask once in your .cshrc file and never set it again
67
Directory permissions are different from file permissions: Listing file names requires:_____ Creating file names requires: _____ Accessing files information (if you know the name) requires:_____
read permission write permission execute permission
68
How can you change the permissions for a whole tree of files and sub directories?
chmod -R Example: chmod -R a-x+X publicDocs Recursively (i.e. on all files and directories in publicDocs) removes execute permission for all classes and adds special execution permission for all classes it recursively changes the mode for each chmod operand that is a directory and all sub-directories and files receive those permissions.