CLOs - Searching for files Flashcards

1
Q

When commands are executed, how many standard file streams (descriptors) are there open for use?

A
  • standard input (stdin)
  • standard output (stdout)
  • standard error (stderr)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are open files in Linuxs?

A
  • internally represented by file descriptors
  • these are represented by numbers starting at zero
  • stdin is file descriptor 0
  • stdout is file descriptor 1
  • stderr is file descriptor 2
  • typically other files are opened in addition to these three, which are opened by default
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you change the input of a program called do_something that reads from stdin to an input file?

A

$ do_something < input-file

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

How can you sent the output of a program called do_something to a file?

A

$ do_something > output-file

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

How can you redirect stderr to a seperate file?

A

Using stderr’s file descriptor number (2):
$ do_something 2> error-file

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

How do you give out stdout into a file using file descriptor numbers?

A

$ do_something 1> output-file

instead of

$ do_something > output-file

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

How do you write both stdout and stderr into the same file?
And in Bash?

A

$ do_something > all-output-file 2>&1

bash:
$ do_something >& all-output-file

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

What use have pipes in Linux?

A

To chain together multiple simple commands instead of having complex programs with multiple modes and options

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

Why is the pipeline extra efficient in Linux?

A
  • because later commands in the chain do not have to wait for earliert commands to finish to start processing data in their input streams
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you find files in you file-hierarchy?

A

using locate and find utilities

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

How do you use locate?

A

$ locate zip | grep bin

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

How does locate work and how can you force an update?

A
  • uses a database created by a related utility updatedb for search
  • in background automatically updated once a day, but can be forced with running updatedb from command line as root user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly