Top Job Interview Questions for Linux Professionals
See also:
Linux Interview Questions Part 1
Linux Interview Questions Part 2
Threat modeling for Penetration Testers Kali Linux
36) What are environmental variables?
Environmental
variables are global settings that control the shell's function as well as that
of other Linux programs. Another common term for environmental variables is
global shell variables.
37) What are the different modes when using vi editor?
There
are 3 modes under vi:- Command mode – this is the mode where you start in- Edit
mode – this is the mode that allows you to do text editing- Ex mode – this is
the mode wherein you interact with vi with instructions to process a file
38) Is it possible to use shortcuts for a long pathname?
Yes,
there is. A feature known as filename expansion allows you do this using the
TAB key. For example, if you have a path named /home/iceman/assignments
directory, you would type as follows: /ho[tab]/ice[tab]/assi[tab] . This,
however, assumes that the path is unique and that the shell you're using
supports this feature.
39) What is redirection?
Redirection
is the process of directing data from one output to another. It can also be
used to direct an output as an input to another process.
40) What is grep command?
grep
a search command that makes use of pattern-based searching. It makes use of
options and parameters that are specified along with the command line and
applies this pattern in searching the required file output.
41) What could be the problem when a command that was issued
gave a different result from the last time it was used?
One
highly possible reason for getting different results from what seems to be the
same command has something to do with case sensitivity issues. Since Linux is
case sensitive, a command that was previously used might have been entered in a
different format from the present one. For example, to lists all files in the
directory, you should type the command ls, and not LS. Typing LS will either
result in an error message if there is no program by that exact name exist or
may produce a different output if there is a program named LS that performs
another function.
42) What are the contents of /usr/local?
It
contains locally installed files. This directory matters in environments where
files are stored on the network. Specifically, locally-installed files go to
/usr/local/bin, /usr/local/lib, etc.). Another application of this directory is
that it is used for software packages installed from source, or software not
officially shipped with the distribution.
43) How do you terminate an ongoing process?
Every
process in the system is identified by a unique process id or pid. Use the kill
command followed by the pid to terminate that process. To terminate all process
at once, use kill 0.
44) How do you insert comments in the command line prompt?
Comments
are created by typing the # symbol before the actual comment text. This tells
the shell to completely ignore what follows. For example "# This is just a
comment that the shell will ignore."
45) What is command grouping and how does it work?
You
can use parentheses to group commands. For example, if you want to send the
current date and time along with the contents of a file named OUTPUT to a
second file named MYDATES, you can apply command grouping as follows: (date cat
OUTPUT) > MYDATES
46) How do you execute more than one command or program from a
single command line entry?
You
can combine several commands by separating each command or program using a
semicolon symbol. For example, you can issue such a series of commands in a
single entry:
ls
–l cd .. ls –a MYWORK which is equivalent to 3 commands: ls -l cd.. ls -a
MYWORK
**Note
that this will be executed one after the other, in the order specified.
47) Write a command that will look for files with an extension
"c", and has the occurrence of the string "apple" in it.
Answer:
Find ./ -name "*.c" | xargs grep –i
"apple"
48) Write a command that will display all .txt files, including
its individual permission.
Answer:
ls
-al *.txt
49) Write a command that will do the following:
-look for all files in the current and subsequent directories
with an extension c,v
-strip the,v from the result (you can use sed command)
-use the result and use a grep command to search for all occurrences of the word ORANGE in the files.
-strip the,v from the result (you can use sed command)
-use the result and use a grep command to search for all occurrences of the word ORANGE in the files.
Find
./ -name "*.c,v" | sed 's/,v//g' | xargs grep "ORANGE"
50) What, if anything, is wrong with each of the following
commands?
a) ls -l-s
b) cat file1, file2
c) ls - s Factdir
b) cat file1, file2
c) ls - s Factdir
Answers:
a) there should be space between the 2 options: ls -l -s
b) do not use commas to separate arguments: cat file1 file2
c) there should be no space between hyphen and option label: ls –s Factdir
a) there should be space between the 2 options: ls -l -s
b) do not use commas to separate arguments: cat file1 file2
c) there should be no space between hyphen and option label: ls –s Factdir
51) What is the command to calculate the size of a folder?
To
calculate the size of a folder uses the command du –sh folder1.
52) How can you find the status of a process?
Use
the command
ps
ux
53) How can you check the memory status?
You
can use the command
free
-m to display output in MB
free
-g to display output in GB
54) Explain how to color the Git console?
To
color the Git console, you can use the command git config—global
color.ui auto. In the command, the color.ui variable sets the default
value for a variable such as color.diff and color.grep.
55) How can you append one file to another in Linux?
To
append one file to another in Linux you can use command cat file2
>> file 1. The operator >> appends the output of the named
file or creates the file if it is not created. While another command cat
file 1 file 2 > file 3 appends two or more files to one.
56) Explain how you can find a file using Terminal?
To
find a file you have to use a command, find . –name
"process.txt" . It will look for the current directory for a
file called process.txt.
57) Explain how you can create a folder using Terminal?
To
create a folder, you have to use command mkdir. It will be
something like these: ~$ mkdir LinuxOS
58) Explain how you can view the text file using Terminal?
To
view the text file, go to the specific folder where the text files are located
by using the command cd and then type less
filename.txt.
59) Explain how to enable curl on Ubuntu LAMP stack?
To
enable curl on Ubuntu, first, install libcurl, once done use following
command sudo/etc/init .d /apache2 restart or sudo
service apache2 restart.
60) Explain how to enable root logging in Ubuntu?
The
command which enables root logging is
#sudo
sh-c 'echo "greater-show-manual-login=true"
>>/etc/lightdm/lightdm.conf'
61) How can you run a Linux program in the background
simultaneously when you start your Linux Server?
By
using nohup. It will stop the process receiving the NOHUP signal
and thus terminating it you log out of the program which was invoked
with. & runs the process in the background.
No comments:
Post a Comment