Linux interview questions for freshers test whether you can work on a server from the command line. Expect questions on everyday commands, file permissions, processes and finding things in logs. This page has 25 questions with short answers and the exact commands to use. Output shown for text commands was produced by running them on a sample file.
For a full command reference with examples, read the Linux commands guide alongside this page.
How to answer Linux interview questions
Answer with the command, what it does and one useful option. "grep -c ERROR app.log counts the lines that contain ERROR. Add -i to ignore case."
Pro tip: Interviewers often say "show me". Practise the commands on a real terminal until you can type them without looking them up.
Linux basics questions
Q1. What is Linux?
30-second answer: Linux is an open-source, Unix-like operating system kernel first released by Linus Torvalds in 1991. A distribution, such as Ubuntu, Debian, Fedora or Red Hat Enterprise Linux, packages the kernel with tools, a package manager and often a desktop. Most servers, cloud machines and Android phones run on the Linux kernel.
Q2. What is the difference between the kernel and the shell?
30-second answer: The kernel is the core of the OS. It manages CPU, memory, devices and files. The shell is a program that reads your commands and asks the kernel to run them. Bash is the most common shell; others include zsh and sh.
The operating system interview questions page covers kernels, processes and memory in more depth.
Q3. Explain the main folders in the Linux file system.
| Folder | Contains |
|---|---|
/ |
Root of the whole file system |
/home |
Users' home folders |
/root |
Home folder of the root user |
/etc |
System configuration files |
/var/log |
Log files |
/bin, /usr/bin |
Commands and programs |
/tmp |
Temporary files |
/dev |
Device files |
/proc |
Live information about processes and the kernel |
30-second answer: Everything starts from /. Configuration is in /etc, logs in /var/log, user files in /home.
Q4. What is the difference between an absolute and a relative path?
30-second answer: An absolute path starts from /, such as /home/asha/notes.txt, and works from anywhere. A relative path starts from the current folder, such as notes.txt or ../logs. . means the current folder, .. means the parent and ~ means your home folder.
Everyday command questions
Q5. Which commands do you use to move around and list files?
| Command | Does |
|---|---|
pwd |
Print the current folder |
cd /var/log |
Change folder |
cd .. |
Go up one level |
ls -l |
Long list with permissions, owner, size and date |
ls -a |
Include hidden files (names starting with .) |
ls -lh |
Sizes in KB, MB, GB |
30-second answer: pwd tells you where you are, cd moves and ls lists. ls -la is the version most people type.
Q6. How do you create, copy, move and delete files and folders?
| Task | Command |
|---|---|
| Create an empty file | touch notes.txt |
| Create folders, including parents | mkdir -p project/src |
| Copy a file | cp a.txt b.txt |
| Copy a folder | cp -r src backup |
| Move or rename | mv old.txt new.txt |
| Delete a file | rm a.txt |
| Delete a folder and its contents | rm -r folder |
30-second answer: cp copies, mv moves or renames, rm deletes. -r works on folders. There is no recycle bin, so check the path before rm -rf.
Q7. How do you view the contents of a file?
30-second answer: cat prints the whole file. less opens it page by page. head -n 10 shows the first lines and tail -n 10 the last lines. tail -f keeps showing new lines as they are added, which is how you watch a live log.
Using this sample app.log:
INFO server started
ERROR db timeout
INFO user login
ERROR disk full
WARN slow query
ERROR db timeout
head -n 2 app.log
tail -n 1 app.log
wc -l app.log
Output:
INFO server started
ERROR db timeout
ERROR db timeout
6 app.log
Q8. How do you search text inside files with grep?
grep -c ERROR app.log
grep -n WARN app.log
grep -v INFO app.log | wc -l
Output:
3
5:WARN slow query
4
30-second answer: grep prints lines that match a pattern. -c counts, -n shows line numbers, -i ignores case, -v shows lines that do not match and -r searches folders.
Q9. How do you find files?
30-second answer: Use find with a starting folder and conditions.
find /var/log -name "*.log"
find . -type f -size +100M
find /tmp -type f -mtime +7
find . -name "*.tmp" -delete
These find .log files, files over 100 MB, files changed more than 7 days ago, and delete .tmp files. locate is faster but searches a database that may be out of date.
Q10. What are pipes and redirection?
| Symbol | Meaning |
|---|---|
| |
Send one command's output into another |
> |
Write output to a file, replacing it |
>> |
Add output to the end of a file |
2> |
Write errors to a file |
2>&1 |
Send errors to the same place as output |
< |
Read input from a file |
grep ERROR app.log | sort | uniq -c | sort -rn
Output:
2 ERROR db timeout
1 ERROR disk full
30-second answer: A pipe joins small commands into one job. This example counts how often each error appears, most common first.
File permission questions
Q11. How do you read Linux file permissions?
-rwxr-xr-- 1 asha devs 512 Dec 5 10:00 deploy.sh
30-second answer: The first character is the type: - for a file, d for a folder, l for a link. Then three groups of three: owner (rwx), group (r-x) and others (r--). r is read, w is write and x is execute. Here the owner asha can do everything, the devs group can read and run, and others can only read.
Q12. How does chmod work with numbers?
| Number | Permission | Meaning |
|---|---|---|
| 7 | rwx |
4 + 2 + 1 |
| 6 | rw- |
4 + 2 |
| 5 | r-x |
4 + 1 |
| 4 | r-- |
4 |
| 0 | --- |
none |
30-second answer: Read is 4, write is 2 and execute is 1. Add them for each of owner, group and others. chmod 754 deploy.sh gives rwxr-xr--. chmod 644 is common for files and chmod 755 for folders and scripts.
Q13. How do you use chmod with letters?
30-second answer: u, g, o and a mean user (owner), group, others and all. + adds, - removes and = sets exactly.
chmod +x deploy.sh # make it executable
chmod g-w report.txt # remove write for the group
chmod o=r notes.txt # others can only read
chmod -R 755 site/ # apply to a folder and everything inside
Q14. What do chown and chgrp do?
30-second answer: chown changes the owner of a file, and can change the group too: sudo chown asha:devs app.log. chgrp changes only the group: chgrp devs app.log. Changing ownership usually needs sudo.
Q15. What is umask?
30-second answer: umask removes permissions from new files and folders. New files start from 666 and folders from 777. With the common umask 022, new files get 644 (rw-r--r--) and folders get 755 (rwxr-xr-x). Type umask to see the current value.
Q16. What is sudo, and who is root?
30-second answer: root is the superuser who can do anything on the system. sudo lets an allowed user run one command as root, for example sudo apt update. It is safer than logging in as root because each command is deliberate and logged.
Process questions
Q17. What is a process, and how do you list processes?
30-second answer: A process is a running program with its own ID, called a PID. ps aux lists all processes, ps -ef is another common format, and top (or htop if installed) shows a live view sorted by CPU use. pgrep java prints the PIDs of processes named java.
Q18. How do you stop a process?
30-second answer: kill PID sends SIGTERM (signal 15), which asks the process to stop cleanly. kill -9 PID sends SIGKILL, which ends it at once without cleanup. Try a normal kill first. pkill name kills by name.
Q19. How do you run a process in the background?
30-second answer: Add & to run a command in the background. jobs lists background jobs, fg brings one to the front and bg resumes a stopped job in the background. Ctrl+Z stops the current job. nohup command & keeps it running after you log out.
Q20. How do you check disk and memory usage?
| Command | Shows |
|---|---|
df -h |
Free and used space on each file system |
du -sh folder |
Total size of a folder |
free -h |
RAM and swap usage |
uptime |
How long the system has run and its load average |
30-second answer: df for disks, du for a folder, free for memory. -h makes sizes readable.
Links, archives and services questions
Q21. What is the difference between a hard link and a soft link?
| Point | Hard link | Soft (symbolic) link |
|---|---|---|
| Command | ln file hardlink |
ln -s file softlink |
| Points to | The same data (inode) | The file's path |
| If original is deleted | Data still available | Link breaks |
| Across file systems | No | Yes |
| Folders | No | Yes |
30-second answer: A hard link is another name for the same data. A soft link is a shortcut to a path, and it breaks if the target moves or is deleted.
Q22. How do you compress and extract files?
tar -czvf backup.tar.gz project/ # create a gzip archive
tar -xzvf backup.tar.gz # extract it
zip -r site.zip site/ # create a zip
unzip site.zip # extract a zip
30-second answer: tar -c creates, -x extracts, -z uses gzip, -v lists files and -f gives the archive name.
Q23. How do you install software on Linux?
30-second answer: Use the distribution's package manager. On Ubuntu and Debian: sudo apt update then sudo apt install nginx. On Red Hat, Fedora and similar: sudo dnf install nginx (older systems use yum). The package manager handles downloads and dependencies.
Q24. How do you manage a service such as nginx?
sudo systemctl status nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl enable nginx # start automatically at boot
journalctl -u nginx # view its logs
30-second answer: Most modern distributions use systemd, so systemctl starts, stops and checks services, and journalctl shows their logs.
Q25. What is cron?
30-second answer: cron runs commands on a schedule. crontab -e edits your jobs. Each line has five time fields, minute, hour, day of month, month and day of week, followed by the command.
0 2 * * * /home/asha/backup.sh
This runs backup.sh every day at 2:00 AM. crontab -l lists your jobs.
Quick revision table
| Task | Command |
|---|---|
| Where am I | pwd |
| List with details | ls -la |
| Search text | grep -n pattern file |
| Find files | find . -name "*.log" |
| Watch a log | tail -f app.log |
| Change permissions | chmod 755 file |
| Change owner | chown user:group file |
| List processes | ps aux, top |
| Stop a process | kill PID, then kill -9 PID |
| Disk and memory | df -h, du -sh, free -h |
How to prepare in one week
| Day | Task |
|---|---|
| 1 | Navigation and file commands |
| 2 | Viewing files, grep and find |
| 3 | Pipes and redirection on a log file |
| 4 | Permissions, chmod, chown, umask |
| 5 | Processes, kill, background jobs |
| 6 | Packages, services, cron, a small shell script |
| 7 | Revise and do a mock interview |
Linux is the base of most DevOps work, so if you are aiming at that role, continue with the DevOps interview questions and the Docker interview questions for freshers. If you are choosing an operating system for coding, see Linux vs Windows for programming.

