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 →
- How do file permissions work in Linux, and what do chmod 755 and 644 mean?
Every file has read, write and execute permissions for three groups of people - the owner, the group and everyone else. chmod changes them; 755 means the owner can do everything while others can only read and execute, and 644 means the owner can read and write while others can only read.
BeginnerIn-depth3 min read - How do you search for text and files in Linux using grep and find?
grep searches inside files for lines matching a pattern, for example grep -rn "error" logs/. find searches the directory tree for files by name, type, size or age, for example find . -name "*.log" -mtime -1. They are often combined to search text inside a chosen set of files.
BeginnerIn-depth2 min read - What are environment variables in Linux, and what does the PATH variable do?
Environment variables are named values (like HOME, USER or PATH) that every process inherits from its parent. PATH is a colon-separated list of directories the shell searches, in order, to find a command you type, so you can run python3 instead of /usr/bin/python3.
BeginnerIn-depth3 min read - What is cron, and how do you read crontab syntax?
cron is a Linux service that runs commands on a schedule. Each crontab line has five time fields - minute, hour, day of month, month and day of week - followed by the command, so "30 2 * * 1-5 /home/ravi/backup.sh" runs the backup at 2:30 AM every Monday to Friday.
BeginnerIn-depth3 min read - What is the difference between >, >>, 2>&1 and | in the Linux shell?
The > operator writes a command's output to a file and overwrites it, >> appends to the file, 2>&1 sends error output to the same place as normal output, and the pipe | feeds one command's output straight into the next command's input.
BeginnerIn-depth3 min read