Linux System Administration

0 of 83 lessons complete (0%)

Starting up and Shutting Down

Console in Linux

You don’t have access to this lesson

Please register or sign in to access the course content.

The console in Linux is a text-based interface that allows users to interact directly with the system. It provides a command-line environment where users can execute commands, run programs, and manage the system. Unlike graphical user interfaces (GUIs), the console operates purely through text input and output.

Types of Consoles:

  1. Physical Console (TTY):
    • A physical console is the interface you see on the monitor when no graphical interface (like GNOME or KDE) is running.
    • It’s often called a TTY (TeleTYpewriter), a reference to older terminal devices.
    • You can switch between multiple TTYs using key combinations like Ctrl+Alt+F1 to Ctrl+Alt+F6, each providing a separate login session.
    • Example: When you boot into Linux without a graphical interface, you’re typically taken to TTY1, where you can log in and run commands directly.
  2. Virtual Console:
    • A virtual console is similar to a physical console but exists as a terminal window within a graphical environment.
    • Virtual consoles are typically accessed through terminal emulators like GNOME Terminal, xterm, or Konsole in a GUI environment.
    • These consoles provide the same functionality as a physical console but run inside the graphical interface.

Summary of Commands Related to Console

CommandPurposeKey OptionsExample
ttyDisplay the terminal nameNoneExample:
1. Show the terminal name: tty
clearClear the terminal screenNoneExample:
1. Clear the screen: clear
resetReset the terminal to default stateNoneExample:
1. Reset the terminal: reset
whoDisplay users currently logged inNoneExample:
1. Show current users: who
wShow who is logged on and what they are doingNoneExample:
1. Display users and their activities: w
lastShow the last logins-a (show hostname), -x (show system shutdowns)Example:
1. Show recent logins: last
dmesgDisplay kernel ring buffer messagesNoneExample:
1. Show kernel messages: dmesg
ttyDisplay the file name of the terminal connected to standard inputNone1. Display the terminal device: tty
echoDisplay a line of text-n (no trailing newline), -e (enable interpretation of backslash escapes)Example:
1. Print text: echo "Hello, World!"
sudoExecute a command as another user or root-u user (run as another user), -i (run as login shell)Example:
1. Run command as root: sudo ls /root

Example Usage:

Display the Terminal Name:

tty

This command shows the file name of the terminal connected to the standard input, e.g., /dev/tty1.

Clear the Terminal Screen:

clear 

This command clears the terminal screen of all previous output.

Reset the Terminal:

reset 

This command resets the terminal to its default state, useful if the terminal display is corrupted.

Show Users Currently Logged In:

who 

This command lists the users currently logged into the system.

Display Users and Their Activities:

w 

This command shows who is logged on and what they are currently doing.

Show Recent Logins:

last 

This command displays a list of recent logins, reboots, and shutdowns.

Show Kernel Messages:

dmesg 

This command prints out messages from the kernel ring buffer, useful for debugging and troubleshooting hardware issues.

Print Text:

echo "Hello, World!" 

This command prints the text “Hello, World!” to the terminal.

These commands and their examples provide basic functionality for managing and interacting with the console in Linux.