Linux administrator Interview Questions and Answers:

  1. What are the filesystem in linux ?

\==. In Linux operating system, everything on Linux is a file on Linux.

7 types of files in linux.

If in the ll results of it shows off

  • Then regular file.

d- directory

c– character device files

l- link file

s- socket file.

b- block device file

l- pipe files.

The very first type of file in Linux is C-type. When we go in to /dev and then heat ll-long list will appear in front of permissions there will be C which denotes C means character devices. Whenever we want output of the file to print in other file at that time we use character device file. Where we get the output of the running command. Whatever come, and you run you can print the output of that command on the top of this file which is C type. In /dev it's an autofs file.

Second file system is d means directory which means folder. Then what is the difference between file and folder. Folder means directory, so the difference is- the directory is nothing but the special kind of file which contains metadata of the other files and folders.

The third file system is nothing but b which denotes block device. Block device means a particular file system where we can store the data.

S file system means socket when a system is running, and it has to pass on information from one process to another process that particular file is known as socket.

Pipes files are the main files which are used by the kernel for running some special process you do not see all this file in general.

  1. What is the command to check the file modification time?

\== If we press ll space file names then we can see when the file was modified last time. If we use touch command it will update the last updated time for that file. Means touch space filename will update the timestamp of that particular file.

  1. How can we check who modified the file.?

\== There is a particular tool called as aide we can install that tool yum install aide -y. That tool will show who modified the file and what modified it.

  1. How do you check the difference between files ?

\== There is a command known as diff. We can use diff command to differentiate between two files or to check the difference between two files. We can use (diff file1 file2) to check the difference between the file1 and file2. Info diff will show the different options of diff command.

  1. How will you find the files containing the string word "root" ?

\== We can use grep command for the same. grep "root" /etc/passwd. It will show the files with root word. We can also use cat filename pipe it and grep it with string word.

  1. How will you insure the file will not be deleted accidentally?

\== There is a command chattr +i space file name. Then, if we try to delete this file, it will show operation not permitted. And if you want to delete that file, then we need to run same chattr command with minus I (-i) option.

  1. What is the difference between cp and mv?

\== i node is nothing but the physical location of the data. If you want to check the i-node, then we need to use the command (ll -li). If we use CP command then the file will get copy at the particular location and i-node of that file will be different. If we are using mv then the file is getting moved from that one location to another location and i node of that file will remain the same. That means with the help of MV only location of that file is getting change but not the i-node and i-node, It means the physical location of that file or data. With CP command the one new i-node it is getting created but with MV command i-node is not getting created. But if while copy or while moving the file if the file system is different from the i-node will get changed and the old I node will get free. Means another file can use that i-node.

  1. What is standard input and standard output?

\== Standard input means we are typing the command. The command is nothing but the standard input, and the result of that command is a standard output. For example, if we use ll command, the result will get shown. The ll is nothing but the standard input, and the result is nothing but the standard output. If we type the wrong command, the standard out will show like --bash typed command: command not found. This is just standard output for the wrong command. If we use ls >> /vin it will print the result. But if we use wrong command then the result will not get printed in the file because the wrong command has a standard output that is not getting printed into the file. If you want to print the error into the file, then we are using command with two in front of the redirect sign. e.g. lslsls 2> /vin. This lslsls is the error and standard output will be the error, still that error will get printed into the slash vin file.

Linux Users and Groups management.

  1. How to add user on Linux?

\== User add is a simple command to add users on Linux. Like, we will use useradd space username to add the user. To find out whether a user has been added or not, we will grep username in /etc/passwd file.

\== We have files to check the information stored about users like /etc/passwd which will show the user's name and /etc/groups will show the group information. /etc/shadow file stores the actual encrypted passwords for everything on your system. The shadow file is located at /etc/shadow, and is only accessible to the root user.

If we use rpm -qf /etc/passwd we will get output as setup-2.12.2-2.e18.norch and if we use this name and do

rpm -ql setup-2.12.2-2.e18.norch then we will get the list of all files which stores the information about the users.

  1. What is the use of /etc/skel?

\== Whatever files are present in this directory, it will be copied to the user's home directory, when we create a new user.

  1. What is the use of /etc/login.defs files?

\== This is the file which contains default parameters of user creation. This file contains information like whether a mail directory will be created and if yes where. What is maximum password days minimum password length? What is warning age search information will be stored in this file. What will be the minimum group ID maximum group ID this kind of information we will get in this file. System group ID minimum, system group ID maximum, when system users are getting created this will be the minimum and maximum values for their ID's. Create home option is there if you put no there, then there will be no home directory for the newly created users. If you create user as a Ram, and we check in /etc/passwd then there will be showing home directory as /home/Ram but actual there is no such folder because we have mentioned the option there for home directory as no.

  1. What I need to do if I don't want to create a mailbox for user?

\== There is file /etc/default/useradd which we need to edit and set create mail spool option as no. Then there will be no mailbox will not be created.

  1. How to change home directory or login shell or userid?

\== We need to use usermod command for the same. We need to use commands with options.

To change user home directory

usermod -d /home/ram ram. usermod is command -d to change directory and directory location with name and username.

usermod -s /sbin/nologin ram == To change the default login shell.

Assign a new UID to a user using the usermod command. Second, assign a new GID to group using the groupmod command. Finally, use the chown and chgrp commands to change old UID and GID respectively.

I hope you enjoy the blog post!

If you find the blog helpful, please do like it and share it with your friends. If you have any doubts or questions related to the topics covered in the blog, feel free to ask them in the comments section. I’ll be more than happy to help!