Linux Practice exams

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

printenv Explanation OBJ-2.1: The printenv command displays the values of environment variables.

To see all the variables that are in the user's environment, use the _______ command. printer ping printenv processvar

WHAT Explanation OBJ-4.3: The WHAT column tells the "w" program which session is currently running.

What column tells the "w" program which session is running? STATUS PROGRAM WHAT WHICH

whereis Explanation OBJ-2.2: The whereis command lets users locate the executable, source, and manual page files for any command.

What command can be used to find the executable and man pages that exist for a given command? where whereis executeis executeman

ls -la Explanation OBJ-2.3: The command ls -la will provide the long view of the directory listing with all of the information, including the file permissions.

What command should be used to display the permissions for every file in the current directory? ls -la dir -la ls -all dir -all

ln -s Explanation OBJ-5.4: To create a soft link from the shell, you should use "ln -s <original_file> <link_created>". The soft link is essentially a pointer to the original file, and when the original file is deleted, the soft link does not point to anything, so "no such file or directory" is reported.

What command would you use to create a symbolic link in Linux? ln -d ln -s link -d link -s

Directories Explanation OBJ-2.3: A directory is a special file type that contains a list of other files instead of actual data. The other types of files listed do not have this ability.

Which Linux file type hold lists of files rather than the actual data? Regular Special Directories Named pipes

1000 Explanation OBJ-5.1: Regular users on a Linux system begin at UID 1000 and increment by 1 for each additional user.

Which UID is usually used to represent the first regular user on a Linux system? 1 10 100 1000

man -k copy Explanation OBJ-2.2: The command "man -k <keyword>" will search for the keyword in all of the man pages and return any results it finds. This is an easy way to find which command to use for a certain action if you cannot remember a command's name or syntax.

Which command can be used to search help files that mention the word "copy"? whatis copy man -k copy man copy copy help

cp Explanation OBJ-2.4: The cp command stands for copy.

Which command is used to copy files from one directory to another? mv copy cp rm

id Explanation OBJ-5.2: Only the id command can provide information about the user's identity, including the names of the groups they belong to. If you use cat /etc/passwd or cat /etc/groups, they can give you parts of that information, but not all of the information unless you run both of those commands.

Which command is used to provide information about a user's identity, including the names of the groups that the user belongs to? cat /etc/groups id echo $UID cat /etc/passwd

man -k copy Explanation OBJ-2.2: The -k option of the man command is equivalent to the apropos command. It searches the short manual page descriptions for keywords and displays any matches.

Which command line can be used to search help files that mention the word 'copy'? help copy man copy man -k copy info copy

apropos Explanation OBJ-2.2: The command apropos searches manual page names and descriptions for a user-supplied keyword.

Which command searches manual page names and descriptions for a user-supplied keyword? pros props apos apropos

w Explanation OBJ-5.1: The w command displays a list of all logged in to the system and what they are doing. This command is similar to the who command but ends up displaying more information about logged in users.

Which command shows who is logged on and what they are doing in the system? who w whoami id

/etc/skel Explanation OBJ-5.2: The /etc/skel directory contains files and directories automatically copied over to a new user's home directory when such a user is created by the useradd program.

Which directory contains the files and directories automatically copied over to a new user's home directory when the account is first created? /etc/group /etc/user /etc/skel /etc/template

/etc/group Explanation OBJ-5.1: The /etc/group file contains a list of every user on the system and their secondary groups.

Which file contains a list of the user's secondary groups? /etc/passwd /etc/shadow /etc/user /etc/group

route Explanation OBJ-4.4: Route command is used to show/manipulate the IP routing table. It is primarily used to set up static routes to specific hosts or networks via an interface.

A Linux computer currently has no access to the internet. Which command is used to display and manipulate the information about the network gateway for the system? gateway route ifconfig netstat

datenow='date ' Explanation OBJ-2.1: To store the output of a command in a variable, you can use either of the following commands in the shell: (1) variable_name=$(command) or (2) variable_name='command'.

The output of the program date should be saved in the variable datenow. What is the correct statement to enter into the shell to set this variable? set datenow='date' date | datenow datenow='date ' date > $datenow

tty Explanation OBJ-1.4: A tty is the Unix device name for a physical or virtual terminal connection. It essentially represents a singular text/computer interface. On Linux, there are multiple tty interfaces (tty0, tty1, tty2, etc.). tty7 is the graphical interface.

Which of the following is the UNIX device name for a physical or virtual terminal connection? dev virt phy tty

