Docsity

200 Linux Interview Q&A PDF: Advanced Linux System Administration & Engineering Practice Q, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
200 Linux Interview Q&A
1. What is Linux?
Correct Answer āœ…āœ…:Linux is an open-source, Unix-like operating system kernel developed
by Linus Torvalds. It is widely used in servers, desktops, mobile devices, and embedded
systems.
2. What is the difference between Linux and Unix?
Correct Answer āœ…āœ…:Linux is an open-source Unix-like operating system kernel, while
Unix is a proprietary operating system developed by AT&T Bell Labs. Unix requires a license,
whereas Linux is free and open-source.
3. Explain the Linux file system hierarchy.
Correct Answer āœ…āœ…:The Linux file system hierarchy is structured in a tree-like format
starting from the root directory (/). Important directories include /bin, /etc, /home, /var, /usr, and
/tmp.
4. What is the root account?
Correct Answer āœ…āœ…:The root account is the superuser account in Linux with unrestricted
access to all commands, files, and system resources. It is used for system administration tasks.
5. How do you change file permissions in Linux?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download 200 Linux Interview Q&A PDF: Advanced Linux System Administration & Engineering Practice Q and more Exams Computer Architecture and Organization in PDF only on Docsity!

200 Linux Interview Q&A

1. What is Linux? Correct Answer āœ…āœ… : Linux is an open-source, Unix-like operating system kernel developed by Linus Torvalds. It is widely used in servers, desktops, mobile devices, and embedded systems. 2. What is the difference between Linux and Unix? Correct Answer āœ…āœ… : Linux is an open-source Unix-like operating system kernel, while Unix is a proprietary operating system developed by AT&T Bell Labs. Unix requires a license, whereas Linux is free and open-source. 3. Explain the Linux file system hierarchy. Correct Answer āœ…āœ… : The Linux file system hierarchy is structured in a tree-like format starting from the root directory (/). Important directories include /bin, /etc, /home, /var, /usr, and /tmp. 4. What is the root account? Correct Answer āœ…āœ… : The root account is the superuser account in Linux with unrestricted access to all commands, files, and system resources. It is used for system administration tasks. 5. How do you change file permissions in Linux?

Correct Answer āœ…āœ… : Use the chmod command. For example, to set read, write, and execute permissions for the owner and read permissions for others, use: chmod 744 filename

6. What is the difference between su and sudo? Correct Answer āœ…āœ… : su switches the user to the root account, requiring the root password. sudo allows a permitted user to execute a command as the superuser or another user, requiring the user's password. 7. How do you check the current runlevel? Correct Answer āœ…āœ… : Use the runlevel command: runlevel 8. How do you list all installed packages in a Debian-based system? Correct Answer āœ…āœ… : Use the dpkg command: dpkg --list 9. How do you view running processes in Linux? Correct Answer āœ…āœ… : Use the ps or top command. For a snapshot: ps aux For a dynamic view:

grep - r "search_string" /path/to/directory

15. How do you compress files using tar? Correct Answer āœ…āœ… : Use the tar command with - czf to create a compressed archive: tar - czf archive.tar.gz /path/to/directory 16. How do you extract files from a tar archive? Correct Answer āœ…āœ… : Use the tar command with - xzf to extract: tar - xzf archive.tar.gz 17. How do you find the IP address of your system? Correct Answer āœ…āœ… : Use the ip or ifconfig command: ip addr show or ifconfig 18. How do you view the contents of a file? Correct Answer āœ…āœ… : Use commands like cat, less, or more. For example: cat filename

19. How do you change the hostname of a Linux system? Correct Answer āœ…āœ… : Use the hostnamectl command: sudo hostnamectl set-hostname newhostname 20. What is the crontab command used for? Correct Answer āœ…āœ… : crontab is used to schedule jobs (commands or scripts) to run periodically. For example, to edit the crontab file: crontab - e 21. How do you add a user in Linux? Correct Answer āœ…āœ… : Use the adduser command: sudo adduser username 22. How do you delete a user in Linux? Correct Answer āœ…āœ… : Use the deluser command: sudo deluser username 23. How do you switch to another user account? Correct Answer āœ…āœ… : Use the su command: su - username

pgrep processname

29. What is a package manager? Correct Answer āœ…āœ… : A package manager automates the process of installing, upgrading, configuring, and removing software packages. Examples include APT for Debian-based systems and YUM/DNF for Red Hat-based systems. 30. How do you update all packages in a Debian-based system? Correct Answer āœ…āœ… : Use the apt update and apt upgrade commands: sudo apt update sudo apt upgrade 31. How do you install a package in a Red Hat-based system? Correct Answer āœ…āœ… : Use the yum or dnf command: sudo yum install package_name or sudo dnf install package_name 32. How do you remove a package in a Debian-based system? Correct Answer āœ…āœ… : Use the apt remove command: sudo apt remove package_name

33. What is the difference between apt-get and apt? Correct Answer āœ…āœ… : apt is a higher-level interface for package management, providing a more user- friendly set of commands that include the functionality of apt-get, apt-cache, and other lower- level tools. 34. What is the find command used for? Correct Answer āœ…āœ… : find is used to search for files and directories based on various criteria. For example, to find all .txt files: find /path/to/search - name "*.txt" 35. How do you count the number of lines, words, and characters in a file? Correct Answer āœ…āœ… : Use the wc command: wc filename 36. What is the purpose of the /etc/passwd file? Correct Answer āœ…āœ… : The /etc/passwd file contains user account information, including username, user ID, group ID, home directory, and shell. 37. What is the /etc/shadow file? Correct Answer āœ…āœ… : The /etc/shadow file contains encrypted user passwords and additional account information like password expiration.

