Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Linuxcommands

Uploaded by

karun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Linuxcommands

Uploaded by

karun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Linux Interview Questions and Answers

Follow – Krishan Bhatt

In this article, we’ll go through a list of commonly asked Linux interview questions with
emojis to make it fun and engaging, followed by detailed answers.

Table of Contents

1. What is the Linux Kernel?

2. Explain the difference between Linux and Unix.

3. How do you change file permissions in Linux?

4. What is the use of the ls command?

5. How do you check the disk space in Linux?

6. What is the purpose of the top command?

7. How do you create a new directory in Linux?

8. What are symbolic links in Linux?

9. How do you view the contents of a file?

10. How do you schedule tasks using cron?

11. Explain the usage of df and du commands.

12. What is the use of chmod and chown?

13. How do you kill a process in Linux?

14. What is the difference between soft and hard links?

15. How do you copy files in Linux?

16. How do you manage services in Linux (systemd)?

17. What is a shell script, and how is it used?

18. Explain how to start and stop a service.

19. How do you manage firewall settings in Linux?

20. How do you check the IP address of a machine?


1. What is the Linux Kernel?

Answer:

The Linux Kernel is the core component of the Linux operating system. It acts as a bridge
between the hardware and applications, managing hardware resources, and allowing
processes to communicate with the system’s hardware. It manages memory,
processes, and hardware like the CPU, disk drives, and networking devices.

2. Explain the difference between Linux and Unix.

Answer:

Linux is an open-source operating system based on Unix standards, while Unix is a


proprietary OS developed in the 1970s. Linux is free and widely used in various
environments, whereas Unix is mainly used in enterprise and commercial
environments. Linux is more flexible, customizable, and supports a broader range of
hardware platforms.

3. How do you change file permissions in Linux?

Answer:

Use the chmod command to change file permissions. Permissions are represented as
read (r), write (w), and execute (x).

For example:

chmod 755 filename

This gives the owner full permissions (rwx), and the group and others read and execute
permissions (r-x).
4. What is the use of the ls command?

Answer:

The ls command is used to list files and directories in the current working directory. It
supports various options like -l for detailed listing and -a to show hidden files.

5. How do you check the disk space in Linux?

Answer:

You can use the df command to check disk space usage.

For example:

df -h

This command provides a human-readable format of disk usage.

6. What is the purpose of the top command?

Answer:

The top command provides a real-time view of running processes, system resource
usage (CPU, memory), and allows you to manage processes.

7. How do you create a new directory in Linux?

Answer:

Use the mkdir command to create a new directory.

For example:
mkdir new_directory

8. What are symbolic links in Linux?

Answer:

A symbolic link is a type of file that points to another file or directory. It acts as a
shortcut. Use the ln -s command to create a symbolic link.

For example:

ln -s target_file link_name

9. How do you view the contents of a file?

Answer:

You can use commands like cat, more, less, tail, or head to view the contents of a file.

For example, to view a file using cat:

cat filename

10. How do you schedule tasks using cron?

Answer:

You can schedule tasks by editing the cron table using crontab -e. Each cron job follows
the format:

* * * * * command

The five asterisks represent minute, hour, day of month, month, and day of week.
11. Explain the usage of df and du commands.

Answer:

• df shows the available disk space on file systems.

• du shows the disk usage of files and directories.

For example:

df -h # to show disk space

du -sh /path # to show disk usage of a path

12. What is the use of chmod and chown?

Answer:

• chmod is used to change file permissions.

• chown is used to change the ownership of a file.

For example:

chown user:group filename

13. How do you kill a process in Linux?

Answer:

Use the kill command followed by the process ID (PID) to terminate a process.

For example:
kill 1234

You can find the PID using the ps or top command.

14. What is the difference between soft and hard links?

Answer:

• A hard link points directly to the inode of a file, meaning it acts as another
copy of the original file.

• A soft link (symbolic link) is a pointer to a file’s path, similar to a shortcut.


If the original file is deleted, a soft link will break, while a hard link will not.

15. How do you copy files in Linux?

Answer:

You can use the cp command to copy files.

For example:

cp source_file destination_file

16. How do you manage services in Linux (systemd)?

Answer:

Use the systemctl command to manage services in Linux.

For example:

systemctl start service_name # to start a service


systemctl stop service_name # to stop a service

systemctl status service_name # to check service status

17. What is a shell script, and how is it used?

Answer:

A shell script is a file containing a series of commands for the shell to execute. It is used
to automate tasks. Shell scripts typically have a .sh extension.

To run a script:

bash script.sh

18. Explain how to start and stop a service.

Answer:

Use the systemctl command to start and stop services.

For example:

systemctl start httpd # to start the Apache service

systemctl stop httpd # to stop the Apache service

19. How do you manage firewall settings in Linux?

Answer:

In most modern Linux distributions, firewalld is used for managing firewall settings. You
can control it using the firewall-cmd command.

For example:
firewall-cmd --add-port=80/tcp # to open port 80

firewall-cmd --reload # to reload firewall settings

20. How do you check the IP address of a machine?

Answer:

You can use the ip a or ifconfig command to check the IP address of your machine.

For example:

ip a # shows network details including IP addresses

ifconfig # alternative command for older systems

This set of questions will help you prepare for Linux interviews with a strong
understanding of both basic and advanced topics!

You might also like