Linux Advance Interview Question And Answer ( Linux Advance Command) Linux Series- 3
100)How to search a word in command mode
->/word
101)If we want to search a word in command mode in forward direction then
which char we have to press?
->n
102)If we want to search a word in command mode in backward direction then
which char we have to press?
->N
103)List down all the insert modes commands
->i I a A o O s S
104)The command which is used to check whether there is any modification in
the file or not?
->$md5sum filename
105)Which command is used to split the file?
->$split filename
106)Write a command to split a file on the basic of no of lines.Split the file try.txt
and each file should contain 4 lines
->$split -no_of_line filename
$split -4 try.txt
107)Write a command to split a file on the basic of bytes.Split the file try.txt and
each file should contain 426723 byte
->split -b byte_value filename
split -b 426723 try.txt
108)Write a command to split a file on the basis of no of chunks.Split the file
try.txt into 3 files.
->$split -n no_of_files filename
$split -n 3 try.txt
109)Which command is used to set default permissions for files or directories
that are created by the user?
->$umask
110)Which command is used to translate the characters?
->$ tr
111) Write a command to convert all the vowels which are in small letters to
capital letters in the given sentence and print that newly translated sentence.
"Man is Mortal"
->$echo "Man is Mortal" |tr 'aeiou' 'AEIOU'
112)Write a command to convert 'abcd' '!@*%' in the given sentence.
"I love apples,dogs,cat and banana".
->$echo "I love apples,dog,cat and banana" |tr 'abcd' '!@*%'
113)Write a command if we want to delete a specific character from the string
using tr command.
"Man is Mortal"
Delete all the vowels .
->$echo "Man is Mortal" |tr -d 'aeiou'
114)Write a command to delete all the vowels from fruits.txt file using .
->$cat fruits.txt | tr -d 'aeiou'
115)Write a command to squeeze all 'o'to single o
"Helloooo Brooooo"
->$echo "Helloooo Brooooo" |tr -s 'o' 'o'
116)Write a command to squeeze 'lo' 'lo'
"Hellllloooooooooo Brrroooooo"
->$echo "Hellllloooooooooo Brrroooooo" |tr -s 'lo' 'lo'
117)Write a command to change space -> tab
"Hello my name is sakshi"
->$echo "Hello my name is sakshi" | tr ' ' '\t'
118)Write a command to print each word in new line
"Hello my name is sakshi sawalikar"
->$echo "Hello my name is sakshi" | tr ' ' '\n'
119)How to find files in a directory using the whole path. Path=
/home/ec2-user/folder1 and filename that you have to search is f1.txt
->$find full_path -name 'filename'
$find /home/ec2-user/folder1 -name 'filename'
120)How to get the last 10 lines of a file.Display last 10 lines of file try.txt
->tail try.txt
121)How to get the last 3 lines of a file.Display last 3 lines of file try.txt
->tail -n 3 try.txt
122)How to get first 10 lines of a file.Display the first 10 lines of file try.txt
->head try.txt
123)How to get the first 5 lines of file.Display the first 5 lines of file try.txt
->head -n 5 try.txt
1000 lines
Print 501-510
-> head -n 510 | tail -n 10 f1.txt
124)Sort the each word of a file try.txt
->cat try.txt | tr -s ' ' '/n' | sort
125)Sort the file try.txt according to the occurrence (count) of each word in the
file and then display the word having the highest count and comes last after
sorting .
->cat try.txt | tr -s ' ' '/n' | sort |uniq -c |sort -n |tail -n 1
126)Sort the file try.txt according to the occurrence (count) of each word in the
file and then display the first word having the highest count and comes first after
sorting .
->cat try.txt | tr -s ' ' '/n' | sort |uniq -c |sort -n |head -n 1
127)Which command is used in linux to view the content of text file one page at a
time.Use that command to view the file f5.txt
->$more f5.txt
128)Write a command to search a word (pavbhaji)in a text file named try.txt using
less command.
->$less try.txt
/pavbhaji
129)Suppose we have a txt file named as f1 having data
A B C D ------------M N O
And we want to print the data in the middle(E F G H) then write a command for
this task.
->$head -n 8 f1.txt|tail -n 4
130)Suppose we have f2.txt having 10000 records and we want from 500 to 510
then
->$head -n 510 f2.txt | tail -n 11
131)Write a command to copy 5000 lines from f2.txt into f3.txt
->$head -n 5000 f2.txt > f3.txt
132)Write a command to see no of lines ,word count and characters of file try.txt
->$wc try.txt
133)If we want to see numbers of lines only ,then write a command for it.
->$wc -l try.txt
134)If we want to see numbers of word count only ,then write a command for it.
->$wc -w try.txt
135)If we want to see numbers of no of characters only ,then write a command for
it.
->$wc -c try.txt
136)Write a command to extract specific fields from emp.txt having data
FPT1,ADHI, SCIENCE
MPT2,SAKSHI,MATHS
HPT3,SHRUTI,BCOM
Write a command to get the output as
FPT1,
MPT2,
HPT3,
->$cut -c 1-5 emp.txt
137)Write a command to get the output as
FPT1
MPT2
HPT3
->$cut -c 1-4 emp.txt
138)Write a command to extract specific fields from emp.txt having data and
write that extracted data into another txt file.
Write a command to get the output as
FPT1,
MPT2,
HPT3,
and save it into another file named as f1.txt
->$cat emp.txt | cut -c 1-5 > f1.txt
139)Write a command to extract 2-5 fields from emp.txt having data and write
that extracted data into another txt file named as f1.txt
->$cat emp.txt |cut -c 2-5 >f1.txt
140)Write a command to extract 3-10 fields from emp.txt having data and write
that extracted data into another txt file named as f1.txt
->$cat emp.txt |cut -c 3-10 >f1.txt
141)Write a command to display the content of files f1.txt f2.txt f3.txt vertically
using paste command
->$paste f1.txt f2.txt f3.txt
142)Write a command to display following output using cut command for emp.txt
file
Output:-FPT1
MPT2
HPT3
->cut -d "," -f2 emp.txt
143)Write a command to display the following output using cut command for
emp.txt file to display third column.
->$cut -d "," -f3 emp.txt
144)Write a command to redirect the output of date command save the output in
m2.txt
->$date > m2.txt or date 1>m.txt
145)Write a command to redirect the output of a command save the error in
m2.txt
->$dates 2>m2.txt
146)Write a command to see the processes that are currently active.
->$ps
147)Print the shell name where processes are currently running.
->$echo $0
148)Write a command to print process id
->$echo $$
149)How to check in which terminal we are?
->$tty -> /dev/pts/
150)Which command is used in Linux to display a detailed list of currently
running processes in a full format.
->$ps -f
$ ps -e … who the demon process / all process
0 Comments