Skip to main content

WORKING WITH COMMANDS

   
                       
Hello guys welcome back to hacker-heaven..after long time..
off-course i was little bit busy..my semester exam are started..
         ok..forget it..

lets wrap upto what we all learn before...not here you have to read all other article on linux commanding.. and all these articles list present  here...

                LINUX TERMINAL COMMAND TUTORIAL LIST

so ,
Up to this point, we have seen a series of mysterious commands, each with its own mysterious options and arguments.

today we all made our own mysterious commands...today we will learn a little bit but this gonna be different from all we learn upto ...about commanding..so lets have a look what we gonna learn today...

● type – Indicate how a command name is interpreted
● which – Display which executable program will be executed
● help – Get help for shell builtins
● man – Display a command's manual page
● apropos – Display a list of appropriate commands
● info – Display a command's info entry
● whatis – Display a very brief description of a command
● alias – Create an alias for a command

What Exactly Are Commands?
A command can be one of four different things:

1. An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in scripting languages such as the shell, perl, python,ruby, etc.

2. A command built into the shell itself. bash supports a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.

3. A shell function. These are miniature shell scripts incorporated into the environment.We learn later to write our own function script which will be executable in the terminal, but for now, just be aware that they exist.

4. An alias. Commands that we can define ourselves, built from other commands.

               Identifying Commands


It is often useful to know exactly which of the four kinds of commands is being used and Linux provides a couple of ways to find out.

type – Display A Command's Type

The type command is a shell builtin that displays the kind of command the shell will execute, given a particular command name. It works like this:

type command


where “command” is the name of the command you want to examine. Here are some examples:

Here we see the results for  first three different commands. Notice that the one for ls (taken from a ubuntu system) and how the ls command is actually an alias for the ls command with the “-- color=tty” option added. Now we know why the output from ls is displayed in color!



         which – Display An Executable's Location

Sometimes there is more than one version of an executable program installed on a system.While this is not very common on desktop systems, it's not unusual on large servers.To determine the exact location of a given executable, the which command is used:

which only works for executable programs, not builtins nor aliases that are substitutes for actual executable programs. When we try to use which on a shell builtin, for example,cd, we either get no response or an error message:


like here in the ubuntu system you got no responce from terminal....but instead of ubuntu...try in fedora or in other system you will get an erro massage as shown below..

[me@linuxbox ~]$ which cd
/usr/bin/which: no cd in (/opt/jre1.6.0_03/bin:/usr/lib/qt-
3.3/bin:/usr/kerberos/bin:/opt/jre1.6.0_03/bin:/usr/lib/ccache:/usr/l
ocal/bin:/usr/bin:/bin:/home/me/bin)

          Getting A Command's Documentation

With this knowledge of what a command is, we can now search for the documentation available for each kind of command.

help – Get Help For Shell Builtins

bash has a built-in help facility available for each of the shell builtins. To use it, 
type “help”   followed by the name of the shell builtin. For example:

help cd


                     A note on notation: 
When square brackets appear : in the description of a command's syntax, they indicate optional items. 

A vertical bar: character indicates mutually exclusive
items. 

In the case of the cd command above:
cd [-L|[-P[-e]]] [dir]

This notation says that the command cd may be followed optionally by either a “-L” or a “-P” 

and further, if the “-P” option is specified the “-e” option may also be included followed by the optional argument “dir”.

While the output of help for the cd commands is concise and accurate, it is by no means tutorial and as we can see, it also seems to mention a lot of things we haven't
talked about yet! Don't worry. We'll get there.

             --help – Display Usage Information

Many executable programs support a “--help” option that displays a description of the command's supported syntax and options. For example:
ls --help




Some programs don't support the “--help” option, but try it anyway. Often it results in an
error message that will reveal the same usage information.

           
            man – Display A Program's Manual Page

Most executable programs intended for command line use provide a formal piece of documentation called a manual or man page. A special paging program called man is used to view them. It is used like this:

command:
man cp

Man pages vary somewhat in format but generally contain a title, a synopsis of the command's syntax, a description of the command's purpose, and a listing and description of each of the command's options. Man pages, however, do not usually include examples,
and are intended as a reference, not a tutorial. As an example, let's try viewing the man page for the ls command:

man cp

On most Linux systems, man uses less to display the manual page, so all of the familiar less commands work while displaying the page.
The “manual” that man displays is broken into sections and not only covers user commands but also system administration commands, programming interfaces, file formats
and more. The table below describes the layout of the manual:

Section          Contents
1                User commands
2                Programming interfaces kernel system calls
3                Programming interfaces to the C library
4                Special files such as device nodes and drivers
5                File formats
6                Games and amusements such as screen savers
7                Miscellaneous
8                System administration commands

Sometimes we need to look in a specific section of the manual to find what we are looking for. This is particularly true if we are looking for a file format that is also the name of a command. Without specifying a section number, we will always get the first instance of a match, probably in section 1. To specify a section number, we use man like this:

command format:
man section search_term

example :

man 5 passwd


This will display the man page describing the file format of the /etc/passwd file.

         apropos – Display Appropriate Commands
                    
                       or
           instead of this we can use another command..
   
                       man -k
