Dear friends, welcome to a spoken tutorial on the Linux Operating System.
In this tutorial, we will study some basic commands.
I am using Ubuntu 10.04.
We assume that you know how to get started with the Linux operating system.
If you are interested, it is available through another spoken tutorial, on the website http://spoken-tutorial.org.
In this tutorial, we will see what are commands and what is a command interpreter.
Then we will learn about how to find help in Linux using the man command.
Now the first question is, "what are commands?".
In simplest terms we can say that Linux commands are words that when keyed in cause some actions to take place.
Linux commands are seldom more than four character in length like ls, who, ps etc.
The commands are in "lower case" and they are "case sensitive". Let us see an example.
Go to the Applications menu.
Select Accessories and then click on Terminal from the available options.
or press Ctrl Alt t on your keyboard to open a terminal window.
Now we can see a prompt ($) and a cursor blinking next to it. This is where we need to type in a command.
Type in the words who and press Enter.
We can see the name of the users logged in. Actually we have just executed a command called who which shows "who are logged into" the system.
But which entity is converting these commands which are nothing more than a few letters into actions?
This is the job of the Command Interpreter, also called the shell.
We can define a shell as a program that acts as the interface between us and the Linux system,
allowing us to enter commands for the operating system to execute.
On Linux it’s quite feasible to have multiple shells installed, with different users able to pick the one they prefer.
On Linux, the standard shell that is always installed as /bin/sh is called bash, the GNU Bourne-Again SHell, from the GNU suite of tools.
The commands we would be covering in this tutorial are generic and can run on most of the Linux shells with slight variations.
Nevertheless, we would be using the bash as the shell for demonstration in this tutorial.
It is because bash is the most popular shell and portable to almost all UNIX.
Other shells include the Bourne shell which is the original Unix shell, C Shell and Korn shell
To see which shell we are using,
go to the terminal and type the command: echo space dollar in capital SHELL and press Enter.
Normally the output is /bin/bash which gives us the bash shell.
There are ways by which we can activate different shells. Those will be covered in an advanced tutorial.
Commands are actually files containing programs, often written in C.
These files are contained in directories. To find out where a command is stored, we can use the type command.
Type at the command prompt: typespace ps and press Enter.
This shows that ps is actually a file stored in the /bin directory.
When we key in a command at the command prompt, the shell searches for a file matching the command name in a list of directories.
If it is found, then the program corresponding to that file is executed, else a “command not found” error is given.
The list of directories searched is specified by the PATH variable, as we will see later.
For now, if we want to see this list, just type the command echo space dollar PATH
in capital and press Enter.
Talking of commands, there is one important thing that we need to know.
Linux commands are of two types: External commands and internal commands.
Now external commands are those which exist as separate files/programs.
Most commands in Linux are of this nature. But there are some commands whose implementation is written within the shell and they do not exist as separate files.
These are internal commands.
The echo command which we will see later, is in fact an internal command.
Go to the terminal and type at the command:
type space echo and press Enter.
The output shows echo is a shell built-in.
So instead of giving a file name it shows that the echo command's implementation is internal to the shell. So it is called internal command.
Another important thing which we need to understand is the structure of commands.
Commands can be of one word or multiple words, separated by white spaces.
In the second case the first word is the actual name of the command while the other words are the arguments.
Arguments can be options or expressions or file names.
A command can perform different tasks depending on the option specified.
They are generally preceded by a single or double minus sign(-), called short and long option, respectively.
Go to the terminal window and type the commands and see their outputs.
Type clear to clear the terminal window.
Then type ls and press Enter.
Again, type clear and press Enter.
Type ls space minus a (-a) and Enter.
Type clear to clear the terminal window.
Now type ls space minus minus all and press Enter.
Again, type clear to clear the terminal .
Now type ls space minus d (-d) and press Enter.
At this point, it is enough to understand how the command's behavior changes with change of options
In Linux we have a larger number of commands,
each of which have many different options.
Commands can also be combined together as we will see later. So how do we keep so much in mind?
In reality you don't have to. This is because of the excellent online help facility available in Linux.
The man command provides documentation on just about every available command on the system.
For instance, to know about say, the ls command, all you have to do is to go to the terminal
and type 'man' command with 'ls' as argument that is type: man space ls and press Enter.
Press q to come out.
man is the system’s manual pager. Each argument given to man is normally the name of a program, utility or function.
The manual page associated with each of these arguments is then found and displayed.
A section, if provided, will direct man to look only in that section of the manual.
The default is to search in all of the available sections, following a predefined order and to show only the first page found, even if page exists in several sections.
You can use man command to know more about the command man itself.
Go to the terminal and type: man space man and press Enter.
Press q to come out of it.
man command has many options.
Here, let me tell the most useful ones. Sometimes we know what we want to do but do not know the exact command. Then what can we do?
man provides the -k option which takes a keyword and returns a list of commands and their brief purpose.
For example, create a directory, we may not know the exact command,
so we can go to the command prompt and type man space minus k space directories and press Enter.
Now we can search each of these commands to see what we actually need.
The same thing can be achieved using apropos command.
Type at the command prompt: apropos space directories and press Enter to see the output.
Sometimes we do not need too much details. We only need to know what a command does.
In that case we can use the whatis command or man -f. Both give one line description about the command.
Go to the terminal, type clear to clear the terminal window.
Now type whatis space ls and press Enter.
Some commands have many options. We may want to obtain a list of the different options that a command has.
Then we use the minus help option.
Go to the command prompt and type: ls space minus minus help and press Enter.
I will scroll up so that you can see all the options on this manual page.
That's it for this part of the Linux Spoken tutorial. Spoken Tutorials are a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
More information on the same is available at the following link .
This script has been contributed by ----------------------(name of the translator) and this is -----------------------(name of the recorder) from --------------------------(name of the place) signing off. Good bye.