Command-line Interface

The Linux Command-line Interface, abreviated CLI, aka bash shell, is like a central control center from which the Linux OS can be administered. This tool is text-baased and it is the Unix equivalent of the old console of Windows OSes, which was long seen as an ancient artifact of the MS-DOS OS, being entirely text-based, especially during the seventies. MS-DOS would gradually make graphics and audio possible, but its adminisration remained fundamentally text-based.

This was to change during the nineties. MS Windows 1, 2, 3, and 3.1, were still launched from the MS-DOS prompt, but in Windows 95 the graphical User Interface, or GUI, could be launched directly from boot, surpassing the console mode. In this OS the console mode and the graphical mode existed on equal footing. From Windows 98 onwards, the roles were turned around: from then on a text-based console, that still resembled DOS, was to be launched from within the graphical interface, the Windows desktop, which became the fundamental OS. During the 2000's MS Windows evolved in the direction of disbanding the text interface all together.

In Unix-like systems however, from which BSD and Linux distros evolved, during the same period, the text-based user-interface kept being the primary front-end of the OS, with the GUI existing on top of it. As a result, in Linux OSes, the brunt of the administration still needs to be done from the text-based shell. However, Linux distros become so user-friendly that the average user does not need the bash shell for daily use of the Linux desktop. More experienced users, however, who form a relatively large part of the total Linux user population, still prefer to use the shell for administration and see this features exactly as one of the main reasons why they love Linux over Windows.

Microsoft, seeing that many IT professionals prefer Linux, partly because of its powerful shell, lately, began giving attention again to Windows' console features. This attention translated into the development of Windows text-based administration tools like Command Prompt, which closely resembles DOS but with modern features, PowerShell, which is an advanced text-based interface that is a spowerful as Linux shell and can be used for advanced features like the running of scripts, and WSL, a tool that allows Windows users to run Linux shell directly in Windows, and use text-based Linux programs on Windows.

Index of Common Linux Shell Commands

On this page I list all commands I use, with an explanation of what they do.

Shell commands are written after the $ symbol. The $ tells the user that the command needs to be executed as a regular user. After writing the command the user activates it into the system by pressing the ENTER key.

Commands can be, for example, for navigation, or to run system programs or installed applications and their features, to run scripts, and more.

su

After executing this command, the user gets prompted to enter his/hers root password. After entering the correct password the mode of the CLI shell reverts to root status. Root allows for maximum system permissions. If the state is not in root, each and every action that requires root access will require the command sudo and then prompt the user to enter their root password. With su, the user enters it only one time and therafter the root status persists until logging out of root. Exiting root is done by the command exit

dpkg, apt-get, apt

dpkg [...]

Dpkg is the package manager of Debian based Linux distributions. It manages download, install, remove, upgrade etc of .deb packages directly. It consists of low-level code and functionality.

sudo dpkg --configure -a

Sudo asks for root permissions for this particular action. The command dpkg --configure -a re-configures any packages that are unpacked but not yet configured, which can happen when an installation or upgrade process was interupted.

apt-get [...]

Is a high-level, easier to use, front-end to dpkg.

apt [...]

Apt is also a high-level front-end to dpg that is again a little more simplified and managable than apt-get and has a bit more features. The apt command group activates actions from the Advanced Package Tool, abreviated APT. This is a higher-level tool that simplifies package management by automatically handling dependencies and managing repositories in Debian-based Linux distributions. Among other things, it takes care of the installation, updating, upgrading, and removal of software packages by automating the process and managing dependencies.

apt install

This is the apt command to install downloadable program packages stored in online repositories.

apt remove

This is the apt command to uninstall a program package installed on a system, while leaving its configuration files intact, so that they can immediately be reused when reinstalled.

apt purge

This is the apt command to uninstall a program package installed on a system, while also removing its configuration files.

apt update

This is the apt command to update the lists of the program packages that currently exist in online repositories.

apt upgrade

This is the apt command to download and install new versions of already installed program packages, from online repositories.

curl

Curl is used to transfer data from or to a server via URLs. It supports various options, protocols, variables, globbing and output formats.

chmod

Chmod changes the access permissions of files and directories.

echo

Echo is used to display text or strings. In scripts it can output messages or variable values, with options to format the output, for example: omitting newlines and interpreting escape characters.

File System Navigation Commands

ls

lists the files in the current directory.

ls -l

This triggers a long listing format which provides additional information about every file and directory within the current directory, including file type, permissions, number of hard links to the file, owner, group, size of the file in bytes, and the time of the last modification.

ls -a

Displays hidden files too.

ls -r

Displays not only the files withi the current directory, but also its subdirectories and the files therein.

cd

Navigates the command-line from one directory to another.

cd [dir name]

Navigates the command-line to the named dir.

cd ..

Navigates the command-line one directory higher (higher-level directories contain lower-level directories).

cd ~

Navigates the command-line to the current user's home folder.

cd /

Navigates the command-line to the operating system's root folder.

touch

touch sets the modification timestamp of a file to current. If the input path does not refer to an existing file, it creates a new file at the path.

source

Source is used to execute commands from a file in the current shell environment. In this way one can run scripts and load configuration files without having to create a new shell. The command is useful for changing environment variables and defining functions to be used in the current session.

mv [filename / directory name]

The command mv + the path of the file or directory as it IS + the path of the file or directory as you want it to be.

cp [filename / directory name]

The command cp + the path of the file or directory as it IS + the path of the file or directory where you want to create a duplicate.

grep "pattern" [file name]

Searches for patterns within a file, for example, words in text files.

mkdir [path]

Creates a new directorie in the current directory or with the path added.