Unix ( Multiple Choice Quistion )
1. Which Symbol be used with grep command to match the the pattern pat at the beginning of a line ?
a. ^pat
b. $pat
c. pat$
d. pat^
Correct Answer : a
Explantion :
Matching the lines that start with a string : The ^ regular expression pattern specifies the start of a line. This can be used in grep to match the lines which start with the given string or pattern.
$ grep "^unix" file.txt
2. Which command is used to sort the lines of a data in a file in reverse order ?
a. sort
b. sh
c. sort-r
d. st
e. None of the above
Correct Answer : c
Explanation : sort is used to sort the data but sort-r is used to sort the data in reverse order
sh command is used to invoke the system shell or default shell
3. Which of the command to change the protection mode of files starting with string emp and ending with 1,2 or 3 ?
a. chmod u+x emp[1-3]
b. chmod 777 emp*
c. chmod u+r ??? emp
d. chmod 222 emp?
e. None of these
Correct answer : a
Explanation : chmod 777 means give red , write , execute permission to everybody .
chmod 222 Write Permissions for Owner, Group members and Others. First 2 assigns write permission for Owner (user), second 2 will assign write permission to Group members and Third 2 assigns write permissions to others.
chmod u+x will made the file executable for your user
4. Which command is used to remove the directory ?
a. rd
b. rmdir
c. dl dir
d. rdir
Correct answer : b
Explanation : rd command is used to remove an empty directory
rmdir
5. Find the occurrences of word and print its occurrence count.
answer : grep –o –i “unix” myfile| wc –lfind . -type f -perm 0777 -print
a. Display all files who has all the three permission for all levels of users
b. Display all directories who has all the three permission for all levels of users
c. Display all files who has minimum level of permission for all levels of users
d. Display all folders who has all the three permission for all levels of users
Explanation : type f return only the files ,
a. awk ‘BEGIN(FS=”|”;s=0)(s=s+$2)END(print s/NR)’ file1
b. awk ‘BEGIN{FS=”|”;s=0}{s=s+$2}END{print s/NR}’ file1
c. awk ‘BEGIN{FS=”|”;s=0}{s=s+$2}END{print s}’ file1
d. awk ‘BEGIN{FS=” ”;s=0}{s=s+$2}END{print s/NR}’ file1
Correct answer : c
8. Select the correct command to search "Hello Unix" in a file ignoring case ?
a. grep "Hello Unix" file name
b. grep -i "Hello Unix" file name
c. grep -c "Hello Unix" file name
d. grep -i file name "Hello Unix"
Correct answer : b
9. Which of the following command in unix used to remove the duplicate lines ?
a. sort -u
b. sort uniq
c. uniq
d. uniqe
correct answer : c
Some Useful Commands of Unix :
1. ls - used to show the list of all the folders in an directory
2. ltr - used to show the list of all the folders but with more information like date time of creation .
3. cmd - used to change the current directory
4. pwd - tells us in which directory , we are working
5. mkdir - used to create new directory
6. cat - used to print content of a file and it also allow us to write content to the directory
7. mv - used to move files from one directory to others .
8. chmod - used to change the permission of files and directory
9. grep - used to search the the string or text
10. echo - used to print the string written after echo
Comments
Post a Comment