Linux 2 Flashcards

1
Q

How would you copy a single file?

A

Call the cp command with two arguments, the source file you want to copy and the target file you want to copy it to.

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

What happens if you use the cp command with a directory as the target?

A

You will end up with a copy of the source file inside of the named directory.

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

How can you copy multiple files at once?

A

Using the cp command, you can list several source files and use a directory name to specify where you want copies of those files to go. The original file names of the source files will be used as the names of the new files in the target directory.

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

What will happen if you try to copy a directory to another directory using cp?

A

If you didn’t use -r (the recursive flag), you will get an error message.

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

What flag can you use to overwrite a file that is not under your current username?

A

The -f (force) flag.

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

What flag can you use in order to prompt for confirmation when copying over existing files?

A

cp -i

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

What command is used to delete files and folders?

A

rm

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

The process for moving files is almost identical to that of copying files. Which command is really just a combination of cp and rm to achieve the desired outcome of moving a file from one location to another?

A

mv

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

Can you use the mv command to move a file across systems?

A

No.

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

What is the Unix philosophy for commands?

A

Don one thing, and do it well.

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

With these seemingly small individual commands, we can build some impressive work flows by redirecting the output of one command to the input to another command using the ____ operator.

A

pipe ( | )

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

In addition to redirecting the output from one process and sending it to another process, we can alos write that output to a file using the ____ operator.

A

>

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

We can use the > to write data to a file, but how can we read data from a file?

A

With the

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

What are two common command line search tools?

A

ack and ag

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

How do you run an ag search?

A

ag

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

By default, your ag query is run recursively against _____.

A

the current directory

17
Q

If you want to specify a path to search against with ag, what can you do?

A

Pass as a final argument the path you want to search.

18
Q

Both Ack and Ag treat the search term as a _____ by default.

A

regular expression

19
Q

How can you stop Ag and Ack from treating your search term as a regular expression, and instead find the exact pattern you type?

A

using the -Q flag

20
Q

What flag can you use if you just want to see the filenames where the pattern was found, rather than the line number, etc.?

A

the list flag (-l)

21
Q

By default, all Ag and Ack searches are case-sensitive, but you can change this with the __ flag.

A

-i

22
Q

What flag can you use to limit the scope of your Ack or Ag search?

A

the -G flag (-g for Ack, -G for Ag)

e.g.: ag readme -l -G action
searches for readme in files which have “action” in the filename

23
Q

How do you use the -ignore-dir flag?

A

ag readme -l –ignore-dir=railties/lib

command, search term, flag, flag = name of directory to be ignored

24
Q

Can you string multiple -ignore-dir flags together?

A

Yes

25
Q

Can you use -ignore-dir to ignore particular files?

A

Yes

26
Q

Which file specifies ignore files for Ag and Ack, respectively?

A

.agignore and .ackrc

27
Q

Since Ag and Ack expect standard input as a source for searching, we can use other commands to _____.

A

provide data to search over.

28
Q

How would you search through all of the running processes to find one that contains the term forego?

A

ps -e | ag forego

29
Q

How can you get a print out of Ag or Ack’s full features?

A

Call the command with no parameters.