Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Linux :: Discontinued :: linuxd~1.txt

Linux for Dipshits: Understanding the Shell




 ________________                              ----------         \     /
/                \________    |      |             |               \   /
|                |            |      |             |                \_/      |-----
|                |-------     |      |             |                 |       |    
\_______________ |________    |      |             |                 |       |-----    
                \         \   |------|         ____|_____            |       | 
                |         |  /        \_______/          \___________/       |_____             
                |         | /          |      |                |     \      /      \
________________/         |/           |      |                |     |\    |        --------
                          |\           |------|                |     | \   |           |
                          | \          | \                     |     |  \  |           |
                          |  \         |  \                    |     |   \ |           |
                                           \                   |     |    \|           |
____________________________________        \                                          |
| Text: Linux For Dipshit's        |
| Lesson: Understanding The Shell  | 
| By: Redemption                   | 
| webmaster@sekurity-net.com       |
| http://www.sekurity-net.com      |
------------------------------------
The shell is a command interpreter, it acts as your interface to the operating system by accepting yout input and performing the tasks you request.

Before i get into the hard-core shit of shells, let me mention that graphikal user interfaces are avaliable for Linux.  That means that for those or you who perfer the point-and-click interface or a couse, there is hope.

In this text we are going to talk about:
-Picking the shell thats best for you
-Getting programs to read and write files
-Connecting the output of one program to the input of another
-Using puotation marks to contrl the interpretation or your input
-Customizing your environment
-Getting familiar with shell conventions
-Examining special characters and what they do

Here we go.....



Available Shells
----------------

Multipule shells are included with Linux distributions. They include Bash, ksh, tcsh, and zsh. The most populat shell by far is bash, a product of the GNU Project of the Free software Foundation.  Bash stands "Bourne Again SHell" (named after stephen bourne, who wrote the first programmable shell for Unix)

In this text, I use the bash shell as the standard.  As a user, you may want to concider ksh as an alternative, particularly if you work with Unix platforms.  The ksh shell is a public-domain impletmentation of the POSIX-compliant Korn shell, which was written by David Korn at AT&T.  The ksh shell is commonly available on most Unix platforms.


Basic Directory Commands
------------------------

Use the followin commands to perform basic managment tasks:
- cd <dirname>: To change your current directory
- mkdir <dirname>: To create a directory
- rmdir <dirname>: To remove an empty directory
- pwd: To find out which direcory you're in

Type pwd (for "print working directory") and the name of the current directory"> and the name of the current directory appeats on-screen. To verify the name of your home directory, type pwd after logging in.

--Cigarette Break--


Character Quoting
-----------------

Some characters have a special meaning to the shell (that is, ths shell treats the chatacters as directions to perform some action).  If you need to enter these characters as a part of a filename, and you dont want the shell to interpret their special meaning, then you need to quote these characters.

-Quoting an individual character
To quote any single character, preceed it with a backslash (\).  For example, to list the names of all files that contain an (*), type this:  ls -a *\**
In the previous line of code, the shell interprets the first and third asterisk but not the second one.  Therefore, it matches any set of characters that contains an asterisk.