To show the kernel log messages Explanation OBJ-4.3: The dmesg (display message or driver message) command is a command on most Unix-like operating systems that prints the message buffer of the kernel. The output of this command typically contains the messages produced by the device drivers and serves to show the kernel's log messages to the screen.

Which of the following is the dmesg command used for? To show the user login and logoff attempts To show the kernel log messages To show the syslog file's informational messages To show the messages for the daemon logs

2 Explanation OBJ-3.3: The standard error (STDERR) is represented by the file descriptor number 2.

Which of the following is the file descriptor number used to represent the Standard Error (STDERR)? 0 1 2 3

0 Explanation OBJ-3.3: The standard in (STDIN) is represented by the file descriptor number 0.

Which of the following is the file descriptor number used to represent the Standard In (STDIN)? 0 1 2 3

1 Explanation OBJ-3.3: The standard out (STDOUT) is represented by the file descriptor number 1.

Which of the following is the file descriptor number used to represent the Standard Out (STDOUT)? 0 1 2 3

/proc Explanation OBJ-4.3: The /proc tree originated in System V Unix, where it only gave information about each running process, using a /proc/$PID/stuff scheme. Linux greatly extended that, adding all sorts of information about the running kernel's status. The intended purpose for the /proc virtual filesystem is to provide an interface into the kernel and its processes.

Which of the following is used as a virtual or pseudo filesystem used to interface with the kernel and process? /boot /proc /sys /dev

/sys Explanation OBJ-4.3: The /sys virtual filesystem is used to interact with the kernel and system as a whole. It did not provide any method to interact with individual processes and was created to move some of the original functions from /proc to /sys to clean up the /proc structure.

Which of the following is used as a virtual or pseudo filesystem used to interface with the kernel and system as a whole but not with individual processes? /boot /proc /sys /dev

gzip filename Explanation OBJ-3.1: The syntax for using gzip is "gzip filename". By default, when you compress a file or folder using the gzip command, it will have the same file name as before but with the extension .gz.

Which of the following options is used to gzip a file called filename? gzip -c filename gzip filename gzip -x filename gzip -z filename

-v Explanation OBJ-3.1: The -v option is used to verbosely show the .tar file progress during execution.

Which of the following options is used with tar to display the tar command's progress during execution? -c -v -f -n

-f Explanation OBJ-3.1: The -f option is used to specify the file name type of the archive file.

Which of the following options is used with tar to specify the filename of the tar archive? -c -v -f -n

rm -r Explanation OBJ-2.4: The rm -r option is used to remove a directory and its files/folders recursively.

Which of the following options must be used to remove a directory and its subdirectories? rmdir -r rm -r rmdir rm -all

root tty2 Wed Sep 29 21:11 - 21:11 (00:00) Explanation OBJ-5.1: The last command reads from a log file and prints the entries of successful login attempts made by the users in the past. The output is such that the last logged in user's entry appears on top.

Which of the following outputs might be displayed when executing the command last? Last login: Fri Mar 23 10:56:39 2019 from server.diontraining.com EXT4-fs (dm-7): mounted filesystem with ordered data mode. Opts: (null) root tty2 Wed Sep 29 21:11 - 21:11 (00:00) system uptime 2.6.32-131.0.15. Mon Oct 31 17:45 - 17:48 (00:03)

-f Explanation OBJ-3.2: The -f option is used to "follow" the contents of the file. This lets tail print the last 10 lines of a file (usually a log file) and continue to print out new lines to the screen as they are added to the file.

Which option can be used with tail to print the last 10 lines of a file and then keep printing any new lines that may be added continuously? -n -f -x -a

-M Explanation OBJ-5.2: The -M option creates a user without a home directory using useradd. When the -m option is used, the user's home directory will be created using the system's default setup and template.

Which option can be used with useradd to create a new user without a home directory? -N -G -M -D

-d Explanation OBJ-5.2: The -d option is used with useradd (useradd -d /path/to/directory username) to specify the user's home directory location instead of using the default directory.

Which option can be used with useradd to specify the home directory for a user? -d -c -b -h

-n Explanation OBJ-2.1: The -n option of the echo command does not output a trailing newline.

Which option will cause the echo command NOT to output a trailing newline? -p -n -s -t

apt Explanation OBJ-1.2: Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu, and related Linux distributions.

Which software handles the installation and removal of software on Debian and Ubuntu? apt install rpm yum

