Linux is one of the most versatile and widely-used operating systems, especially in server environments and development setups. Whether you’re starting your journey in Linux system administration or preparing for interviews, mastering basic Linux commands and concepts is essential. In this blog, we’ll explore 100 basic-level Linux administrator questions with answers to help you practice and improve your Linux skills.
- What is Linux?
Answer: Linux is an open-source operating system based on UNIX, used for servers, desktops, and embedded systems.
- What is the Linux kernel?
Answer: The kernel is the core of the Linux OS that manages hardware resources and system processes.
- What are Linux distributions?
Answer: A Linux distribution is an OS based on the Linux kernel, bundled with software like Ubuntu, CentOS, Fedora, etc.
- What command is used to list files in a directory?
Answer: ls
- How do you change the current directory?
Answer: cd [directory_name]
- What is the command to display the current working directory?
Answer: pwd
- How do you create a new directory in Linux?
Answer: mkdir [directory_name]
- How do you remove an empty directory?
Answer: rmdir [directory_name]
- What is the command to delete a file?
Answer: rm [file_name]
- How do you copy files?
Answer: cp [source] [destination]
- How do you move or rename a file?
Answer: mv [source] [destination]
- What is the root user?
Answer: The root user is the administrative user with full privileges.
- How do you switch to the root user?
Answer: su or sudo -i
- What does the chmod command do?
Answer: It changes the permissions of a file or directory.
- How do you check the current system date and time?
Answer: date
- How do you display the contents of a file?
Answer: cat [file_name]
- What is the touch command used for?
Answer: To create an empty file or update the timestamp of an existing file.
- What does the df command do?
Answer: Displays disk space usage.
- How do you check memory usage?
Answer: free -h
- What is the command to find your Linux kernel version?
Answer: uname -r
- How do you find out which Linux distribution you are using?
Answer: cat /etc/os-release
- How do you list running processes?
Answer: ps or top
- What is the command to kill a process?
Answer: kill [PID]
- What is the grep command used for?
Answer: To search text in files using patterns.
- How do you find the path of a command?
Answer: which [command_name]
- What is a symbolic link?
Answer: A shortcut to another file or directory created using ln -s.
- What does the whoami command do?
Answer: Displays the current user.
- How do you add a new user?
Answer: sudo useradd [username]
- How do you delete a user?
Answer: sudo userdel [username]
- What is the passwd command used for?
Answer: To change a user’s password.
- What does the history command do?
Answer: Displays the list of previously executed commands.
- How do you edit a file in Linux?
Answer: Using text editors like vi, nano, or vim.
- What is the default shell in most Linux systems?
Answer: Bash (Bourne Again Shell)
- How do you compress files in Linux?
Answer: gzip [file_name] or tar -czf [archive.tar.gz] [files]
- What is the ping command used for?
Answer: To check the connectivity to another system or server.
- How do you change file ownership?
Answer: chown [owner:group] [file_name]
- What is the difference between apt and yum?
Answer: apt is used in Debian-based systems, and yum is used in Red Hat-based systems.
- How do you install a package in Debian-based Linux?
Answer: sudo apt install [package_name]
- How do you uninstall a package?
Answer: sudo apt remove [package_name]
- What does ifconfig do?
Answer: Displays or configures network interfaces (use ip in newer systems).
41. How do you restart a Linux system?
Answer: sudo reboot
42. How do you shut down a Linux system?
Answer: sudo shutdown now
43. What does the hostname command do?
Answer: Displays or sets the hostname of the system.
44. How do you view system logs?
Answer: cat /var/log/syslog or journalctl
45. What is a cron job?
Answer: A scheduled task configured using the crontab utility.
46. How do you edit cron jobs?
Answer: crontab -e
47. What is the purpose of the /etc/passwd file?
Answer: It stores user account information.
48. What is the purpose of the /etc/shadow file?
Answer: It stores encrypted user passwords.
49. How do you check disk usage for a specific directory?
Answer: du -sh [directory_name]
50. What is the command to unmount a filesystem?
Answer: umount [mount_point]
51. How do you create a file system on a partition?
Answer: mkfs.ext4 [device_name]
52. What is the purpose of /etc/fstab?
Answer: It defines how and where partitions should be mounted automatically.
53. What does the mount command do?
Answer: Mounts a filesystem to a directory.
54. What is the default runlevel for most Linux systems?
Answer: Runlevel 5 (multi-user graphical mode) or 3 (multi-user command-line mode).
55. How do you change runlevels?
Answer: Use the telinit or systemctl isolate command.
56. What is a package manager?
Answer: A tool to install, update, and remove software (e.g., apt, yum, dnf).
57. What does echo do in Linux?
Answer: Displays a string or outputs text to the terminal.
58. How do you search for files in Linux?
Answer: find [path] -name [file_name]
59. How do you search for a specific package?
Answer: apt search [package_name] or yum search [package_name]
60. How do you check open ports on your system?
Answer: netstat -tuln or ss -tuln
61. What does the wget command do?
Answer: Downloads files from the web.
62. What is the difference between hard link and soft link?
Answer:
- Hard Link: Points to the file’s data.
- Soft Link: A symbolic reference to a file’s path.
63. What is the purpose of tar?
Answer: Archives multiple files into one file.
64. How do you extract a tar.gz file?
Answer: tar -xzf [file.tar.gz]
65. How do you check the permissions of a file?
Answer: ls -l [file_name]
66. What is the command to check system uptime?
Answer: uptime
67. What does df -h show?
Answer: Disk space usage in a human-readable format.
68. What is the /proc directory?
Answer: A virtual filesystem with information about running processes.
69. How do you monitor system resource usage?
Answer: top or htop
70. What does the alias command do?
Answer: Creates shortcuts for commands.
71. How do you create an alias?
Answer: alias [alias_name]='[command]’
72. What is the env command used for?
Answer: Displays the environment variables.
73. How do you set an environment variable?
Answer: export VAR_NAME=value
74. What does the sed command do?
Answer: Edits text in a file or stream.
75. How do you extract specific lines from a file?
Answer: Using sed or awk.
76. What is the diff command used for?
Answer: Compares two files and shows the differences.
77. How do you create a partition in Linux?
Answer: Use the fdisk or parted command.
78. How do you check disk partitions?
Answer: lsblk or fdisk -l
79. How do you check CPU information?
Answer: cat /proc/cpuinfo
80. How do you check system memory usage?
Answer: cat /proc/meminfo or free -h
81. What is the purpose of the man command?
Answer: Displays the manual for a command.
82. What does the sudo command do?
Answer: Executes commands as another user (typically root).
83. What does the ls -a command do?
Answer: Lists all files, including hidden ones.
84. What is the use of nohup?
Answer: Runs a command immune to hangups (e.g., after logout).
85. How do you archive a directory?
Answer: tar -cvf [archive.tar] [directory_name]
86. How do you unzip a .zip file?
Answer: unzip [file.zip]
87. How do you view the first 10 lines of a file?
Answer: head [file_name]
88. How do you view the last 10 lines of a file?
Answer: tail [file_name]
89. What does the cut command do?
Answer: Extracts sections of lines from a file.
90. What is the uptime command used for?
Answer: Shows how long the system has been running.
91. How do you check the Linux OS version?
Answer: cat /etc/os-release
92. How do you forcefully delete a directory?
Answer: rm -rf [directory_name]
93. What is the purpose of /etc/hosts?
Answer: Maps hostnames to IP addresses.
94. What does the scp command do?
Answer: Securely copies files between systems.
95. What does the rsync command do?
Answer: Synchronizes files between locations.
96. How do you find large files on your system?
Answer: find / -type f -size +1G
97. What is the iptables command used for?
Answer: Configures the firewall rules.
98. What does the yum command do?
Answer: Manages software packages on Red Hat-based systems.
99. What is ssh used for?
Answer: Provides secure access to remote systems.
100. How do you display information about a command?
Answer: man [command_name] or [command_name] –help