Friday, September 1, 2017

Unix mcqs

1. Which of the following commands is used to identify the type of file by context?
Ans: file

2. Which command is used to terminate a process?
Ans: kill

3. In shell scripts to check if file is empty
Ans: if[-s file]

4. To print all even numbered lines from the file file2
Ans: awk'NR%2==0{print $0}'file2

5. The option in tr command that replaces each input sequence of a repeated character that is listed in SET1 with a single occurence of that character
Ans: -s

6. Which of the following command are used to rename the file name from file1.txt to file2.txt?
Ans: mv file1.txt file2.txt

7. In Shell Scripting, command substitution is performed when a command is given as
Ans: 'command'

8. Which of the following commands will provide same output?
(1) cal -l
(2) cal -m
(3) cal -s
(4) cal
Ans: (1), (3) and (4) only

9. Pattern in awk command is optional
Ans: True

10. In vi editor forward search is performed using_______
Ans: /pattern

11. In ls command, the -i option is used to
Ans: print the index number of each file

12. Which filter works vertically?
Ans: cut

13. Command used to change the password is
Ans: passwd

14. "CompanyList" is a file having the names of IT companies. From the file, you have to print the names of all the companies except TCS and Wipro? Select the appropriate command from below options?
Ans: grep -v -e "TCS" -e "WIPRO" "CompanyList"

15. Command to find the count of lines in a given file is
Ans: awk 'BEGIN{sum=0}{sum=sum+1}END{print sum}'filename

16. In shell scripts to check if file is executable 
Ans: if[-x file]

17. To get all login names and number of users logged on
Ans: who -q

18. Command that translate or delete characters
Ans: tr

19. The command to be used to add permission for everyone to read a file in the current directory named myfile
Ans: All of these (chmod a+r myfile, chmod ugo+r myfile, chmod 777 file2)


  • References for Study Purpose:
1. Python for Unix and Linux System Administration 1st Edition (Highly Recommended)
2. Unix Concepts and Applications 4th Edition (Highly Recommended)
3. Unix and Shell Programming
4. Advanced UNIX Programming 2nd Edition by Rochkind Marc J. Arthur 
5. Unix Network Programming: Volume 1: The Sockets Networking API 3rd Edition
6. Unix and Linux: Visual Quickstart Guide
7. Unix and Shell Programming Textbook 1st Edition


No comments:

Post a Comment