both command will do the same task ....

It is also possible to search the list of man pages for possible matches based on a search term. It's very crude but sometimes helpful. Here is an example of a search for man pages using the search term “floppy”:


The first field in each line of output is the name of the man page, the second field shows the section.

       whatis – Display A Very Brief Description Of A Command

The whatis program displays the name and a one line description of a man page matching
a specified keyword:


              info – Display A Program's Info Entry

The GNU Project provides an alternative to man pages for their programs, called “info.”
Info pages are displayed with a reader program named, appropriately enough, info. Info pages are hyperlinked much like web pages. Here is a sample:


The info program reads info files, which are tree structured into individual nodes, each
containing a single topic. Info files contain hyperlinks that can move you from node to
node. A hyperlink can be identified by its leading asterisk, and is activated by placing the
cursor upon it and pressing the enter key.
To invoke info, type “info” followed optionally by the name of a program. Below is a
table of commands used to control the reader while displaying an info page:

Command                    Action
?                         Display command help
PgUp or Backspace         Display previous page
PgDn or Space             Display next page
n Next -                  Display the next node
p Previous -              Display the previous node
u Up -                    Display the parent node of the currently displayed
                           node, usually a menu.
Enter                     Follow the hyperlink at the cursor location
q                             Quit

Most of the command line programs we have discussed so far are part of the GNU
Project's “coreutils” package, so typing:

info coreutils


will display a menu page with hyperlinks to each program contained in the coreutils package.

           Creating Your Own Commands With alias

Now for our very first experience with programming! We will create a command of our own using the alias command. But before we start, we need to reveal a small command
line trick. It's possible to put more than one command on a line by separating each command with a semicolon character. It works like this:

command1 ,command2 ,command3

let's have an explainatory example in support of this statement...

command:
cd /usr; ls; cd -



As we can see, we have combined three commands on one line. First we change directory to /usr then list the directory and finally return to the original directory (by using 'cd -') so we end up where we started. Now let's turn this sequence into a new command using
alias. The first thing we have to do is dream up a name for our new command.
Let's try “zerocool”. Before we do that, it would be a good idea to find out if the name “zerocool” is
already being used or not. To find out, we can use the type command again:

as you can see the 'zerocool' command is not found so we can use this to alias any other command with same name..

but before we proceed to the practical..let's see what is the original format of the 'alia' command..

alias name='string'

After the command “alias” we give alias a name followed immediately (no whitespace allowed) by an equals sign, followed immediately by a quoted string containing the meaning to be assigned to the name. After we define our alias, it can be used anywhere the
shell would expect a command. Let's try it:

command:  alias zerocool='cd /usr; ls; cd -'


We can also use the type command again to see our alias:

type zerocool


this will display the use of actual command..

To remove an alias, the unalias command is used, like so:

command: unalias zerocool




While we purposefully avoided naming our alias with an existing command name, it is not uncommon to do so. This is often done to apply a commonly desired option to each invocation of a common command. For instance, we saw earlier how the ls command is
often aliased to add color support: To see all the aliases defined in the environment, use the alias command without arguments.
Here are some of the aliases defined by default on a Fedora system. Try and figure out what they all do:

There is one tiny problem with defining aliases on the command line. They vanish when your shell session ends.

ok...that's it for today..but once again i remind you specially for beginner's...keep practicing.

well said...
           "Practice make man perfect"

watch video of this article..here..

ok..until next article this is..
                           ZEROCOOL
                           SIGN OUT

Popular posts from this blog

MALTEGO-INFORMATION GATHERING GRAPH

Hello Friend,                 Welcome back to Hacker_heaven .in this article i am gonna show you how to gather deep information about any specific website.so just stick with me...

DEEP SOUND -STEGNOGRAPHY

In the series of the steganography ..today we are going to discuss the hiding of data in the music file through the help of the window based tool name       "DEEP SOUND" ..now a days very famous TV series name             Mr. Robot . . off course i am  fan of this show..where elliot use this tool for hiding his secret data.. read previous article on steganography                                                         so without wasting much time lets start .. 1.install the DEEP SOUND go to the official website of the deep sound and download it to your machine.  and open up the interface of the deep sound. 2. setting click on the setting gear icon, an pop-up window show up...where languge remain same as english,           change your output  directory ..like i change it to the documents by browsing the folder. after that check the box for encrypt files .. after that it will ask for the password.. input your password for the sec

LINUX HIERARCHY-GUIDING TOUR

                       Hello guys welcome back...in today article..we gonna discuss about the linux system hirarchy..which is much different than the window hirarchy..and it's important to learn..actually this article is continue of previous one...                            LINUX TERMINAL COMMAND – EXPLORE THE SYSTEM The file system layout on our Linux system is much like that found on other Unix-like  systems. The design is actually specified in a published standard called the Linux Filesystem Hierarchy Standard. Not all Linux distributions conform to the standard exactly but most come pretty close. Next, we are going to wander around the file system ourselves to see what makes our Linux system tick. This will give you a chance to practice your navigation skills. One of the things we will discover is that many of the interesting files are in plain human-readable text. As we go about our tour, try the following: 1. cd into a given directory 2. List the dir