Core Linux Interview Questions

Core Linux Interview Questions

1.You need to define a macro, a key binding for the existing command. How would you do it?

Answer : There is a command called bind, in bash shell which is capable of defining macro, or binding a key. In order to bind a key with an existing command, we need to generate Character Sequence emitted by the key. Press Ctrl+v and then key F12, I got ^[[24~
[root@localhost ~]# bind ‘”\e[24~”:”date”‘
Note : Different types of terminals or terminal emulators can emit different codes for the same key.
2. A user is new to Linux and he wants to know full list of available commands, what would you suggest him?

Answer : A command ‘compgen ­c’ will show a full list of available commands.

[root@localhost ~]$ compgen -c l. ll ls which if then else elif fi case esac for select while until do done …
3. Your assistant needs to print directory stack, what would you suggest?

Answer : The Linux command ‘dirs’, will print the directory stack.

[root@localhost ~]# dirs /usr/share/X11
4. You have lots of running jobs, how would you remove all the running processes, without restarting the machine?

Answer : The Linux command ‘disown -r’ will remove all the running Processes.

5. What does the command ‘hash’ is used for in bash Shell?
Answer : Linux command ‘hash’ manages internal hash table, fins and remember full path of the specified command, Display used command names and number of times the command is used.
[root@localhost ~]# hash hits command 2 /bin/ls 2 /bin/su
6. Which built­in Linux command performs arithmetic operation of Integers in Bash?
Answer : The ‘let’ command that performs, arithmetic operation of integer in bash shell.
#! /bin/bash … … let c=a+b … …
7. You have a large text file, and you need to see one page at a time. What will you do?
Answer : You can achieve the above result by pipeling the output of ‘cat file_name.txt’ with ‘more’ command.
[root@localhost ~]# cat file_name.txt | more
8. Who own the data dictionary?
Answer : The user ‘SYS’ owns the data dictionary. Users ‘SYS’ and ‘SYSEM are created by default, automatically.
9. How to know a command summary and useability in Linux?
Assume you came across a command in /bin directory, which you are completely unaware of, and have no idea what it does. What will you do to know its useability?
Answer : The command ‘whatis’ display a summary of its useability from the man page. For example, you would like to see a summary of ‘zcat’ command which you don’t know previously.
[root@localhost ~]# whatis zcat zcat [gzip] (1) – compress or expand files
10. What command should you use to check the number of files and disk space used by each user’s defined quotas?
Answer : The command ‘repquota’ comes to rescue here. Command repquota summaries quotas for a file system.

Comments are closed.