[HowTo] Use the terminal / TTY

Difficulty: ★☆☆☆☆

When receiving support, or simply browsing documentation, you will see most (if not all) actions asked of you will take form of commands to use in a terminal.

About the terminal

The terminal emulator is an interface allowing a user to interact with a system through commands, as well as Command Line Interface and Text User Interface applications.
All desktop environments available on Linux ship with a terminal.

About TTY

The TeleTYpewritter is terminal interface connected directly to the standard input and output, and thus doesn’t require a dedicated graphical processor.
There are commonly 24 teletypes, accessible with Ctrl+Alt+Fx (for 1 to 12) and Ctrl+Alt+Shift+Fx (for 13 to 24). TTY7 is the one usually used for graphical sessions.

Why use a terminal ?

  • Stability
    Since CLI commands rarely require sophisticated graphical output, that is so much of code not needed to maintain. Thus, these commands are usually minimal in size and less prone to bugs.

  • Communication
    While GUI applications need instructions to guide a user toward a feature, CLI commands may only need relevant parameters. This is much straightforward to share with another user.

  • Security
    Some tasks may need to be done with superuser privileges. Running any application with those privileges involves a risk, but that risk reduces the fewer code needed to execute it. This is why commands are recommended over GUI applications for such cases.

How to execute a command in a terminal

:arrow_right: Simply type or paste the command, and tap Enter.

:star: For clarity sake, when you are asked to execute several commands – usually presented one per line – prefer executing one after the other, rather than the whole group at once. This way, you will know which result pertains to which command.

:star: It is not abnormal for a command not to produce any output. This is actually the normal behavior when a search command does not find anything, or when a process command succeeds.

Keyboard cheatsheet

  • Copy
    Ctrl+Shift+C
  • Paste
    Ctrl+Shift+V
  • Interrupt
    Ctrl+C
  • Reuse a previous command
    Up

Tips

  • Run with English output
    This is most useful for sharing debug and error information, while you have set your system to use another language.
LANG=C <command>
  • Paginate output
    Navigate with Up and Down
    Navigate pages with Page Up and Page Down
    Exit with Q
<command> | less
  • Write output to file
    The command output will be sent to the file, replacing its content, instead of the standard output.
    That file will be automatically created if missing, but its parent folder must already exist.
<command> > /path/to/file
  • Append output to file
    The command output will be sent to the file, added at its end, instead of the standard output.
    That file will be automatically created if missing, but its parent folder must already exist.
<command> >> /path/to/file
  • Send output to an online pastebin
    The command output will be sent to the pastebin instead of the standard output.
    A link to the generated pastebin will be provided in the standard output.
<command> | curl -F 'clbin=<-' https://clbin.com
8 Likes

@maycne.sonahoz one minor suggestion, could you include a description above the line

command | less

As you have described the next three examples, the new user might be confused if the bottom or the top example wasn’t explained.

For the rest this is top notch work.

1 Like