Unix - Study Mode
[#456] Which command is used to display the top of the file?
Correct Answer
(B) head
Explanation
Solution: In Unix, the head command is used to display the top part of a file. It prints the first 10 lines of the specified file by default. If you want to display a different number of lines, you can specify it using the -n option followed by the number of lines you want to display. So, head is the correct command to display the top of a file.
[#457] Which command is used to copy all files having the string chap and any two characters after that to the progs directory?
Correct Answer
(A) cp chap?? progs
Explanation
Solution: In Unix, the cp command is used to copy files or directories. The pattern chap?? matches files with the string chap followed by any two characters. When followed by progs , it indicates that all files matching this pattern should be copied to the progs directory. So, cp chap?? progs is the correct command to copy all files having the string chap and any two characters after that to the progs directory.
[#458] Which command is used to change protection mode of files starting with the string emp and ending with 1,2, or 3?
Correct Answer
(A) chmod u+x emp[1-3]
Explanation
Solution: In Unix, the chmod command is used to change the permissions or protection mode of files or directories. The pattern emp[1-3] matches files starting with the string emp and ending with 1 , 2 , or 3 . By adding u+x to the chmod command, it grants execute permission to the owner of the file. So, chmod u+x emp[1-3] is the correct command to change the protection mode of files starting with the string emp and ending with 1 , 2 , or 3 .
[#459] Which command is used to remove a directory?
Correct Answer
(B) rmdir
Explanation
Solution: In Unix, the rmdir command is used to remove or delete a directory. It is specifically designed to remove directories and will only work if the directory is empty. If the directory contains any files or subdirectories, rmdir will not remove it and will generate an error message. So, rmdir is the correct command to remove a directory.
[#460] Which of the following keys is used to replace a single character with new text?
Correct Answer
(B) s
Explanation
Solution: In Unix command line editors like vi or Vim, the s key is used in the command mode to replace a single character under the cursor with new text. After pressing s , you can enter the replacement text, and the character under the cursor will be replaced with it. So, s is the correct key to replace a single character with new text.