Linux Interview Questions:
- What is Linux, and what are its main features?
- Linux is an open-source operating system modeled on UNIX. Its main features include multitasking, multi-user capabilities, portability, security, and a rich set of utilities and applications.
- What are the different Linux distributions?
- Popular Linux distributions include Ubuntu, CentOS, Debian, Fedora, Red Hat Enterprise Linux (RHEL), and Arch Linux, each tailored for specific use cases and user preferences.
- How do you check the Linux kernel version?
- You can check the Linux kernel version using the command
uname -r
orcat /proc/version
.
- You can check the Linux kernel version using the command
- What is the purpose of the
ls
command?- The
ls
command lists files and directories in the current directory. Options can be added to modify its output, such asls -l
for a detailed view.
- The
- What is the difference between a hard link and a soft link in Linux?
- A hard link points directly to the inode of a file, making it indistinguishable from the original. A soft link (or symbolic link) is a pointer to the filename, which can break if the original file is deleted.
- How do you change file permissions in Linux?
- You can change file permissions using the
chmod
command, specifying the permission type (read, write, execute) and the user category (owner, group, others).
- You can change file permissions using the
- What is the Linux file system hierarchy?
- The Linux file system hierarchy is organized into a tree structure with directories like
/
,/home
,/etc
,/var
,/usr
, and/bin
, each serving a specific purpose.
- The Linux file system hierarchy is organized into a tree structure with directories like
- How do you view running processes in Linux?
- You can view running processes using the
ps
command (e.g.,ps aux
) or thetop
command for a dynamic view of processes.
- You can view running processes using the
- What is the purpose of the
grep
command?- The
grep
command searches for specific patterns within files or output, allowing users to filter and find relevant information quickly.
- The
- How do you create a new user in Linux?
- You can create a new user using the
useradd
command, followed by the username, and set a password with thepasswd
command.
- You can create a new user using the
Intermediate Level:
- What is the purpose of the
/etc/passwd
file?- The
/etc/passwd
file stores user account information, including username, user ID (UID), group ID (GID), home directory, and shell.
- The
- How do you search for files in Linux?
- You can search for files using the
find
command (e.g.,find /path/to/search -name "filename"
) or thelocate
command for quicker results if the database is updated.
- You can search for files using the
- What is a process, and how is it different from a thread?
- A process is an instance of a running program, while a thread is a smaller unit of a process that can run concurrently, sharing the same resources.
- How do you schedule tasks in Linux?
- You can schedule tasks using the
cron
daemon, defining time-based jobs in the crontab file with thecrontab -e
command.
- You can schedule tasks using the
- What is the purpose of the
chmod
command?- The
chmod
command changes the file mode (permissions) of a file or directory, controlling read, write, and execute access for users.
- The
- How do you find the disk usage in Linux?
- You can find disk usage using the
du
command (e.g.,du -sh *
) to summarize the size of files and directories.
- You can find disk usage using the
- What is the
sudo
command, and how is it used?- The
sudo
command allows users to execute commands with superuser privileges, enabling them to perform administrative tasks without logging in as the root user.
- The
- How can you view system logs in Linux?
- System logs can be viewed using the
tail
command on log files in the/var/log
directory (e.g.,tail -f /var/log/syslog
).
- System logs can be viewed using the
- What is the difference between the
apt
andyum
package managers?apt
is used in Debian-based systems (like Ubuntu) for package management, whileyum
is used in Red Hat-based systems (like CentOS) for managing packages.
- What is a shell in Linux?
- A shell is a command-line interface that allows users to interact with the operating system by executing commands and scripts. Common shells include Bash, Zsh, and Sh.
Advanced Level:
- What is a daemon in Linux?
- A daemon is a background process that runs independently of user control, often providing services like logging, printing, or web serving.
- How do you monitor system performance in Linux?
- You can monitor system performance using tools like
top
,htop
,vmstat
,iostat
, andsar
to analyze CPU, memory, and disk usage.
- You can monitor system performance using tools like
- What is the purpose of the
rsync
command?- The
rsync
command is used for synchronizing files and directories between local and remote systems, providing options for compression and delta transfers.
- The
- How can you check network connectivity in Linux?
- You can check network connectivity using commands like
ping
,traceroute
, andnetstat
to diagnose network issues.
- You can check network connectivity using commands like
- What is the difference between TCP and UDP?
- TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures reliable data transfer, while UDP (User Datagram Protocol) is a connectionless protocol that allows faster data transmission without guaranteed delivery.
- How do you set environment variables in Linux?
- Environment variables can be set using the
export
command (e.g.,export VARIABLE_NAME=value
), and can be made persistent by adding them to configuration files like.bashrc
or.profile
.
- Environment variables can be set using the
- What is a swap space in Linux?
- Swap space is a portion of the hard disk used as virtual memory when RAM is full, allowing the system to continue functioning by moving inactive pages from memory to disk.
- How can you manage services in Linux?
- Services can be managed using commands like
systemctl
for systems with systemd (e.g.,systemctl start/stop/restart service_name
) orservice
for older init systems.
- Services can be managed using commands like
- What is the purpose of the
tar
command?- The
tar
command is used for creating and extracting compressed archive files, commonly used for backups and file transfers.
- The
- How do you secure a Linux server?
- You can secure a Linux server by implementing firewalls (e.g.,
iptables
,ufw
), regularly updating software, configuring SSH settings, using strong passwords, and enabling SELinux.
- You can secure a Linux server by implementing firewalls (e.g.,
![Sarath Tamminana](https://i0.wp.com/enminto.com/wp-content/uploads/2021/05/Profile-Image-e1621598995164.jpg?resize=100%2C100&ssl=1)
The founder of TacoBIG.com.He is a Cloud Architect from Bangalore interested in contributing guidance to Cloud related communities. He loves to read books and share knowledge with others. He is keen on understanding Financial wisdom and sharing thoughts on how to achieve financial freedom.