Before screens were common on computers, the operating system output was displayed on automated typewriters connected to a mainframe over a telephone line. Modern computers use a text interface to interact with system features. The Linux text interface is technically known as the TTY, which stands for teletypewriter. This type of interface is commonly referred to as a command-line interface (CLI).
Linux runs virtual consoles to allow users independent login sessions. These virtual consoles are also referred to as TTY consoles. The first TTY runs the GNOME Desktop Manager (GDM) service, in which you log in to the system. When you log in to the GNOME desktop, your session occupies the second TTY automatically.
Even with a graphical environment enabled, you can log in to your local machine by using a text-only console. To use a text-only console, switch to an unused TTY. For example, press Alt+Ctrl+F3 to switch to the third virtual console.
Unlike a desktop session, a console session does not lock itself after an inactivity period, so make sure to close the session after you finish your work.
You can close the session by typing exit or by pressing Ctrl+d.
To return to the desktop session, press Alt+Ctrl+F2. Or you can press Alt+Ctrl+F1 to return to the GDM.
The Linux command-line interface is one of the most popular features of the operating system. Constantly switching between TTY consoles would be inconvenient, so you can use applications that emulate a TTY behavior. This application is generally known as a terminal.
The TTY console and a terminal application both run on what is called a Linux shell. A shell provides a command prompt, keyboard shortcuts for faster interaction, some built-in commands, and a number of convenient functions for programming or shell scripting. Most Linux distributions use the Bash shell.
The GNOME desktop's terminal application is intuitively named Terminal.
To launch the Terminal application, click in the upper left of the desktop.
Type terminal on the search bar and press Enter.
Alternatively, after clicking , click the icon in the panel at the bottom of the screen to browse through all installed applications and select the Terminal application.
After you open the Terminal application, you are automatically logged in to a Bash shell. Unlike when switching to a new TTY console, you do not need to log in to the Terminal application because you launched it within your existing login session.
Applications are usually high-level graphical components that interact with the system to perform specific user activities, such as creating a presentation or navigating the Internet. In Linux, programs such as text editors, music players, and graphic editors, run in the shell instead of running as graphical applications on a desktop. If the Linux system does not have a graphical interface, then you cannot interact with graphical applications, but you can perform system-related tasks with a shell.
Linux shells are popular for allowing users to perform system-wide configurations. When you use the Linux shell, either in a console or a terminal, you give the computer a command. Commands are different from applications, in that you interact with commands by using only the terminal.
Some commands are built into the shell itself, but most of them are installed on the system. When you type a command, the shell searches a set of system directories to find the command. This set of directories is known as a path.
Some commands gather information about users or the computer system itself, and other commands locate or even modify files.
In Linux, you commonly run commands to interact with the computer.
By running commands, you can avoid navigating through different tools to obtain system information or to perform a simple task.
For example, to view the computer name, you can open the settings application, navigate to the section, and review the label.
Alternatively, in a terminal, you use only the hostname command.
In the following example, the command returns mycomputer.example.com, which is the full name of the machine.
[user@host ~]$ hostname
mycomputer.example.comMost commands have a default action when they are run, but the command is not limited to performing that action.
You can add one or more options to a command to modify its behavior.
Generally, a command option starts with a dash (-) and uses a single letter, or the option starts with two dashes (--) and uses a word.
In the following examples, you add the -d option to show the domain name and the -s option to show the short name of the machine.
[user@host ~]$hostname -dexample.com [user@host ~]$hostname -smycomputer
A command also accepts arguments. Arguments are the target of the command, such as a file or other object upon which the command acts.
For example, the id command prints the user ID that the system uses to uniquely identify a user.
In the following example, you use the id command by itself.
Because you do not use options, the id command performs its default action, which is to print the current user information.
[user@host ~]$ id
uid=1000(user) gid=1000(user) groups=1000(user),10(wheel)
...output omitted...In the following example, you use the id command with an option, but with no argument.
The -u option specifies to print only the user ID.
The command assumes the current user as the argument.
[user@host ~]$ id -u
1000In the final example, you use the id command with both an option and an argument.
The id command receives devops as the target user for the command.
The -u option prints the devops user ID, which is different from the previous example.
[user@host ~]$ id -u devops
1001Commands can have multiple options and the meaning of the options are not interchangeable between commands.
You can view the options for a command by using the --help option.
The who command shows the users who are logged in to the machine.
[user@host ~]$ who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
Print information about users who are currently logged in.
-a, --all same as -b -d --login -p -r -t -T -u
-b, --boot time of last system boot
...output omitted...The date and timedatectl commands provide time information.
The main difference is that by default, the timedatectl command shows time zone information and whether the machine clock is synced with a time server.
This sync information is important because some services rely on the system time to work correctly.
The following example shows the output of the date and timedatectl commands:
[student@workstation ~]$ date
Fri Sep 29 13:35:20 EDT 2023[student@workstation ~]$timedatectlLocal time: Fri 2023-09-29 13:35:22 EDT Universal time: Fri 2023-09-29 17:35:22 UTC RTC time: Fri 2023-09-29 17:35:22 Time zone: America/New_York (EDT, -0400)System clock synchronized: yesNTP service: active RTC in local TZ: no
The passwd command update user passwords.
By default, it changes the current user's password, so you do not need to specify the account name as an argument.
The root user, however, can change the password for any user.
In this scenario, you must specify the target account as the argument.
With tab completion, you request that the shell program completes a command by pressing the Tab key. If you have typed enough characters that a command word is uniquely matched, then the shell completes the word. If the characters that you entered do not match a unique command, then the shell completes as many characters as it can, and then stops until you provide additional characters. Pressing Tab a second time displays the command words that match the typed pattern.
In the following example, typing host and pressing Tab twice displays four choices.
When you type an additional n and press Tab again, the shell completes the hostname command.
[user@host ~]$hostTab+Tabhost hostid hostname hostnamectl [user@host ~]$ host
nTab[user@host ~]$
hostnamemycomputer.example.com
For more information about terminals, shells, and consoles, refer to Terminals, Shells, Consoles, and Command Lines at https://learn.spidernet.pl/sysadmin/terminals-shells-consoles
For a list of Linux starter commands, refer to Linux Commands Cheat Sheet at https://developers.redhat.com/cheat-sheets/linux-commands-cheat-sheet-old