2.
What command is used to change directories?
Explanation
The command "cd" is used to change directories in a command line interface. It allows the user to navigate through different directories or folders on the computer's file system. By typing "cd" followed by the desired directory name, the user can switch to that directory and access its contents. This command is commonly used in operating systems like Unix, Linux, and Windows Command Prompt.
3.
What command is used to change the permissions of a file?
Explanation
The command "chmod" is used to change the permissions of a file. This command allows the user to modify the permissions for the owner, group, and others on the file. By using different options and parameters with the "chmod" command, the user can grant or revoke read, write, and execute permissions for the file. This command is commonly used in Unix-like operating systems to manage file permissions and ensure the security and accessibility of files.
4.
ls -al
Correct Answer
A. Formatted listing with hidden files
Explanation
The command "ls -al" is used to display a formatted listing of files and directories in the current directory. The "-a" option includes hidden files in the listing, while the "-l" option provides detailed information about each file or directory, such as permissions, owner, size, and modification date. Therefore, the correct answer is "formatted listing with hidden files".
5.
What is the command to delete a file?
Correct Answer
rm
rm -f
Explanation
The command "rm" is used to delete a file in a Unix/Linux system. It stands for "remove" and is a basic command for deleting files. The command "rm -f" is a more forceful version of the "rm" command, where the "-f" flag is used to forcefully remove the file without prompting for confirmation. Both commands can be used to delete files, but "rm -f" is more commonly used when you want to delete files without any confirmation prompts.
6.
What command is used to change ownership of a file?
Correct Answer
chown
Explanation
The command "chown" is used to change the ownership of a file. This command allows the user to transfer the ownership of a file to another user or group. By using "chown", the user can modify the permissions and access rights of a file, granting ownership to a specific user or group. This command is commonly used in Unix-based operating systems to manage file ownership and control access to files.
7.
How would you show a list of files and directories that are inside the current directory?
Explanation
The correct answer for this question is "ls". In Unix-based systems, the "ls" command is used to list the files and directories that are inside the current directory. It provides a simple and concise way to view the contents of the current directory without displaying any additional information. This command is widely used by users to navigate and explore the file system.
8.
head file
Correct Answer
A. Show top 10 lines
Explanation
The correct answer is "show top 10 lines" because the command "head" is used to display the beginning or top portion of a file. By typing "head file", it will show the first 10 lines of the file "file".
9.
mv file1 file2
Correct Answer
A. Rename or move file 1 to file 2
Explanation
The given command "mv file1 file2" is used to rename or move file1 to file2. It does not delete the files or copy file1 to file2.
10.
ps
Correct Answer
A. Display currenty active processes
Explanation
The correct answer is "display current active processes" because out of the given options, it is the only one that pertains to showing the currently running processes on a system. The other options, such as displaying the date and time or showing a monthly calendar, are unrelated to displaying active processes.
11.
__________ command used to create an empty file.
Explanation
The touch command is used to create an empty file.
12.
cp -r dir1 dir2
Correct Answer
A. Copy dir1 to dir 2, create dir 2 if it doesn't exist
Explanation
The given command "cp -r dir1 dir2" is used to copy the directory "dir1" and all its contents to the directory "dir2". If "dir2" does not exist, it will be created. This command does not involve copying or deleting individual files, it specifically deals with copying directories.
13.
What command clears the contents of your terminal display?
Correct Answer
clear
reset
Explanation
The correct answer is "clear". This command is used to clear the contents of the terminal display, removing all previous commands and output from the screen. The "reset" command, on the other hand, resets the terminal to its default settings, but does not clear the display.
14.
tail file
Correct Answer
A. Show bottom 10 lines
Explanation
The correct answer is "show bottom 10 lines" because the command "tail file" is used to display the last few lines of a file. By default, it displays the last 10 lines of the file. Therefore, the command "tail file" is equivalent to "show bottom 10 lines".
15.
pwd
Correct Answer
A. Show current directory
Explanation
The command "pwd" is used to show the current directory in a command line interface. It displays the full path of the current working directory, allowing the user to see where they are located within the file system. This can be helpful for navigating and organizing files and directories.
16.
You want to view a listing of previously entered commands. What command wouldyou use?
Correct Answer
A. History
Explanation
history command lists all commands in history. All history commands
stored in ~/.bash_history file.
17.
What command allows you to view a file one page at a time?
Correct Answer
less
more
Explanation
The correct answer is "less". The "less" command allows you to view a file one page at a time. It is a pager program that displays text files or the output of other commands on the terminal. It allows you to scroll through the file using the arrow keys or specific commands, making it easier to navigate through large files without overwhelming the screen with too much information at once. The "more" command is similar but has fewer features compared to "less".
18.
What command creates an empty directory?
Explanation
The correct answer is "mkdir". The mkdir command is used to create a new directory or folder in a file system. By using this command, an empty directory can be created.
19.
What is the command to switch to the root user account?
Correct Answer
su
sudo su root
sudo su
Explanation
The correct answer is "su". This command is used to switch to the root user account in Unix-like operating systems. "sudo su root" is also a valid command to switch to the root user account using the sudo command. "sudo su" alone can also be used to switch to the root user account, but it is not recommended as it can potentially cause security risks.
20.
The symbol represents home directory is?
Explanation
The symbol "~" is commonly used to represent the home directory in various operating systems, including Unix and Unix-like systems. The home directory is the default directory for a user when they log in, and it typically contains their personal files and settings. Using "~" as a shortcut allows users to quickly navigate to their home directory without having to specify the full path.
21.
What is the command to run a program with elevated permissions?
Correct Answer
sudo
Explanation
The command "sudo" is used to run a program with elevated permissions. It allows a user to execute a command as a superuser or another user, granting them temporary administrative privileges. This is commonly used in Unix-based operating systems to perform tasks that require higher privileges, such as installing software or making system changes.
22.
Which command to use for complete details of a command on the shell?
Explanation
The correct answer is "man". The "man" command is used to display the manual page for a given command on the shell. It provides detailed information about the command, including its syntax, options, and examples. By using the "man" command, users can access comprehensive documentation and get a complete understanding of how a specific command works.
23.
How do you see hidden files in your home directory?
Explanation
The correct answer is "ls -la". This command lists all files and directories, including hidden ones, in a detailed format. The "-l" option displays the files in a long format, showing permissions, owner, size, and other details. The "-a" option shows all files, including hidden ones that start with a dot. Therefore, using "ls -la" allows you to see hidden files in your home directory.
24.
What two commands display the status of processes on a Linux system?
Correct Answer
A. Ps and top
Explanation
b. Both ps and top yield process status. None of the other listed commands are related to processes.
25.
Which command is used to view the complete file without modifying it ?
Explanation
The cat command is used to view the complete file without modifying it. It displays the contents of a file on the terminal.
26.
What command is used to search files for a pattern?
Explanation
The command "grep" is used to search files for a pattern. It is a powerful tool that allows users to search for specific text or patterns within files. By using various options and regular expressions, grep can efficiently search through multiple files and directories to find the desired pattern. It is commonly used in command-line environments for tasks such as log analysis, text processing, and data extraction.
27.
What is the command to search all files in your current directory for
the word plasmodium?
Correct Answer
A. Grep plasmodium *
Explanation
The correct answer is "grep plasmodium *". The grep command is used to search for patterns in files. In this case, it is searching for the word "plasmodium" in all files in the current directory. The asterisk (*) is a wildcard that represents all files in the directory. Therefore, this command will search all files in the current directory for the word "plasmodium".
28.
Chmod 644 finance.doc644 equals to
Correct Answer
A. Rw- r-- r--
Explanation
The given answer, "rw- r-- r--", represents the permission settings for the file "finance.doc" when using the chmod command with the argument "644". In this case, "rw-" indicates that the owner of the file has read and write permissions, while "r--" indicates that the group and other users only have read permissions. This means that the owner can read and modify the file, while the group and other users can only read the file.
29.
How do you copy an entire directory structure? E.g. from Project to Project.backup
Correct Answer
A. Cp -r Project Project.backup
Explanation
To copy an entire directory structure from "Project" to "Project.backup", the correct command is "cp -r Project Project.backup". The "-r" flag is used to recursively copy all files and directories within the "Project" directory to the "Project.backup" directory. This ensures that the entire directory structure is copied over. The other options, "cp Project Project.backup" and "mv Project Project.backup", do not include the "-r" flag and would only copy or move the top-level directory, without its contents. The option "mv -r Project Project.backup" is incorrect as the "-r" flag is not valid for the "mv" command.
30.
You're now in directory X3 (see below). Moving to directory X1 using command:X1 |__ X2 |__ X3
<--- You're here
Correct Answer
A. Cd ../..
Explanation
The command "cd ../.." is used to move up two levels in the directory structure. The ".." represents the parent directory, so using it twice moves up two levels. In this case, it will take you from directory X3 to the root directory.
31.
If you want to restrict users from directory content listing, you have to
Correct Answer
A. Change the directory read permission
Explanation
To restrict users from directory content listing, you need to change the directory read permission. By changing the directory read permission, you can prevent users from viewing the contents of the directory, including any files or subdirectories within it. This ensures that the directory's content remains private and inaccessible to unauthorized users.
32.
You want to change the permissions on the file named “fifteen” so that owner has all permissions while all other users don't have any permissions. Which command should you use?
Correct Answer
A. Chmod 700 fifteen
Explanation
The correct answer is "chmod 700 fifteen". This command will change the permissions of the file named "fifteen" so that the owner has all permissions (read, write, and execute), while all other users (group and others) don't have any permissions. The number "700" represents the permission settings, where the first digit (7) represents the owner's permissions, the second digit (0) represents the group's permissions, and the third digit (0) represents the permissions for others.
33.
What is the default directory path for system log files?
Correct Answer
/var/log
/var/log/
Explanation
The default directory path for system log files is typically "/var/log" or "/var/log/". This is where various log files are stored on a Unix-like operating system. The logs contain important information about system events, errors, and activities, which can be useful for troubleshooting and monitoring the system's performance. The "/var/log" directory is commonly used by many Linux distributions and Unix-based systems to organize and store log files.
34.
In order to append the output of ls to a file called bazz, which of the following
command lines would you use?
Correct Answer
A. Ls >> bazz
Explanation
The correct answer is "ls >> bazz". This command line appends the output of the "ls" command to a file called "bazz". The ">>" symbol is used for appending output to a file, while ">" symbol is used for overwriting the file with the new output. The other options are incorrect because they either redirect the output to a file without appending it (">" and ">&") or use the incorrect syntax ("&>").
35.
One single command to completely remove directory X1 and all it's contents (see below)X1 |__ X2 |__ X3
Correct Answer
A. Rm -rf X1
Explanation
The correct answer is "rm -rf X1" because the "rm" command is used to remove files and directories, and the "-rf" options are used to forcefully remove directories and their contents recursively. This means that the command will remove directory X1 and all its contents, including directory X2 and file X3.
36.
What command shows you memory utilization?
Correct Answer
free
top
Explanation
The command "free" shows the memory utilization by displaying the total amount of free and used memory in the system. On the other hand, the command "top" provides a dynamic real-time view of the system, including information about memory usage, CPU usage, and other system statistics. Both commands can be used to monitor memory utilization, but "free" specifically focuses on memory while "top" provides a broader overview of system performance.
37.
Which command will display the last lines of the text file file1?
Correct Answer
A. Tail file1
Explanation
d. The tail command is used for checking the last lines of a text file. By default, it displays 10 lines.
38.
The symbol represents current directory is?
Explanation
The symbol "." represents the current directory in a file system. It is commonly used in command line interfaces to refer to the current working directory. This symbol allows users to navigate and access files and directories within the current directory without having to specify the full path.
39.
Which command will list the contents of a directory, listed by file modification time, in reverse order (last modified file shows up at the bottom of a listing)?
Correct Answer
A. Ls -lart
Explanation
The command "ls -lart" will list the contents of a directory, listed by file modification time, in reverse order. The "-l" option displays the files in a long format, including the modification time. The "-a" option includes hidden files in the listing. The "-r" option reverses the order of the listing, so that the last modified file shows up at the bottom. Finally, the "-t" option sorts the files by modification time.
40.
How would you remove a directory that is not empty?
Explanation
The correct answer is "rm -r". The "rm" command is used to remove files and directories in Unix-like operating systems. The "-r" option stands for "recursive", which means it will remove the specified directory and its contents, including any subdirectories and files within it. By using "rm -r", you can remove a directory that is not empty.
41.
What is the command to view data in real time as it is being added to a file?
Correct Answer
A. Tail -f
Explanation
The correct answer is "tail -f". The "tail" command is used to display the last part of a file, and the "-f" option allows the command to continuously display the file as it is being updated in real time. This is useful for monitoring log files or any other files that are constantly being appended with new data.
42.
If you want to protect files from content modifications, you have to
Correct Answer
A. Change the file write permission
Explanation
To protect files from content modifications, you need to change the file write permission. By changing the write permission, you can restrict users from making any changes to the file, ensuring its integrity and preventing unauthorized modifications. This allows you to maintain the original content and prevent any accidental or intentional alterations to the file. Changing the file read permission or the directory permissions would not directly address the issue of content modifications.
43.
You're now in directory X1 (see below). Moving to directory X3 using command:X1 <--- You're here |__ X2 |__ X3
Correct Answer
A. Cd X2/X3/
Explanation
The correct answer is "cd X2/X3/" because it correctly navigates to directory X3, which is located inside directory X2. The command "cd X2/X3/" specifies the path to directory X3 relative to the current directory X1.
44.
Which one of the following statements correctly describes the > and
>> symbols in the context of the bash shell?
Correct Answer
A. > writes standard output to a new file, and >> appends standard output to an existing file.
Explanation
b. The > character opens and writes to a new file, while >> appends to an existing file, unless that file doesn't exist, in which case it is opened first.
45.
You want to search the file myfile for all occurrences of a string containing at leastfive characters, where character number 2 and 5 are "a" and character number 3 isNOT "b". Which command would you use?
Correct Answer
A. Grep .a[^b].a myfile
Explanation
String Processing Tools like grep, sed, awk uses wildcard characters.
. Ã Any Single character from the range
[abc] Ã Any Single Character from the set
[a-c] Ã Any Single Character from the Range
[^abc] Ã Any Single Character except from the set.
[^a-c] Ã Any Single Character except from the range.
According to QUESTION, in 2nd and 5th position must be a and in 3rd position not b.
B. . means any single character in first postion., a means a must be in second postions,
[^b] means b must not be in third postion, . means any single character in fourth position
and a in fifth position.
46.
How would you avoid accidentally removing files?
Explanation
The option "rm -i" is the correct answer because it prompts the user for confirmation before deleting each file. This allows the user to double-check and avoid accidentally removing files. The other options, "rm -chk," "rm -a," and "rm -r," do not provide any confirmation and can lead to unintentional file removal.
47.
How do you find files in your current directory modified more than 48 hours ago?
Correct Answer
A. Find . -mtime 2
Explanation
The correct answer is "find . -mtime 2". This command uses the "find" utility to search for files in the current directory (and its subdirectories) that were modified exactly 2 days ago. The dot (.) represents the current directory, and the option "-mtime" specifies the time period for the search. The number 2 indicates that the files modified within the last 48 hours will be returned.
48.
The command to restrict user not to delete finance.doc within directory /home/budi
Correct Answer
A. Chmod -w /home/budi
Explanation
The correct answer is "chmod -w /home/budi". This command removes the write permission for the directory "/home/budi", which means that users will not be able to delete the file "finance.doc" within that directory. The other options either only modify the permissions of the file "finance.doc" or change the permissions of the entire directory without specifically targeting the file.
49.
Which one of the following commands is equivalent to the following command for
user jdoe whose home directory is /home/jdoe?# chmod 754 ~/file1
Correct Answer
A. Chmod u=rwx,g=rx,o=r /home/jdoe/file1
Explanation
a. User mode 7 is the same as u=rwx, group mode 5 is the same as g=rx, and other mode 4 is the same as o=r. The ~/ syntax implies the user's home directory.