Which of the following commands creates the ZIP archive poems.zip containing all files in the current directory whose names end in .txt?
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.Reference:
Linux Essentials - Linux Professional Institute (LPI), section 3.1.1
3.1 Archiving Files on the Command Line - Linux Professional Institute Certification Programs, slide
Which of the following commands will search for the file foo.txt under the directory /home?
The correct command to search for the file foo.txt under the directory /home is find /home --name foo.txt. This command uses the find command, which is used to search for files and directories that match certain criteria. The first argument, /home, specifies the starting point of the search. The second argument, -name, indicates that the search is based on the name of the file or directory. The third argument, foo.txt, is the name of the file to be searched for. The find command will recursively search all the subdirectories under /home and print the path of any file or directory that matches the name foo.txt.
The other commands are incorrect for various reasons:
A . search /home --file foo.txt is incorrect because there is no such command as search in Linux. The correct command for searching files and directories is find.
B . search /home foo.txt is incorrect because, as mentioned above, there is no search command in Linux. Also, this command does not use any option to specify the search criteria, such as -name, -type, -size, etc.
C . find /home -- file foo.txt is incorrect because the option -file is not valid. The correct option for specifying the type of file or directory is -type, followed by a letter that indicates the type, such as f for regular file, d for directory, l for symbolic link, etc. For example, find /home -type f -name foo.txt would search for a regular file named foo.txt under /home.
E . find /home foo.txt is incorrect because this command does not use any option to specify the search criteria, such as -name, -type, -size, etc. This command will search for any file or directory that has foo.txt as part of its name, not exactly as its name. For example, this command will also match a file named barfoo.txt or a directory named foo.txt.bak.
Running the command rm Downloads leads to the following error:
rm: cannot remove 'Downloads/': Is a directory
Which of the following commands can be used instead to remove Downloads, assuming Downloads is
empty? (Choose two correct answers.)
To remove a directory, you need to use a command that can delete directories, not just files. The rm command can only remove files by default, unless you use the -r option, which stands for recursive. This option tells rm to delete the directory and all of its contents, including subdirectories and files. The rmdir command can also remove directories, but only if they are empty. If the directory contains any files or subdirectories, rmdir will fail and display an error message. Therefore, the correct commands to remove Downloads, assuming it is empty, are rmdir Downloads and rm -r Downloads. The other commands are either invalid or do not work on directories.Reference:
Linux Essentials - Linux Professional Institute (LPI), section 2.3.1
LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition, chapter 4, page 93.
What is true about links in a Linux file system?
A symbolic link, also known as a symlink or soft link, is a special type of file that points to another file or directory by its name. A symbolic link can point to a file or directory on the same or different file system, as long as the target is accessible. For example, you can create a symbolic link to a file on a USB drive or a network share, as long as the device is mounted or the connection is established. However, if the target of the symbolic link is moved, renamed, or deleted, the link becomes broken and does not work. To create a symbolic link, you can use the ln command with the -s or --symbolic option, followed by the target name and the link name. For example,ln -s /mnt/usb/file.txt link.txtcreates a symbolic link named link.txt that points to the file.txt on the USB drive mounted at /mnt/usb.
The other options are not true about links in a Linux file system. A symbolic link can point to a directory as well as a file. A hard link, which is a direct reference to the same data as another file, can only point to a file and not a directory. A hard link cannot span across different file systems, because it depends on the inode number, which is unique within a file system. When the target of the symbolic link is moved, the link is not automatically updated, but becomes broken. Any user can create hard links, as long as they have the permission to read and write the target file and the link directory.
Linux Essentials - Linux Professional Institute (LPI)
Ln Command in Linux (Create Symbolic Links) | Linuxize
Which of the following commands extracts the contents of the compressed archive file1.tar.gz?
The correct command to extract the contents of the compressed archive file1.tar.gz istar -xzf file1.tar.gz. This command uses the following options:
-xmeans extract files from an archive.
-zmeans filter the archive through gzip, which is a compression program that reduces the size of files.
-fmeans use the following archive file name, which is file1.tar.gz in this case.
The other commands are incorrect for the following reasons:
tar -czf file1.tar.gzcreates a compressed archive file1.tar.gz from the files specified after the command, not extract it.
ztar file1.tar.gzis not a valid command, as ztar is not a standard program or option for tar.
tar --extract file1.tar.gzis missing the-zoption to handle the gzip compression, and also the-foption to specify the file name.
detar file1.tar.gzis not a valid command, as detar is not a standard program or option for tar.
Linux Essentials - Topic 106: The Linux Operating System, section 106.2 Use single shell commands and one line command sequences to perform basic tasks on the command line.
LPI Linux Essentials Study Guide: Exam 010 v1.6, 3rd Edition, Chapter 5: Working with Files and Directories, section Compressing and Archiving Files.
Paul Hall
1 day agoMichael Sanchez
15 days agoElizabeth Hernandez
1 month agoHarold Rodriguez
2 months agoRebecca Jackson
2 months agoBarbara Brown
3 months agoAmanda Robinson
3 months agoBrenda Garcia
4 months agoKevin Baker
3 months agoSandra Martinez
3 months agoStephen Sanchez
3 months agoChristopher Rodriguez
4 months agoPaul Flores
3 months agoJulio
4 months agoJacqueline
4 months agoHeidy
5 months agoMica
5 months agoMitzie
5 months agoClare
5 months agoKaitlyn
6 months agoFelice
6 months agoDarrin
6 months agoMarion
6 months agoFrank
7 months agoDenna
7 months agoKaycee
7 months agoDetra
7 months agoBettye
8 months agoFrancesco
8 months agoWillard
8 months agoLuis
8 months agoBenedict
9 months agoGabriele
9 months agoMalinda
9 months agoFrederica
9 months agoRashad
10 months agoMarta
10 months agoLorrine
10 months agoTawna
10 months agoRichelle
11 months agoTayna
11 months agoNobuko
11 months agoSkye
11 months agoFiliberto
1 year agoVince
1 year agoHeike
1 year agoDominque
1 year agoWillie
1 year agoEura
1 year agoMalcom
1 year agoJina
1 year agoDanilo
1 year agoMa
1 year agoWinifred
1 year agoBarney
1 year agoMyong
1 year agoLizbeth
1 year agoCarla
2 years agoRuth
2 years agoGeraldo
2 years agoJoye
2 years agoNickolas
2 years agoHeike
2 years agoStanton
2 years agoDalene
2 years agoStarr
2 years agoLoren
2 years agoSophia
2 years agoBernardo
2 years agoDelsie
2 years agoTasia
2 years agoKrissy
2 years agoRolland
2 years agoAdelina
2 years agoJanet
2 years agoLaila
2 years agoRodrigo
2 years agoAlyce
2 years agoGeorgene
2 years agoFranklyn
2 years agoCatarina
2 years agoMerilyn
2 years agoDesirae
2 years agoLore
2 years agoMaile
2 years agoVerdell
2 years ago