> For the complete documentation index, see [llms.txt](https://gitbook.nicacton.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.nicacton.com/cloud-computing/red-hat/rhel/basics.md).

# Basics

## Input/Output Redirection

Three things to remember:

* `stdin` device is the keyboard
* `stdout` device is the screen
* `stderr` is reserved for error output

### Output Redirection

`$ ls -al > listing` will store output of `ls -al` in a file called `listing`

`>>` performs the same function but appends data instead of rewriting a file

### Input Redirection

`$ sort < listing` will push the `listing` file to the `sort` command

### Pipes

Pipes take the output of one command and feed it into another. You can give any command scrolling output by piping it through `less` like `$ ls -l | less`&#x20;

### Error Redirection

When an application has an error, this goes to `stderr` which can be pushed to a file using `2>` so if `myscript.sh` were to push an error, then `$ myscript.sh 2> errors` would push only the errors to a file called `error`. The 2 in the redirect specifies to redirect stderr, with normal output showing on the screen. You can write all output and errors to the same file using something like `$ myscript.sh > allout.txt 2>&1`
