Which of the following commands puts the lines of the file data.csv into alphabetical order?
a..z data.csv
sort data.csv
abc data.csv
wc -s data.csv
grep --sort data.csv
The sort command is used to sort the lines of a file or a stream of input according to a specified criterion, such as alphabetical order, numerical order, reverse order, etc. By default, the sort command sorts the lines in ascending alphabetical order, using the firstcharacter of each line as the key. For example, the command sort data.csv will sort the lines of the file data.csv in alphabetical order and display the output on the screen. If you want to save the sorted output to a new file, you can use the redirection operator (>) to specify the output file name. For example, the command sort data.csv > sorted_data.csv will sort the lines of the file data.csv in alphabetical order and save the output to a new file named sorted_data.csv. The other commands are either invalid or do not perform the sorting operation. The a…z command does not exist, the abc command is a text editor, the wc command counts the number of words, lines, and bytes in a file, and the grep command searches for a pattern in a file or a stream of input. Therefore, the correct answer is B. References:
Which of the following commands can be used to resolve a DNS name to an IP address?
dnsname
dns
query
host
iplookup
The host command is used to resolve a DNS name to an IP address or vice versa. It can also perform other DNS queries, such as finding the mail servers for a domain. The host command has the following syntax: host [options] [name] [server]. The name argument can be a hostname, such as or an IP address, such as 192.168.0.1. The server argument is optional and specifies the name or IP address of the DNS server to query. If no server is given, the default system resolver is used. References:
What is defined by a Free Software license?
Details of the technical documentation each contributor has to provide.
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.
Conditions for modifying and distributing the licensed software.
A free software license is a notice that grants the recipient of a piece of software extensive rights to modify and redistribute that software. These actions are usually prohibited by copyright law, but the rights-holder (usually the author) of a piece of software can remove these restrictions by accompanying the software with a software license which grants the recipient these rights. Software using such a license is free software (or free and open-source software) as conferred by the copyright holder. Free software licenses grant users the freedom to use it for any purpose, study and change the source code and copy and redistribute the software with or without modifications. Free software must come with source code or provide access to it, while the freedom to redistribute includes the right to give away copies gratis as well as sell copies1 References: 1: Free-software license - Wikipedia
Which statements about the directory /etc/skel are correct? (Choose two.)
The personal user settings of root are stored in this directory.
The files from the directory are copied to the home directory of the new user when starting the system.
The files from the directory are copied to the home directory of a new user when the account is created.
The directory contains a default set of configuration files used by the useradd command.
The directory contains the global settings for the Linux system.
The /etc/skel directory is a skeleton directory that contains the default files and directories that are automatically copied to the home directory of a new user when the account is created by the useradd command12. The purpose of this directory is to provide a consistent and uniform environment for all new users and to save the system administrator’s time and effort in configuring the user settings12. The /etc/skel directory can be customized by adding or removing files and directories as needed, depending on the desired default settings for the new users12.
The other options are incorrect because:
References:
Which command copies the contents of the directory /etc/, including all sub-directories, to /root/?
copy /etc /root
cp -r /etc/* /root
cp -v /etc/* /root
rcp /etc/* /root
cp -R /etc/*.* /root
The correct command to copy the contents of the directory /etc/, including all sub-directories, to /root/ is cp -r /etc/* /root. This command uses the cp command, which stands for copy, and is used to copy files and directories on Linux and Unix systems. The command also uses the following options and arguments123:
The other options are incorrect because they use different commands or syntax that do not copy the contents of the directory /etc/, including all sub-directories, to /root/. For example:
References: 1: Cp Command in Linux (Copy Files) | Linuxize 2: cp command in Linux with examples - GeeksforGeeks 3: How to Copy Files and Directories in the Linux Terminal
The file script.sh in the current directory contains the following content:
#!/bin/bash echo $MYVAR
The following commands are used to execute this script:
MYVAR=value
./script.sh
The result is an empty line instead of the content of the variable MYVAR. How should MYVAR be set in order to make script.sh display the content of MYVAR?
!MYVAR=value
env MYVAR=value
MYVAR=value
$MYVAR=value
export MYVAR=value
The reason why the script.sh does not display the content of the variable MYVAR is that the variable is not exported to the environment of the script. When a script is executed, it runs in a separate process that inherits the environment variables from the parent process, but not the shell variables. A shell variable is a variable that is defined and visible only in the current shell session, while an environment variable is a variable that is exported to the environment and visible to all processes that run in that environment1.
To make a shell variable an environment variable, we need to use the export command. The export command takes a shell variable name and adds it to the environment of the current shell and any subshells or processes that are created from it2. For example, to export the variable MYVAR with the value value, we can use:
export MYVAR=value
This will make the variable MYVAR available to the script.sh when it is executed, and the script will print the value of MYVAR as expected. Alternatively, we can also use the export command with the -n option to remove a variable from the environment, or with the -p option to list all the environment variables2.
The other options are not valid ways to set MYVAR as an environment variable. The !MYVAR=value option is not a valid syntax for setting a variable in bash. The env MYVAR=value option will run the env command with the MYVAR=value argument, which will print the environment variables with the addition of MYVAR=value, but it will not affect the current shell or the script.sh3. The MYVAR=value option will set MYVAR as a shell variable, but not as an environment variable, so it will not be visible to the script.sh1. The $MYVAR=value option will try to set the variable whose name is the value of MYVAR to the value value, which is not what we want4. References:
Which of the following commands creates the ZIP archive poems.zip containing all files in the current directory whose names end in .txt?
zip *.txt > poems.zip
zcat *.txt poems.zip
zip poems.zip *.txt
zip cfz poems.zip *.txt
cat *.txt | zip poems.zip
The zip command is used to create compressed archive files that can contain one or more files or directories. The zip command takes the name of the archive file as the first argument, followed by the names of the files or directories to be included in the archive. You can also use wildcards to match multiple files or directories with a common pattern. For example, the command zip poems.zip *.txt will create the ZIP archive poems.zip containing all files in the current directory whose names end in .txt. The other commands are either invalid or do not perform the desired operation. The command zip *.txt > poems.zip will try to create an archive for each file ending in .txt and redirect the output to poems.zip, which is not a valid archive file. The command zcat *.txt poems.zip will try to decompress and concatenate the contents of the files ending in .txt and poems.zip, which is not a valid ZIP file. The command zip cfz poems.zip *.txt will fail because the options c, f, and z are not valid for the zip command. The command cat *.txt | zip poems.zip will try to read the contents of the files ending in .txt from the standard input and create an archive named poems.zip, but this will not preserve the file names or attributes of the original files. References:
A directory contains the following three files:
texts 1.txt
texts 2.txt
texts 3.csv
Which command copies the two files ending in.txtto the/tmp/directory?
cp ??.txt /tmp/
cp *.txt /tmp/
cp. \.txt /tmp/
cp ?.txt /tmp/
cp $?.txt /tmp/
The correct command to copy the two files ending in .txt to the /tmp/ directory is cp *.txt /tmp/. This command uses the wildcard character * to match any number of characters beforethe .txt extension. Therefore, it will copy both texts 1.txt and texts 2.txt to the destination directory /tmp/. The other options are incorrect because they use different wildcard characters or syntax that do not match the desired files. For example, option A uses ?? to match exactly two characters before the .txt extension, but the files have a space and a number, which are not considered as one character. Option C uses a backslash \ to escape the dot . before the .txt extension, but this is unnecessary and will cause the command to fail. Option D uses ? to match exactly one character before the .txt extension, but the files have more than one character. Option E uses $? to match the exit status of the previous command before the .txt extension, but this is not relevant and will cause the command to fail123 References: 1: Linux wildcards | How do wildcards work in Linux with examples? - EDUCBA 2: Wildcards in Linux explained with 10 examples | FOSS Linux 3: What are wildcard characters in Linux? – Sage-Answers
Which of the following directories must be mounted with read and write access if it resides on its own dedicated file system?
/opt
/lib
/etc
/var
/usr
The /var directory must be mounted with read and write access if it resides on its own dedicated file system. The reason is that the /var directory contains files and directories that are expected to change in size and content as the normal operation of the system progresses, such as logs, spool files, and temporary files1. Therefore, the /var directory needs to have enough space and permission to accommodate these changes. If the /var directory is mounted as read-only, some system services and applications may fail to start or function properly2.
The other options are not directories that must be mounted with read and write access if they reside on their own dedicated file system. The /opt directory contains optional or third-party software packages that are not part of the default installation1. The /lib directory contains libraries and kernel modules that are essential for the binaries in /bin and /sbin directories1. The /etc directory contains configuration files for the system and applications1. The /usr directory contains user-related programs, libraries, documentation, and data1. These directories are usually mounted as read-only to prevent accidental or malicious modification of their contents3. References:
Which of the following examples shows the general structure of a for loop in a shell script?
for *.txt as file => echo $file
for *.txt ( echo $i )
for file in *.txt do
echo $i done
for ls *.txt exec {} \;
foreach @{file} { echo $i
}
The general structure of a for loop in a shell script is as follows12:
for variable in list do commands done
The variable is the name of a loop counter or iterator that takes on the values of the items in the list. The list can be a sequence of words, numbers, filenames, or the output of a command. The commands are the body of the loop that are executed for each value of the variable. The do and done keywords mark the beginning and the end of the loop body.
The option C. for file in *.txt do echo $i done follows this structure, with the variable being file, the list being *.txt (which matches all the files with the .txt extension in the current directory), and the command being echo $i (which prints the value of the variable i, which is presumably set somewhere else in the script).
The other options are incorrect because:
for file in *.txt do echo $file done
for i in *.txt do echo $i done
for file in *.txt do exec $file done
for file in * do echo $file done
References:
Why are web browser cookies considered dangerous?
Cookies support identification and tracking of users.
Cookies are always public and accessible to anyone on the internet.
Cookies consume significant amounts of storage and can exhaust disk space.
Cookies store critical data which is lost when a cookie is deleted.
Cookies can contain and execute viruses and malware.
Web browser cookies are small pieces of data that are stored by a website on a user’s browser. They are used to remember information about the user, such as preferences, login details, shopping cart items, etc. Cookies can also be used to identify and track users across different websites, which can have implications for privacy and security. For example, cookies can be used to show targeted ads based on the user’s browsing history, or to collect personal information without the user’s consent. Cookies are not inherently dangerous, but they can pose some risks if they are misused or compromised by malicious actors. References:
What is the preferred source for the installation of new applications in a Linux based operating system?
The vendor's version management system
A CD-ROM disk
The distribution's package repository
The vendor's website
A retail store
The distribution’s package repository is the preferred source for the installation of new applications in a Linux based operating system. A package repository is a collection of software packages that are maintained by the distribution and can be easily installed, updated, or removed using a package manager. Package repositories offer several advantages, such as:
The other sources are not preferred because they may not offer these benefits and may cause problems with the system. The vendor’s version management system, the vendor’s website, or a CD-ROM disk may contain packages that are not compatible with the distribution or may conflict with other packages. A retail store may not have the latest or the most suitable packages for the system. References:
Which command displays file names only and no additional information?
ls -a
ls -lh
ls -l
ls -alh
ls -nl
The ls command is used to list the files and directories in a given path. By default, the ls command displays only the file names, without any additional information. However, the ls command can also take various options to modify its output. For example, the -l option tells ls to display the long format, which includes the file permissions, owner, group, size, date, and name. The -h option tells ls to display the file sizes in a human-readable format, such as KB, MB, GB, etc. The -a option tells ls to display all files, including thehidden ones that start with a dot (.). The -n option tells ls to display the numeric user ID and group ID instead of the user name and group name. Therefore, the only option that does not add any additional information to the file names is the -a option. The command ls -a will display all the file names in the current directory, including the hidden ones, but nothing else. References:
What parameter of ls prints a recursive listing of a directory's content? (Specify ONLY the option name without any values or parameters.)
ls -R
The -R parameter of the ls command prints a recursive listing of a directory’s content, meaning that it will list not only the files and directories in the current directory, but also the files and directories in all the subdirectories12. For example, if you have a directory structure like this:
/home/user/├──dir1│├──file1│└──file2└──dir2├──file3└──file4
You can use the command ls -R /home/user/ to list all the files and directories recursively, and the output will look like this:
/home/user/: dir1 dir2
/home/user/dir1: file1 file2
/home/user/dir2: file3 file4
The -R parameter is also known as the --recursive option, which is the long form of the same parameter12. You can use either -R or --recursive to achieve the same result.
References:
Which files are the source of the information in the following output? (Choose two.)
uid=1000 (bob) gid=1000 (bob) groups=1000 (bob), 10 (wheel), 150
(docker), 1001 (libvirt)(wireshark),989
/etc/id
/etc/passwd
/etc/group
/home/index
/var/db/users
The files /etc/passwd and /etc/group are the source of the information in the following output:
uid=1000 (bob) gid=1000 (bob) groups=1000 (bob), 10 (wheel), 150 (docker), 1001 (libvirt) (wireshark), 989
The /etc/passwd file contains information about user accounts, such as the username, password, user ID (UID), group ID (GID), full name, home directory, and login shell1. The /etc/group file contains information about groups, such as the group name, password, group ID (GID), and members2.
The output shows the UID, GID, and group membership of the user bob. The UID and GID of bob are 1000, which can be found in the /etc/passwd file. The groups that bob belongs to are bob, wheel, docker, libvirt, wireshark, and 989, which can be found in the /etc/group file. The group names are shown in parentheses after the GID, except for the last group, which has no name.
The other options are not files that store user and group information in Linux. The /etc/id file does not exist by default. The /home/index file is not a standard file and has no relation to user and group information. The /var/db/users file is not a standard file and has no relation to user and group information. References:
Which of the following is a protocol used for automatic IP address configuration?
NFS
LDAP
SMTP
DNS
DHCP
DHCP stands for Dynamic Host Configuration Protocol. It is a protocol that provides quick, automatic, and central management for the distribution of IP addresses within a network. It also configures other network information, such as the subnet mask, default gateway, and DNS server information, on the device1. DHCP uses a client/server architecture, where a DHCP server issues unique IP addresses and automatically configures the devices that request them2. DHCP allows devices to move freely from one network to another and receive an IP address automatically, which is helpful with mobile devices1.
The other options are not protocols used for automatic IP address configuration. NFS stands for Network File System, which is a protocol that allows a user to access and modify files over a network as if they were on their own computer. LDAP stands for Lightweight Directory Access Protocol, which is a protocol that provides access to a centralized directory service that stores information about users, groups, computers, and other resources on a network. SMTP stands for Simple Mail Transfer Protocol, which is a protocol that enables the sending and receiving of email messages over a network. DNS stands for Domain Name System, which is a protocol that translates domain names into IP addresses and vice versa. References:
What is true about the owner of a file?
Each file is owned by exactly one user and one group.
The owner of a file always has full permissions when accessing the file.
The user owning a file must be a member of the file’s group.
When a user is deleted, all files owned by the user disappear.
The owner of a file cannot be changed once it is assigned to an owner.
In Linux, every file and directory is associated with an owner and a group. The owner is the user who created the file or directory, and the group is the group to which the owner belongs. Therefore, each file is owned by exactly one user and one group. This is true for option A. The other options are false for the following reasons:
What is the UID of the user root?
1
-1
255
65536
0
The UID of the user root is always 0 on Linux systems. This is because the kernel uses the UID 0 to check for the superuser privileges and grant access to all system resources. The name of the user account with UID 0 is usually root, but it can be changed or have aliases. However, some applications may expect the name root and not work properly with a different name. The UID 0 is reserved for the root user and cannot be assigned to any other user. The UID 0 is stored in the /etc/passwd file along with other user information. References:
Which package management tool is used in Red Hat-based Linux Systems?
portage
rpm
apt-get
dpkg
packagectl
RPM stands for RPM Package Manager (formerly known as Red Hat Package Manager), which is a powerful, command-line package management tool developed for the Red Hat operating system. It is now used as a core component in many Linux distributions such as CentOS, Fedora, Oracle Linux, openSUSE and Mageia1. RPM can install, uninstall,and query individual software packages, but it cannot manage dependency resolution like YUM2. YUM is another package management tool that is based on RPM and can handle dependencies automatically. YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux2. Therefore, the correct answer is B. rpm, as it is the underlying package management tool used in Red Hat-based Linux systems. References:
What can be found in the /proc/ directory?
One directory per installed program.
One device file per hardware device.
One file per existing user account.
One directory per running process.
One log file per running service.
The /proc/ directory is a virtual file system that contains information about the system and the processes running on it. It is not a conventional file system that stores files on a disk, but rather a dynamic view of the kernel’s data structures. One of the features of the /proc/ directory is that it contains one subdirectory for each process running on the system, which is named after the process ID (PID). For example, the subdirectory /proc/1/ contains information about the process with PID 1, which is usually the init process. The process subdirectories contain various files that provide information about the process, such as its status, memory usage, open files, environment variables, command line arguments, and more. The /proc/ directory also contains a symbolic link called ‘self’, whichpoints to the process that is accessing the /proc/ file system. Therefore, the correct answer is D. One directory per running process.
The other options are incorrect because:
References:
What happens to a file residing outside the home directory when the file owner's account is deleted? (Choose two.)
During a file system check, the file is moved to /lost +found.
The file is removed from the file system.
The UID of the former owner is shown when listing the file's details.
The user root is set as the new owner of the file.
Ownership and permissions of the file remain unchanged.
When a user account is deleted, the files owned by that user are not automatically deleted from the file system, unless they are in the user’s home directory. The files residing outside the home directory will remain unchanged, but they will have an invalid owner. The owner of a file is identified by a numeric user ID (UID), which is mapped to a user name by the /etc/passwd file. When a user is deleted, the corresponding entry in the /etc/passwd file is removed, but the UID of the file is not changed. Therefore, when listing the file’s details, the UID of the former owner is shown instead of the user name. For example, if the user alice with UID 1001 is deleted, and she owns a file named report.txt in the /tmp directory, the output of ls -l /tmp/report.txt will look something like this:
-rw-r–r-- 1 1001 users 1024 Nov 20 14:11 /tmp/report.txt
The user root is not set as the new owner of the file, nor is the file moved to /lost+found or removed from the file system. The /lost+found directory is used to store files that are recovered from a corrupted file system after running the fsck command, not from deleted user accounts. The file system check does not affect the ownership or permissions of the files, unless there is a serious inconsistency that needs to be fixed. References:
Where is the operating system of a Raspberry Pi stored?
On the master device attached to the Raspberry Pi’s IDE bus.
On a read only partition on the Raspberry Pi’s firmware, next to the BIOS.
On a removable SD card which is put into the Raspberry Pi.
On a Linux extension module connected to the Raspberry Pi’s GPIO pins.
On rewritable flash storage which is built into the Raspberry Pi.
The Raspberry Pi uses an SD card (or microSD card for newer models) as its main storage device. This means that the operating system and any other files are stored on the SD card, which can be easily inserted or removed from the Raspberry Pi. The SD card also allows the user to switch between different operating systems by using different cards or partitions. The Raspberry Pi does not have any internal storage, such as a hard disk drive or a solid state drive, nor does it use any external devices, such as an IDE bus, a firmware partition, or a GPIO module, to store the operating system. References:
What command displays manual pages? (Specify ONLY the command without any path or parameters.)
man
The command that displays manual pages for Linux commands is the man command. The man command is used to display the manual pages for a given command or topic. For example, to view the manual page for the ls command, you can type:
man ls
This will open the manual page for the ls command in a pager, which allows you to scroll and search through the text. You can also specify the section number of the manual page if there are multiple pages with the same name. For example, to view the manual page for the passwd command in section 1, you can type:
man 1 passwd
The man command is one of the most useful and important commands for learning and using Linux. It provides detailed information about the syntax, options, arguments, examples, and other aspects of a command or topic. You can also use the --help option to get a brief summary of the usage and options of a command. For example, to get a quick help for the man command, you can type:
man --help
To learn more about the man command and how to use it effectively, you can refer to the following resources:
Which of the following commands creates an archive filework.tarfrom the contents of the directory./
work/?
tar --new work.tar ./work/
tar –cf work.tar ./work/
tar –create work.tgz –content ./work/
tar work.tar < ./work/
tar work > work.tar
The correct command to create an archive file work.tar from the contents of the directory ./work/ is tar –cf work.tar ./work/. This command uses the -c option to create a new archive, the -f option to specify the file name, and the ./work/ argument to indicate the source directory. The other commands are incorrect for various reasons:
Copyright © 2014-2024 Examstrust. All Rights Reserved