In this article, we’ve included 7th set of 10 basic Linux Interview Questions and detailed answers that will help candidates prepare for the Linux interview and get the best job in the IT industry.
These Linux interview questions and answers will be useful for both freshers and experienced professionals at any level.
Some of the questions are for advanced Linux professionals, however, beginners or fresher can easily understand the answers and explanations described below.
Just like other operating systems, Linux operating system consist of five major components:
Processes that require a user intervention are called foreground processes. A foreground process is any command or program that you run in the terminal and you have to wait for its completion.
If it runs for a long time, you will be not able to start any other processes until the current program finishes.
For example, When you run the below command that started runs in foreground by default, receives input from the keyboard, and sends output to the screen.
hostnamectl
Processes that run independently without the need for user interaction are referred to as background processes.
This can be placed in the background, which allowing the user to access the terminal, and continue to work, rather than waiting for a long job to finish. To run a process in the background, append an ampersand (&) at the end of the command name.
command &
To run a process in the background, add the ampersand symbol ‘&’ at the end of the command name as shown below:
By default, the background process will continue to write messages to the terminal where you started the command, you can suppress the ‘stdout’ and ‘stderr’ messages using the following syntax:
ping fosstechi.com > /dev/null 2>&1 & [1] 24497
Use the Jobs command to display the status of background work in the current shell session.
jobs -l [1]+ 24497 Running ping fosstechi.com > /dev/null 2>&1 &
A man page (stands for manual page) is a built-in manual for using Linux commands. It displays the user manual of any command that we can run on the terminal.
It provides a comprehensive overview of the command, including NAME, SYNOPSIS, CONFIGURATION, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, ENVIRONMENT, FILES, VERSIONS, CONFORMING TO, NOTES, BUGS, EXAMPLE, AUTHORS, and SEE ALSO.
The basic man command syntax is:
man [option] [section number] [command name]
For example, to view man page of free command, run:
man free Man: find all matching manual pages (set MAN_POSIXLY_CORRECT to avoid this) * free (1) free (3) free (3p) Man: What manual page do you want? Man:
The man command displays detailed information about a Linux command, but if you want to see a brief overview of the options available for the Linux command, use the '--hlep'
or '-h'
option in any Linux command.
df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include pseudo, duplicate, inaccessible file systems -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below -h, --human-readable print sizes in powers of 1024 (e.g., 1023M) -H, --si print sizes in powers of 1000 (e.g., 1.1G) -i, --inodes list inode information instead of block usage
The term “path” refers to the unique location of a file or directory in a file system. Absolute path is the path of a file or directory from the root directory i.e. from ‘/’.
For example, to view the ‘FOSSTechi.txt’ file using the absolute path, run:
ls -lh /home/linuxgeek/Documents/FOSSTechi.txt -rw-r--r-- 1 linuxgeek users 25 Sep 4 02:06 /home/linuxgeek/Documents/FOSSTechi.txt
Relative path is the path of a file or directory from the present working directory (pwd), not ‘/’.
For example, to view the ‘FOSSTechi.txt’ file using the relative path, run:
ls -lh Documents/FOSSTechi.txt -rw-r--r-- 1 linuxgeek users 25 Sep 4 02:06 Documents/FOSSTechi.txt
The cron daemon is a utility that popularly known as cron job or crontab. It is used to execute a task (command or script) repeatedly at a specified time by reading the crontab (cron tables). It can be monthly, weekly, daily, hourly, every minute, even every second.
cron job is very useful to perform regular tasks such as regular backups, daily scans, /tmp directory cleanup, and restarting the system at a given time.
The Linux crontab has ‘six’ fields, the first ‘five’ fields (1-5) indicate the date and time of execution, and the ‘6’th’ field is used to execute a command or script.
.-----------------> Minute (0-59) | .--------------> Hour (0-23) | | .-----------> Day of Month (1-31) | | | .--------> Month (1-12) or (jan,feb,mar,apr ...dec) | | | | .-----> Day of Week (0-6) (Sunday=0 or 7) or (sun,mon,tue,wed,thu,fri,sat) | | | | | .--> Command to be executed | | | | | | * * * * * * MIN HOUR DOM MON DOW CMD
To list the logged-in user’s crontab entry, run:
$ crontab -l
anacron command is used to execute commands periodically, which is similar to cron. But this tool is specifically designed for a system (Laptop & Desktop) that is not running 24×7.
For instance, you have scheduled a job at ’01 AM’ midnight using crontab, and if your system is powered off at the time then the backup script will not be executed.
This is where anacron comes into picture. It is make sure that the next time you power on the desktop/laptop again, the backup script will be executed.
anacron configuration file is located at ‘/etc/anacrontab’
There are ‘four’ fields for anacron job, and the format is listed below:
$ cat /etc/anacrontab period delay job-identifier command | | | | | | | : | | | '--------> command or shell script to be executed. | | : | | '--------> It's a anacron job-id, which is used to name the timestamp file created in /var/spool/anacron | : | '--------> The number of minutes anacron should wait before executing the job (delay in minutes) : '--------> Specifies how frequently the job should be executed, in days (@daily, @weekly, @monthly)
The below table describes the difference between the cron and anacron.
S.No | cron | anacron |
---|---|---|
1 | It is a daemon that runs scheduled tasks | anacron itself doesn’t run as a service/daemon, but cron checks if anacron is available for the daily, weekly and monthly tasks. |
2 | Minimum granularity is minute and jobs can be scheduled for every minute. | Minimum time frame is 1 day so, you can’t run hourly jobs with anacron. |
3 | Anybody can schedule a job if it is not banned by the super user. | Only super user can schedule jobs. |
4 | It’s suitable for Linux servers | It’s suitable for Linux Laptop and Desktops |
5 | It is designed for systems that are up and running 24×7. If a job is scheduled and the system is down at that time, the job will not be executed. | It is designed for systems that are not running 24×7. If the system is not available during the scheduled job, the job will be executed when the system comes back up. |
In this guide, we’ve included the most frequently asked 7th set of 10 basic Linux Interview Questions and detailed answers for your reference purpose and we hope it will be very useful.
If you have any questions or feedback, feel free to comment below.
Cron is a command-line job scheduler available on Linux operating systems that allows users to…
In computing, there are two types of IP addresses, IPv4 and IPv6. By default, IPv6…
A tarball is commonly known as a TAR file, short for tape archive, which is…
A tar archive is a file that stores a collection of directories and files, also…
On Linux, you can quickly find out how LUNs are mapped to the underlying OS…
Keeping your Ubuntu system up-to-date is critical to ensuring a system's stability and security. This…
This website uses cookies.