\d Explanation OBJ-3.3: The \d option would be added to add the date to the prompt in the shell.

Which string should you add to put the date into the prompt of the shell? \D /d /D \d

Hard link Explanation OBJ-5.4: A hard link, unlike a symbolic link, contains the data in the target file.

Which type of link contains the data in the target file? Hard link Symbolic link Sticky link Smooth link

/etc Explanation OBJ-4.3: The /etc folder is where configuration files are usually stored in a Linux system.

After installing a new package, in which directory are you most likely to find its configuration file? /conf /etc /usr /opt

/etc Explanation OBJ-4.3: /etc is a folder which contains all your system configuration files.

After installing a new package, in which directory are you most likely to find its configuration file? /lib /etc /conf /usr

globbing

Filename expansion using asterisks (*), question marks (?), and so on is sometimes called _.

find . -name MyFile.xml Explanation OBJ-2.3: find is a command that searches one or more directory trees of a file system, locates files based on some user-specified criteria, and applies a user-specified action on each matched file.

How can the current directory and its subdirectories be searched for in the file named MyFile.xml? find . -name MyFile.xml grep MyFile.xml | find grep -r MyFile.xml find -P MyFile.xml | grep

command >file 2>/dev/null Explanation OBJ-3.3: Specifying 2>/dev/null will filter out the errors so that they will not be output to your console. In more detail: 2 represents the error descriptor, which is where errors are written to. By default, they are printed out on the console. /dev/null is the standard Linux device where you send output that you want to be ignored.

How can the normal output of a command be written to a file while discarding the error output? command < output > /dev/null command > discard-error > file command > /dev/null 2&>1 output command >file 2>/dev/null

The combination of Linux, Apache, MySQL and PHP or other programming languages Explanation OBJ-4.1: LAMP (Linux, Apache, MySQL, PHP) is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language.

What does LAMP mean? The Linux Advanced Mode Programming Interface which gives advanced capabilities to application developers The combination of Linux, Apache, MySQL and PHP or other programming languages The bus ID of an attached USB device that emits light Short for Lightweight Access Management Protocol which synchronizes permissions in a network

Free/Libre Open Source Software

What does the abbreviation FLOSS stand for?

The t is used to show that the directory is globally writable, but only the owner can delete their own files within the directory Explanation OBJ-5.3: The t is a sticky bit, a specialized permission bit set on a directory that allows only the owner of the file within that directory, the owner of the directory, or the root user to delete or rename the file.

What does the letter t at the end of drwxrwxrwt indicate within the following directory permissions? drwxrwxrwt 14 root root 36864 2012-03-02 11:17 /tmp The t is used to show that the directory is globally writable, but only the owner can delete their own files within the directory The directory is accessible by everyone The directory contains only temporary files that can be deleted by the system when more space is needed The files contained in this directory can only be access by the root user

Permanent Explanation OBJ-4.4: DHCP supports three mechanisms for IP address allocation. Automatic allocation allows DHCP to assigns a permanent IP address to a device. Dynamic allocation is used when DHCP assigns an IP address to a device for a limited period of time. Manual allocation occurs when a device's IP address is assigned by the network administrator, and DHCP is used to convey the assigned address to the device.

What is NOT one of the ways that DHCP can be used to deliver IP addresses? Manual Automatic Dynamic Permanent

The conditions for modifying and distributing the licensed software Explanation OBJ-1.3: A free software license is a notice that grants the recipient of a piece of software extensive rights to modify and redistribute that software.

What is defined by a Free Software license? The programming languages which may be used to extend the licensed program A complete list of libraries required to compile the licensed software Limits on the purposes for which the licensed software may be used The conditions for modifying and distributing the licensed software

if [ $x -gt $y ] Explanation OBJ-3.3: The standard syntax for an if statement is "if [ condition ]." In this case, the comparison is testing if the variable X is greater than the variable Y.

What is the correct statement to be used for comparison in a Linux shell script? if [ $x -gt $y ] if $x -gt $y if ( $x -gt $y) if { $x -gt $y }

abc Explanation OBJ-3.3: A token is a sequence of characters that forms a word or punctuation sign. It is made up of ordinary characters or operator characters but not both.

What is the output of the following command? for token in a b c; do echo -n ${token}; done anbncn abc $token$token$token {a}{b}{c}

zip myfile.zip filename.txt Explanation OBJ-3.1: The syntax for zipping a file into a zip archive is "zip myfile.zip filename.txt".

