0% found this document useful (0 votes)
5 views

Linux Interview Questions

Cooool

Uploaded by

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

Linux Interview Questions

Cooool

Uploaded by

Ayman Ben sat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Linux Interview Questions and Answers

1. What is Linux, and why is it widely used?


Linux is an open-source operating system based on Unix. It’s widely used for its
stability, security, and flexibility. It is especially popular in server environments and
cloud infrastructure.
2. What is the Linux file structure or directory hierarchy?
The Linux file system has a hierarchical structure, with directories like /home for user
files, /etc for configuration files, /var for variable files, /bin for essential user
commands, and /root for the root user’s home directory.
3. Explain the role of the kernel in Linux.
The kernel is the core component of Linux that manages system resources, including
the CPU, memory, and I/O devices. It facilitates communication between hardware and
software.
4. How do you check the current working directory?
To check current working directory we use pwd. PWD stands for "print working
directory" and displays the path of the current directory.
5. How do you list all files, including hidden ones, in a directory?
ls -a
The -a option in the ls command shows all files, including those that start with a dot (.),
which are hidden files in Linux.
6. How do you view the contents of a file?
cat filename, less filename, or more filename
cat prints the file contents directly to the screen, while less and more allow for paginated
viewing.
7. What command would you use to copy a file from one directory to another?
cp source_file destination_directory/
cp stands for "copy." You can specify a source file and destination directory or path.
8. How do you move or rename a file?
mv old_filename new_filename
The mv command is used for moving or renaming files. Moving a file to a new directory
without changing its name also renames it.
9. How do you delete a file or directory?
rm filename for files, rm -r directory_name for directories
rm is used to remove files, and the -r option allows recursive deletion of directories and
their contents.
10. How do you search for a specific word in a file?
grep "word" filename
grep searches for patterns within files. You can specify a word or pattern and the
filename to search in.
11. How can you find your system's IP address?
ifconfig or ip addr
Both commands display network information, including IP addresses.
12. How do you check disk usage for all directories in the current path?
du -h
du shows disk usage, and -h displays the results in a human-readable format (like MB
or GB).
13. How can you view running processes?
ps
ps shows a snapshot of running processes.
14. What is the command to check free memory and CPU usage?
free -h for memory, top or htop for CPU usage
free -h shows memory usage, while top or htop gives real-time CPU and memory stats.
15. How do you create an empty file?
touch filename
touch creates an empty file or updates the timestamp of an existing file.
16. How do you change file permissions?
chmod
example: chmod 755 filename
chmod changes file permissions. Here, 755 gives the owner full rights and others
read/execute rights.
17. How do you schedule a job using cron?
Explanation: cron jobs are scheduled tasks in Linux. Use crontab -e to edit the crontab
file and schedule commands.
18. What is the command to compress files?
tar -cvf example.tar directory/
tar combines multiple files into tar files. Here, -cvf creates a .tar compressed file.
zip example.zip directory
compressing multiple files into zip file.
19. How do you add a new user in Linux?
Sudo adduser username
adduser creates a new user, and sudo provides administrative permissions if required.
20. Explain the difference between sudo and su.
sudo allows a permitted user to run commands as the superuser or another user, while
su switches the user to the superuser or another account entirely.
21. How can you check system uptime?
uptime
The uptime command shows how long the system has been running since the last boot.
22. What is the difference between a hard link and a soft (symbolic) link?
A hard link is a duplicate reference to the same file data on disk, meaning it points
directly to the inode (the data structure that contains the file metadata and location on
disk). Hard links have the same inode number as the original file because they directly
reference the same data.
While a soft link (or symbolic link) is a pointer to the original file’s path rather than the
actual data on disk. Soft links have their own inode because they only store the path to
the original file, not the actual data.
23. What are Different Os have you familiar with and worked on?

I am familiar with Linux and Windows operating systems.

• Linux

Linux is an open-source operating system based on the Unix architecture. It is known


for its robustness, security, and flexibility.

Distribution Variety: There are numerous distributions (distros) of Linux, such as


Ubuntu, CentOS, Debian, and Fedora. Each serves different user needs and preferences.

Usage: I have worked extensively with Linux for server management, software
development, and deployment. It is commonly used in cloud environments, data
centers, and for programming tasks.
Command-Line Interface (CLI): Linux relies heavily on the command line, which
provides powerful tools for managing the system. Common commands include ls, cd,
mkdir, and chmod.

Package Management: Most Linux distributions come with package managers (like apt
for Debian-based systems and yum for Red Hat-based systems) that simplify the
installation and management of software.

• Windows:

Windows is a operating system developed by Microsoft, widely used in personal


computing and business environments.

User Interface: Windows offers a graphical user interface (GUI) that is user-friendly
and intuitive, making it accessible for non-technical users.

Software Ecosystem: A vast range of applications is available for Windows, including


office suites, graphic design software, and games. Windows is often the preferred
platform for many enterprise applications.

Command Prompt and PowerShell: While Windows emphasizes the GUI, it also
includes command-line tools like Command Prompt and PowerShell for scripting and
automation tasks.

Updates and Support: Windows has a more centralized update mechanism, and users
typically receive regular feature and security updates.

24. Which Linux version you used in your project?


In my projects, I've primarily worked with Ubuntu and Amazon Linux, each of which
has specific advantages based on the project needs.
Amazon Linux is a distribution provided by Amazon Web Services (AWS), optimized
for use on Amazon EC2 instances. It is designed for security, performance, and
seamless integration with other AWS services. I used Amazon Linux for cloud-based
projects, especially for applications hosted on AWS EC2 instances, as it’s tailored for
AWS infrastructure. Amazon Linux receives regular security updates, ensuring a secure
environment for applications.
Ubuntu is a popular, Debian-based Linux distribution known for its user-friendly
design, extensive community support, and wide range of available software packages.
I used Ubuntu primarily for development environments, web servers, and applications
that required a stable, easy-to-configure OS. Uses apt (Advanced Package Tool) for
easy installation and management of software packages.
25. Why we used Linux OS Rather than Windows and any other?
Linux is often chosen over Windows or other operating systems for specific types of
projects and environments because of its unique advantages, especially in terms of
flexibility, security, and performance.
Free and Open Source: Linux is open source, meaning it’s free to use, modify, and
distribute. This reduces licensing costs, especially for organizations with a large number
of servers.
Community Development: The open-source nature of Linux allows for contributions
from a global community, which accelerates innovation, security updates, and software
improvements.
Long Uptime: Linux systems are known for their stability and can run for extended
periods without needing a reboot, making it ideal for servers that need high uptime.
Resilience: Linux is less prone to crashes, memory leaks, and slowdowns compared to
some other operating systems, ensuring better long-term performance.
Command-Line Efficiency: The Linux command-line interface (CLI) provides
powerful commands for managing the system, automating tasks, and scripting, which
often makes system administration more efficient than on GUI-centric operating
systems like Windows.
Developer Tools: Linux supports a wide range of development tools, programming
languages, and libraries, making it a preferred platform for developers.
Server and Cloud Environments: Linux is widely used in server environments and is
the OS of choice for cloud providers (such as AWS, Azure, and Google Cloud), due to
its reliability, performance, and compatibility with server software.

You might also like