






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!































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