What is the proper command to use to compress the file filename.txt into the zip archive called myfile.zip? zip myfile.zip filename.txt unzip filename.txt myfile.zip zip filename.txt myfile.zip unzip myfile.zip filename.txt

* Explanation OBJ-2.4: The * is used to represent no, one, or multiple characters within search criteria. This process is known as globbing.

What symbol can be used to represent none, one, or multiple characters within search criteria? * ? x .

/etc/shadow Explanation OBJ-5.1: The /etc/shadow file stores the actual password in an encrypted format (more like the hash of the password) for the user's account with additional properties related to the user password. Basically, it stores secure user account information. All fields are separated by a colon (:) symbol. It contains one entry per line for each user listed in /etc/passwd file. The last 6 fields provide password aging and account lockout features. Retake testContinue

Which file on a Linux system is modified to set the maximum number of days before a password must be changed? /etc/groups /etc/shadow /etc/passwd /etc/users

CTRL + SHIFT + C Explanation OBJ-1.4: Holding down the CTRL and SHIFT keys and pressing C allows any highlighted text in the terminal to be copied. Pressing CTRL + C within the terminal is recognized as a command interrupt.

Which keyboard shortcut allows copying highlighted text while working in the command line terminal? CTRL + C CTRL + SHIFT + C CTRL + ALT + C CTRL + TAB + C

umask Explanation OBJ-5.3: The umask command is used to change the default permission for files and directories at the time of the file's creation.

Which of the following commands can be used to change default permissions for files and directories at the time of creation? chmod u-rx,go-r filename umask chown chgrp

host Explanation OBJ-4.4: The host command is used for DNS (Domain Name System) lookup operations. It is used to find the IP address of a particular domain name or the domain name of a particular IP address. Nslookup and dig are also commands that can be used to lookup a domain name and convert it to an IP address within a Linux system.

Which of the following commands can be used to resolve a DNS name to an IP address? dns query host iplookup

which Explanation OBJ-2.2: Using the command which, as in "which ls", the PATH variable is searched and starting at the first directory found in the PATH, will look for the command ls. If it is not found, the next directory is searched, and so on.

Which of the following commands can search for executable programs or scripts located in the PATH variable? what why which how

ls -d Explanation OBJ-5.4: ls -d shows information about a directory or symbolic link. This information is usually just its respective path, though.

Which of the following commands is used to show the information about a directory or a symbolic link? ls -d ls -s ln -d ln -s

tar -cf backup.tar /home Explanation OBJ-3.1: The tar command allows you to quickly access a collection of files and place them into a highly compressed archive file. The -c option creates a new archive while -f uses the given filename as the archive's filename. Specifying the directory ensures the files to be placed in the archive file come from that folder.

Which of the following commands will create an archive file, named backup.tar, containing all the files from the directory /home? tar -cf backup.tar /home tar -cf /home backup.tar tar -xf /home backup.tar tar -xf backup.tar /home

find ~ -name '*.pdf' Explanation OBJ-2.1: To display all of the files with a .pdf extension at the end, the command find ~ -name '*.pdf' is used. This will display all files named *.pdf in the home directory.