You can doubble and single quotation marks (" and ') to quote whole strings.  Their meaning is somewhat different.
-Single quotation marks quote almost everything.
-Doubble quotation marks allow the shell to interpret works that start with a ($), which are commonly known as "shell variable references"
-You can use a sigle quotation mark to turn off the special meaning of a double uotation mark, and vice versa.

For example, in the following commaind, the double quotation marks prevent the shell from interpreting the special meaning of the single quotation mark in "it's" but they allow "$money" to be treated as a reference to a shell variable.  The double quptation marksalso prevent the shell from interpreting the whitespace so that "it's my $moeny" is treated as a single argument rather than three separte ones.

grep "it's my money" junkfile"



Using the back-quote character
------------------------------

The single back-quote character (') is useful for telling the shell to excute a command within the back quotation marks, insert the output of the execution into the orginal commain line in place of the command in back quotation marks, and then excute the newly built commaind line.  You can use this trick to display a message that contains the current date.

echo Damn, today is 'date' we will hack r00t to 3 servers soon

The "date" command displays a timestamp to standard output.  By embedding the "date" command within quotation marks in the "echo" command, the shell substitutes the result of execution of "date" into the command line before excuting the "echo" command. 
(The following code shows the input lines in quotations)

"date"
Fri Jul 10 09:30:8 PDT 1998 
"echo Damn, today is 'date' we will hack r00t to 3 servers soon"
today is Fri Jul 10 09:30:8 PDT 1998 we will hack r00t to 3 servers soon


Command History
---------------

The bash shell maintains a command history, a list of up to 500 of the most recently entered commands.  If you type the command history, the shell displays your history list.

The "history" command is useful when you want to reexecute a command without having to retype it. (The number of commands saved can be changed by setting the "HISTSIZE" shell variable).  You can then use the commands described in the following sections to go back though the list and edit reexecute a command.


-Setting command history mode

How you edit recent commands depends on whether you shell is set to vi mode or Emacs mode.
*For vi mode, type set -o vi and press Enter
*For Emacs mode, type set -o emaces and press Enter


-Using Emacs mode

If you are in Emacs mode, you can press Ctrl+P to access the previous command, press Crtl+N to access the next command, or use the arrow keys.  When you finish editing, press Enter to execute the command. 


-Using vi mode

If you are in vi mode, press Esc and then use standard vi commands (k to move up, j to move down, and so on) to access and edit the history list.  When you are ready to execute the edited command, press Enter.

--Cigarette Break--


Customizing the Environment
---------------------------

Linux, in the Unix tradition, has always allowed you to customize your work environment, and this section shows you some of the ways to do that.



Creation shell aliases
----------------------

While you can use shell and environment variables to remember whats in the character string, a shell alias is specifically designed to allow you to make up names for commands.

alias [name[=command]]

_______________________________________________________________________________________________
Argument  |   Function
-----------------------------------------------------------------------------------------------
name      | The name of the alias, if not specified "alias" lists all your current aliases  
-----------------------------------------------------------------------------------------------
command   |Command string assigned to the alias. if "command" contains any spaces or special                                         |characters, it must be quoted
-----------------------------------------------------------------------------------------------

Suppose that you wnat to occasionally print files on a printer named "soy" (rather than on your defauly printer) Normally, you type " lpr -p soy file " (excluding the quotations) to print to the other printer, but you want an easier way. The following command establishesan alias called "lpsoy" that would do this for you.

alias lpsoy='lpr -P soy'

After the alias is created, you can direct you printer output to print "soy" by using the alias.  For example to print the file "lentil.loaf", type "lpsoy lentil.loaf"

You can use the "unalias" command to delete a shell alias.  For example, to delete you alias "lpsoy" type "unalias lpsoy"


-Displaying environment variables

Any ecvironment variable is also available as a shell variable, so you can display as environment variable just as you would a shell variable, by useing the "$" prefix as an argument to a command (such as echo) that displays the value of its arguments.

echo $var

_____________________________________________________________________________
Option or Argument   |    Function
-----------------------------------------------------------------------------
var                  | Name of the environment (or shell) variable to display
-----------------------------------------------------------------------------

Figuring out which variables are local to your current shell and which are from the environment can be confusing.  Type "export" with no variable names to see a list of variables that are exported.
Suppose that you have written some shell scripts that e-mail recipes to your 133t haxx0rz. The scripts need to know where you keep your list of e-mail addresses.  The shell scripts also need to know the name of the directory where the recipes are located.  The easiest way to pass this infomation would be to set some evironment variables. Whenever the shell starts the scripts, the scrpts can just read in the values.

export 133t_ADDRESSES=~/Addr/haxx0rs
export RECIPES=~/Recipes/133t


-Setting environment variables

Environment variables are saved in such a way that they are avaliable to any shell that is a child of the current shell. Thus, environment variables are the right place to save things suck as you search path and the name of your printer.

export var=value
(or)
var=value
export var

The order of the commands doesnt matter in the preceding exaply. The "export" statement performs the binding.  If the shell variable is already set, its current value is ezported to the environment.  If the value is changed at a later time, the environment variable follows the value of the shell variavle.

_______________________________________________________________________________________________
Option or Argument   |   Function
-----------------------------------------------------------------------------------------------
var                  | Name of the variable to set.
-----------------------------------------------------------------------------------------------
value                | A string value to be assigned. You must quote (value) if it contains                                                                |spaces or other characters that have special meaning to the shell
-----------------------------------------------------------------------------------------------

If you want to invoke one command with a different value for either a shell or environment variable, but not change its value the command line.  For you cant specify the variable value on the command line.  For example, to run a script called 133t_haxxor with the "PRINTER" variable set to fastone, just type "Printer=fastone 133t haxxor".


-Setting shell edit modes

With the bash and kron shells, you have your choice whether to use vi-style or Emacs-style command line editing. My advice is that if you use the vi or Emacs text editor, set your shell mode to the editing mode that matches your editor (which will help you get more comfortable with  your editor)  If you dont currently use either, try each mode and pick the one that you are most comfortable with.

To set the shell mode to vi, use the following command: set -o vi
To set the shell mode to Emacs, use this command: set -o emacs

You can place either of these commands in your ".profile" file so that the mode will be automatically set at login time.

One significant difference between the useing the editing commands in vi and thos in Emacs is that in vi mode you need to press "esc" to activate the editing command (you have to switch back and forth between insert and command mode in vi command line mode_. In Emacs, you just need to type the key combinations, as shown in the following table.

________________________________________________________________________________
(Emacs)  |   (vi)   |    (Function)
--------------------------------------------------------------------------------
Ctrl+P   |    K     |  Moves back one command in your history list
--------------------------------------------------------------------------------
Ctrl+N   |    J     |  Moves forward one line in your history list
--------------------------------------------------------------------------------
Ctrl+B   |    H     |  Moves back one character in the displayed command line
--------------------------------------------------------------------------------
Ctrl+F   |    L     |  Moves forward one character in the displayed command line
--------------------------------------------------------------------------------
Esc+B    |    b     |  Moves back one word
--------------------------------------------------------------------------------
Esc+F    |    *     |  Moves forward one word
--------------------------------------------------------------------------------
Crtl+A   |    0     |  Moves to beginning of line
--------------------------------------------------------------------------------
Ctrl+E   |    $     |  Moves to the end of line
--------------------------------------------------------------------------------
         |    i     |  Enter insert mode
--------------------------------------------------------------------------------
         |   Esc    |  Exit insert mode
--------------------------------------------------------------------------------
         |    a     |  Appends to line
--------------------------------------------------------------------------------
Esc+Del  |    X     |  Deletes backward one character
--------------------------------------------------------------------------------
Ctrl+D   |    x     |  Deletes forward one character
--------------------------------------------------------------------------------
Esc+D    |    dw    |  Delete forward one character
--------------------------------------------------------------------------------
Esc+K    |    D     |  Deltes forward to end of line
--------------------------------------------------------------------------------
Esc+.    |  Esc+_   |  Inserts last word of previous command
--------------------------------------------------------------------------------

After you've mastered these command, check out the man pages (enter man bash or man ksh) for additional editing commands.


--Ok kiddies, time to go to bed, i'll pick back up in the morning--
--Ok lil boys and girls, im ready to go once again--


-Standard environment variables
 Environment variables are ued to set your working environment.  You change their values to change their default environment.  You may also want to add new variables that your own programs use.
_______________________________________________________________________________________________
Variable      |     Function
-----------------------------------------------------------------------------------------------
DISPLAY       |  Display location (for the X windows system)
-----------------------------------------------------------------------------------------------
HOME          |  Path to your home directory
-----------------------------------------------------------------------------------------------
HOSTNAME      |  Name of this computer system
-----------------------------------------------------------------------------------------------
LOGNAME       |  Your login name
-----------------------------------------------------------------------------------------------
MAIL          |  Path to your e-mail file
-----------------------------------------------------------------------------------------------
PATH          |  Command search path, colon separate list. ex:               
              |  /bin:/usr/bin:/usr/local/bin/~/bin
-----------------------------------------------------------------------------------------------
SHELL         |  Path to default shell
-----------------------------------------------------------------------------------------------
TERM          |  Terminal type
-----------------------------------------------------------------------------------------------

Say that you want to create a new environment variable called 133t and set it to be equal to the directory path where you keep all your good files.  Then you can referencethis directory and time you want to copy or access a file in that directory.

THe following commands she the variables and then list the file "super" from that directory useing the "less" command. Placing the "export" command i your ".profile" file makes "133t" available every time you log on.

export 133t=/home/tofu/Good-files
less $133t:feer.txt

To add a new directory to your current search path, enter: Path=$Path:newdir

The command adds a new directory named newdir to the nect of the path (last directory to be searched)

Directory Naming Conventions
----------------------------

A popualr practice is to name directories with a leading capital letter 
(for example, "Correspondence" or "secret").  This wat, all directories displayed together in a file list (ls) and are easily identifies.

If you are unsure which enties in a list are directories, type: ls -F  and press enter. A/  is displayed at the end of any directory.


Directory Referencing
---------------------

A reliable way to access a file in your home directory (or one of its branches) is ti use a title (~).  It acts as an abbreviation for ths path to your home directory.  For example, if your current directory is not your dome directory but you want to get a list of the files in your home directory, you can type: ls ~  and an alternative to: ls /home/133t.

You can also follow the tilde with a user name (such as ~red) to access information in the directory of a user name "red".  For example, to change your current directory to a directory name 133t that is in the home of a user whos login name is red, type:  cd ~red/133t.


Files Associated with a Program
-------------------------------

Whenever you start any program, three files are associated with the program.  In Linux speak, these files are referred to as:

*stdin - For standard input
*stdout - For standard output
*stderr - For standard error

-Redirecting the files

The files associated with a program are all initially associated with both your keyboard and display, but you can also connect the files to other files and programs.  THe following table lists characters you can use to redirect the files.

________________________________________________________________________________________________
Redirection Character   |  What it does
------------------------------------------------------------------------------------------------
>                       |  Redirects the output of the command to a file or device.
------------------------------------------------------------------------------------------------
>>                      |  Acts like >, but if the file alteady exists, appends the new data to                                                                                               				|  the end of and existing file.  If the file does not exist, it is                                                                                                   				|  created
------------------------------------------------------------------------------------------------
2>                      |  Redirects the error output (also called "stderr) of the command to a                                                                                               				|  file or device. (error output is a second output fule available to                                                                                                 				|  every program.  The Program itself decides which output to write to:                                                                                               				|  stout and which to: stderr.)
------------------------------------------------------------------------------------------------
<                       |  Redirects the input of the command from a file or device
------------------------------------------------------------------------------------------------
|                       |  Joins two imple commands so that they work together in a more useful                                                                                                                      	|  way.
------------------------------------------------------------------------------------------------


-Connecting commands

Many commands can read from standard inut and write to standard output.  Linux calls commands that can do this "filters".  The name comes from the fact that they are filtering whatever comes in to prodeuce whatever is supposed to come out.

Filters allow commands to connect to other commands though pipes or to become part of a pipeline.  When using the pipe character (|) with two commandsm the pope connects the output of the left-hand command to the input of the right-hand command.  For example:  ls -la | less   
pipes the output of the file list command (ls) into the input of the "less" command, which alloes you ro scrill back and forth though the file listing.

System resources present the only limitation on how many commands can be connected together in this way.  For example, the "grep" command is a filter.  It can read standard out putm apply some selection criteria to the input, and then send the selected information to standard output.  The filliwung pipeline can run the program "monthly", filter its output though "grep" (in this case, looking for lines with the word "super" in them), and display the seleted lines on the screen.

monthly | grep super



-Redirecting command output
 
The > operator is used to reditect the output of a command to a file or device.  For example, to cause the output of the program "monthly" to be redirected to a new file called "monthly.output", you would enter the command:

monthly > monthky.output

If "monthly.output" does not exist, >> acts just like > and creates a new file name. 

The filename " /dev/tty " is a special name that always points at your screen.  If you write a shell script in which you want the output of one command to come back to the screen no matter where "stdout" and "stderr" are redirected, redirect that command's output to " /dev/tty ".



-Redirecting command input

To indicate that the input for a command is to come from a file rather than your keyboard, you use the < operator.  For example, to run a program named 133t and have it read from the file "input.data", use:

133t < input.data

You can combine input redirection with other redirection.  To run monthly with its input comming from "input.data", its output sent to "133t.output" and its error output comming bck to the screen (pretty typical situation), use:

133t <input.data> 133t.errors


-Redirecting error messages

If you wnat to redirect the error message from a program to a file use the 2> operator.  for example, if you want the error messages from program 133t to be sent to 133t.errors, use:

133t 2> 133t.errors

You can redirect both "stderr" and "stdout" to different places.  For example, to append the standard output of 133t to "133t.output" and send the error messages to "133t.errors" use:

133t >> 133t.output 2> 133t.errors

If you want to run a command and redirect both "stdout" and "sterr", you need to use the command " 2>&1 ", which means, essentially, "redirect output stream 2 to the same place as output stream 1." For example the "stdout" and the "stderr" of 133t to 133t.both, you would use:
 
133t >133t.both 2>&1 


--Cigarette Break--



File Naming Conventions
-----------------------

Linux does not impose any structure on the name of a file, other than prohibiting the use of a slash  character (/) in a filename, and requiring the length of the filename to be fewer that 256 characters.  Although this state of anarchy may sound desirable to some, you should follow certian file-naming conventions to keep yourself out of trouble. When in doubt, keep filenames simple.

In Linux, filenames are case-sensitive.  The file "redemption" is different from "Redemption", "REDEMPTION", or "ReDeMpTiOn".  These three files name all life happily together in the same directory.

Some special characters, which are technically legal to use in a filename, may get you into trouble decause of their other meanings.  The following table offers "better safe than sorry" choices for filename characters.

______________________________________________________________________________________________
Lowercase letters   |  Always safe to use
----------------------------------------------------------------------------------------------
Uppercase letters   |  Always safe to use, but many people reserv then for directory names
----------------------------------------------------------------------------------------------
Numbers             |  Always safe to use
----------------------------------------------------------------------------------------------
Underscores (_)     |  Always safe to use. (They make good word separators)
----------------------------------------------------------------------------------------------
Hyphens             |  Dont use as a first chatacter
----------------------------------------------------------------------------------------------
Commas              |  Always safe to use
----------------------------------------------------------------------------------------------
Periods             |  Always safe to use
----------------------------------------------------------------------------------------------

Linux/Unix uses whitespace as an argument separator.  Dont use spaces in filenames


Pathnames
---------

A files pathname consists of the files full name, starting at the root of the file tree.  Therefore, if your home directory is /home/tofu, and you have a subdirectory called Secret, and pathname of "love.letters" would be /home/t0f0/Secret/love.letters.  This fule is totalle distinct from a file with a similat name in a different directory, such as /home/red/Secret/love.letters or /home tofo/Correspondence/love.letters


Shell Command Elements
----------------------

When you want to instruct the shell to perform a task, you need to pass it a whole set ot information.  The basic elements or a shell command are the following:

*The name of the command to run
*Any command-line that you want to use
*Any arguments require by the command
*Instructions on how to handel the input and output data streams
*Whether the command should run in its own shell, that is, "&"

For instance, heres an example of a shell command:
diff -i first secont > result

*"diff", is the name of the command that you are asking th shell to run
*"-i" is and option, it must be generally appear between the command name and the arguments
*"first" is the first argument
*"second" is the second argument
*">" is a redirection operator
*"result" is the name of the file where the command output is redirected.
*Each of these items is commonly called a "word",  The words of the shell command are separated   by "whitespace, which is defined as one or more space ot tab characters.

The most basic command consists of only a command name.  For example, to display the current date, type: date and press Enter.

Most shells interpret the redirection operator first, and then parse the other command parameters.  For that reason, a line consisting only the output redirection and file name (for example >Iron_133t) creats an empty file called "Iron_133t.

Some commands need arguments to operate. For example, if you wabt to edit a text file with vi, you need to tellthe editor the name of the file.  Thus, VI myfile starts up the editor and tells it to open a file named myfile.

The third type of information that is passwd to a command is a command-line option.  Options modify the operation of a command.  For examply, "ls" lists the files in your current directory, but it does not display file with names begging with a dot. (These are know as hidden files)  The -a option (ls -a) instructs ls to include in the optput thoes that have filenames starting with a dot.

--Cigarette Break--


Shell Variables
---------------

Shell variables are local place for your shell to store infomation. For example, the shel variable "HOME" is set to the pathname of you login directory.  In Bash and ksh, you can set shell variables is that environment variables by the use of the "export" statement.

The difference between shell variables and environment variables is that the environment variables are available to the shells that you start up later.  Shell variables are available to the shell that you start up later,  Shell variables are available to the shell that you start up later.  Shell variables, on the other hand, are used only in the shell in which they were created.  Shell variables are identified by placing a $ (dollar sign) in front of the variable name.

The following sequence sets the shell variable "Iron" to the value "133t".  The second line exports the shell variable to an environment variable.  The third line then displays the environment variable useing the "echo" command.

Iron=133t
export Iron
echo Iron is $l33t

*If your login shell is Bash, zsh, or ksh, then the environment varibles in ~/.profile are used every time you log in.
*The .bashrc file contains environment variables that are used as the defaul settings for the Bash shell.
*The equivalent files for csh and tcsh are .login and .cshrc.

The following table shows the standard shell variables:
______________________________________________________________________________________________
Shell variable     |    What it means
----------------------------------------------------------------------------------------------
$?                 |  Return status of last command 
----------------------------------------------------------------------------------------------
HOME               |  Pathname of your home dircetory
----------------------------------------------------------------------------------------------
MAIL               |  Name of the fule to check for incomming mail
----------------------------------------------------------------------------------------------
OLDPWD             |  Pathname of current directory before previous "cd" command
----------------------------------------------------------------------------------------------
PWD                |  Your current directory
----------------------------------------------------------------------------------------------
SHELL              | Path name of your shell
----------------------------------------------------------------------------------------------

Many common shell variables are available.  Type "set" to see your current variables and theit assigned values.


Special Characters
------------------

Many chatacters have specual meanings to the shell.  The characters and their meanings vary from shell to shell and system to system.  Use the documentation on your shell and the "stty" command to verify these chatacters.  The following list offers codeexamples showing the proper way to use the "stty" command.  The table that follows the list provies likely default meanings for some keyboard entries and characters.

*To display all your current terminal settings, type "stty -a"
*To change a "stty" mode that is either true or false, type "stty" followed by the name of the  mode to turn it on.  To turn a mode off, precede the name with a "-". For example, to turn off  the "opost" mode, type "stty -opost".
*To change the value of a setting, type "stty name value".  For  example, to change the erase command to Control+H, you would type "stty erase" then press Crtl+H.

______________________________________________________________________________________________
Special Entry       |     What it does
----------------------------------------------------------------------------------------------
Enter		        |  Tells the shell that your command isread to be processed.
----------------------------------------------------------------------------------------------
Spacebar or tab     |  Separates words in commands.
----------------------------------------------------------------------------------------------
Backspace or Delete |  Either key deletes the most recently type character. 
----------------------------------------------------------------------------------------------
;                   |  Allows you to enter multiple commands on the same line.
----------------------------------------------------------------------------------------------
&                   |  Starts the command in the line preceding the & in the background.
----------------------------------------------------------------------------------------------
|                   |  Connects the standard output of the command on the left to the right.
----------------------------------------------------------------------------------------------
!                   |  Denotes a history reference (in Bash and tcsh only).
----------------------------------------------------------------------------------------------
#                   |  Comment.  The remainder of the line is ignored by the shell.
----------------------------------------------------------------------------------------------
\                   |  Takes away the special meaning of a special character that follows it.
----------------------------------------------------------------------------------------------
'                   |  Disables the special meaning of characters enclosed in singe quotation.
----------------------------------------------------------------------------------------------
"                   |  Disables the special meaning of chatacters enclosed in doubble quote's.
----------------------------------------------------------------------------------------------
`                   |  Executes what's in the quoted string
----------------------------------------------------------------------------------------------
$                   |  Introduces a reference to a shell variable.
----------------------------------------------------------------------------------------------
*                   |  Matches any number of characters
----------------------------------------------------------------------------------------------
?                   |  Matches a single chatacter
----------------------------------------------------------------------------------------------
[ ]                 |  Matches any single chatacter contained within the brackets
----------------------------------------------------------------------------------------------
Ctrl+C              |  Sents an interrupt signal to a running program
----------------------------------------------------------------------------------------------
Ctrl+D              |  Sends an eng of file to the program currently reading from the keyboard
----------------------------------------------------------------------------------------------
Ctrl+U              |  Cancels the line that you are entering and allows you to start over
----------------------------------------------------------------------------------------------
Ctrl+Z              |  Pauses the current program
----------------------------------------------------------------------------------------------


--Cigarette Break--


Startup Files
-------------

Most startup or configuration files are located at your home directory directory and have names that start with a dot (.).  Bash has teo main coniguration files:

_________________________________________________________
Startup File    |       When Bash Reads It
---------------------------------------------------------
.bash_profile   |  At login time
---------------------------------------------------------
.bashrc         |  Each time a new shell is started
---------------------------------------------------------

You can force Bash or ksh to read a file and interpret it by useing the . (dot) command.  For example, you may have some shell variables that you want to set when you are working on a special project.  Use your editor to put the commans in a file, name the file ".special", and then enter the following command:

. .special

The shell then interprets the file ans sets the variables.

The following table shows setup files for both the Bash and Korn shells.

______________________________________________________________________________________________
Bash                       |            Korn            |                Function         
----------------------------------------------------------------------------------------------
/ect/profile               |        /etc/profile        |        Executed at login time
----------------------------------------------------------------------------------------------
$HOME/.profile             |       $HOME/.profile       |        Executed at login time
----------------------------------------------------------------------------------------------
$HOME/.bashrc              |                            |        Executed at shell startup
----------------------------------------------------------------------------------------------
$HOME/.bash_logout         |                            |        Executed at logout
----------------------------------------------------------------------------------------------


Well I had fun.  Only took me about 24 hours, and a pack of cigarettes!
In closing: Have fun, but be careful. I am not held responsible for any misuse of any information displayed here, and if you accidentally mess up your stuff, im not responsible either.

Greets to: 
http://www.sekurity-net.com
http://www.legion2000.org
http://www.hcvorg.com
http://www.kracked.com

Flames to:
http://www.hackcity.com
http://www.cyberarmy.com
http://www.2600.com (Burn Kevin!)

Thanks,
-Redemption
(12/27/98)



TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH