A Command line is a user’s text-based interactive interface which can be used to
send instructions to the computer systems. Over the years, many shells have been
developed for Unix-like systems, but the default shell for most Linux
distributions and Mac OS X is the Bourne-Again Shell also called bash
which is the improved version of Bourne Shell (sh).
In a clear concept, if you are conversant with the Microsoft Windows system, the
command line interpreter is the command prompt which is similar to the
bash in Linux systems. The command line is just a way of interacting with
your computer where you have to type commands to execute your instructions. We
believe almost all Operating systems we use today, consist of clickable icons
which helps you interact with your computer, but the command line will also do
the same with no clickable icons, but instead, you have to input your text known
as commands before interacting with the system.
This article is to help most beginners who tend to be confused about what a
shell, terminal, and a console are. It will provide you with an in-depth
understanding of Command-line and Graphical User Interface (GUI) and basic
commands needed to start working on Linux Systems
DIFFERENCE BETWEEN A CONSOLE, TERMINAL, COMMAND LINE AND GRAPHICAL USER INTERFACE
As a beginner getting to know more about Linux environment gets more confusing
when you are asked to differentiate what these terms mean. Even when you can
distinguish theoretically, but you still have to be able to grab the concept behind their meanings.
CONSOLE AND TERMINAL
Linux Consoles is responsible for receiving all kernel messages and warnings. It
allows single-mode user-login. A console consists of a physical and a virtual
console.
Physical consoles are the physical terminals connected to your systems via
serial ports. Physical terminals can be your keyboards and monitor, which makes
use of the system resources such as the Hard disk, RAM, CPU, etc. Linux physical
console supports different virtual consoles which act as separate terminals with
a unique login session. Users can only have to access the bash shell through a
terminal.
Most times, virtual consoles are referred to as a virtual terminal or a
terminal, but both words have a different meaning. While virtual consoles are
multiple logical consoles that can each support an independent login session.
When a terminal window opens, a shell prompt is displayed for the current log-in
user**. The shell prompt** and the terminal taskbar will indicate the hostname,
username, and the current working directory.
GRAPHICAL USER INTERFACE AND COMMAND LINE
GNOME and KDE are two predominate windows-like desktop environment for Linux
systems such as Debian, RHEL, Ubuntu and many others. GNOME is considered
the predominant desktop for most Linux systems because of its intuitive design
and clean interface. It provides the core user interface functions for the GNOME
desktop environment.
To be clear, GNOME was formerly an acronym for GNU Network Object Model
Environment, but the acronym was dropped because it no longer reflects the
mission of the GNU project. So GNOME is just “GNOME.”
In most Linux Distro like Red Hat Enterprise Linux, the first time a new user
installs Linux, as the system is booted, setup programs run to enable the user
to configure basic account settings. The GNOME HELP application pops up on
the screen with documentation and videos instructions on how to get started with
the GNOME environment.
An Overview GNOME 3 Desktop of Red Hat Enterprise Linux
The GNOME shell has various parts, the top bar which provides application and
places menu, the date, network, volume, and the power button. The windows list
(bottom of the desktop) provides an easy way to access, minimize, and restore
all windows in the current workspace.
HOW TO POWER OFF OR RESTART A LINUX SYSTEM FROM GUI
They are various ways to shut down different Linux distros both from the GUI and
CLI. To shutdown Ubuntu or RHEL machine from the GUI, make a way to the top
right corner of the GUI shell and click on the power button, you have different options either to restart, shutdown or logoff, depending on the Linux distro. You can as well press a combination of CTRL+ALT+DEL. In the dialogue that appears you will have the option to either shut down or restart the machine or cancel the option. If no choice is chosen after 60 seconds, the system will automatically shut down itself.
HOW TO SHUT DOWN OR REBOOT LINUX SYSTEM FROM THE COMMAND LINE
Shutting down from the CLI is what most Linux system administrators find interesting, and most at times, it’s the only option available, especially when
you are on an ssh session to another remote system. You are left with various commands from Linux to shut down or reboot your system from the command-line interface.
These commands are:
Shutdown
Reboot
Halt
Power off
They are other commands, “init 6 and init 0,” which you can use to reboot
and halt the Linux system respectively.
Shutting down or restarting a multi-user system, you need to set a parameter on
when the shutdown is expected to begin, and this gives prior notice to other users of the shutdown. However, shutting down a single user system is pretty straightforward since you are the only user on the system.
To shut down your system you have a lot of pretty options to detect when to expect the shutdown, but first, you have to be in the sudo group or be the superuser (root) to be able to perform the shutdown command.
A time string and a message can follow the shutdown command. You can type
shutdown <space> time <space> message. The system will automatically
disable any user from logging in to the system 5mins to shutdown
The shutdown command can also be scheduled to be now. (that’s replacing the
30 minutes to now). The time string can also be in this format such as HH: MM and must be in 24 hours
To cancel a shutdown, use the –c option. Note that if you don’t provide a time string, you can’t pass a warning message and shutdown will begin one minute from the time the command was sent.
To reboot or halt a Linux system, you can use the reboot or halt command. Also, note that the power-off option performs the same function as in reboot now.
COMMAND SYNTAX
The bash (default shell for Linux) is a program that interprets the command typed in by the user. Each string typed in the shell have three parts; The command, option, and argument. Commands are preinstalled names of programs. The option can begin with a single dash (-) or double dash (–). Each of these three parts is typed in and separated with space.
BASIC LINUX COMMANDS FOR BEGINNERS
While working on the bash shell, we should be careful on the usage of our commands, options, and arguments as the Linux bash shell is highly case sensitive, especially when it comes to filenames. For example, “documents” is different from “Documents.” If you try to work on the Document directory and you are typing “document” on the shell while you don’t have such directory, the system will throw an error that “they are no such file or directory.” “Documents” is the system default directory. This is where the Tab completion key comes in. Tab key enables users to quickly complete commands and filenames when they have typed enough to make it unique. If the few characters typed is unique, tapping the tab key twice will complete the command. It also helps you know if you are typing the wrong command or not; as pressing the Tab key won’t work if you failed to input the right text on the shell.
Below are few commands to get you started working on the Linux machine;
The date command: The date command is used by the superuser to set the
system date and time and can be followed by a plus sign that specifies the format string
The passwd command: The passwd command can only be used by the superuser to change and set a password for the local user’s password. The original password
must be specified before the change will be allowed
The head and tail command: The head and tail command is used to view the beginning of a file, respectively. By default, these commands display the first and the last ten lines, respectively. The command can be followed by the –n option, which allows you to specify the number of lines to be viewed.
The wc command: The wc command counts the number of words, character, and
lines in the file. It can take the –l, -w,-c option to count the number of lines, word, and character respectively.
The ls command: ls command is used to view the content of an entire directory tree or a specific directory by specifying the directory name.
The useradd command: The useradd command is used by the root user to add
users to the system. It has several options to determine how the command will
behave.
The man command: Man command is used to view the manual page of any command.
If you are finding it difficult to use or understand a command, you can type
man and the command name to view information on that particular command.
The uname command: uname command is used to view the architectural properties of a system such as the CPU and numbers of logical CPUs in the
system, the kernel version, etc.
The ifconfig command: The ifconfig command is used to view the network
devices, properties, and IP address of the system. This is just the basic things
you can use ifconfig for as a beginner
The free command: free command is used to view the amount of memory space
available in the system. It displays the total available space, used, and free space in the system.
The du command: du command is used to view the disk space of a directory or
a file. It can be used to track a file or a directory which are consuming excess space in the system.
The df command: The df command is used to get the full summary of a disk and
disk usage in a system. You should be able to differentiate du and df command. The du command checks for directory and file disk usage while the df command checks for disk usage summary in the system
The pwd command: The pwd command is used to display the current working
directory in a Linux system
The cd command: This command is used to switch between directories while
working on the bash shell. Let’s say you are on the root’s home directory and you need to go to the document directory; you can send a command cd Document
on the bash, and that switches you to the document directory
The cat command: The cat command is used to print the content of a file to
the screen. It is almost similar to head and tail commands
The history command: The history command is used to display the previously
executed commands. It is a handy command to view the commands you have executed.
You can also press Ctrl+R to do the same function as history
The sudo command: The sudo command is used to gain superuser access. Linux
system regular users are limited to some operations in a Linux system, such as
adding users, creating passwords, deleting or modifying system files. The root
user can only do these operations, but for a regular user to have access to
those limited operations, the root user has to add him to the sudo group by
editing the sudo file.
CONCLUSION
Working on the Linux command line interface gets pretty easy when you get used
to your commands. You don’t have to be scared of how to memorize the commands.
Moreover, you don’t need to memorize the commands; you will get used to them
with time.
Also, your Tab key is your best friend when working on Linux CLI. Just press
the tab key twice, and it gives you the uniqueness of what you need to type.
If you are also finding it difficult to understand or use any command, you can
as well use your man command to look up to how the various commands work and
its uses.
REFERENCES
History man page
du man page
dh man page
sudo man page
GNOME Help: Getting started with GNOME
Red Hat Enterprise Red Hat System Administration I