1.2 Given a scenario, manage files and directories Flashcards

1
Q

Command: cp

A

copies files or directories to another location
Syntax: cp [options] SOURCE DESTINATION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What 2 options can be used with the cp command to also include the contents of a directory?

A

-r or -R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Command: mkdir

A

creates a new directory
Syntax: mkdir [options] DIRECTORY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What option must be used with command mkdir to create all directories in the path if they don’t exist, i.e. /folder1/folder2/directory?

A

-p

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Command: rmdir

A

removes a directory, if it is empty
Syntax: rmdir [options] DIRECTORY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Command: ls

A

lists the contents of a directory
Syntax: ls [options] DIRECTORY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Command: pwd

A

prints full name of the current working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Command: cd

A

changes the current working directory
Syntax: cd [path/directory]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Command: cat

A

shows, read-only, text of a file
Syntax: cat [filename]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Command: less

A

like cat, but content is shown with paging
Syntax: less [filename]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define vi(m)

A

default text editor included with Linux distributions, can be complex to use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define nano

A

Simple, easy to use CLI text editor that must be installed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ls -a, what does the switch “a” do

A

shows all files/folders, including hidden

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ls -l, what does the switch “l” do

A

long - shows more detailed information, such as permissions, file size, etc…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Command: touch

A

creates the file, if it doesn’t exist, otherwise updates the modification of the file
Syntax: touch [filename]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define tar command

A
  1. compresses files and directories into a single file
  2. maintains directory structure and other features such as file permissions
17
Q

What is the tar command used to backup a directory to a tar file?

A

tar -cvf [name of tar file] [directory/file to backup]
*note “v” is optional, enables verbose mode to show the progress

18
Q

What is the tar command used to restore a tar file?

A

tar -xvf [tar filename]

19
Q

What does the “d” switch do for tar command?

A

Compares a directory to the tar file and identifies differences

20
Q

What does the “J” switch do for tar command?

A

Specifies use of the xz utility for compression/decompression (.xz)

21
Q

What does the “z” switch do for tar command?

A

Specifies use of the gzip utility for compression/decompression (.gz)

22
Q

What does the “j” switch do for tar command?

A

Specifies use of the bzip2 utility for compression/decompression (.bz2)

23
Q

What does the “r” switch do for tar command?

A

Adds files to the end of an existing tar archive

24
Q

What does the “t” switch do for tar command?

A

Lists the files in the tar archive file

25
Q

How can one back up only the files that have changed since a previous tar backup?

A

The “u” switch will append files to the tar archive only if the modification date is newer than the file in the tar archive

26
Q

What is the syntax and switch to restore a tar file to a specified location

A

tar -xf [tar filename] -C [location]

27
Q

How do you add files to an existing tar archive?

A

The “r” switch

28
Q

What is the basic gzip syntax to compress a file? What potential issue happens using this syntax?

A
  1. gzip [filename]
  2. The original, uncompressed file, is replaced with the new compressed file
29
Q

What is the syntax to compress a file with gzip to a new file without overwriting the original file?

A

gzip -C [filename to compress] > [newfilename]

30
Q

What switch decompresses a file with gzip?

A

“d”

31
Q

What gzip switch lists the files in a compressed file?

A

“l”

32
Q

What gzip switch recursively compresses all files & sub-directories, and is equal to tar -z?

A

“r”

33
Q

What is the basic command syntax to compress a file with xz?

A

xz [filename]
*this overwrites the original file

34
Q

What is the syntax to compress a file with xz to a new file without overwriting the original file?

A

xz -k [filename]

35
Q

What switch decompresses a file compressed with xz?

A

“d”