Friday, 25 January 2013

Introduction to shell programming.


The Unix operating system provides a rich set of commands to getting details of a file to even sending emails. Its always have been used by nerds and tech-savvy who are bored of Windows and working with codes fantasize most of the programmers. 

There are about 200 commands distributed with the Linux/Unix OS and they virtually are enough for performing basic work handling. 


Its commonly referred to as Shell programming . The shell is simply a program that reads in the command you type and converts them into a form more readily understood by the Unix system.
The Kernel is the heart of Unix system and resides in the computer memory from the time the computer is turn on and booted until the time it is shut down.

Here, we will try to understand some of the basics commands along with their examples and even more will be discussed in coming posts. 

To open Linux terminal, just press Alt +F2 .
Linux terminal is also known as command line.You can type any of the below mention commands at $ prompt. 

To get Linux shell, you need to have a terminal. To know which shell you are working on, 
just type the following command. 
echo $SHELL

And to know the path of the shell you are using.
echo $PATH


Chapter 1 deals with some of the file and directly related commands in brief. We will cover them in details in upcoming chapters. Its just to provide a basic idea to the user to get start with the programming environment. 

File related commands. 

cat file             Displays the contents of a file

More file          Displays the contents of a file and pausing after each screen.     
                        Pressing Space is required.

Rm file             Delete a file.

cp file1 file2     file1 is the source file and file2 is the destination file name. It  
                        copies the content of source file to destination file. 

mv file1 file2    Move contents of file1 to contents of file2. File1 is the source file and 
                        File2 is the destination file. 

ls -l                   List files and sub directories present in working directory. Here, -l (use of  
                         "-" with lower case L displays more information about the 
                         files/subdirectories like size of file, when was it last modified, and if 
                         protected with password then that code.)

ls -a                   using -a will display all the files and will exclude the files starting with 
                          .(period).

grep string file   Search the string mentioned in the file name file specified. 

pico file             It provides a user friendly screen editor to edit the file.

Directory Commands.

cd [directory]     Change current directory to the [directory] mentioned. 
                          If its not mentioned, home directory is set. 

mkdir directory    Create a new sub directory in the directory you are working. 

rmdir directory    Delete a sub directory named directory. It must be empty to be 
                           deleted. 

pwd                    Displays current working directory. 


Some other commands to know.

print file             Send file to printer. 

man command   Display help/information about the command. 

du                      List the number of KiloBytes for each directory in the current directory. 

!!                       Repeats the last command.

We will cover some more topics in coming posts. 
Do subscribe to the RSS feed by entering your email id in the right side of the website. 

aditi.
Open Source Revolution.

1 comment:

  1. I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!
    sales leads

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...