Correct Answer āœ…āœ… : Use the umount command: sudo umount /mnt

44. What is the purpose of the /proc directory? Correct Answer āœ…āœ… : The /proc directory is a virtual file system providing information about system processes and kernel parameters. 45. How do you change the current directory? Correct Answer āœ…āœ… : Use the cd command: cd /path/to/directory 46. How do you display the current directory? Correct Answer āœ…āœ… : Use the pwd command: pwd 47. How do you create a new directory? Correct Answer āœ…āœ… : Use the mkdir command: mkdir new_directory 48. How do you remove an empty directory?

Correct Answer āœ…āœ… : Use the rmdir command: rmdir empty_directory

49. How do you remove a directory and its contents? Correct Answer āœ…āœ… : Use the rm - r command: rm - r directory_name 50. What is the purpose of the /etc/hosts file? Correct Answer āœ…āœ… : The /etc/hosts file maps hostnames to IP addresses, providing a way to associate names with IP addresses without using DNS. 51. How do you display all open network connections? Correct Answer āœ…āœ… : Use the netstat command: netstat - tuln 52. What is the ifconfig command used for? Correct Answer āœ…āœ… : ifconfig is used to configure network interfaces, assign IP addresses, and manage network connections. However, ip is recommended for newer systems. 53. How do you configure a network interface using the ip command? Correct Answer āœ…āœ… : Use the ip addr command:

Correct Answer āœ…āœ… : iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel.

59. How do you list the current iptables rules? Correct Answer āœ…āœ… : Use the iptables - L command: sudo iptables - L 60. How do you allow incoming SSH connections on iptables? Correct Answer āœ…āœ… : Use the iptables - A command: sudo iptables - A INPUT - p tcp --dport 22 - j ACCEPT 61. How do you save iptables rules? Correct Answer āœ…āœ… : Use the iptables-save command: sudo iptables-save > /etc/iptables/rules.v 62. What is the tcpdump command used for? Correct Answer āœ…āœ… : tcpdump is a packet analyzer that captures and displays the network traffic passing through a network interface. 63. How do you capture packets on a specific interface using tcpdump? Correct Answer āœ…āœ… : Use the tcpdump - i command:

sudo tcpdump - i eth

64. What is the ss command used for? Correct Answer āœ…āœ… : ss is used to dump socket statistics and display information about network connections. 65. How do you display listening ports using ss? Correct Answer āœ…āœ… : Use the ss - tuln command: ss - tuln 66. What is the hostname command used for? Correct Answer āœ…āœ… : hostname displays or sets the system's hostname. 67. How do you change the system's hostname? Correct Answer āœ…āœ… : Use the hostnamectl command: sudo hostnamectl set-hostname newhostname 68. What is a shell in Linux? Correct Answer āœ…āœ… : A shell is a command-line interpreter that provides a user interface for accessing the operating system's services. 69. What is the difference between bash and sh?

74. How do you define a variable in a shell script? Correct Answer āœ…āœ… : Use the = operator without spaces: variable_name="value" 75. How do you access a variable in a shell script? Correct Answer āœ…āœ… : Use the $ symbol: echo $variable_name 76. How do you read user input in a shell script? Correct Answer āœ…āœ… : Use the read command: read variable_name 77. How do you use an ifstatement in a shell script? Correct Answer āœ…āœ… : Use the if keyword followed by the condition and then keyword. For example: if [ condition ]; then commands fi 78. How do you use a for loop in a shell script?

Correct Answer āœ…āœ… : Use the for keyword followed by the loop variable and in keyword. For example: for i in 1 2 3; do echo $i done

79. How do you use a while loop in a shell script? Correct Answer āœ…āœ… : Use the while keyword followed by the condition. For example: while [ condition ]; do commands done 80. How do you pass arguments to a shell script? Correct Answer āœ…āœ… : Use positional parameters $1, $2, etc. For example: ./script.sh arg1 arg 81. How do you display the current date and time? Correct Answer āœ…āœ… : Use the date command: Date 82. How do you display a calendar for the current month?

Correct Answer āœ…āœ… : Use the uptime or top command.

88. What is the dmesg command used for? Correct Answer āœ…āœ… : dmesg displays the kernel ring buffer messages, useful for debugging hardware and driver issues. 89. How do you clear the terminal screen? Correct Answer āœ…āœ… : Use the clear command: Clear 90. How do you schedule a one-time job using at? Correct Answer āœ…āœ… : Use the at command followed by the time. For example: echo "command" | at 10: 91. How do you list scheduled at jobs? Correct Answer āœ…āœ… : Use the atq command: atq 92. How do you remove a scheduled at job? Correct Answer āœ…āœ… : Use the atrm command followed by the job number:

atrm job_number

93. How do you schedule a recurring job using cron? Correct Answer āœ…āœ… : Edit the crontab file using crontab - e and add the job with the schedule. For example: 0 5 * * * /path/to/script.sh 94. How do you list all cron jobs for the current user? Correct Answer āœ…āœ… : Use the crontab - l command: crontab - l 95. How do you remove all cron jobs for the current user? Correct Answer āœ…āœ… : Use the crontab - r command: crontab - r 96. How do you view the system's scheduled cron jobs? Correct Answer āœ…āœ… : View the /etc/crontab file and files in /etc/cron.d/. 97. How do you send a message to all logged-in users? Correct Answer āœ…āœ… : Use the wall command: echo "message" | wall