Saturday, 10 January 2015

Lets Start with Terminal

Terminal :
         Terminal is an interface in which you can type and execute text based commands. It can be much faster to complete some tasks using a terminal than with graphical applications and menus. Another benefit is allowing access to many more commands and scripts. Similar to Terminal,we have Command prompt (cmd) in Microsoft Windows.

   Alternative names for the terminal:
  • Console
  • Shell
  • Command Line
  • Command Prompt                               
           I am going to use Terminal on Ubuntu 14.04 Linux Distribution. Go to launcher and type terminal/Terminal ,also you can use terminal shortcut Ctrl+Alt+t  to get to terminal.
       And here we go..



       The best fun in linux is to play  terminal with commands and scripts.

Lets Start with the fun.


Whats today's date ?

      Command: date
      Output :  Mon Jan  5 17:07:43 IST 2015.. this is my time.
      format is : Day Month Date Time Time-Format Year

      IST: Indian Standard Time
      Time is according to 24 hour clock.

Want to see calender ?

     Command: cal
     Output: it will view the going month calender including dates and days.

    To see the other month calender:
         Command format: cal [Month] [Year]
         Command: cal Mar 2015
         Command: cal March 2015
         Command: cal 3 2015

    These 3 variety of command you can enter to get calender of any month.

Who are the users on the system you are sitting ?

     command: who
     output:

          The row after command written is details of system : at what time the system is started ..can be indicated by system name :0 and see next line to it system name pts/0 indicates that the one terminal window is open.

           Try this: Open one more terminal without closing other terminals. Type 'who' and compare the two output on terminals. Again open one more terminal , don't close other terminals ,type who command..see the difference.


       Output format: user_name terminal_name_working_on date time (leave it for time-being)

How to view the process ?
     Command: ps
     Output :
       PID TTY          TIME CMD
     1216 pts/0    00:00:00 bash
     1230 pts/0    00:00:00 ps ...in my terminal

     PID: Process ID
     TTY:  "TeleTYpewriter" which were devices that allowed users to connect to   early computers.

 For the next Command ...

  Now, Lets go to GUI of the Ubuntu.
   Like windows in users folder, In Linux we have 'Home'. In that folder we have all data and named as: Desktop,My Videos,My Music,My Pictures.. similar to windows.
files are organized in separate folders called directories.

Users folder in windows




Home folder in Linux
Now lets return to Terminal ,

How to list  folders and files in My Home?

      Command: ls
      Output: List the names of the files available in the Home directory.

      Output As..
             shrenoid@shrenoid-Inspiron-5520:~$ ls
             bealert of this~   ideapage~                  recordnote2.txt~
             bealert of this~~  jdk1.7.0_67                recordnote.txt~
             car.java~          jdk-7u67-linux-x64.tar.gz  rgb.txt~
             Desktop            Music                      Templates
             Documents          Pictures                   Untitled Document~
             Downloads          Public                     Videos
             examples.desktop   readthis.pdf
             greatlines.txt~    recordnote1.txt~


How to copy the output text to file ?

       Using Symbol '>'
       Command: ls > note1 ...without any space

       output: there is no output displayed on terminal. Cursor returns next to $ sign. Then how to see the contains of the file.
   
    Here's the Next Command.

    Command: cat [file name]
    Type: cat note1 
    Output: U will get all contains of the file note1 on the terminal screen

How to count the Number of lines in a file ?

Command: wc [file name]
Output format: [no of lines] [no of words] [no of characters]

Type: wc note1
Output: something output like

shrenoid@shrenoid-Inspiron-5520:~$ wc list
 15  16 168 list

where 15 is no of lines
           16 is no of words
           168 is no of characters of list file.

How to change directory?
 
Command: cd [directory name/folder name]
If folder name is Documents in home folder.
Command: cd Documents

And you will be in that folder with indication: ~/Documents$
If folder is in present folder or not can be checked using:
  'ls' command or using 'nautilus .' command.

In which location i am working now ?
 Command: pwd
 Output: It gives current working location.
shrenoid@shrenoid-Inspiron-5520:~$ pwd
/home/shrenoid


To go back to previous folder :
 Command: cd .. ..pay attention on space between cd and .. .

Is there much mess on the screen :

We need to clear out the screen? How to do it?

Command: clear
Output: terminal will have clean and fresh screen.

Don't Exit from terminal using -
 Command: exit
 Output: terminal window will be closed.

No comments:

Post a Comment