Krazy Kaksha

Interview Prep

Linux Interview Questions and Answers for Freshers (Commands Included)

Krazy Kaksha 6 min read

Linux Interview Questions and Answers for Freshers (Commands Included)

Linux questions come up in almost every fresher interview for roles like software developer, DevOps, cloud, testing and support. Interviewers do not expect you to be a system admin, but they do expect you to know the basic commands, file permissions and how processes work. Below are the 35 most asked Linux interview questions for freshers with short answers you can speak in the interview.

Open a terminal (or a free online Linux shell) and try every command once. A command you have typed yourself is much easier to explain.

Quick summary

AreaWhat they ask most
BasicsLinux vs Unix, kernel, shell, distributions
Filesls, cd, cp, mv, rm, find, file permissions, chmod
Textcat, grep, head, tail, wc, sort, pipes
Processesps, top, kill, nohup, foreground and background
Systemdf, du, free, boot process, users and groups
Networkingping, ifconfig / ip, netstat / ss, ssh, curl

Linux Basics

1. What is Linux?
Linux is a free and open source operating system kernel made by Linus Torvalds in 1991. With GNU tools it becomes a full operating system.

2. What is the difference between Linux and Unix?
Unix is an older, mostly paid operating system (like AIX, Solaris). Linux is a free, Unix-like system that anyone can change and share.

3. What is the kernel?
The core of the operating system. It manages memory, processes, devices and system calls between hardware and programs.

4. What is a shell? Name some shells.
A shell is a program that takes your commands and passes them to the kernel. Examples: bash, sh, zsh, ksh.

5. What is a Linux distribution?
A package of the Linux kernel with tools and software. Examples: Ubuntu, Fedora, Debian, CentOS, Red Hat, Arch.

Files and Directories

6. Which commands do you use to move around and list files?
pwd shows the current folder, cd changes folder, ls -l lists files with details, ls -a shows hidden files.

7. How do you copy, move and delete files?
cp a b copies, mv a b moves or renames, rm file deletes, rm -r folder deletes a folder with its contents.

8. Explain file permissions in Linux.
Each file has read (r), write (w) and execute (x) permissions for three groups: owner, group and others. Example: -rwxr-xr--.

9. What does chmod 755 mean?
Owner gets 7 (read, write, execute), group gets 5 (read, execute), others get 5. Read = 4, write = 2, execute = 1.

10. What is the difference between chmod, chown and chgrp?
chmod changes permissions, chown changes the owner, chgrp changes the group.

11. What is the difference between a hard link and a soft link?
A hard link points to the same inode, so it works even if the original is deleted. A soft (symbolic) link points to the file path and breaks if the original is removed. Made with ln and ln -s.

12. How do you search for a file?
find / -name "file.txt" searches by name. locate file.txt is faster but uses a database.

13. What is an inode?
A data structure that stores file details like size, owner, permissions and the location of data blocks, but not the file name.

Working with Text

14. How do you view a file?
cat shows the whole file, less lets you scroll, head -n 10 shows the first 10 lines, tail -n 10 shows the last 10.

15. What does tail -f do?
It keeps showing new lines as they are added to a file. Used to watch log files live.

16. What is grep? Give an example.
grep searches text for a pattern. grep -i "error" app.log finds lines with “error”, ignoring case. -r searches inside folders.

17. What is a pipe?
The | symbol sends the output of one command into another. Example: ps aux | grep java.

18. How do you count lines, words and characters?
wc -l, wc -w and wc -c.

19. What is the difference between > and >>?
> writes output to a file and replaces old content. >> adds to the end of the file.

Processes

20. What is a process? How do you see running processes?
A process is a running program. ps aux lists processes, top or htop shows them live with CPU and memory use.

21. How do you stop a process?
kill PID sends a stop signal. kill -9 PID forces it to stop. pkill name stops by name.

22. What is the difference between foreground and background processes?
A foreground process holds the terminal. Add & to run in the background. jobs, fg and bg move them around.

23. What is nohup?
It keeps a command running after you log out. Example: nohup python app.py &.

24. What is a zombie process?
A process that has finished but still has an entry in the process table because its parent has not read its exit status.

25. What is a daemon?
A background service that starts at boot and runs without a user, like sshd or cron.

System and Users

26. How do you check disk space and memory?
df -h shows disk space, du -sh folder shows folder size, free -h shows memory.

27. Explain the Linux boot process.
BIOS or UEFI, then the boot loader (GRUB), then the kernel, then init or systemd, then the login screen.

28. What is sudo?
It runs a command as the root (admin) user. Only users in the sudo group can use it.

29. How do you add a user?
useradd name or adduser name, then passwd name to set a password.

30. What is cron?
A scheduler that runs commands at fixed times. Jobs are set with crontab -e, for example 0 2 * * * backup.sh runs at 2 AM daily.

Networking

31. How do you check if a server is reachable?
ping google.com checks reachability. traceroute shows the path.

32. How do you see your IP address?
ip a (new) or ifconfig (old).

33. How do you check open ports?
ss -tuln or netstat -tuln lists listening ports.

34. What is SSH?
Secure Shell, used to log in to a remote server safely. ssh user@server-ip. It uses port 22 by default.

35. What are curl and wget?
Both download data from a URL. wget is mainly for downloading files, curl is also used to test APIs.

Tips for the interview

  • Say the command and also what it does in one line.
  • If you are not sure about a flag, say “I would check with man or –help”, which interviewers like.
  • Keep 5 to 6 commands you use daily ready as examples.

Keep preparing

Save this page and revise it the night before your interview.

Doubts? Ask here

Leave a comment

Your email is not shown. Comments appear after a quick check.