Unix Interview Questions and Answers
This section covers frequently asked Unix interview questions.
1. What is Unix?
Unix is a portable, multitasking, multi-user operating system. It's known for its efficiency and flexibility.
2. Unix Distributions.
(This section would list various Unix distributions, such as Solaris, AIX, HP-UX, BSD, etc.)
3. Features of Unix.
- Multi-user capabilities
- Multitasking
4. Core Concepts of Unix.
- Kernel: The core of the operating system, managing hardware and processes.
- Shell: A command-line interpreter.
- Commands and Utilities: Built-in tools for various tasks.
- Directories: Organize files in a hierarchical structure.
5. What is a Unix Shell?
A shell is a command-line interpreter that allows users to interact with the Unix operating system.
6. What is a Filter?
A filter is a program that takes input, processes it, and outputs the result.
7. Device Representation in Unix.
Devices are represented as files in the /dev
directory.
8. Deleting Files and Subdirectories.
Use the command rm -r *
(use with caution!).
9. Making a Shell Script Executable.
Use the chmod
command (e.g., chmod +x myscript.sh
).
10. Terminating an if
Statement.
Use fi
.
11. Common Unix Shells.
(This section lists common Unix shells and their names, such as Bourne shell (sh), C shell (csh), Bash (bash), etc.)
12. Features of Korn Shell (ksh).
- Arrays
- Job control
- Command aliasing
- String manipulation
- Built-in arithmetic
13. cat
vs. more
Commands.
cat
displays the entire file content. more
displays page by page.
14. Restricting Incoming Messages.
Use the mesg
command.
15. Killing the Last Background Job.
Use the command kill $!
.
16. File Identification Data Structure.
Inode.
17. Pipes in Unix.
Pipes (|
) connect the output of one command to the input of another.
18. Links and Symbolic Links.
A hard link is an additional name for an existing file. A symbolic link (symlink) is a pointer to a file.
19. Unix System Bootup.
(This section would detail the typical boot process in a Unix-like system, involving BIOS/UEFI, bootloader, kernel initialization, and the launching of the init process.)
20. Changing Your Password.
Use the passwd
command.
21. Listing Directories.
(This section would list various options with the `ls` command for controlling output.)
22. Displaying the Date.
Use the date
command.
23. Logging Out.
Use the logout
command.
24. System Shutdown Commands.
(This section lists common commands for shutting down a Unix-like system: `halt`, `init 0`, `init 6`, `poweroff`, `reboot`, `shutdown`.)
25. Types of Unix Files.
- Regular files
- Directories
- Special files (devices)
26. Hidden Files.
Files whose names begin with a dot (.) are hidden files.
27. Single Dot (.) vs. Double Dot (..).
.
: Current directory..
: Parent directory
28. Creating Files.
Use a text editor (like vi
) or the touch
command.
29. Displaying File Contents.
Use the cat
command (and options like -b
for line numbers).
30. Counting Words in a File.
Use the wc
command (e.g., wc -w filename
).
31. Creating a Blank File.
Use the touch
command.
32. Finding the Present Working Directory.
Use the pwd
command.
33. Getting File Information.
Use the file
command.
34. Changing the Directory.
Use the cd
command.
35. Moving Files.
Use the mv
command.
36. Copying Files.
Use the cp
command (e.g., cp -r source destination
for recursive copying).
37. Removing Files in Unix.
Use the rm
command. The -r
option removes directories and their contents recursively (use with caution!).
Syntax
rm filename #Removes a single file
rm -r directory_name #Removes a directory and its contents recursively
38. Creating a Directory.
Use the mkdir
command.
Syntax
mkdir directory_name
39. Removing a Directory.
Use the rmdir
command (to remove an empty directory) or `rm -r` (to remove a directory and its contents).
Syntax
rmdir directory_name #Removes an empty directory
rm -r directory_name #Removes a directory and its contents recursively