Input and Output Redirects Flashcards
What is stdin?
Standard input and it has a file descriptor number as 0.
What is stdout?
Standard Output and it has a file descriptor value as 0.
What is stderr?
Standard error and it has a file descriptor value as 2.
How can the output of a command be routed to a file?
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»_space;. A single > will overwrite existing contents in file.
Example: ls -l > listings
ls -la»_space; listings
How can you feed file contents into a file or email.
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 can you redirect error messages to a file?
Any error on the terminal is considered stderr. Using 2>.
Example: ls -l /root 2> ‘error file’
telnet localhost 2> ‘error file’
What is this character and what is it used for | ?
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
What command can you use to check the manual of a command?
man
Example: man ls
man grep
What command can be used to find a command based on a keyword
Apropos
Example: apropos manual
apropos search
What command looks up a given command?
whatis
Example: whatis ls
whatis systemctl
What option can you universally use with any command for help?
–help
Example: ls –help