Interview Questions and Answers in Linux: Part-1

vivek bangare

Vivek Bangare


Top Interview Questions and Answers in Linux: Part-1

Hello everyone, In this article, we will mostly talk about top interview questions and answers in Linux. Along with that will go through some examples also. I will create a series of questions and answers for beginners to advanced levels.

Check Linux Kernal Version
  • uname -a
  • uname -v
  • uname -r
Verify current IP address in linux
  • ifconfig
  • ip addr show eth0
Free disk space

df -ah (h is used for human readable format)

How to verify manage services in linux?

Verifying service status:

  • service {service_name} status
  • systemctl status {service_name} // new one

for ex: systemctl status nginx

Start a specific service:

  • service {service_name} start
  • systemctl start {service_name}

for ex: systemctl start nginx

Stop a specific service:

  • service {service_name} stop
  • systemctl stop {service_name}

for ex: systemctl stop nginx

Restart a specific service:

  • service {service_name}restart
  • systemctl restart {service_name}

for ex: systemctl restart nginx

Size of directory

du -sh {directory_name}

How to open ports in linux?

netstat -tulpn

Verify CPU usage process

ps aux | grep {process_name}

for ex: ps aux | grep apache2


Deal with mount

ls /mnt

mount /dev/sda2 /mnt


Getting manual of any command

man {command}

Finding mount filesystem

findmnt /mnt

Unmount filesystem

sudo unmount /mnt

Manipulating data and generates reports
  • awk '{print}' {file_name}
  • awk '/manager/{print}' {file_name}
  • awk '{print} $1,$2' {file_name}
  • awk 'if($3=="B6") print $0;' {file_name}
  • awk 'BEGIN{for(i=1;i<=6;i++) print "squareof"', i; "is", i*i;}'
Stream editor
  • sed 's/unix/linux/' {file_name}
  • sed 's/unix/linux/2' {file_name}
  • sed 's/unix/linux/g' {file_name}
  • sed 's/unix/linux/3g' {file_name}
  • sed '3 s/unix/linux/' {file_name}