Linux_Q

 What is Kernel? Explain its functions.

A kernel is considered the main component of Linux OS. It is simply a resource manager that acts as a bridge between hardware and software. Its main role is to manage hardware resources for users and is generally used to provide an interface for user-level interaction. A kernel is the first program that is loaded whenever a computer system starts. It is also referred to as low-level system software.


What is BASH?

BASH (Bourne Again Shell) is basically a command language interpreter


What are two types of Linux User Mode?

There are two types of Linux user mode as given below:  

  • Command Line 
  • GUI


What is swap space?

Swap space, as the name suggests, is basically a space on a hard disk that is used when the amount of physical memory or RAM is full. It is considered a substitute for physical memory. Its main function is to substitute disk space for RAM memory when real RAM does not have enough space to hold all programs that are executing, and more space is required.


What is Linux Shell? What types of Shells are there in Linux?

Different types of shells are commonly used on typical Linux system as listed below: 

  • CSH (C Shell)
  • KSH (Korn Shell)
  • BASH (Bourne Again Shell)
  • TCSH
  • ZSH
  • Bourne Shel


Name different types of modes used in VI editor.

  • Command Mode/Regular Mode: It is the default mode for the vi editors. It is generally used to type commands that usually perform particular or specific vi functions. To enter this mode from another mode (Insert mode), one must press [esc]. In simple words, it lets you view the content.  
  • Insertion Mode/Edit Mode: This mode allows you to do text editing, or type text into a file. To enter this mode from another mode (command mode), one must press [esc]. In simple words, it lets you delete or insert text or content.
  • Ex Mode/Replacement Mode: This mode is generally used to save the files and execution of the commands. It basically executes files with different parameters. To enter this mode, one must press [:]. In simple words, it lets you overwrite content or text.


Write the difference between Soft and Hard links?

Hard Links: It is a special kind of file that points to the same underlying inode as another file. It can be referred to as an additional name for an existing file on Linux OS. Total number of hard links for a file can be displayed using the “ls -l” command. Such links cannot be used across file systems. Hard links can be created using the following command: 



Which command is used to check the size of file or directory?

The command used to check the size of the file or directory is “du”. Here “du” stands for disk usage that is used to check information of disk usage of files and directories on a machine. It is also used to display files and directory sizes in a recursive manner. 


What is the pwd command?

“pwd” command is basically a command that is used to print the complete path of the current working directory starting from the root (/). Here, “pwd” stands for Print Working Directory. It is considered one of the most basic and most used commands in Linux.

 

What are the file permissions in Linux?

There are 3 types of permissions in Linux OS that are given below:

  • Read: User can read the file and list the directory.
  • Write: User can write new files in the directory .
  • Execute: User can access and run the file in a directory.


How to exit from vi editors?

The following commands are used to exit from vi editors.

  • :wq saves the current work and exits the VI.
  • :q! exits the VI without saving current work.



What are the basic components of Linux?

The basic components of Linux are:

  • Kernel: It is the core component of the Operating System that manages operations and hardware.
  • Shell: Shell is a Linux interpreter which is used to execute commands.
  • GUI: GUI stands for Graphical User Interface which is another way for a user to interact with the system. But unlike CLI, GUI consists of Images, Buttons, TextBoxes for interaction.
  • System Utilities: These are the software functions that allows the user to manage the computer.
  • Application Programs: Software programs or set of functions designed to accomplish a specific task.


Which are the Linux Directory Commands?

There are 5 main Directory Commands in Linux:

pwd: Displays the path of the present working directory.

        Syntax: $ pwd

ls: Lists all the files and directories in the present working directory.

        Syntax: $ ls

cd: Used to change the present working directory.

        Syntax: $ cd <path to new directory>

mkdir: Creates a new directory

        Syntax: $ mkdir <name (and path if required) of new directory>

rmdir: Deletes a directory

        Syntax: $ rmdir <name (and path if required) of directory>

 


