Input and Output Redirects Flashcards

1
Q

What is stdin?

A

Standard input and it has a file descriptor number as 0.

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

What is stdout?

A

Standard Output and it has a file descriptor value as 0.

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

What is stderr?

A

Standard error and it has a file descriptor value as 2.

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

How can the output of a command be routed to a file?

A

All output of any given command is considered stdout. Using >.
If using the same file for additional output or to append to the same file use&raquo_space;. A single > will overwrite existing contents in file.
Example: ls -l > listings
ls -la&raquo_space; listings

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

How can you feed file contents into a file or email.

A

Input is used when feeding file contents to a file or email. Using <.
Example: cat < listings
mail -s “office memo” …@gmail.com < ‘memo letter’

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

How can you redirect error messages to a file?

A

Any error on the terminal is considered stderr. Using 2>.
Example: ls -l /root 2> ‘error file’
telnet localhost 2> ‘error file’

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

What is this character and what is it used for | ?

A

The symbol is called a pipe and is used by the shell to connect the output of one command directly to the input of another command.
Example: command1 {argument} | command2 {argument}
cat /var/log/messages | grep error

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

What command can you use to check the manual of a command?

A

man
Example: man ls
man grep

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

What command can be used to find a command based on a keyword

A

Apropos
Example: apropos manual
apropos search

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

What command looks up a given command?

A

whatis
Example: whatis ls
whatis systemctl

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

What option can you universally use with any command for help?

A

–help
Example: ls –help

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