The Bourne-again Shell or Bash is one of the basic tools in a Linux/Unix Operating System. It can be found in many distributions. One of its advantages is that it can execute scripts from the Bourne shell (.sh files). Further, it also understands commands for the Korn shell (ksh) and the Berkeley UNIX C shell (csh). It's mainly used to make user input or execute programs on computers or servers without a graphical user interface. In the following, you will find some really basic and very useful shell commands.
There are two possibilities to open a shell. You may open it over the graphic user interface (GUI), e.g.
a window of your Linux machine or you simply press CTLR+ALT+T. In both
cases you should see a the terminal, i.e the bash session, in which you are able to type in commands.
If you want a new terminal session, just press the key combination one more time. You can also press CTLR+SHIFT+T to open a new tab in your current terminal window. If you press CTLR+ALT+(F1-F6), the window will switch to one of the virtual terminals. To access this virtual-terminal, you have to provide your user credentials. Please note that you will not get any feedback while typing in your password.
When you open a shell or logon to your virtual terminal, your work directory is in most causes your
home folder on the system. Often you want to change this current work directory. You have to do this,
because calling some programs directly from their main folders is far easier than typing in the entire
path to the program-executables.
So to change the directory to a subfolder, you simply type:
The command cd is basically a synonym to change the dictonary.
If you want to change into the parent folder, the command is:
It is also possible to "jump" to a different folders by typing in the absolute path from the root of the filesystem.
When you want to know what files are located in your current folder, there is a command for that too. In particular, typing ls in you shell and hitting enter will print all files and subfolders of the current folder or the folder you have passed to it over as command argument.
If you want more information about the files, you can pass -l as command argument to ls. This will print in addition information such as file size. Usually, not all folders are shown, because they include some user configuration-files and are often not necessary to the user. If you want to display also these files, you have to pass the command-argument -a to the ls command.
If you want to execute a program, which is in your current working dictionary, simply type:
If the program is in another dictionary, you have to call with the respective path to the executable. It does not matter whether the path is relative to your current folder or absolute from the root of the file system. However, be careful, in this case, the working folder of your program will your current working folder, and this may cause executions errors.
If you want to download a program (from the official repositories) and do not know what it is good for, you can check, it manual page (short man page) by just typing:
If the man page exists in the internal documentations of the system, it be will shown to you.
You can close the terminal session by using the exit command:
If you need more information about the shell, just check the Unix Tutorial written by Alex Batko