MODULE 18- Special directories and files Flashcards

1
Q

What happens when the setuid permission is set on an executable binary file?

A

→ The file is executed with the permissions of the file owner, not the user who runs it.

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

What does a lowercase “s” in the file permissions (e.g., rwsr-xr-x) indicate?

A

→ It indicates that the setuid permission is set and the execute permission is also set for the user.

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

Which symbolic command would you use to add the setuid permission to a file?

A

→ chmod u+s file

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

Why is setuid used on certain system utilities like passwd?

A

→ It allows normal users to run these utilities with root privileges to access files like /etc/shadow.

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

What does an uppercase “S” in the file permissions (e.g., rwSr-xr-x) indicate?

A

→ It indicates that the setuid permission is set but the execute permission for the user is not set.

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

What happens when a directory with the setgid permission creates another directory?

A

→ Any new directory created within a setgid directory will inherit the setgid permission, meaning it will also be owned by the group that owns the parent directory.

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

How do you remove the setuid permission using the symbolic method?

A

→ chmod u-s file

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

How would you add the setuid permission numerically, given that the original file permissions are 775?

A

→ chmod 4775 file

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

Which permission allows a user to run an executable file with the group permissions of the file, effectively giving them temporary access to the group that owns the file.

A

setgid permission on a file

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

How can you identify the setgid permission on a file using ls -l?

A

→ The setgid permission is indicated by an “s” in the group’s execute position (e.g., -rwxr-sr-x).

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

Which command allows you to setgid numerically?

A

add 2000 to the file’s existing permissions.

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

What problem does the setgid permission solve in the scenario with users bob, sue, and tim working on a shared directory?

A

→ Without setgid, files created by one user are owned by their primary group, potentially preventing other users in the shared directory from accessing those files. Setgid ensures files are owned by the shared group.

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

Which command allows you to setuid numerically?

A

add 4000 to the file’s existing permissions.

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

Which permission prevents users from deleting files they do not own in a shared directory, allowing only the owner of the file or the root user to delete files?

A

The sticky bit permission.

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

Which data structure contains file metadata like permissions, ownership, and timestamps (but not the file name)?

A

→ The inode table.

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

What command can be used to view the inode number of a file?

A

→ ls -i <file></file>

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

Define the concept described as “two file names pointing to the same inode number.”

A

→ Hard link.

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

What makes two files hard-linked copies of each other?

A

→ They share the same inode number.

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

What command is used to create a hard link?

A

→ ln target link_name

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

What is the file type indicator for a symbolic link in ls -l output?

A

→ l (lowercase L) as the first character in the permissions string.

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

What is the main identifier for a file in the filesystem?

A

→ The inode number, not the file name.

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

What does the arrow (->) in symbolic link listings indicate?

A

→ The target file that the link points to.

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

Which type of link is described as a file that points to another file by its path?

A

→ Symbolic link (soft link).

5
Q

What command and option are used to create a symbolic link?

A

→ ln -s target link_name

5
What is the key difference between a hard link and a symbolic link?
→ A hard link points to an inode; a symbolic link points to a pathname.
5
Why can't hard links be used across different file systems?
→ Because each file system has its own set of inodes.
5
Which link type clearly displays its target path in ls -l output?
→ Symbolic link.
5
Which type of link cannot point to a directory and Which type of link allows linking to directories?
→ Hard link cannot point to a directory and → Symbolic link allows linking to directories.
6
How do you add the sticky but numerically?
By adding 1000 to current permissions
7
Which character means both the stickybit and execute permissions are available and which one means the execute permission is not available?
t means the stickybit and execute permissions are available and T means the execute permission is not available?
8
Which special permission prevents users from deleting files they do not own in a shared writable directory like /tmp?
The sticky bit permission, which ensures only the file's owner or root can delete files in a shared directory.
9
Which command symbolically enables the sticky bit on a directory?
chmod o+t directory_name
9
Which identifier is used by the system to reference a file, independent of its name?
The inode number, a unique ID associated with each file on a filesystem.
10
What does the number between file permissions and owner in ls -li output represent?
The link count, indicating how many hard links exist to that inode.
11
Which link type ensures that deleting one of several linked files won’t remove the data?
Hard links, because the file data remains accessible as long as at least one link remains.
11
Which command can help you find all filenames with the same inode number as a given file?
find / -inum 2> /dev/null, useful for locating hard links.
12
Which type of link fails entirely if the original file it points to is removed?
Symbolic links
13
Which link type is visually obvious and clearly shows its target in ls -l output?
Symbolic links, due to the -> arrow and the l file type indicator.
13
Which type of link can cross filesystem boundaries or link across partitions?
Symbolic links, since they point to a path and not an inode.
14
Which link type fails with a "cross-device link" error when crossing filesystems?
Hard links, due to inode numbers being unique to each filesystem.
15
Which type of link cannot be created for a directory due to OS restrictions?
Hard links, as linking to directories this way could compromise the filesystem hierarchy.
16
Which link type is permitted for linking directories and often used in practice for organization?
Symbolic links, which can point to directories without issues.
16
Which command creates a symbolic link named binary pointing to the /bin directory?
ln -s /bin binary, producing a visible soft link in the working directory.
17
Which type of file acts as a shortcut that "points to" another file, allowing indirect access to its contents?
A symbolic link (also called a soft link), which stores a path to the target file and redirects operations to it.
18
Which command creates a symbolic link named link_name that points to a target file?
ln -s target link_name
19
What would the command ln -s /etc/passwd mypasswd create in the current directory?
A symbolic link named mypassword that points to the /etc/passwd file.
20
Which file type allows two different filenames to reference the same inode, thereby making them equivalent in access and content?
A hard link, which points directly to the same inode as the original file.
21
Which block of data in a file system stores metadata like permissions, ownership, and timestamps—but not filenames or file contents?
The inode table, which maps inodes to file data and attributes.
22
Which command would you use to view both the inode and link count of files in long format?
ls -li, which shows inode, permissions, link count, and other metadata.
23
Which command creates file.hard.1 as a hard link to file.original
ln file.original file.hard.1
24
/tmp and /var/tmp are examples of which type of directories?
/tmp and /var/tmp are examples of sticky bit directories
25
In which 2 directories are all users allowed to create temporary files?
/tmp and /var/temp
26
Create a file named source containing the text "data"
echo "data" > source
27
Which command is used to delete a file?
The rm command
28
Which type of links do not increase the link count of files with which they are linked?
Symbolic links