What are daemons?

A daemon is a computer program that runs as a background process to provide functions that might not be available in the base Operating System.



 What are the process states in Linux?

The process states are as follows:

Ready: The process is created and is ready to run

Running: The process is being executed

Blocked or wait: Process is waiting for input from the user

Terminated or Completed: Process completed execution, or was terminated by the Operating System

Zombie: Process terminated, but the information still exists in the process table.


Why is the tar command used?

The tar command is used to extract or create an archived file.

Suppose you want to extract all the files from the archive named sample.tar.gz, then the command will be:

    

    
$ tar -xvzf sample.tar.gz

Suppose you want to create an archive of all the files stored in the path /home/linux/, then the command will be:

        $ tar -cvzf filename.tar.gz

where c: create archive, x: extract, v: verbose, f: file



Explain the redirection operator.

The redirection operator is used to redirect the output of a particular command as an input to another command or file.

There are two ways of using this:

    ‘>’ overwrites the existing content of the file or creates a new file.

    ‘>>’ appends the new content to the end of the file .


How do you check if a particular service in running?

    $ service <servicename> status


Why LVM is required?

LVM stands for Large Volume Management, it is a storage management device. Users can create, resize, and delete LVM partitions. It increases abstraction, flexibility, and control. LVM is used to gather existing storage devices into the group and allocate logical units. 


What is the tail command in Linux?

The Tail command print the last N number of lines of the given data, it prints 10 lines by default.


What is the top Command in Linux?

The top command is used to show the system process and it displays and updates the sorted process information. 


What is the df command in Linux?

Users can use the df command to troubleshoot disk space issues. Here df stands for display free disk space.

df Command Example:

    df -h


What is fdisk -l command used for?

fdisk -I command show disks partitions sizes and types (run as root).


How do you create a new user account and set the password for a user from a shell prompt in Linux?

Answer: To create a new user account from a shell prompt follow the below steps:

Log in as root user if you are not logged in as root using su – command.

Enter the root user password

The useradd command is used to create a new user in Linux. So, type command useradd and give the username you want to create as given below:

Useradd smith

To set the password of the user smith type the command: passwd smith

It will prompt for the new password. Enter the new password for user smith.

It will ask to retype the password. So, retype the same password and password is set for the user.



Explain all the fields in the/etc/passwd file?

Answer: /etc/passwd file contains the useful information for all the system users who log in. We have many fields in /etc/passwd file such as username, password, user ID, group ID, comment or user ID info, home directory, command /shell, etc. So, this file contains sensitive information regarding all the user accounts. There is a single line per user in this file. Colon (:) separates the fields in /etc/passwd.


Below is the explanation of the fields.

Username: First field is the username that contains the username which is 1 to 32 length characters.

Password: This field does not show the actual password as the password is encrypted. Here, x character shows that password is encrypted that is located in /etc/shadow file.

User ID (UID): All the users created in Linux is given a user ID whenever the user is created. UID 0 is fixed and reserved for the root user.

Group ID (GID): This field specifies the name of the group to which the user belongs. The group information is also stored in a file /etc/group.

User ID Info: Here you can add comments and you can add any extra information related to the users like full name, contact number, etc.

Home directory: This field provides the path where the user is directed after the login. For example, /home/smith.

Command/shell: This field provides the path of a command/shell and denotes that user has access to this shell i.e. /bin/bash.


How can an administrator know whether a user account is locked or not?

Answer: To check if the user account is locked or not just run this command in the shell:

passwd –S <username>

Or search for the grep username in the location /etc/shadow file and it will show a symbol ‘!’ prefix to the encrypted field in the password box.

To just unlock the password type this command:

    passwd –u <username>

If there is a double exclamation mark then run this command two times:

    usermod –U <username>


What is the difference between “rm” and “rm –r”?

Answer: “rm” command is used to delete all the files while “rm –r” command is used to delete all the files in a directory and also in subdirectories.

