103.3 Perform basic file management Flashcards
What command will let you read the contents of a compressed tarball without actually decompressing it?
gzip: zcat tarball.tar.gz
bzip2: bzcat tarball.tar.bz2
xz: xzcat tarball.tar.xz
What does the caret character do in globbing? (^)
It matches any one character except those in the list. It is case sensitive. It excludes those characters.
What does this expression mean in globbing? : [0-9]
It will match a range of numbers
What does this command do? #ls [Pp]*.csv?
It will list files with names of any character length that start with a capital P or lower case p in their name.
What will #ls ????.txt do?
It will find any files with .txt extension that specifically have 4 characters in their name.
What is a wild card?
It is a symbol that can stand for one or more characters.
What does the star * character stand for?
It matches zero or more characters in an expression of globbing.
What does file globbing help with?
It allows to find or act on files that are matched using wildcards.
What does this command do? #find ~ -name "*.tar.*" -exec cp -v {} /home/admin \;
It will find in the home directory any files that have tar in their name and pass the output to exec to copy what find found and show verbosely what it is copying to /home/admin
What does this command do? #find . -empty -type f -exec rm -f {} \;
It will find within the home directory empty files types and execute a deletion without being prompted for confirmation for all results found by the find command.
How do you close an exec statement in a command?
By using \; (backslash and semicolon) #find . -empty -type f -exec rm -f {} \;
What does the exec statement do in the file command?
The exec statement for the find command will act on the result of the find command itself.
How do you find a file type in a path?
find path -type f
How do you find a file type in a path?
find path -type f
How do you find files that are empty in a directory?
find path -empty
What command do you use to find a file that has been added to a directory prior to another one?
find path -newer filenameforreference
How do you find a file that has been accessed within a specific amount of time?
#find path -atime 2 2=48hrs
How do you find a file that has been changed within a specific amount of time?
#find path -ctime 1 1 stands for the last 24 hours period. 2 = 48hrs 3= 72hrs ....
Which user can find files outside the user’s own home directory?
root. So you have to append the find command with [sudo]
What command decompresses a file created with xz?
unxz file.xz
How do you use the xz command to compress a single file?
xz passwd
How do you use the bunzip2 command to decompress a single file?
bunzip2 compressedfile.bz2
How do you use the gunzip command to decompress a single file?
gunzip file.gz
What is the syntax to compress a single file using bzip2?
bzip2 filetocompress
What do the commands gzip and bzip2 do to the original file it compresses?
It replaces the original file with the new compressed file.
How do you use the gzip command to compress a single file?
gzip filetocompress
What is the syntax to decompress a file created with bzip2?
tar -xvjf tarball.tar.bz2
What command compresses more a file, gzip or bzip2?
bzip2
What uses more cpu power to compress files, gzip or bzip2?
bzip2