Which of the following commands will output a list of all of the file names under your home directory and all subdirectories with file names ending with .pdf? search .pdf ls -name -R '*.pdf' find /home/*.pdf find ~ -name '*.pdf'

/boot Explanation OBJ-4.3: The /boot directory contains the kernel, its associated files, and its needed drivers to boot up the operating system during the startup process.

Which of the following directories contain all of the installed kernels on your system and their needed drivers? /boot /proc /sys /dev

/var Explanation OBJ-4.3: /var is a standard subdirectory of the root directory in Linux contains files to which the system writes data during the course of its operation. /var/log contains log files.

Which of the following directories is often used to store log files? /var /temp /dev/hdc1d2p3 /usr

Popularity Explanation OBJ-1.3: The heightened value proposition from open source compared to most proprietary formats include security, affordability, transparency, interoperability, scalability, and localization.

Which of the following is NOT a heightened value proposition of Open Source Software compared to Proprietary Software? Security Popularity Interoperability Localization

Users who modify and distribute the software under the GPL license must make the modifications they made available to the recipients under the same license Explanation OBJ-4.1: The GPL license is copyleft; therefore, users must disclose the source code and make any modified versions of the code open source. Under GPL, users cannot change any of the original license terms or introduce their own. The BSD license family does not compel users to do any of these things and instead has fairly relaxed redistribution terms.

Which of the following is a requirement of the GPL license but not the BSD license? The GPL license forbids the removal of copyright and license notices from source code files that are distributed The GPL license contains a disclaimer of warranty requiring users not to hold the software authors liable for any damages The GPL license requires that any legal disputes be settled with the mediation of the Free Software Foundation Users who modify and distribute the software under the GPL license must make the modifications they made available to the recipients under the same license

MySQL Explanation OBJ-1.2: MySQL is an open-source relational database management system.

Which of the following is an open-source relational database management system? MyDatabase MySQL OpenDatabase MSdatabase

Impress Explanation OBJ-1.2: Impress is the LibreOffice equivalent of Microsoft PowerPoint. It can even read and write to PowerPoint files directly from within Impress.

Which of the following programs on a Linux system could you use as a replacement for Microsoft PowerPoint? Draw Present Keynote Impress

Writer Explanation OBJ-1.2: Writer is a well-known word processor that is part of the LibreOffice suite. It can be used to replace just about anything that Microsoft Word can do. While vi and nano are text editors, they are not full-featured word processors like Microsoft Word. Pages is a word processor developed by Apple, and it only works on Mac OS X systems.

Which of the following programs on a Linux system could you use as a replacement for Microsoft Word? Pages Pico Writer Nano

^pattern Explanation OBJ-3.3: To search for lines beginning with the given pattern using grep, ^pattern should be used. If the pattern is enclosed in single quotes, it suppresses the meaning of all of the meta-characters with special meanings.

Which of the following provides the correct syntax to search for lines beginning with the given pattern using the grep command? ^pattern pattern^ $pattern pattern$

$2 Explanation OBJ-3.3: Inside a script, the $1 variable references the first argument from the command line and $2 is the second argument, and so on. The variable $0 references to the current script.

Which of the following statements may be used to access the second command line argument to a script? $arg2 $2 $1 $var2

2>&1 Explanation OBJ-3.3: The statement "2>&1" is used to redirect the standard output and standard error to the same file.

Which of the following statements would be used for sending both standard output and standard error to the same location? 2 &> 2 >& 2 <& 2>&1

Create the user's home directory Explanation OBJ-5.2: The useradd command does not create the user's home directory by default. To automatically create the user's home directory with the useradd command, the -m option is used to create the user's home directory with default configuration files.

Which of the following tasks is not performed automatically for a user account when it is created using the useradd command? Assign a UID Create the user's home directory Assign a default shell Define the user's home directory

Linux determines a file's type via code in the file's header(shebang). This process doesn't depend on file extensions to know which software to use for opening the file.

Why Windows file extensions are meaningless to the shell?

Because the file gets truncated before sort is executed Explanation OBJ-3.2: This is because the redirection is carried out first. This means that the > data.txt truncates the file so that sort finds nothing.

Why is the file data.txt empty after executing sort data.txt > data.txt? Because sort cannot sort text files, only binary files Because sort detects that both files are the same Because the file gets truncated before sort is executed Because the file gets executed before sort is truncated

case Explanation OBJ-3.3: A case statement uses a variable, and each pattern shown before the right parenthesis is a possible value of that variable. If the user's entry is equal to the value before the parenthesis, the case is run. Using a series of nested if-then-else statements will work, but it is rather clumsy and confusing to understand. A case statement is a much more efficient choice.

You have been asked to create a script will present the user with a onboard menu in which they can select 4 different commands to run by entering 1, 2, 3, or 4. Which of the following statements should you use to create the simplest and most effective method of choosing the command to run based on the user's input? if case for while

GPL version 3

You have developed free software and want to ensure that the software itself, but also all future results based on it, remain free as well. Which license do you choose? CC BY GPL version 3 2-Clause BSD License LGPL

mv password.txt .password.txt Explanation OBJ-2.3: To hide a file in the Linux filesystem, simply rename it with a prefixed dot (.) to its filename. Therefore, mv password.txt .password.txt will cause the file password.txt to be renamed as a "dot" file and become hidden from the ls command.

You have just created a text file with a secret password in it called password.txt. You want to ensure that the password is not seen when the ls command is run within the current directory. What command should you use to ensure the text file is hidden from the filesystem? rn password.txt .password.txt mv password.txt password.hidden mv password.txt .password.txt rn password.txt password.hidden

nodes

the linked pages for the info command are called


Ensembles d'études connexes

BIO2300 Unit 3 Brachial Plexus of Nerves Concept E

View Set