{"id":12499,"date":"2024-08-29T10:15:37","date_gmt":"2024-08-29T04:45:37","guid":{"rendered":"https:\/\/www.placementpreparation.io\/blog\/?p=12499"},"modified":"2024-12-26T17:09:30","modified_gmt":"2024-12-26T11:39:30","slug":"linux-interview-questions-for-freshers","status":"publish","type":"post","link":"https:\/\/www.placementpreparation.io\/blog\/linux-interview-questions-for-freshers\/","title":{"rendered":"Top Linux Interview Questions for Freshers"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Are you preparing for your first Linux interview and wondering what questions you might face?<\/p><p>Understanding the key Linux interview questions for freshers can give you more clarity.<\/p><p>With this guide, you&rsquo;ll be well-prepared to tackle these Linux interview questions and answers for freshers and make a strong impression in your interview.<\/p><p><a href=\"https:\/\/www.guvi.in\/courses\/aptitude\/interview-preparation\/?utm_source=placement_preparation&amp;utm_medium=blog_banner&amp;utm_campaign=linux_interview_questions_for_freshers_horizontal\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-10341 size-full\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal.webp\" alt=\"interview preparation course desktop banner horizontal\" width=\"2270\" height=\"600\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal.webp 2270w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-300x79.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-1024x271.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-768x203.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-1536x406.webp 1536w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-2048x541.webp 2048w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2024\/05\/interview-preparation-course-desktop-banner-horizontal-150x40.webp 150w\" sizes=\"(max-width: 2270px) 100vw, 2270px\"><\/a><\/p><h2 id=\"practice-linux-interview-questions\">Practice Linux Interview Questions and Answers<\/h2><p>Below are the top 50 Linux interview questions for freshers with answers:<\/p><h3 id=\"list-all-files\">1. How do you list all files, including hidden files, in a directory in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>ls -a<\/strong> command to list all files in a directory, including hidden files that start with a dot (.).<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>ls -a<\/p>\n<\/div><\/div><h3 id=\"directory-size-command\">2. How can you find the size of a directory and its contents in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>du -sh<\/strong> command to display the total size of a directory and its contents in a human-readable format.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>du -sh \/path\/to\/directory<\/p>\n<\/div><\/div><h3 id=\"last-10-lines-command\">3. What is the command to display the last 10 lines of a file?<\/h3><p><strong>Answer:<\/strong><\/p><p>The <strong>tail<\/strong> command shows the last 10 lines of a file, which is useful for viewing the end of log files or other text files.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>tail filename.txt<\/p>\n<\/div><\/div><h3 id=\"copy-file-command\">4. How do you copy a file from one directory to another in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>cp<\/strong> command to copy a file from one directory to another, specifying the source file and destination directory.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>cp \/path\/to\/source\/file.txt \/path\/to\/destination\/<\/p>\n<\/div><\/div><h3 id=\"delete-recursively-command\">5. How can you recursively delete all files and directories within a specified directory?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>rm -rf<\/strong> command to recursively remove all files and directories within a specified directory.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>rm -rf \/path\/to\/directory\/<\/p>\n<\/div><\/div><h3 id=\"change-file-ownership\">6. How do you change the ownership of a file in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>chown<\/strong> command to change the ownership of a file, specifying the new owner and optionally the group.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>chown username:groupname filename.txt<\/p>\n<\/div><\/div><h3 id=\"modify-file-permissions\">7. How do you modify the permissions of a file to make it readable and writable by the owner, and readable by the group and others?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>chmod<\/strong> command with the mode <strong>644<\/strong> to set these permissions.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>chmod 644 filename.txt<\/p>\n<\/div><\/div><h3 id=\"add-new-user\">8. What is the command to add a new user to a Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>useradd<\/strong> command followed by the username to add a new user, and <strong>passwd<\/strong> to set the password.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>useradd newuser<br>\npasswd newuser<\/p>\n<\/div><\/div><h3 id=\"switch-user-account\">9. How do you switch to a different user account in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>su<\/strong> command followed by the username to switch to a different user account.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>su &ndash; username<\/p>\n<\/div><\/div><h3 id=\"list-logged-users\">10. How do you list all the users currently logged into the system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>who<\/strong> command to list all users currently logged into the system, including their login time and terminal.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>who<\/p>\n<\/div><\/div><h3 id=\"view-running-processes\">11. How do you view all running processes in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>ps aux<\/strong> command to display a detailed list of all running processes along with their statuses.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>ps aux<\/p>\n<\/div><\/div><h3 id=\"kill-process-command\">12. What is the command to kill a process using its PID in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>kill<\/strong> command followed by the process ID (PID) to terminate a process.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>kill 12345<\/p>\n<\/div><\/div><h3 id=\"monitor-resource-usage\">13. How do you monitor real-time system resource usage like CPU and memory in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>top<\/strong> command to monitor real-time CPU and memory usage, along with other system metrics.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>top<\/p>\n<\/div><\/div><h3 id=\"schedule-task-cron\">14. How can you schedule a task to run at a specific time using cron?<\/h3><p><strong>Answer:<\/strong><\/p><p>Edit the <strong>crontab<\/strong> file using <strong>crontab -e<\/strong> and add a cron job specifying the time and the command to run.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>0 2 * * * \/path\/to\/script.sh<\/p>\n<\/div><\/div><h3 id=\"process-memory-usage\">15. How do you find the memory usage of a specific process in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>pmap<\/strong> command with the <strong>-x<\/strong> flag to report memory usage for a specific process using its PID.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>pmap -x 12345<\/p>\n<\/div><\/div><h3 id=\"check-ip-address\">16. How do you check the IP address of your Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>ip addr show<\/strong> or <strong>ifconfig<\/strong> command to display the IP address of your network interfaces.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>ip addr show<\/p>\n<\/div><\/div><h3 id=\"test-network-connectivity\">17. What command would you use to test the connectivity to another host on the network?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>ping<\/strong> command followed by the host&rsquo;s IP address or domain name to test network connectivity.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>ping google.com<\/p>\n<\/div><\/div><h3 id=\"open-firewall-port\">18. How do you open a specific port on your Linux firewall using iptables?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>iptables -A INPUT -p tcp &ndash;dport 8080 -j ACCEPT<\/strong> command to allow traffic on a specific port.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>iptables -A INPUT -p tcp &ndash;dport 8080 -j ACCEPT<\/p>\n<\/div><\/div><h3 id=\"check-open-ports\">19. What is the command to check open ports and listening services on a Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>netstat -tuln<\/strong> or <strong>ss -tuln<\/strong> command to list all open ports and listening services.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>netstat -tuln<\/p>\n<\/div><\/div><h3 id=\"secure-ssh-access\">20. How do you secure SSH access to a Linux server?<\/h3><p><strong>Answer:<\/strong><\/p><p>Disable root login by editing the <strong>\/etc\/ssh\/sshd_config<\/strong> file and set <strong>PermitRootLogin no<\/strong>, then restart the SSH service.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>service sshd restart<\/p>\n<\/div><\/div><h3 id=\"backup-shell-script\">21. Write a simple shell script to back up a directory to a specified location.<\/h3><p><strong>Answer:<\/strong><\/p><p>A basic shell script can use the <strong>cp<\/strong> command to copy a directory to a backup location.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>#!\/bin\/bash<br>\ncp -r \/path\/to\/source \/path\/to\/backup\/<\/p>\n<\/div><\/div><h3 id=\"pass-script-arguments\">22. How do you pass arguments to a shell script and use them within the script?<\/h3><p><strong>Answer:<\/strong><\/p><p>Arguments passed to a shell script can be accessed using <strong>$1<\/strong>, <strong>$2<\/strong>, etc., corresponding to the first, second, and subsequent arguments.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>#!\/bin\/bash<br>\necho &ldquo;First argument: $1&rdquo;<br>\necho &ldquo;Second argument: $2&rdquo;<\/p>\n<\/div><\/div><h3 id=\"script-shebang-purpose\">23. What is the purpose of the shebang (#!) at the beginning of a shell script?<\/h3><p><strong>Answer:<\/strong><\/p><p>The <strong>shebang<\/strong> specifies the interpreter to be used to execute the script, typically <strong>\/bin\/bash<\/strong> for Bash scripts.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>#!\/bin\/bash<\/p>\n<\/div><\/div><h3 id=\"midnight-script-schedule\">24. How do you schedule a shell script to run every day at midnight?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>crontab<\/strong> command to schedule the script by adding an entry like <strong>0 0 * * * \/path\/to\/script.sh<\/strong>.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>crontab -e<\/p>\n<\/div><\/div><h3 id=\"make-script-executable\">25. How do you make a shell script executable?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>chmod +x<\/strong> command to make the script executable, allowing it to be run directly from the command line.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>chmod +x script.sh<\/p>\n<\/div><\/div><h3 id=\"check-disk-space\">26. How do you check the available disk space on your Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>df -h<\/strong> command to check the available disk space in a human-readable format, showing mounted filesystems and their usage.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>df -h<\/p>\n<\/div><\/div><h3 id=\"specific-directory-usage\">27. What command is used to check the disk usage of a specific directory?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>du -sh<\/strong> command to check the disk usage of a specific directory, showing the total size.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>du -sh \/path\/to\/directory\/<\/p>\n<\/div><\/div><h3 id=\"create-disk-partition\">28. How do you create a new partition on a Linux disk using fdisk?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>fdisk<\/strong> command to select the disk, then create a new partition by entering <strong>n<\/strong> and following the prompts.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>fdisk \/dev\/sda<\/p>\n<\/div><\/div><h3 id=\"mount-partition-command\">29. What is the command to mount a partition in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>mount<\/strong> command specifying the partition and the directory where it should be mounted.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>mount \/dev\/sda1 \/mnt\/mydrive<\/p>\n<\/div><\/div><h3 id=\"check-filesystem-type\">30. How do you check the filesystem type of a partition in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>blkid<\/strong> or <strong>df -T<\/strong> command to display the filesystem type of a partition.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>blkid \/dev\/sda1<\/p>\n<\/div><\/div><h3 id=\"find-specific-text\">31. How do you find all files containing a specific text string in a directory and its subdirectories?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>grep -r<\/strong> command to search recursively for a specific text string in a directory and its subdirectories.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>grep -r &ldquo;search_term&rdquo; \/path\/to\/directory\/<\/p>\n<\/div><\/div><h3 id=\"create-compressed-archive\">32. What is the command to create a compressed archive of a directory in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>tar<\/strong> command with the <strong>-czvf<\/strong> options to create a compressed archive (tar.gz) of a directory.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>tar -czvf archive_name.tar.gz \/path\/to\/directory\/<\/p>\n<\/div><\/div><h3 id=\"extract-tar-gz\">33. How do you extract a .tar.gz file in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>tar<\/strong> command with the <strong>-xzvf<\/strong> options to extract a <strong>.tar.gz<\/strong> file to the current directory.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>tar -xzvf archive_name.tar.gz<\/p>\n<\/div><\/div><h3 id=\"process-pid-search\">34. How do you search for a running process by its name and display its PID?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>pgrep<\/strong> command followed by the process name to find its PID.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>pgrep process_name<\/p>\n<\/div><\/div><h3 id=\"redirect-command-output\">35. How do you redirect the output of a command to a file, overwriting the file if it exists?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>&gt;<\/strong> operator to redirect the output of a command to a file, overwriting it if it already exists.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>command &gt; output.txt<\/p>\n<\/div><\/div><h3 id=\"etc-fstab-purpose\">36. What is the purpose of the \/etc\/fstab file in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>The <strong>\/etc\/fstab<\/strong> file contains static information about filesystems and defines how disk partitions, devices, and remote filesystems should be mounted at boot.<\/p><h3 id=\"edit-bootloader-config\">37. How do you view and edit the bootloader configuration in a Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use a text editor to view and edit the GRUB bootloader configuration file located at <strong>\/etc\/default\/grub<\/strong>, and then update GRUB.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo nano \/etc\/default\/grub<br>\nsudo update-grub<\/p>\n<\/div><\/div><h3 id=\"change-default-runlevel\">38. How do you change the default runlevel in a Linux system using systemd?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>systemctl set-default<\/strong> command to change the default runlevel (target) in a systemd-based Linux system.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo systemctl set-default multi-user.target<\/p>\n<\/div><\/div><h3 id=\"list-service-statuses\">39. What is the command to list all services and their statuses on a systemd-based Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>systemctl list-units &ndash;type=service<\/strong> command to list all services and their current statuses.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>systemctl list-units &ndash;type=service<\/p>\n<\/div><\/div><h3 id=\"enable-service-startup\">40. How do you enable a service to start automatically at boot in a systemd-based Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>systemctl enable<\/strong> command to configure a service to start automatically at boot.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo systemctl enable service_name<\/p>\n<\/div><\/div><h3 id=\"display-kernel-version\">41. How do you display the current Linux kernel version?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>uname -r<\/strong> command to display the current Linux kernel version running on the system.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>uname -r<\/p>\n<\/div><\/div><h3 id=\"load-kernel-module\">42. How do you load a kernel module manually in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>modprobe<\/strong> command followed by the module name to load a kernel module manually.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo modprobe module_name<\/p>\n<\/div><\/div><h3 id=\"change-process-priority\">43. How do you change the priority of a running process in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>renice<\/strong> command to change the priority of a running process, identified by its PID.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo renice 10 12345<\/p>\n<\/div><\/div><h3 id=\"check-cpu-usage\">44. How do you check the CPU usage of processes on a Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>top<\/strong> or <strong>htop<\/strong> command to monitor CPU usage by processes in real-time.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>top<\/p>\n<\/div><\/div><h3 id=\"kernel-buffer-contents\">45. What is the command to view the contents of the kernel ring buffer?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>dmesg<\/strong> command to view the kernel ring buffer, which contains system and kernel messages.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>dmesg<\/p>\n<\/div><\/div><h3 id=\"configure-static-ip\">46. How do you configure a static IP address in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Edit the network configuration file, typically located at <strong>\/etc\/network\/interfaces<\/strong> or use <strong>nmtui<\/strong> for NetworkManager, and specify the static IP details.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>sudo nano \/etc\/network\/interfaces<\/p>\n<\/div><\/div><h3 id=\"check-routing-table\">47. How do you check the routing table on a Linux system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>route -n<\/strong> or <strong>ip route<\/strong> command to display the routing table and determine how network traffic is routed.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>ip route<\/p>\n<\/div><\/div><h3 id=\"display-dns-servers\">48. What is the command to display the DNS server(s) used by your system?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>cat \/etc\/resolv.conf<\/strong> command to display the DNS server(s) configured for your system.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>cat \/etc\/resolv.conf<\/p>\n<\/div><\/div><h3 id=\"traceroute-network-issues\">49. How do you check for network connectivity issues using the traceroute command?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>traceroute<\/strong> command followed by a domain or IP address to identify the path and any delays in the network.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>traceroute google.com<\/p>\n<\/div><\/div><h3 id=\"configure-port-forwarding\">50. How do you configure port forwarding using iptables in Linux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>iptables<\/strong> command to set up port forwarding by specifying the source and destination ports.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>iptables -t nat -A PREROUTING -p tcp &ndash;dport 80 -j DNAT &ndash;to-destination 192.168.1.10:8080<\/p>\n<\/div><\/div><h2>Final Words<\/h2><p>Getting ready for an interview can feel overwhelming, but going through these Linux fresher interview questions can help you feel more confident.<\/p><p>With the right preparation, you&rsquo;ll ace your Linux interview but don&rsquo;t forget to practice the Linux basic commands, shell scripting, and system administration-related interview questions too.<\/p><h2>Frequently Asked Questions<\/h2><h3>1. What are the most common interview questions for Linux?<\/h3><p>The most common interview questions for Linux often include topics like basic commands, file permissions, shell scripting, and system administration tasks.<\/p><h3>2. What are the important Linux topics freshers should focus on for interviews?<\/h3><p>The important Linux topics freshers should focus on include command-line usage, file management, process control, networking basics, and shell scripting.<\/p><h3>3. How should freshers prepare for Linux technical interviews?<\/h3><p>Freshers should prepare for Linux technical interviews by practicing common commands, understanding system administration concepts, and writing simple shell scripts.<\/p><h3>4. What strategies can freshers use to solve Linux coding questions during interviews?<\/h3><p>Strategies freshers can use include breaking down the problem, using built-in Linux tools effectively, and testing commands or scripts before presenting the solution.<\/p><h3>5. Should freshers prepare for advanced Linux topics in interviews?<\/h3><p>Yes, freshers should prepare for advanced Linux topics like networking, security, and automation if the role requires deeper system knowledge.<\/p><hr><h2>Explore More Linux Resources<\/h2><ul class=\"explore-more\">\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/linux-project-ideas-for-beginners\/\">Linux Project Ideas<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/mcq\/linux\/\">Linux MCQ<\/a><\/li>\n<\/ul><h2>Explore More Interview Questions<\/h2><ul class=\"explore-more\">\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/python-interview-questions-for-freshers\/\">Python<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/java-interview-questions-for-freshers\/\">Java<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/sql-interview-questions-for-freshers\/\">SQL<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/react-interview-questions-for-freshers\/\">React<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/javascript-interview-questions-for-freshers\/\">JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/c-programming-interview-questions-for-freshers\/\">C Programming<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/html-interview-questions-for-freshers\/\">HTML<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/css-interview-questions-for-freshers\/\">CSS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/angular-interview-questions-for-freshers\/\">Angular<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/cpp-interview-questions-for-freshers\/\">C++<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/spring-boot-interview-questions-for-freshers\/\">Spring Boot<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/node-js-interview-questions-for-freshers\/\">Node JS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/excel-interview-questions-for-freshers\/\">Excel<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/c-sharp-interview-questions-for-freshers\/\">C#<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/dbms-interview-questions-for-freshers\/\">DBMS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/php-interview-questions-for-freshers\/\">PHP<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Are you preparing for your first Linux interview and wondering what questions you might face?Understanding the key Linux interview questions for freshers can give you more clarity.With this guide, you&rsquo;ll be well-prepared to tackle these Linux interview questions and answers for freshers and make a strong impression in your interview.Practice Linux Interview Questions and AnswersBelow [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":12500,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-12499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-interview-questions"],"_links":{"self":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/comments?post=12499"}],"version-history":[{"count":2,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12499\/revisions"}],"predecessor-version":[{"id":12502,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12499\/revisions\/12502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media\/12500"}],"wp:attachment":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media?parent=12499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/categories?post=12499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/tags?post=12499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}