For Example,

    rm file.txt: It will delete the file with name file.txt

    rm –r directory: It will remove directories and subdirectories and also their contents.




What is the use of Swap space in Linux?
Answer: In Linux, Swap space is used when the RAM is full. It may be considered as a physical memory substitute. The main function of swap space is to substitute disk space for RAM memory. Basically, swap space is nothing but an extension of RAM



To check memory status, which command is used?
Answer: “free” is the most used command to check the memory status in Linux. Other than the “free” command. ” “vmstat,” “top” and “htop” commands are used to check the memory status.



What is the use of run-level command?
Answer: After boot, the run-level command is helpful in defining the state of the machine. By default, the run level of the system is set by the system administrator



Define Linux Kernel.

Answer: Kernel is low-level software for computer systems. The kernel is a main component of the Linux operating system. It acts as a bridge between hardware and software. Whenever a computer system starts, the kernel is the first program that is loaded. The main function are:

  • Memory management
  • Device management
  • Storage management
  • Process management


How can you search for a specific file in Linux?


Define the Zombie process.
Answer: Zombie process in Linux, refers to the process that is removed from the user system but still resides in the processor’s memory. The child process always first becomes a zombie before being deleted from the process table.

What is the difference between su and sudo?
Answer:
su: Switches to the root user or another user account and requires the root password.
sudo: Executes a command as another user, typically the root user, but requires the current user's password (who must have sudo privileges).

How do you schedule a cron job in Linux?
Answer: Cron jobs are scheduled using the crontab file. To edit the crontab file, use:crontab -e

How do you kill a process in Linux?
Answer: You can kill a process using the kill command followed by the process ID (PID). First, use ps or top to find the PID of the process, then run:kill PID


How do you mount and unmount a file system in Linux?
Answer: Mount: To mount a file system, use the mount command. For example, to mount a USB drive:mount /dev/sdb1 /mnt/usb
Unmount: To unmount the file system, use the umount command:
umount /mnt/usb




Differentiate between Hard and Soft links.


How can you check the network connectivity between two Linux systems?

What is SSH and how is it used to access a Linux server remotely?

What is the purpose of the /etc/fstab file?

How do you check for free disk space on a Linux system?
Which commands would you use to extract files from an archive
How do you find and terminate a process consuming excessive CPU or memory
What is “load average” in Linux, and how do you check it
How do you change file permissions using the chmod command? Explain symbolic and numeric modes
What are some popular Linux distributions?
How do you change file permissions in a simple way
How do you view the manual or help page for a Linux command
What is the difference between absolute and relative paths?
What is the difference between absolute and relative paths?
How would you handle a “disk full” error on a Linux system?
You notice a sudden spike in server CPU utilization. How would you troubleshoot and identify the root cause



 Which command is used to list all files in a directory, including hidden files?
a) ls
b) ls -a
c) ls -l
d) ls -lh


 What is the command to check the current working directory in Linux?
a) pwd
b) cd
c) home
d) dir


Which command is used to change file permissions in Linux?
a) chmod
b) chperm
c) chown
d) chattr


What does the mkdir command do?
a) Creates a file
b) Deletes a directory
c) Creates a directory
d) Moves a file


 How do you view the contents of a file in Linux?
a) cat
b) ls
c) touch
d) rm


 Which command is used to display the running processes in Linux?
a) ps
b) top
c) jobs
d) All of the above


What is the use of the grep command in Linux?
a) To search for patterns within files
b) To display disk usage
c) To list users
d) To change file ownership

 What does the df command display?
a) Free and used memory
b) Disk space usage
c) List of files in a directory
d) Network configuration


 Which file contains user account information in Linux?
a) /etc/shadow
b) /etc/passwd
c) /etc/group
d) /etc/hostname


 What is the purpose of the kill command in Linux?
a) To stop a running process
b) To delete a file
c) To create a new user
d) To restart the system

Post a Comment

0Comments

Post a Comment (0)