Register Login

Unix Interview Questions and Answers for Experienced

Updated Apr 20, 2025

1. What is UNIX? What does UNIX stand for?

UNIX is a powerful, multiuser, multitasking operating system designed for flexibility and security. Originally developed in the 1970s, it's widely used on servers and workstations.

UNIX stands for: Uniplexed Information and Computing Service.

2. How to rename a file in UNIX?

mv old-file-name new-file-name

3. How to delete a directory in UNIX?

Empty directory:

rmdir directoryname

Directory with files:

rm -r directoryname

4. What is the difference between UNIX and LINUX?

Feature UNIX LINUX
Cost Usually proprietary and paid Mostly free and open source
Usage Servers, mainframes, workstations Servers, desktops, mobile devices
File Systems jfs, gpfs, hfs, xfs, zfs ext2/3/4, xfs, btrfs, FAT, NTFS
Source Code Closed Open source
Examples AIX, Solaris, HP-UX Ubuntu, CentOS, Fedora

5. How to change a password in UNIX?

passwd

6. How to find a file in UNIX?

find . -name "filename"

7. How to use grep command in UNIX?

The grep command searches for patterns in files.

grep [options] pattern [file...]

Example:

grep "error" logfile.txt

8. How to kill a process in UNIX?


kill -SIGTERM PID      # Graceful stop
kill -9 PID            # Forceful kill
killall process_name   # Kill by name
  

9. What is UNIX shell scripting?

Shell scripting involves writing a sequence of UNIX commands in a file to automate repetitive tasks.

10. How to run a shell script in UNIX?


cd /path/to/script
nano script.sh         # or any editor
chmod +x script.sh     # make it executable
./script.sh            # run the script
 

11. How to write a function in UNIX shell script?


myFunction() {
  echo "Hello World"
}

myFunction

12. How to add comments in UNIX shell script?

# This is a comment

13. What is the difference between Kill and Kill -9 in UNIX?

  • kill: Sends SIGTERM (15) – graceful termination.
  • kill -9: Sends SIGKILL – immediate and forceful termination.

14. Difference between CAT and VI commands in UNIX?

  • cat: Displays or creates files.
  • vi: Interactive full-screen text editor.

15. What are the different dialects in UNIX?

  • AT&T UNIX (System V)
  • BSD UNIX (Berkeley Software Distribution)
  • Microsoft XENIX
  • HP-UX (Hewlett-Packard)
  • AIX (IBM)
  • Solaris (Sun Microsystems)

16. Difference between MV and CP commands in UNIX?

  • mv: Moves or renames a file (original removed).
  • cp: Copies a file (original remains).

17. Different ways to create a file in UNIX?

cat > filename
touch filename
echo "Text" > filename
printf "Text\n" > filename
  

18. What is the use of awk command in UNIX?

The awk command is used for pattern scanning and text processing.

awk '{print $1}' filename

9. How to copy a directory in UNIX?

cp -R source_dir/ destination_dir/

20. What is the UNIX command to create a shortcut for tail?

alias mytail='tail -n 200'

21. How to change file permissions in UNIX?

chmod 755 filename

22. How to change the owner of a file in UNIX?

chown newowner filename

23. How to view file permissions in UNIX?

ls -l

24. How to list running processes in UNIX?

ps aux

25. What is the difference between a foreground and a background process?

Foreground: Runs in the current terminal.
Background: Runs independently of the terminal using &.

26. How to run a command in the background?

command &

27. What is the use of the find command?

find /path -name "filename"

28. What is the use of the sed command?

sed 's/old/new/g' filename

29. How to compress a file using gzip?

gzip filename

30. How to extract a .tar.gz file?

tar -xzvf file.tar.gz

31. How to check disk space usage?

df -h

32. How to check memory usage?

free -m

33. How to check current logged-in users?

who

34. What is the use of set -x and set +x in shell scripting?

They enable (set -x) and disable (set +x) debugging mode in shell scripts.

35. What are environment variables? How to list them?

printenv

36. What is the difference between .bashrc and .bash_profile?

  • .bashrc: Executes on interactive non-login shell.
  • .bash_profile: Executes on login shell.

37. How to schedule a job in UNIX?

crontab -e

38. What is shebang (#!) in UNIX shell scripts?

#!/bin/bash


×