Wednesday, March 27, 2013

Learning unix basics on OpenSolaris 2009


If you end a command line with a backslash, bash lets you continue the command on the next
line. This feature is useful for entering lengthy commands:

$ touch \

> file1

ctrl+a to take the cursor to the beginning of the line

ctrl+e to take the cursor at the end of the line

Alt+F and Alt+B move forward 

and backward, respectively, on a word-by-word, instead of character-by-character.

from the beginning of the line Ctrl+K will cut the line and at the end of the line Ctrl+Y to 
paste are the same line as in emacs .

to get a list of all the commands in your path
that start with ‘‘fil,’’ type fil and press Tab twice:
$ file

bash first completed the word up to file (because there were no commands starting with fil
that didn’t have an e next), and then provided a list of possibilities with the second Tab.


file file-roller filesync
$ file


$ history

1ls

2ls-a

3 pwd

4 whoami

5 touch testfile

6 which gcc

7 which cc

8 rm testfile

9 history

history an integer argument to see only that number of previous commands:

$ history 2

12 date

13 history 2

To Execute a command in the history, use ! . To execute the previous com-
d, use the !! shortcut:

$ !4

whoami

test

$ date

Thu Mar 28 00:08:13 IST 2013


$ !!

date

Thu Mar 28 00:08:13 IST 2013

you can see the environment variables by the command

declare

or you can use the command

set


You can print the values of the environment variables using the echo or printf commands,
accessing the value of the variable by prefixing it with the usual $ character:

$ echo $SHELL

/bin/bash

$ printf ’’$PATH \n’’

/usr/bin

Set the value of an environment variable with an assignment statement. The following example
sets the shell history size to 1,000:

$ echo $HISTSIZE

500

$ HISTSIZE =1000

$ echo $HISTSIZE

1000

Use the which command to see which version of a command you are executing
based on your path:

$ which grep
/usr/gnu/bin/grep
$ which xterm
/usr/X11/bin/xterm
$ which which
/usr/gnu/bin/which

The user created by the installer is set up with the following path:

$ echo $PATH

/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin


Directory Description

/usr/bin The default directory for commands; contains utilities such as grep and
tr , a pplications such as firefox and thunderbird , shells such as
bash and zsh , and myriad other commands

/usr/ccs/bin Traditionally System V development tools, but these have mostly moved
to /usr/bin

/usr/gnu/bin The GNU versions of commands; slightly different versions of many of
them are also found in /usr/bin

/usr/sbin The system tools, commands, and daemons, such as zfs , dumpadm ,
in.routed , and others. These are generally privileged commands.

/usr/sfw/bin Traditionally the Sun Freeware (mostly GNU) tools, but almost all of
these have been moved to /usr/bin , with symlinks left here; or
symlinks have been added to /usr/bin

/usr/ucb Traditiona lly the BSD tools, but these have been moved to / usr/bin ,
with only a few symlinks left here

/usr/X11/bin X11 commands, such as xterm , xhost , and others
/usr/openwin/bin;
/usr/X/bin;
/usr/X11R6/bin
Aliases for /usr/X11/bin
/usr/xpg4/bin Ve rsions of some of the tools that adhere to the POSIX standard, where
the versions in /usr/bin don’t

/bin Alias for /usr/bin

/sbin System tools and utilities required for booting and possibly recovering
the system if /usr is not mounted. These are generally privileged
commands.


Add a location to your path

$ PATH =$PATH:/export/home/sourav/personal/data
$ echo $PATH

this folder /export/home/sourav/personal/data will be show and any executable file there can be 

invoked directly,the executable permission has to be set though


No comments:

Post a Comment