Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- What does SGID do on a directory, and when is it useful?
On a directory, SGID makes new files and sub-folders inherit the directory's group instead of the creator's primary group. It is used for shared team folders so everyone's files stay accessible to the same group. It shows as s in the group execute slot.
IntermediateQuick answer1 min read - What does the execute permission mean on a directory?
On a directory, execute (x) means permission to enter it and access items by name. Read (r) lets you list names, and write (w) lets you create or delete entries. Without x on a directory you cannot cd into it or open files inside, even if the files themselves are readable.
IntermediateQuick answer1 min read - What is the sticky bit, and why does /tmp have it?
The sticky bit on a directory means only a file's owner, the directory's owner or root may delete or rename files inside, even if others have write permission on the directory. It shows as a t at the end of the permissions, for example drwxrwxrwt.
IntermediateQuick answer1 min read - What is the SUID bit, and how can passwd change root-owned files?
SUID makes an executable run with the permissions of its file owner instead of the user who launched it. passwd is owned by root with SUID set, so a normal user can update /etc/shadow through it. The bit shows as s in the owner execute slot.
IntermediateQuick answer1 min read - What is umask, and how does it decide default file permissions?
umask is a mask of permission bits that are removed from the defaults for newly created files and directories. Files start from 666 and directories from 777, so a umask of 022 gives files 644 and directories 755.
IntermediateQuick answer1 min read