0% found this document useful (0 votes)
4 views5 pages

UNIX Viva Questions Answers Expanded

The document provides a comprehensive list of UNIX viva questions and answers covering basic commands, file handling, permissions, process management, disk management, advanced commands, shell scripting, and system administration concepts. It includes commands for listing files, managing directories, changing permissions, and understanding the booting process. Additionally, it explains key concepts such as environment variables, hard and soft links, and runlevels in UNIX/Linux.

Uploaded by

codecon90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

UNIX Viva Questions Answers Expanded

The document provides a comprehensive list of UNIX viva questions and answers covering basic commands, file handling, permissions, process management, disk management, advanced commands, shell scripting, and system administration concepts. It includes commands for listing files, managing directories, changing permissions, and understanding the booting process. Additionally, it explains key concepts such as environment variables, hard and soft links, and runlevels in UNIX/Linux.

Uploaded by

codecon90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

UNIX Viva Questions and Answers

Basic UNIX Commands

1. What command is used to list files and directories?

Answer: ls

2. How to view hidden files in a directory?

Answer: ls -a

3. What is the command to display the current working directory?

Answer: pwd

4. How to create a new directory in UNIX?

Answer: mkdir <directory_name>

5. How to remove a file and a directory?

Answer: rm <file_name>

rm -r <directory_name>

File Handling

6. How to create a new file or update the timestamp of a file?

Answer: touch <file_name>

7. How to read a file's content?

Answer: cat <file_name>

8. How to copy and move files in UNIX?

Answer: cp source_file destination_file

mv source_file destination_file

9. What does the grep command do?

Answer: grep searches for patterns in files.


UNIX Viva Questions and Answers

grep "word" filename

10. How to display the first 10 lines of a file?

Answer: head <file_name>

Permissions and Users

11. How to change file permissions?

Answer: chmod 755 file_name

12. What does chmod 777 mean?

Answer: Gives read, write, and execute to owner, group, and others.

13. How to see file permissions and owners?

Answer: ls -l

14. How to switch to another user?

Answer: su - <username>

Process Management

15. How to see the list of running processes?

Answer: ps

16. How to kill a running process by PID?

Answer: kill <PID>

17. What command shows real-time system processes?

Answer: top

Disk and Directory Management


UNIX Viva Questions and Answers

18. How to check disk usage of a directory?

Answer: du -sh <directory>

19. How to check free disk space?

Answer: df -h

20. How to find a file in the system?

Answer: find / -name <file_name>

Advanced and Useful Commands

21. How to redirect output of a command to a file?

Answer: command > output.txt

22. What is the difference between > and >>?

Answer: > overwrites, >> appends

23. How to search for a string in multiple files?

Answer: grep "text" *.txt

24. What is a pipe (|) in UNIX?

Answer: Passes output of one command to another.

ls -l | grep "test"

25. How to schedule a task using cron?

Answer: crontab -e

0 5 * * * /home/user/script.sh

Shell Scripting and Concepts

26. What is a shell in UNIX?

Answer: A shell is a command-line interpreter that provides a user interface to the UNIX operating system. It interprets
UNIX Viva Questions and Answers

user commands and executes them.

27. What is the difference between a shell and a kernel?

Answer: The kernel is the core part of the OS that manages hardware and system resources. The shell acts as an

interface between the user and the kernel.

28. How do you write a basic shell script?

Answer: A basic shell script starts with:

#!/bin/bash

echo 'Hello, World!'

29. How can you pass arguments to a shell script?

Answer: You can pass arguments using $1, $2, etc.

Example:

./script.sh arg1 arg2

Inside script: echo $1 $2

30. What is the use of `read` command in shell scripts?

Answer: `read` is used to take user input in a script.

Example:

echo "Enter name:"

read name

echo "Welcome $name"

System Administration & Concepts

31. What is the purpose of the /etc/passwd file?

Answer: It stores essential information about user accounts such as username, user ID, group ID, home directory, and

default shell.

32. What are environment variables? Give examples.


UNIX Viva Questions and Answers

Answer: Environment variables are used to define the environment in which programs run.

Examples: PATH, HOME, USER, SHELL.

33. What is the difference between hard link and soft link?

Answer: A hard link is a direct reference to the file's inode. A soft link (symbolic link) is a pointer to the file path. Deleting

the original file breaks the soft link, not the hard link.

34. Explain the booting process of UNIX.

Answer: The booting process includes BIOS POST, loading the boot loader (like GRUB), initializing the kernel, mounting

the root filesystem, starting the init system, and finally starting user-level services.

35. What are runlevels in UNIX/Linux?

Answer: Runlevels define the state of the system. For example:

0 Halt

1 Single-user mode

3 Multi-user mode (CLI)

5 Multi-user mode (GUI)

6 Reboot

You might also like