Difference between revisions of "BOSS-Linux/C2/Basic-Commands/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "Pending upload")
 
 
Line 1: Line 1:
Pending upload
+
'''Title of script''':  Basic Commands in Linux
 +
 
 +
'''Author: Anirban Roy Choudhury'''
 +
 
 +
'''Keywords:  Shell,commands,options,help,apropos,man'''
 +
 
 +
Resources for the tutorial:[[File:Resources_for_Basic_Commands_in_linux.zip]]
 +
 
 +
{| style="border-spacing:0;"
 +
| style="border-top:0.035cm solid #000000;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| <center>'''Visual Cue'''</center>
 +
| style="border:0.035cm solid #000000;padding:0.097cm;"| <center>'''Narration'''
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display Slide 1
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Dear friends, welcome to a spoken tutorial on the Linux Operating System.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| In this tutorial, we will study some basic commands.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display Slide 2
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| I am using Linux Operating System
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| We assume that you know how to get started with the Linux operating system.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| If you are interested, it is available through another spoken tutorial, on the website [http://spoken-tutorial.org/ http://spoken-tutorial.org].
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide 3
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| In this tutorial, we will see what are commands and what is a command interpreter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Then we will learn about how to find help in Linux using the man command.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide 4
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Now the first question is, "what are commands?".
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| In simplest terms we can say that Linux commands are words that when keyed in cause some actions to take place.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Linux commands are seldom more than four character in length like ls, who, ps etc.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The commands are in lower case and they are case sensitive. Let us see an example .
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the applications menu.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Open a terminal window
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Select accessories and then click on terminal from the available options
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Now we can see a prompt ($) and a cursor blinking next to it. This is where we need to type in a command. 
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt
 +
 
 +
who
 +
 
 +
and press enter
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Type in the words who and press enter.
 +
 
 +
 
 +
 
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display Slide 5
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| But which entity is converting these commands which are nothing more than a few letters into actions?
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| This is the job of the Command Interpreter, also called the shell.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| On Linux it’s quite feasible to have multiple shells installed, with different users able to pick the one they prefer.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| On Linux, the standard shell that is always installed as /bin/sh is called bash (the GNU Bourne-Again SHell), the GNU suite of tools.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The commands we would be covering in this tutorial are generic and can run on most of the Linux shells, with slight variations.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Nevertheless, we would be using the bash as the shell for demonstration in this tutorial.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| It is because bash is the most popular shell and portable to almost all UNIX.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Other shells include the Bourne shell (sh) which is the original Unix shell, C Shell (csh) and Korn shell(ksh)
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt
 +
 
 +
echo $SHELL
 +
 
 +
 
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| To see which shell we are using go to the terminal and type the command '''echo space dollar in capital SHELL''' and press enter)
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Commands are actually files containing programs, often written in C.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| These files are contained in directories. To find out where a command is stored, we can use the '''type''' command.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt type ps
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"|  Type at the command prompt '''type space ps''' and enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| This shows that '''ps''' is actually a file stored in the '''/bin''' directory.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| If it is found, then the program corresponding to that file is executed, else a '''command not found''' error is given.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The list of directories searched is specified by the PATH variable, as we will see later.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  Type at the command prompt echo $PATH
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| For now, if we want to see this list, just type the command '''echo space dollar PATH''' in capital and press enter
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide 6
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Talking of commands, there is one important thing that we need to know.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Linux commands are of two types: External commands and internal commands.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Now external commands are those which exist as separate files/programs.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The echo command, which we will see later, is in fact an internal command.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Go to the terminal and type at the command prompt '''type echo'''
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the terminal and type at the command, '''type space echo''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The output shows '''echo as a shell bulletin.''' 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide
 +
 
 +
 
 +
 
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Another important thing which we need to understand is the structure of commands.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Commands can be of one word or multiple words, separated by white spaces.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| In the second case the first word is the actual name of the command while the other words are called arguments.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Arguments can be options or expressions or file names.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the terminal window and type the commands and see their outputs.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Type '''clear''' to clear the terminal window
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  ls
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Then type '''ls''' and press enter
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Again, type '''clear''' and press enter
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  ls -a
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Type '''ls space minus a''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Type '''clear''' to clear the terminal window
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  ls --all
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Now type '''ls space minus minus all''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  ls -d
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Again, type '''clear''' to clear the terminal .Now type '''ls space minus d''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| At this point it is enough to understand how the command's behavior changes with change of options
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide 8
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| In Linux we have a larger number of commands, each of which have many different options.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The man command provides documentation on just about every available command on the system.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  Type at the command prompt
 +
man ls
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  press q
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Press q to come out.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display Slide 8
 +
 
 +
 
 +
 
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| '''man''' is the system’s manual pager. Each argument given to man is normally the name of a program, utility or function.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The default is to search in all of the available sections, following a pre-defined 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  Type at the command prompt
 +
man man
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the terminal and type '''man space man''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  Press q
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Press '''q''' to come out of it.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display Slide 8
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| '''man''' command has many options.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| 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 return a list of commands and their brief purpose.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt
 +
 
 +
man -k directories
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| For example, create a directory, we may not know the exact command, so we can go to the comand prompt and type '''man space minus k space directories''' and press enter.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Now we can search each of these commands to see what we actually need.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| The same thing can be achieved using '''apropos''' command.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|  Type at the command prompt apropos directories
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Type at the command prompt ''' apropos space directories''' and press enter to see the output.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Some times 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.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Go to the terminal
 +
 
 +
Type at the command prompt
 +
 
 +
clear
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the terminal type '''clear''' to clear the terminal window
 +
 
 +
 
 +
 
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt whatis ls
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| now type '''whatis space ls''' and press enter
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Some commands have many options. We may want to obtain a list of the different options that a command has. Then we use the '''--help''' option.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Type at the command prompt
 +
 
 +
ls --help
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Go to the command prompt and type ''' ls space minus minus help''' and press enter
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| I will scroll up so that u can see all the options on this manual page
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:none;padding:0.097cm;"| Display slide 9
 +
| style="border-top:none;border-bottom:0.035cm solid #000000;border-left:0.035cm solid #000000;border-right:0.035cm solid #000000;padding:0.097cm;"| Thats 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 [http://spoken-tutorial.org/NMEICT-Intro http://spoken-tutorial.org/NMEICT-Intro] Thanks for joining us This is Anuradha Amrutkar signing off. Good bye
 +
 
 +
|}

Latest revision as of 10:58, 12 November 2014

Title of script: Basic Commands in Linux

Author: Anirban Roy Choudhury

Keywords: Shell,commands,options,help,apropos,man

Resources for the tutorial:File:Resources for Basic Commands in linux.zip

Visual Cue
Narration
Display Slide 1 Dear friends, welcome to a spoken tutorial on the Linux Operating System.
In this tutorial, we will study some basic commands.
Display Slide 2 I am using Linux Operating System
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.
Display slide 3 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.
Display slide 4 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.
Open a terminal window Select accessories and then click on terminal from the available options
Now we can see a prompt ($) and a cursor blinking next to it. This is where we need to type in a command.
Type at the command prompt

who

and press enter

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.
Display Slide 5 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), 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 (sh) which is the original Unix shell, C Shell (csh) and Korn shell(ksh)
Type at the command prompt
echo $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 type ps Type at the command prompt type space ps and 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.
Type at the command prompt echo $PATH For now, if we want to see this list, just type the command echo space dollar PATH in capital and press enter
Display slide 6 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 prompt type echo Go to the terminal and type at the command, type space echo and press enter.
The output shows echo as a shell bulletin. 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.
Display slide


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 called 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.
Type at the command prompt Go to the terminal window and type the commands and see their outputs.
Type clear to clear the terminal window
ls Then type ls and press enter
Again, type clear and press enter
ls -a Type ls space minus a and press enter.
Type clear to clear the terminal window
ls --all Now type ls space minus minus all and press enter.
ls -d Again, type clear to clear the terminal .Now type ls space minus d and press enter.
At this point it is enough to understand how the command's behavior changes with change of options
Display slide 8 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.
Type at the command prompt
man ls
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 Press q to come out.
Display Slide 8


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 pre-defined 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.
Type at the command prompt
man man
Go to the terminal and type man space man and press enter.
Press q Press q to come out of it.
Display Slide 8 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 return a list of commands and their brief purpose.
Type at the command prompt

man -k directories

For example, create a directory, we may not know the exact command, so we can go to the comand 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 directories Type at the command prompt apropos space directories and press enter to see the output.
Some times 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 at the command prompt

clear

Go to the terminal type clear to clear the terminal window



Type at the command prompt whatis ls 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 --help option.
Type at the command prompt
ls --help
Go to the command prompt and type ls space minus minus help and press enter
I will scroll up so that u can see all the options on this manual page
Display slide 9 Thats 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 http://spoken-tutorial.org/NMEICT-Intro Thanks for joining us This is Anuradha Amrutkar signing off. Good bye

Contributors and Content Editors

Nancyvarkey, PoojaMoolya