Jarkko's guides
You are here: Home » Linux » The command line

The command line

This page explains how to access and use a command line.

There is no real difference in meaning today between the terms “terminal” and “console”. They stem from the time of old mainframe computers. The first ones had a terminal (with teletypewriter and printer) to interact with the computer. Later ones got a piece of furniture called console (with a keyboard and screen). Having said that, how I use the terms below is how they are typically used for a Linux system.

The shell is the piece of software that receives the typed commands (from the terminal/console) and sends output back (to the terminal/console). The default shell in Linux is GNU Bash.

Console

The basic interface of Linux is the (virtual) console, which looks just like DOS: a black screen in text mode with a command prompt.

If you have a PC in front of you running Linux then it most likely boots up into a desktop environment. You can then switch to a console with Ctrl+Alt+F1. Once in a console, you can switch between multiple consoles with Alt+F1 to Alt+F6 (for immediately jumping) or Alt+← and Alt+→ (to jump one). With Alt+F7 you will switch back to the desktop environment.

Terminal emulator

If you have Linux with a desktop environment, then you can start a terminal emulator to get a command line. The traditional one is xterm, which still works, but is old-fashioned. There are multiple modern alternatives which you can find in the menu of your desktop environment. KDE e.g. has konsole, which I often use. It supports creating multiple tabs:

linux:konsole.png

PuTTY

If you are working in Windows and need to connect to a remote Linux machine you can use PuTTY from https://www.putty.org. It allows you to log in and get a shell. It does require that SSH (Secure SHell) is set up and enabled on the Linux machine.

linux:putty.png

  • To paste text that you've just copied in a PuTTY window: Ctrl+V doesn't work, but Shift+Insert does.
  • To copy text from the PuTTY window: It is sufficient to only highlight the text by dragging over the text while holding the left mouse button. You can then immediately paste the highlighted text in other windows with Ctrl+V.

SSH

If you are working in Linux and need to connect to a remote Linux machine you can use SSH on the command line:

ssh host.domainname.com

Key commands

The following keys are accepted (and handled by the console/terminal and/or Bash shell).

Tab completion (by the Bash shell) can save you a lot of typing. By pressing Tab it finishes what you are typing in several situations. It can finish filenames and environment variable names, among other things. If there are multiple options for the completion you can press Tab a second time to get a list of remaining options.

Key What is does
↑ Recall previous command
Tab Tab completion
Ctrl+B or ← Move cursor: left
Ctrl+F or → Move cursor: right
Alt+← Move cursor: to start of previous word
Alt+→ Move cursor: to after current word
Ctrl+A or Home Move cursor: to start of line
Ctrl+E or End Move cursor: to end of line
Ctrl+D or Del Delete: character under cursor
Ctrl+H or Backspace Delete: character before cursor
Ctrl+U Delete: from cursor to start of line
Ctrl+K Delete: from cursor to end of line
Ctrl+W Delete: previous word
Ctrl+Y Insert what was last deleted
Ctrl+T Swap character under cursor and previous
Ctrl+L Refresh the screen
Ctrl+D Quit the shell. This is a faster alternative to typing exit.
Ctrl+C Stop/cancel the current (foreground) process
Ctrl+\ Stop current process more abruptly. See also processes.
Ctrl+Z Freeze current process. See also processes.
Ctrl+S Freeze/suspend output 1)
Ctrl+Q Unfreeze/resume output
Ctrl+V Next key that is pressed is entered as an escape code2)
1)
More often than not people hit these keys by accident and then wonder why the command line is frozen. Konsole will show a helpful message about this.
2)
This is only occasionally useful.
Previous Next

ALL THE TOPICS ON THIS WEBSITE:

Linux

Raspberry Pi

Digital room correction

Web design

By Jarkko Huijts
Jarkko's guides

Table of Contents

Table of Contents

  • The command line
    • Console
    • Terminal emulator
    • PuTTY
    • SSH
    • Key commands

LINUX

  • Intro
  • History
  • Open source
  • Distributions
  • Command line
  • Tool help
  • Remote access
  • Directory hierarchy
  • Basic commands
  • Viewing & editing files
  • Processes
  • GNU & other utilities
  • Users & permissions
  • Partitions & mounting
  • System administration
  • Software packages
  • Desktop environments
  • Scripting
  • Audio

AVAILABLE TOPICS

  • Linux
  • Raspberry Pi
  • Digital room correction
  • Web design