What is Linux, and how does it differ from other operating systems?
Linux is an open-source, Unix-like operating system kernel that forms the basis of various Linux distributions (distros). Unlike proprietary operating systems, Linux is freely available and highly customizable.
Explain the file system hierarchy in Linux.
The Linux file system hierarchy includes directories like /bin, /usr, /home, /etc, and /var. These directories organize system files, user data, and configuration files in a structured manner.
What is the difference between a shell and a terminal in Linux?
A shell is a command-line interface that interprets user commands and executes them, while a terminal is a program that provides the user with access to the shell. The terminal displays the shell prompt.
What is a Linux distribution (distro), and name a few popular ones.
A Linux distribution is a complete operating system package that includes the Linux kernel, system libraries, utilities, and often a package manager. Examples of popular distros include Ubuntu, CentOS, Debian, and Fedora.
Explain the purpose of the sudo command.
The sudo (superuser do) command allows authorized users to execute commands with elevated privileges, typically as the root user, to perform administrative tasks.
How do you search for a file in Linux?
You can use the find command to search for files in Linux. For example, to find a file named “example.txt” in the current directory and its subdirectories, you can use find . -name “example.txt”.
What is a symbolic link (symlink) in Linux?
A symbolic link is a special type of file that acts as a reference or pointer to another file or directory. It allows for flexible file organization and redirection.
Explain the difference between hard links and symbolic links.
Hard links: Point to the same data blocks as the original file. Deleting the original file does not remove data until all hard links are deleted.
Symbolic links: Act as references to the original file or directory. They can span filesystems and point to files or directories that may not exist.
What is the purpose of the /etc/passwd file in Linux?
The /etc/passwd file stores user account information, including usernames, user IDs (UIDs), group IDs (GIDs), home directories, and default shells. It is used for user authentication.
How do you check the available disk space in Linux?
You can use the df (disk free) command to display information about disk space usage on mounted filesystems. The -h option provides human-readable output.
Explain how to archive and compress files in Linux using tar and gzip.
To create a compressed archive using tar and gzip, you can use the following command:
tar -czvf archive.tar.gz /path/to/files
What is the purpose of the /etc/fstab file?
The /etc/fstab file contains information about disk drives and partitions, specifying how they should be mounted at boot time. It defines mount points and options for each filesystem.
What is the significance of the chmod command in Linux?
The chmod command is used to change the permissions of files and directories. It allows users to control who can read, write, or execute a file or directory.
How do you schedule tasks in Linux using cron jobs?
To schedule tasks using cron jobs, you can edit the crontab file using the crontab -e command. You specify the timing and command to run in the crontab file.
Explain the use of the ps command in Linux for process management.
The ps command is used to list running processes on a Linux system. Common options include ps aux to display detailed information about all processes and ps -ef for a process tree view.
What is the difference between UNIX and LINUX?
Unix originally began as a propriety operating system from Bell Laboratories, which later on spawned into different commercial versions. On the other hand, Linux is free, open source and intended as a non-propriety operating system for the masses.
What is BASH?
BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. It has since been adapted as the default shell for most systems running Linux.
What is Linux Kernel?
The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction.
What is LILO?
LILO is a boot loader for Linux. It is used mainly to load the Linux operating system into main memory so that it can begin its operations.
What is a swap space?
Swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
What is the advantage of open source?
Open source allows you to distribute your software, including source codes freely to anyone who is interested. People would then be able to add features and even debug and correct errors that are in the source code. They can even make it run better and then redistribute these enhanced source code freely again. This eventually benefits everyone in the community.
What are the basic components of Linux?
Just like any other typical operating system, Linux has all of these components: kernel, shells and GUIs, system utilities, and an application program. What makes Linux advantageous over other operating system is that every aspect comes with additional features and all codes for these are downloadable for free.
Does it help for a Linux system to have multiple desktop environments installed?
In general, one desktop environment, like KDE or Gnome, is good enough to operate without issues. It’s all a matter of preference for the user, although the system allows switching from one environment to another. Some programs will work in one environment and not work on the other, so it could also be considered a factor in selecting which environment to use.
What is the basic difference between BASH and DOS?
The key differences between the BASH and DOS console lie in 3 areas:
– BASH commands are case sensitive while DOS commands are not;
– Under BASH, / character is a directory separator and \ acts as an escape character. Under DOS, / serves as a command argument delimiter and \ is the directory separator
– DOS follows a convention in naming files, which is 8 character file name followed by a dot and 3 characters for the extension. BASH follows no such convention.
What is the importance of the GNU project?
This so-called Free software movement allows several advantages, such as the freedom to run programs for any purpose and freedom to study and modify a program to your needs. It also allows you to redistribute copies of software to other people, as well as the freedom to improve software and have it released for the public.
Describe the root account.
The root account is like a systems administrator account and allows you full control of the system. Here you can create and maintain user accounts, assigning different permissions for each account. It is the default account every time you install Linux.
What is CLI?
CLI is short for Command Line Interface. This interface allows the user to type declarative commands to instruct the computer to perform operations. CLI offers greater flexibility. However, other users who are already accustomed to using GUI find it difficult to remember commands including attributes that come with it.
What is GUI?
GUI, or Graphical User Interface, make use of images and icons that users click and manipulate as a way of communicating with the computer. Instead of having to remember and type commands, the use of graphical elements makes it easier to interact with the system, as well as adding more attraction through images, icons, and colors.
How do you open a command prompt when issuing a command?
To open the default shell (which is where the command prompt can be found), press Ctrl-Alt-F1. This will provide a command line interface (CLI) from which you can run commands as needed.
How can you find out how much memory Linux is using?
From a command shell, use the “concatenate” command: cat /proc/meminfo for memory usage information. You should see a line starting something like Mem: 64655360, etc. This is the total memory Linux thinks it has available to use.
You can also use commands
free – m
vmstat
top
htop
to find current memory usage
What is a typical size for a swap partition under a Linux system?
The preferred size for a swap partition is twice the amount of physical memory available on the system. If this is not possible, then the minimum size should be the same as the amount of memory installed.
What are symbolic links?
Symbolic links act similarly to shortcuts in Windows. Such links point to programs, files or
directories. It also allows you instant access to it without having to go directly to the entire
pathname.
Does the Ctrl+Alt+Del key combination work on Linux?
Yes, it does. Just like Windows, you can use this key combination to perform a system restart. One difference is that you won’t be getting any confirmation message and therefore, a reboot is immediate.
How do you refer to the parallel port where devices such as printers are connected?
Whereas under Windows you refer to the parallel port as the LPT port, under Linux you refer to it as /dev/lp . LPT1, LPT2 and LPT3 would therefore be referred to as /dev/lp0, /dev/lp1, or /dev/lp2 under Linux.
Are drives such as hard drive and floppy drives represented with drive letters?
No. In Linux, each drive and device have different designations. For example, floppy drives are referred to as /dev/fd0 and /dev/fd1. IDE/EIDE hard drives are referred to as /dev/hda, /dev/hdb,/dev/hdc, and so forth.
How do you change permissions under Linux?
Assuming you are the system administrator or the owner of a file or directory, you can grant permission using the chmod command. Use + symbol to add permission or – symbol to deny permission, along with any of the following letters: u (user), g (group), o (others), a (all), r (read), w (write) and x (execute). For example, the command chmod go+rw FILE1.TXT grants read and write access to the file FILE1.TXT, which is assigned to groups and others.
In Linux, what names are assigned to the different serial ports?
Serial ports are identified as /dev/ttyS0 to /dev/ttyS7. These are the equivalent names of COM1 to COM8 in Windows.
How do you access partitions under Linux?
Linux assigns numbers at the end of the drive identifier. For example, if the first IDE hard drive had three primary partitions, they would be named/numbered, /dev/hda1, /dev/hda2 and /dev/hda3.
What are hard links?
Hard links point directly to the physical file on disk, and not on the pathname. This means that if you rename or move the original file, the link will not break since the link is for the file itself, not the path where the file is located.
What is the maximum length for a filename under Linux?
Any filename can have a maximum of 255 characters. This limit does not include the path name, so therefore the entire pathname and filename could well exceed 255 characters.
What are filenames that are preceded by a dot?
In general, filenames that are preceded by a dot are hidden files. These files can be configuration files that hold important data or setup info. Setting these files as hidden makes it less likely to be accidentally deleted.
Explain virtual desktop.
This serves as an alternative to minimizing and maximizing different windows on the current desktop. Using virtual desktops can clear the desktop when you can open one or more programs. Rather than minimizing/restoring all those programs as needed, you can simply shuffle between virtual desktops with programs intact in each one.
How do you share a program across different virtual desktops under Linux?
To share a program across different virtual desktops, in the upper left-hand corner of a program window look for an icon that looks like a pushpin. Pressing this button will “pin” that application in place, making it appear in all virtual desktops, in the same position onscreen.
What does a nameless (empty) directory represent?
This empty directory name serves as the nameless base of the Linux file system. This serves as an attachment for all other directories, files, drives, and devices.
What is sudo in Linux?
The word “sudo” is the short form of “Superuser Do” that allows you to run the command with system privileges. With this command, you can get the system’s administrative access to perform various tasks. The sudo command requires a password before the execution to verify the user’s authorization.
What is umask?
It is used for user file creation mode. When a user creates any file, then it has default file permission. Umask specifies restrictions for these permissions on the file, i.e., controls the permissions.
How to find and kill a process in Linux?
You can use different commands to kill a process, but first, you must find the PID of that specific process. So, please run the below command:
ps aux | grep <process>
Once you get the PID of the process then run the kill command to end it:
kill <PID>
If you don’t want to find the PID, then you can use the pkill command to kill a process by its name:
pkill <process>
The pkill command sends a signal (by default, SIGTERM) to the matched processes, causing them to terminate.
What is network bonding in Linux?
Network bonding is the process of creating a single network by combining two or more network interfaces. This combination of networks improves redundancy and performance by increasing bandwidth and throughput. The major benefit of network bonding is that the overall network works fine even if a single network in the bonding does not work properly.
What is SELinux?
SELinux or also known as Security-Enhanced Linux, is the security framework. It offers an additional layer of security to improve access control and strengthen security. SELinux was developed to improve the security policies to prevent unauthorized access and exploitation. However, learning about SELinux is essential before working on it can create serious security issues.
What is the purpose of the SSH protocol in Linux, and how do you securely connect to a remote server using SSH?
The Secure Shell (SSH) is a protocol in Linux which is used to establish a secure encrypted connection between a local and remote machine. It allows to securely access and manage remote servers. If we want to connect to a remote server using SSH. We can use the following command.
ssh username@remote_ip
Here replace the `username` with the desired username of the remote server and replace the `remote_ip` with the IP address of the remote server.
How do you check the contents of a file without opening it in Linux?
In Linux we can use the `cat` command to view the content of a file without opening it in an editor form.
For example: If we want to check content of a file with file_name = `geeks.txt`
cat geeks.txt
What is the purpose of the crontab file in Linux, and how do you schedule recurring tasks using cron jobs?
The crontab file in Linux is used to schedule recurring tasks or cron jobs. It contains a list of commands or scripts that are executed at specified time intervals. To edit the crontab file, you can use the crontab -e command.
For example: If we want to run a script name `jayesh.sh` every day at 5 AM, we can use the following procedure.
First, we need to open the crontab in editorial format.
crontab -e
Secondly, add the entries in the crontab fi
0 5 * * * /path/to/jayesh.sh
How do you find and replace text in a file using the sed command in Linux?
The sed command (stream editor) can be used to find and replace text in a file. The basic syntax is sed ‘s/pattern/replacement/g’ filename.
For example: to replace all occurrences of “true” with “False” in a file
sed ‘s/true/False/g’ file_name
What is the purpose of the sudoers file in Linux, and how do you configure sudo access for users?
The sudoers file in Linux controls the sudo access permissions for users. It determines which users are allowed to run commands with superuser (root) privileges. To configure sudo access, you can edit the sudoers file using the visudo command.
For example:
sudo visudo
Now add this line anywhere in the file. For instance, if we want to grant a user full sudo access.
user_name ALL=(ALL) ALL
How do you change the ownership of a file or directory in Linux using the chown command?
In Linux, you can change the ownership of a file or directory using the chown command. The basic syntax is chown new_owner: new_group filename.
For example: If we want to change the ownership of a file to user “Jayesh” and group “users”.
chown jayesh:users file_name
What is the purpose of the ping command in Linux, and how do you test network connectivity to a remote host?
Ping command is used to test the network connectively between the local and remote hosts. It basically sends an ICMP echo request packet to the remote host and waits for the corresponding echo reply packet.
For example: If we want to check the connectivity to a remote host, we use the following command.
ping remote_host_
Here replace `remote_host_ip` with the Ip address of the host
How do you recursively copy files and directories in Linux using the cp command?
In linxux we can simply use `-R` option with the `cp` command to recursively copy the file and directories.
For example:
cp -R sourece_durectory destination_directory
What is the purpose of the netstat command in Linux, and how do you view network connections and listening ports?
The netstat command in Linux is used to display active network connections, routing tables, and listening ports. To view network connections and listening ports, use the netstat command with appropriate options.
For example: If we want to display all listening TCP ports, we can use the following command.
netstat -tuln
How do you set up a static IP address in Linux using the command-line interface?
To set up a static IP address in Linux using the command-line interface, you need to modify the network configuration file. The location and name of the file may vary depending on the Linux distribution, but commonly it is /etc/network/interfaces. Open the file with a text editor and modify the configuration to set a static IP address, subnet mask, gateway, and DNS servers.
For example:
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Save the file and restart the network service or reboot the system for the changes to take effect.
What is the Linux Kernel?
Written in C programming language, the Linux kernel is the core component of a Linux system. It is the lowest level of software that can interact with the hardware. It interfaces the OS and the underlying hardware and allows communication between the two.
The kernel performs the following major tasks:
Manages underlying hardware devices.
Launches and manages applications.
Manages OS resources including RAM, CPU, and disk utilization.
What is GRUB?
GRUB (Grand Unified Bootloader) is a bootloader from the GNU project. It’s a program that is responsible for managing the boot process. Basically, it takes over from the BIOS at system startup and loads the kernel into the main memory. The kernel then loads the operating system and its components.
The GRUB splash screen is typically what you will see on your screen once the system starts up. It displays a simple menu that provides a couple of boot options.
What are the Essential Components of Linux?
A Linux system comprises the following essential components:
Kernel – This is the core part of the Linx system that manages underlying hardware components and applications at the OS level.
Shell – This is an interpreter that provides a command-line interface that accepts commands issued through the keyboard and passes them to the OS for execution.
GUI – This is an acronym for Graphical User Interface. It comprises graphical components that users leverage to interact with the system. These include the desktop, windows, icons, buttons, taskbars, and pop-ups.
Application programs – These are software applications installed on a Linux system that perform specific tasks. For example Firefox web browser, VLC media player, LibreOffice suite, and many more.
What are Shells Used in Linux?
Commonly used shells In Linux include:
bash [Bourne Again Shell] – This is the default shell on a majority of Linux systems.
zsh [Z Shell] – This is the default shell in Kali Linux and macOS. It is built on top of bash and packs with additional features such as spelling correction, plugin support, better customization, etc.
ksh [Korn Shell] – This is a high-level programming language shell.
csh [C Shell] – Its syntax borrows heavily from the C programming language. Highly useful for anyone with C programming knowledge.
What is Swap Space in Linux?
Swap space refers to space on the hard drive that is an extension of the RAM or physical memory. It is used by the system when the RAM capacity is almost getting depleted and can no longer support running applications. Swap space stores additional programs which can no longer be processed by the RAM.
How to Check Linux Memory Utilization?
The following are some of the most used Linux commands you can use to check your system’s memory utilization.
free – Display the amount of free and used memory in the system.
top – Display running Linux processes and utilization.
htop – An interactive system monitor, process viewer, and process manager.
vmstat – Display virtual memory statistics.
To check your Linux system memory performance and utilization, run:
$ free -m
$ top
$ htop
$ vmstat
How to Check Linux Disk Space Utilization?
Disk space usage can be checked using the df and du commands.
df Command – Show Linux File System Disk Usage
The df command (short for disk free) is used to display the total and available disk space for the filesystems on your system. It is often used with the -Th options for displaying the output in a human-readable format.
$ df -Th
Show Linux File System Disk Usage
du Command – Show Disk Usage of Files and Directories
The du command (short for disk usage) displays the file space usage in a directory. It tracks space occupied by files and directories. The like the df command, du is used with the -h option to display output in a human-readable format.
$ du -h
Show Linux Directory File Disk Usage
What are an Inode and PID?
An inode is a file structure that stores metadata for files in Linux. The metadata includes file size, permissions needed to access the file, user and group ID, creation timestamp, and the path to the file.
An inode number is a unique number or integer given to each file on a Linux system.
$ ls -li ravi.txt
1594567 -rwxrwxr-x 1 tecmint tecmint 0 Oct 28 10:58 ravi.txt
1594567 is the inode number and the -i flag shows the inode of the ravi.txt file.
A PID (Process ID) is a unique ID given to each running process on a Linux system. We can use the pidof command to find the process ID of any running program.
$ pidof firefox
40982
What are Daemons?
Daemons are service processes that run in the background without any user interaction. They provide the functionality to other processes and handle periodic requests and forward them to appropriate applications for execution.
What are Process States in Linux?
In Linux, a process is an instance of a running program or service. There are four process states. At any given time, a process will be in any of the following states:
Ready: The process has already been created and is ready to run.
Running: The process is alive or being executed.
Stopped: The process finished running and was terminated by the operating system.
Wait: The process is waiting for some user input.
Zombie: The process has been terminated, but the information still exists in the process table.
To check the Linux process state use the ps command as shown.
$ ps a
Check Linux Process States
The STAT column shows the running state of the process.
What is GUI?
GUI is an acronym for Graphical User Interface. These are the graphical elements of a Linux operating system which include windows, icons, menus, buttons, taskbars, and much more.
The GUI makes it easier to interact with the system and is mostly preferred by beginners or novices who are not adept at working on the CLI.
What is CLI?
CLI is an acronym for Command Line Interface. This is an interface that allows users to type commands on a shell provided by the terminal. The CLI is mostly used by experienced Linux users or system administrators and engineers.
The CLI is the preferred mode of administering the system since it consumes fewer system resources, unlike the GUI which has a high resource overhead.
What is the Root Account?
This is the most privileged account on the Linux system. It allows you full control of the Linux system. You can do virtually anything you want including upgrading the system, installing and uninstalling software packages, creating and removing users, configuring services, and much more.
In most Linux distributions, you will be required to create a root account during installation.
What is Open Source Software?
The characteristic of software being open source implies that you view its source code, modify it and redistribute it to other users without license restrictions. Other users would then be in a position to make further changes including debugging and rectifying errors in the source code.
In effect, open-source software becomes widely used and hence benefits everyone.