Linux-Interview Questions

ยท

5 min read

  1. What are the Linux flavors?

    • Linux distributions or flavors include Ubuntu, CentOS, Debian, Fedora, Red Hat Enterprise Linux (RHEL), and many others. Each has its own package management system and configurations but shares the Linux kernel at its core.
  2. What is process management?

    • Process management in Linux involves monitoring, controlling, and organizing processes running on the system. This includes starting, stopping, prioritizing, and managing resources allocated to processes.
  3. How to create a User? and How to give permissions to the user.

    • To create a user: sudo adduser username

    • To give permissions: Use chmod to change file permissions or chown to change ownership.

  4. How do you add a user to an Existing Group In Linux?

    • sudo usermod -aG groupname username
  5. How to change the owner permissions of the User or the file?

    • sudo chown newowner filename to change ownership.

    • sudo chmod permissions filename to change permissions.

  6. How to check the disk space in Linux?

    • df -h for overall disk usage.

    • du -h for usage by specific directories.

  7. How to check memory in Linux?

    • free -h for overall memory usage.

    • top or htop for a dynamic view of memory usage by processes.

  8. What does the top command display?

    • The top command displays real-time information about processes, CPU usage, memory usage, and system uptime.
  9. What is the use of lsblk command in Linux?

    • lsblk lists information about block devices (like disks and partitions) in a tree-like format.
  10. How to do Disk partition in Ubuntu?

    • Use fdisk, parted, or gparted tools to create, delete, and manage disk partitions.
  11. Where is fstab in Linux?

    • /etc/fstab is a configuration file that contains information about filesystems and storage devices, including mount points and options.
  12. What is the Linux boot process?

    • The Linux boot process involves BIOS/UEFI initialization, bootloader (like GRUB) loading the kernel, kernel initialization, and starting of system services and user-space processes.
  13. What is a Linux filesystem? What is /etc and /bin?

    • A Linux filesystem organizes how data is stored and retrieved on disk. /etc contains system-wide configuration files, while /bin holding essential binary executables.
  14. What are Crontab and Cronjob?

    • Crontab is the command used to edit cron jobs. Cronjobs are scheduled tasks that run at specified intervals or times automatically.
  15. What is virtualization?

    • Virtualization allows multiple virtual instances of operating systems or applications to run on a single physical machine, enabling efficient resource utilization.
  16. What is SElinux?

    • SELinux (Security-Enhanced Linux) is a Linux kernel security module that provides access control security policies, including mandatory access controls (MAC).
  17. How DNS works?

    • DNS (Domain Name System) translates domain names (like example.com) into IP addresses that computers use to communicate over networks.
  18. What is Apache?

    • Apache HTTP Server is a widely used open-source web server software that delivers web content to clients over the internet.
  19. What is PHPAdmin?

    • phpMyAdmin is a free and open-source tool written in PHP that manages MySQL databases through a web interface.
  20. Do you know about firewalls?

    • Firewalls are network security systems that monitor and control incoming and outgoing network traffic based on predetermined security rules.
  21. What is an SSL certificate? How can we create the SSL certificate and where will we do the configurations in Apache for the SSL certificate?

    • An SSL certificate encrypts data exchanged between a web server and a client. It can be created using tools like OpenSSL. Configuration for SSL in Apache is done in the virtual host configuration files.
  22. Which is better, Apache or Nginx? For a higher load, which web server is best?

    • Nginx is often preferred for serving static content and handling concurrent connections efficiently, making it suitable for high-load scenarios. Apache is versatile and supports a wide range of configurations and modules.
  23. What is the path of Apache configuration files?

    • Apache configuration files are typically found in /etc/apache2/ on Ubuntu or /etc/httpd/ on CentOS.
  24. ๐ˆ๐Ÿ ๐ฒ๐จ๐ฎ ๐ฐ๐š๐ง๐ญ ๐ญ๐จ ๐ซ๐ฎ๐ง ๐š ๐ญ๐š๐ฌ๐ค/๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ ๐ข๐ง ๐›๐š๐œ๐ค๐ ๐ซ๐จ๐ฎ๐ง๐ ๐ž๐ฏ๐ž๐ง ๐ข๐Ÿ ๐ฒ๐จ๐ฎ ๐œ๐ฅ๐จ๐ฌ๐ž ๐ฒ๐จ๐ฎ๐ซ ๐ญ๐ž๐ซ๐ฆ๐ข๐ง๐š๐ฅ, ๐ฐ๐ก๐š๐ญ ๐ข๐ฌ ๐ญ๐ก๐ž ๐ฐ๐š๐ฒ?

    Ans: Using nohup command

  25. ๐–๐ก๐ข๐œ๐ก ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ๐ฌ ๐ข๐ง๐Ÿ๐จ๐ซ๐ฆ๐š๐ญ๐ข๐จ๐ง ๐š๐›๐จ๐ฎ๐ญ ๐ค๐ž๐ซ๐ง๐ž๐ฅ-๐ซ๐ž๐ฅ๐š๐ญ๐ž๐ ๐ฆ๐ž๐ฌ๐ฌ๐š๐ ๐ž๐ฌ ๐š๐ฅ๐จ๐ง๐  ๐ฐ๐ข๐ญ๐ก ๐ก๐š๐ซ๐๐ฐ๐š๐ซ๐ž ๐š๐ง๐ ๐ฌ๐ฒ๐ฌ๐ญ๐ž๐ฆ ๐ฌ๐ญ๐š๐ซ๐ญ๐ฎ๐ฉ ๐ฆ๐ž๐ฌ๐ฌ๐š๐ ๐ž๐ฌ ๐ฌ๐ญ๐จ๐ซ๐ž๐ ๐ข๐ง ๐ค๐ž๐ซ๐ง๐ž๐ฅ ๐ซ๐ข๐ง๐  ๐›๐ฎ๐Ÿ๐Ÿ๐ž๐ซ?

    Ans: dmesg command

  26. ๐–๐ก๐ข๐œ๐ก ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐œ๐š๐ง ๐ฒ๐จ๐ฎ ๐ฎ๐ฌ๐ž ๐ญ๐จ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐š ๐ฅ๐ข๐ฌ๐ญ ๐จ๐Ÿ ๐œ๐ฎ๐ซ๐ซ๐ž๐ง๐ญ๐ฅ๐ฒ ๐œ๐จ๐ง๐Ÿ๐ข๐ ๐ฎ๐ซ๐ž๐ ๐๐ก๐ฒ๐ฌ๐ข๐œ๐š๐ฅ ๐•๐จ๐ฅ๐ฎ๐ฆ๐ž๐ฌ?

    Ans: lvs command

  27. ๐–๐ก๐ข๐œ๐ก ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ๐ฌ ๐ฆ๐ž๐ฆ๐จ๐ซ๐ฒ ๐ฎ๐ฌ๐š๐ ๐ž, ๐ข๐ง๐œ๐ฅ๐ฎ๐๐ข๐ง๐  ๐ญ๐ก๐ž ๐š๐ฆ๐จ๐ฎ๐ง๐ญ ๐จ๐Ÿ ๐ฌ๐ฐ๐š๐ฉ ๐ฌ๐ฉ๐š๐œ๐ž ๐›๐ž๐ข๐ง๐  ๐ฎ๐ฌ๐ž๐?

    Ans: free command

  28. ๐“๐ก๐ž /๐ก๐จ๐ฆ๐ž ๐ฉ๐š๐ซ๐ญ๐ข๐ญ๐ข๐จ๐ง ๐ข๐ฌ ๐ซ๐ฎ๐ง๐ง๐ข๐ง๐  ๐จ๐ฎ๐ญ ๐จ๐Ÿ ๐๐ข๐ฌ๐ค ๐ฌ๐ฉ๐š๐œ๐ž. ๐–๐ก๐ข๐œ๐ก ๐œ๐จ๐ฆ๐ฆ๐š๐ง๐ ๐œ๐š๐ง ๐ฒ๐จ๐ฎ ๐ฎ๐ฌ๐ž ๐ญ๐จ ๐๐ž๐ญ๐ž๐ซ๐ฆ๐ข๐ง๐ž ๐ฐ๐ก๐ข๐œ๐ก ๐ฎ๐ฌ๐ž๐ซ'๐ฌ ๐ก๐จ๐ฆ๐ž ๐๐ข๐ซ๐ž๐œ๐ญ๐จ๐ซ๐ฒ ๐ข๐ฌ ๐ฎ๐ฌ๐ข๐ง๐  ๐ญ๐ก๐ž ๐ฆ๐จ๐ฌ๐ญ ๐ฌ๐ฉ๐š๐œ๐ž?

    Ans: we can use du command

  29. ๐‡๐จ๐ฐ ๐ญ๐จ ๐œ๐ก๐ž๐œ๐ค ๐ฒ๐จ๐ฎ๐ซ ๐‹๐ข๐ง๐ฎ๐ฑ ๐…๐ข๐ฅ๐ž๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ?

    Ans: lsblk -f

  30. ๐‡๐จ๐ฐ ๐ญ๐จ ๐’๐Ž๐‘๐“ ๐ญ๐ก๐ž ๐œ๐จ๐ง๐ญ๐ž๐ง๐ญ ๐Ÿ๐ซ๐จ๐ฆ ๐š ๐Ÿ๐ข๐ฅ๐ž ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: sort -r file

  31. ๐‡๐จ๐ฐ ๐ญ๐จ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐”๐๐ˆ๐๐”๐„ ๐œ๐จ๐ง๐ญ๐ž๐ง๐ญ ๐Ÿ๐ซ๐จ๐ฆ ๐š ๐Ÿ๐ข๐ฅ๐ž ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: sort file | uniq

  32. ๐‡๐จ๐ฐ ๐ญ๐จ ๐ฌ๐ž๐š๐ซ๐œ๐ก ๐ฆ๐ฎ๐ฅ๐ญ๐ข๐ฉ๐ฅ๐ž ๐ฐ๐จ๐ซ๐๐ฌ ๐š๐ง๐ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐ฆ๐š๐ญ๐œ๐ก๐ข๐ง๐  ๐œ๐จ๐ง๐ญ๐ž๐ง๐ญ ๐Ÿ๐ซ๐จ๐ฆ ๐š ๐Ÿ๐ข๐ฅ๐ž ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: egrep "word1|word2" file

  33. ๐‡๐จ๐ฐ ๐ญ๐จ ๐‚๐Ž๐”๐๐“ ๐ง๐จ. ๐จ๐Ÿ ๐ฅ๐ข๐ง๐ž๐ฌ ๐ข๐ง ๐š ๐Ÿ๐ข๐ฅ๐ž ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: wc -l file

  34. ๐‡๐จ๐ฐ ๐ญ๐จ ๐œ๐ก๐ž๐œ๐ค ๐ข๐Ÿ ๐ญ๐ฐ๐จ ๐Ÿ๐ข๐ฅ๐ž๐ฌ ๐š๐ซ๐ž ๐ข๐๐ž๐ง๐ญ๐ข๐œ๐š๐ฅ ๐จ๐ซ ๐ง๐จ๐ญ ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: cmp fileA fileB

  35. ๐‡๐จ๐ฐ ๐ญ๐จ ๐œ๐จ๐ฆ๐ฉ๐š๐ซ๐ž ๐š๐ง๐ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐๐ข๐Ÿ๐Ÿ๐ž๐ซ๐ž๐ง๐œ๐ž ๐›๐ž๐ญ๐ฐ๐ž๐ž๐ง ๐Ÿ๐ข๐ฅ๐ž๐ฌ ๐ข๐ง ๐‹๐ข๐ง๐ฎ๐ฑ?

    Ans: diff -u fileA fileB

  36. ๐‡๐จ๐ฐ ๐ญ๐จ ๐ซ๐ž๐œ๐จ๐ซ๐ ๐ฒ๐จ๐ฎ๐ซ ๐š๐œ๐ญ๐ข๐ฏ๐ข๐ญ๐ฒ ๐จ๐ง ๐ญ๐ž๐ซ๐ฆ๐ข๐ง๐š๐ฅ ๐ข๐ง ๐š ๐Ÿ๐ข๐ฅ๐ž?

    Ans: script

  37. ๐‡๐จ๐ฐ ๐ญ๐จ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐ฌ๐ญ๐š๐ซ๐ญ๐ข๐ง๐  ๐ญ๐ฐ๐จ ๐œ๐ก๐š๐ซ๐š๐œ๐ญ๐ž๐ซ๐ฌ ๐จ๐Ÿ ๐š๐ฅ๐ฅ ๐ฅ๐ข๐ง๐ž?

    Ans: cut -c1-2 file.txt

  38. ๐‡๐จ๐ฐ ๐ญ๐จ ๐๐ข๐ฌ๐ฉ๐ฅ๐š๐ฒ ๐š ๐ฌ๐ฉ๐ž๐œ๐ข๐Ÿ๐ข๐œ ๐ฅ๐ข๐ง๐ž ๐Ÿ๐ซ๐จ๐ฆ ๐š ๐Ÿ๐ข๐ฅ๐ž?

    Ans: sed -n '5p' file.txt

  39. ๐‡๐จ๐ฐ ๐ญ๐จ ๐ซ๐ž๐ฉ๐ฅ๐š๐œ๐ž ๐š ๐ฌ๐ฉ๐ž๐œ๐ข๐Ÿ๐ข๐œ ๐ฐ๐จ๐ซ๐ ๐ฐ๐ข๐ญ๐ก๐ข๐ง ๐š ๐Ÿ๐ข๐ฅ๐ž?

    Ans: sed -n 's/from/to/g' file.txt

  40. ๐‡๐จ๐ฐ ๐ญ๐จ ๐ž๐ฑ๐ญ๐ž๐ง๐ ๐ฌ๐ข๐ณ๐ž ๐จ๐Ÿ ๐š ๐Ÿ๐ข๐ฅ๐ž ๐ฐ๐ข๐ญ๐ก๐จ๐ฎ๐ญ ๐š๐๐๐ข๐ง๐  ๐š๐ง๐ฒ ๐๐š๐ญ๐š?

    Ans: truncate -s 100M file.txt

  41. ๐‡๐จ๐ฐ ๐ญ๐จ ๐œ๐ก๐ž๐œ๐ค ๐œ๐ฉ๐ฎ/๐œ๐จ๐ซ๐ž/๐ญ๐ก๐ซ๐ž๐š๐ ๐ข๐ง๐Ÿ๐จ ๐จ๐Ÿ ๐ฒ๐จ๐ฎ๐ซ ๐ฅ๐ข๐ง๐ฎ๐ฑ ๐ฌ๐ž๐ซ๐ฏ๐ž๐ซ?

    Ans: lscpu

ย