1.
Which of the following run level reboot the machine?
Correct Answer
D. 6
Explanation
Run level 6 is the correct answer because it is specifically designated for rebooting the machine. In Unix-like operating systems, each run level has a specific purpose, and run level 6 is reserved for system reboot. When the system enters run level 6, it initiates the reboot process, shutting down all running processes and restarting the machine. The other run levels listed (0, 4, 2, and 1) have different purposes such as shutting down the system, multi-user mode, or single-user mode, but run level 6 is specifically used for rebooting.
2.
If the file newdir/file2 does not exist but the directory newdir does exist, what is the effect of the following command?
mv file1 newdir/file2
Correct Answer
A. File1 will be moved to newdir and renamed file2.
Explanation
The command "mv file1 newdir/file2" will move the file named "file1" to the directory "newdir" and rename it as "file2". This means that the original file "file1" will no longer exist in its original location and can now be found in the "newdir" directory with the new name "file2".
3.
Consider the following command:[root@localhost ~]# echo $?0What does the output“0” indicates?
Correct Answer
C. “0” indicates that last command was successful.
Explanation
The output "0" indicates that the last command was successful.
4.
What type of files are typically in the /etc directory?
Correct Answer
A. Configuration files.
Explanation
The /etc directory typically contains configuration files. These files store settings and parameters for various programs and services on a Linux system. They are used to customize the behavior and functionality of the system and its applications. Examples of configuration files commonly found in the /etc directory include network configuration files, user account settings, system startup scripts, and package manager configurations.
5.
Consider the following command:[root@localhost ~]# cat /etc/passwd | grep root | cut -d: -f1,7
What will be the output?
Correct Answer
E. Root: /bin/bash.
Explanation
The given command is using the "cat" command to display the contents of the "/etc/passwd" file. The output of this command is then piped "|" to the "grep" command, which searches for lines containing the word "root". The output of the "grep" command is then piped "|" to the "cut" command, which uses ":" as the delimiter and selects the first and seventh fields from each line. Therefore, the output will be "root: /bin/bash", which represents the username "root" and the shell "/bin/bash".
6.
For the file reports.txt, which of the following commands would, ignoring case, extract every line containing the word "expense", the lines before and after each match, and print the relevant line numbers?
Correct Answer
B. Grep -A1 -B1 -n -i expense reports.txt
Explanation
The correct answer is "grep -A1 -B1 -n -i expense reports.txt". This command will search for the word "expense" in the file "reports.txt" while ignoring case. It will also print the line numbers of the relevant lines. Additionally, it will print the line before and after each match using the options -A1 and -B1 respectively.
7.
Consider the following file:[root@localhost ~]# cat catscatcatalogconcatenatepolecatCatWhat will be the output when you fire the below command:sed ‘s/[Cc]at$/dog/’ cats.
Correct Answer
E. dog
catalog
concatenate
poledog
dog
Explanation
The sed command is used to perform text transformations on a file. In this case, the command 's/[Cc]at$/dog/' is used to replace the word 'cat' or 'Cat' at the end of a line with the word 'dog'.
The given file contains the following lines:
- cat
- catalog
- concatenate
- poledog
- cat
When the sed command is applied to this file, the word 'cat' at the end of the first line is replaced with 'dog'. The rest of the lines remain unchanged. Therefore, the output will be:
- dog
- catalog
- concatenate
- poledog
- cat
8.
Where is the configuration information for network interface eth0 stored?
Correct Answer
D. /etc/sysconfig/network-scripts/ifcfg-eth0
Explanation
The configuration information for network interface eth0 is stored in the file /etc/sysconfig/network-scripts/ifcfg-eth0.
9.
In the file /etc/sysconfig/network-scripts/ifcfg-eth0, which variable is modified to the value "dhcp" in order to get the IP address automatically from DHCP server? (write the name of variable in capital letters only).
Correct Answer
BOOTPROTO
Explanation
The variable that needs to be modified to "dhcp" in order to get the IP address automatically from the DHCP server is BOOTPROTO.
10.
How many fields (columns) are there in /etc/shadow and /etc/gshadow respectively?
Correct Answer
D. 9, 4
Explanation
The correct answer is 9, 4. In the /etc/shadow file, there are 9 fields or columns, which include the username, encrypted password, last password change date, minimum password age, maximum password age, password warning period, password inactivity period, account expiration date, and reserved field. In the /etc/gshadow file, there are 4 fields or columns, which include the group name, encrypted password, list of group administrators, and list of group members.
11.
Which of the following commands could be used to configure a system's date and time?
Correct Answer
A. Date
Explanation
The correct answer is "date". The "date" command is commonly used in Unix-like operating systems to display or set the system's date and time. By running the "date" command with appropriate options and arguments, users can view the current date and time, as well as modify them to set a new date and time.
12.
Consider the following scripts:echo "Enter the username:"read NAMEuseradd $NAMEecho $NAME | passwd $NAME --stdinWhat will be the password if I run the above script and enter the username as 'abc'?
Correct Answer
C. Password will be abc
Explanation
The password will be 'abc' because the script uses the 'useradd' command to create a new user and the 'passwd' command to set the password. The password is set to the value of the variable '$NAME', which is 'abc' in this case.
13.
What command will be run by this sequence? [root@localhost ~]# !?cat
Correct Answer
B. The most recent command that has cat in the command name.
Explanation
The given sequence [root@localhost ~]# !?cat will run the most recent command that has "cat" in the command name. This means that if there was a previous command that included "cat" in its name, the sequence will run that command.
14.
Consider the following file:[root@localhost ~]# cat examplebAafced433152aWhat will be the output of below command? Why?cat example | sort | uniq -d
Correct Answer
D. A, because a is repeated twice.
Explanation
The correct answer is "a, because a is repeated twice." This is because the command "cat example | sort | uniq -d" is used to display the duplicate lines in the file "example". The output will be the lines that are repeated in the file, and in this case, the letter "a" is repeated twice.
15.
In the following shell script, how many times will the date command run? for i in a b; do date; done
Correct Answer
C. 2
Explanation
The date command will run 2 times in the given shell script. This is because the script uses a for loop to iterate through the values "a" and "b". For each iteration, the date command is executed, resulting in a total of 2 executions.
16.
Which among the following file should be modified in order to make the permanent configuration to the vim editor?
Correct Answer
E. Either .vimrc or .exrc
Explanation
To make permanent configurations to the vim editor, either the .vimrc or .exrc file should be modified. These files contain settings and customization options for the vim editor. Modifying either of these files allows users to set preferences such as key mappings, syntax highlighting, and other editor configurations. By making changes to these files, users can ensure that their preferred settings are applied every time they use the vim editor.
17.
What umask setting wouls be required to give, when creating a directory, read/write/execute for yourself, read & execute for group but only execute for others?
Correct Answer
B. 026
Explanation
The umask setting determines the default permissions for newly created files and directories. In this case, a umask setting of 026 would be required. This means that when creating a directory, the owner would have read, write, and execute permissions (7), the group would have read and execute permissions (5), and others would have only execute permissions (6).
18.
Consider a directory /root/dropzone. Which amongst the following permissions should be set up so that group and others can save files in the directory, but they cannot read the files that are there? Root must be able to read and write the directory.
Correct Answer
E. Drwx-wx-wx
Explanation
The correct answer is "drwx-wx-wx". This permission setting allows the group and others to save files in the directory ("/root/dropzone") by having write access, but they cannot read the files that are already there as they do not have read access. Root, however, can still read and write to the directory as it has full permissions.
19.
Write down the command to view the calendar of January 2010.
Correct Answer
cal 01 2010
cal 1 2010
Explanation
The command "cal 01 2010" and "cal 1 2010" are both correct answers because they both specify the month and year (January 2010) to view the calendar. The "cal" command is used to display a calendar in the terminal, and the format for specifying the month and year is either with leading zeros (01) or without leading zeros (1).
20.
Write down the file in which DNS configuration are made.
Correct Answer
/etc/resolv.conf
Explanation
The DNS configuration is made in the file "/etc/resolv.conf". This file contains information about the DNS servers that the system should use to resolve domain names to IP addresses. By editing this file, users can specify the DNS server addresses, search domains, and other DNS settings for their system.
21.
Suppose you want to view the man page for the gshadow file format. How might you do that?
Correct Answer
B. Man 5 gshadow
Explanation
To view the man page for the gshadow file format, you would use the command "man 5 gshadow". The "man" command is used to display the manual pages for various commands and topics, and the number "5" specifies the section of the manual where the gshadow file format is documented. By typing this command, you can access the specific information about the gshadow file format.
22.
What will the following command do:find -size 1024k exec rm -f {} \;
Correct Answer
A. It will delete the file/s of exactly 1 mb
Explanation
The given command "find -size 1024k exec rm -f {} \;" is using the "find" command to search for files with a size of exactly 1 megabyte (1024 kilobytes) and then executing the "rm -f" command to delete those files. Therefore, the command will delete the file/s that are exactly 1 megabyte in size.
23.
Choose the inappropriate option regarding the at and crontab.
Correct Answer
B. The syntax for deleting jobs in at is
the syntax for deleting jobs in crontab is
24.
What command will you type to install linux using CLI?
Correct Answer
D. Linux text
Explanation
To install Linux using the command line interface (CLI), you would type "linux text" in the command prompt. This command initiates the installation process in text mode, allowing you to install Linux without a graphical user interface (GUI). By using the "linux text" command, you can install Linux on a system that may not have the necessary hardware or resources to support a GUI-based installation.
25.
In which of the following file can you set the default run-level?
Correct Answer
B. /etc/inittab
Explanation
In the given options, the correct file to set the default run-level is /etc/inittab. This file is used by the init process to determine the default run-level for the system. It contains configuration information for initializing and controlling the system during the boot process.