Sage-Code Laboratory
index<--

Shell Console

Shell console is available on your computer if you have installed Linux or MacOS. Also shell console is available on any Unix or FreeBSD system. On Windows there is a console called "Command Line" but for Bash you need a simulator. In this article we try to demistify the misteries of this tool.

Unix console

Most systems have a GUI (UX) user interface. This is using the mouse to select a program to run. Each program or application may be represented as an icon. Some operating systems have a menu and a task bar. Learning this things is out fo the scope of this tutorial.

In the app list or menu system tools you will find a speciall app that usually is a brack square. If you click this icon you will start the console.

Older computers and especially servers do not need GUI and can run just console applications. The console on these systems is the entire screen. For these kind of computers the screen is also much smaller than the modern desktops.

Windows console

On Windows you must use Windows Start button with left mouse click to run a command and type: cmd - this start the command line but this is not the Linux shell. You need to install a different application that is a shell symulator to run Bash.

Windows 10 has support for virtualization (WSL) Windows Sybsystem for Linux. You can use this feature to install Ubuntu and run native shell commands using a real Linux.

To work remote you can install Putty that is a free software. You can connect to a remote Linux or Unix machine and run remote commands in Bash. You can also use SCP or SFTP protocols to transfer files from local folder to a remote folder.

Visit and download: https://putty.org

Secure Shell

You can work remote using SSH (Secure Shell) protocol. This can be started from console using command: ssh with connection credentials and address. If the remote machine is listening SSH protocol and your firewall alows it, you can type commands locally but they are executed remotely.

There are graphic tools that can connect using SSH protocol to transfer files over SCP or SFTP. Some of these tools are licensed, but there are free trials that you can try before buy.

Visit and download:https://winscp.net

Shell commands

After you start the shell console, a prompt will wait for you input. You must know at least several basic commands to get started. One of the most handful command is: "man". This command will display a list of commands that you can use.

Notice that shell commands not alwais are the same as Bash commands. On every different operating system you can have a different default shell.

You can install on a computer different versions of Bash in different folders but only one should be in your $PATH. This is the default Bash interpreter that starts automaticly when you open the console and type: bash command.

First commands

Let's start learning two simple commands: "echo" and "pwd". The "echo" is used to output a string to the standard output, that is usually the console. The "pwd" command display the current folder. In Bash, there is a default folder that is current, and you can change it using "cd" command.

Console
>bash
~$ echo "hello"
hello
~$
~$ pwd
/Users/sagecode/Documents/GitHub/bash
~$
~$ cd ..
~$ pwd
/Users/sagecode/Documents/GitHub
$

Frequent symbols

Bash is a language of conventions, symbols and delimitors. You must understend these symbols before learning the commands. It is not difficult, let's try some.

Sybol Purpose
$ Bash prompt
. Current folder
.. Parent folder
- Command option
-- Long option
& Run in background
>Output redirect
<Inpput redirect
| Pipeline
/ Root folder
~ User home folder
"" Long filenames

Note: Most of these symbols are used for other things in shell scripts, depending on the context. This is why Bash is difficult to master because you have to learn and relearn symbol's multiple ussages.

Finding help

You can find help in the shell command. First method is to use command: man command | more This will display the help for a particule command and let you scroll down by using space or enter key. You can end help mode using ESC key, then type ":Q" and you are out.

The second way to find help is by using any command with -h option. This will not execute the command but display a list of options, and eventually an exemple that is good enaugh to remenber what you have probably forgotten.

Third method is to navigate in this tutorial or other external resources. You can also use Google search but my advice is to learn from reference manuals. This is the best free resource I could find:

Bash Reference Manual:https://devdocs.io


Read next: Shell Commands