1.
How can you append the output of a command to a file?
Correct Answer
B. Command >> file
Explanation
To append the output of a command to a file, you can use the "command >> file" syntax. The double greater than sign (>>) is used to redirect and append the output of the command to the specified file. This means that the output will be added to the end of the file without overwriting any existing content.
2.
With what command you can see what folder you are in?
Correct Answer
D. Pwd
Explanation
The command "pwd" stands for "print working directory" and is used to display the current directory or folder that the user is in. This command is commonly used in command line interfaces to keep track of the user's location within the file system. By typing "pwd" and pressing enter, the user can see the full path of the current directory, which helps in navigating and locating files and folders.
3.
How do you delete a file?
Correct Answer
A. Rm filename
Explanation
The correct answer is "rm filename". The "rm" command in Unix/Linux is used to remove or delete files and directories. By using "rm" followed by the name of the file, you can delete the specified file.
4.
How do you get all files with on the 3rd place an r, g or i?
Correct Answer
D. Ls ??[rgi]*
Explanation
The correct answer is "ls ??[rgi]*". This answer uses the "?" wildcard to represent any single character and the "[rgi]" to match the characters 'r', 'g', or 'i'. Therefore, this command will list all files with any two characters followed by either 'r', 'g', or 'i'.
5.
What command do you have to use to go to the parent directory?
Correct Answer
D. Cd ..
Explanation
The correct answer is "cd ..". This command is used to go to the parent directory in the file system. The ".." represents the parent directory, allowing the user to navigate up one level in the directory structure.
6.
With what command you can see your user name?
Correct Answer
C. Whoami
Explanation
The correct answer is "whoami". The "whoami" command is used to display the username of the current user in a Unix-like operating system. It is a simple and straightforward way to quickly see the username associated with the current session.
7.
With what can you stop a process?
Correct Answer
A. Kill
Explanation
The correct answer is "Kill." In computing, the "kill" command is used to terminate or stop a running process. It sends a signal to the process, instructing it to stop execution. This signal can be used to gracefully shut down a process or forcefully terminate it, depending on the specific use case. The other options listed, such as "Delete," "Stop," and "Shutdown," do not typically refer to stopping a process but rather involve other actions such as removing files, halting a system, or shutting down a computer.
8.
What does the command ls do?
Correct Answer
B. Display of files and folders, present in the folder where you are
Explanation
The command "ls" is used in the command line interface to list the files and folders present in the current directory. It does not show a calendar, open a file, or display the contents of a file.
9.
What command is used to forward errors to a file?
Correct Answer
D. 2> filename
Explanation
The command "2> filename" is used to forward errors to a file in Linux. The number "2" represents the standard error stream, and the "> filename" redirects the output to the specified file. This allows any error messages generated by a command to be saved in a file for later analysis or troubleshooting.
10.
How can you display a list of all files, including the hidden files?
Correct Answer
A. Ls -a
Explanation
The correct answer is "ls -a". The "ls" command is used to list files and directories in a directory. The "-a" option is used to display all files, including hidden files, in the directory. Therefore, "ls -a" is the correct command to display a list of all files, including hidden files.
11.
How will you list only the empty lines in a file (using grep)?
Correct Answer
C. Grep “^$” filename.txt
Explanation
The correct answer is "grep “^$” filename.txt". This command uses the grep utility with the regular expression "^$" to search for lines that contain nothing between the start and end of the line. This effectively matches empty lines in the file "filename.txt".
12.
How do you read arguments in a shell program?
Correct Answer
B. $1 would be the first command line argument, $2 the second, and so on
$0 is the name of the script or function
Explanation
The correct answer is that $1 would be the first command line argument, $2 would be the second, and so on. This is because in a shell program, arguments passed from the command line are assigned to variables starting from $1, $2, $3, and so on. $0, on the other hand, represents the name of the script or function itself. Therefore, both options a and b are incorrect.
13.
Which of the following is NOT a proper shell name?
Correct Answer
D. Ssh : sea shell
Explanation
The given options are all shell names except for "ssh: sea shell". This is not a proper shell name as "ssh" stands for Secure Shell, which is a network protocol for secure remote login and other secure network services. It is not a type of shell used for command line interfaces.
14.
In Shell scripting, what does '$?' return?
Correct Answer
A. $? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.
Explanation
The correct answer is that $? will return the exit status of a command. If the command is executed successfully, the exit status will be 0. If the command fails, the exit status will be a non-zero value.
15.
In Shell scripting What does $# stand for?
Correct Answer
B. # will return the number of parameters that are passed as the
command-line arguments.
Explanation
In Shell scripting, the symbol $# represents the number of parameters that are passed as command-line arguments. This means that it will return the count of arguments that are provided when executing the shell script. It does not represent the number of errors or any other options mentioned in the question.
16.
In Shell scripting, what is $*?
Correct Answer
C. It's mainly used for showing all params. This shows all parameter values passed in the shell script.
Explanation
$* is a special variable in shell scripting that is used to display all the parameter values passed in a shell script. It allows the script to access and manipulate all the arguments provided when the script is executed. This is useful when a script needs to work with multiple inputs or parameters.
17.
How can you get/set an environment variable from a program?
Correct Answer
A. Getenv() and putenv()
Explanation
The correct answer is getenv() and putenv(). The getenv() function is used to retrieve the value of an environment variable, while the putenv() function is used to set or change the value of an environment variable. These functions are commonly used in programming to interact with the environment variables of a system.
18.
To change mode of myfile to 'rwxr–r–' , the command used is
Correct Answer
D. Chmod(myfile,0744)
Explanation
The correct answer is "chmod(myfile,0744)". The "chmod" command is used to change the permissions of a file or directory. In this case, the "myfile" is being changed to "rwxr--r--", which means the owner has read, write, and execute permissions, while the group and others have only read permission. The numbers in the command represent the permissions in octal form, with the first digit representing the owner's permissions, the second digit representing the group's permissions, and the third digit representing others' permissions.
19.
All UNIX files have their description stored in a structure called 'inode.' Which of the below fields are not part of the inode?
Correct Answer
A. File access count
Explanation
The file access count is not part of the inode structure in UNIX. The inode contains information about the file owner identifier, file type, and file access permissions. The file access count refers to the number of times the file has been accessed and is typically stored separately from the inode.
20.
Which of the below commands is NOT used to view the contents of a file?
Correct Answer
D. Disp command
Explanation
The disp command is not used to view the contents of a file. The ls command is used to list the files in a directory, the cat command is used to display the contents of a file, and the more command is used to view the contents of a file one screen at a time. However, the disp command is not a valid command for viewing file contents.
21.
How do you find out what’s your shell?
Correct Answer
C. Echo $SHELL
Explanation
The correct answer is "echo $SHELL". This command is used to display the current shell being used by the user. The "$SHELL" is a system variable that holds the path to the current shell executable. By using the "echo" command, the value of the "$SHELL" variable is printed to the console, revealing the user's current shell.
22.
Fork() command is used to create a new process. State true or false.
Correct Answer
A. True
Explanation
The fork() command is indeed used to create a new process. When the fork() command is executed, it creates a new process by duplicating the existing process. The new process, known as the child process, is an exact copy of the parent process, except for a few differences in process ID and memory address. Therefore, the correct answer is true.