home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / linuxdipshit.txt < prev    next >
Encoding:
Text File  |  1999-03-24  |  38.2 KB  |  596 lines

  1.  ________________                              ----------         \     /
  2. /                \________    |      |             |               \   /
  3. |                |            |      |             |                \_/      |-----
  4. |                |-------     |      |             |                 |       |    
  5. \_______________ |________    |      |             |                 |       |-----    
  6.                 \         \   |------|         ____|_____            |       | 
  7.                 |         |  /        \_______/          \___________/       |_____             
  8.                 |         | /          |      |                |     \      /      \
  9. ________________/         |/           |      |                |     |\    |        --------
  10.                           |\           |------|                |     | \   |           |
  11.                           | \          | \                     |     |  \  |           |
  12.                           |  \         |  \                    |     |   \ |           |
  13.                                            \                   |     |    \|           |
  14. ____________________________________        \                                          |
  15. | Text: Linux For Dipshit's        |
  16. | Lesson: Understanding The Shell  | 
  17. | By: Redemption                   | 
  18. | webmaster@sekurity-net.com       |
  19. | http://www.sekurity-net.com      |
  20. ------------------------------------
  21. 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.
  22.  
  23. 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.
  24.  
  25. In this text we are going to talk about:
  26. -Picking the shell thats best for you
  27. -Getting programs to read and write files
  28. -Connecting the output of one program to the input of another
  29. -Using puotation marks to contrl the interpretation or your input
  30. -Customizing your environment
  31. -Getting familiar with shell conventions
  32. -Examining special characters and what they do
  33.  
  34. Here we go.....
  35.  
  36.  
  37.  
  38. Available Shells
  39. ----------------
  40.  
  41. 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)
  42.  
  43. 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.
  44.  
  45.  
  46. Basic Directory Commands
  47. ------------------------
  48.  
  49. Use the followin commands to perform basic managment tasks:
  50. - cd <dirname>: To change your current directory
  51. - mkdir <dirname>: To create a directory
  52. - rmdir <dirname>: To remove an empty directory
  53. - pwd: To find out which direcory you're in
  54.  
  55. 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.
  56.  
  57. --Cigarette Break--
  58.  
  59.  
  60. Character Quoting
  61. -----------------
  62.  
  63. 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.
  64.  
  65. -Quoting an individual character
  66. 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 *\**
  67. 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.
  68.  
  69. You can doubble and single quotation marks (" and ') to quote whole strings.  Their meaning is somewhat different.
  70. -Single quotation marks quote almost everything.
  71. -Doubble quotation marks allow the shell to interpret works that start with a ($), which are commonly known as "shell variable references"
  72. -You can use a sigle quotation mark to turn off the special meaning of a double uotation mark, and vice versa.
  73.  
  74. 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.
  75.  
  76. grep "it's my money" junkfile"
  77.  
  78.  
  79.  
  80. Using the back-quote character
  81. ------------------------------
  82.  
  83. 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.
  84.  
  85. echo Damn, today is 'date' we will hack r00t to 3 servers soon
  86.  
  87. 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. 
  88. (The following code shows the input lines in quotations)
  89.  
  90. "date"
  91. Fri Jul 10 09:30:8 PDT 1998 
  92. "echo Damn, today is 'date' we will hack r00t to 3 servers soon"
  93. today is Fri Jul 10 09:30:8 PDT 1998 we will hack r00t to 3 servers soon
  94.  
  95.  
  96. Command History
  97. ---------------
  98.  
  99. 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.
  100.  
  101. 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.
  102.  
  103.  
  104. -Setting command history mode
  105.  
  106. How you edit recent commands depends on whether you shell is set to vi mode or Emacs mode.
  107. *For vi mode, type set -o vi and press Enter
  108. *For Emacs mode, type set -o emaces and press Enter
  109.  
  110.  
  111. -Using Emacs mode
  112.  
  113. 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. 
  114.  
  115.  
  116. -Using vi mode
  117.  
  118. 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.
  119.  
  120. --Cigarette Break--
  121.  
  122.  
  123. Customizing the Environment
  124. ---------------------------
  125.  
  126. 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.
  127.  
  128.  
  129.  
  130. Creation shell aliases
  131. ----------------------
  132.  
  133. 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.
  134.  
  135. alias [name[=command]]
  136.  
  137. _______________________________________________________________________________________________
  138. Argument  |   Function
  139. -----------------------------------------------------------------------------------------------
  140. name      | The name of the alias, if not specified "alias" lists all your current aliases  
  141. -----------------------------------------------------------------------------------------------
  142. command   |Command string assigned to the alias. if "command" contains any spaces or special                                         |characters, it must be quoted
  143. -----------------------------------------------------------------------------------------------
  144.  
  145. 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.
  146.  
  147. alias lpsoy='lpr -P soy'
  148.  
  149. 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"
  150.  
  151. You can use the "unalias" command to delete a shell alias.  For example, to delete you alias "lpsoy" type "unalias lpsoy"
  152.  
  153.  
  154. -Displaying environment variables
  155.  
  156. 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.
  157.  
  158. echo $var
  159.  
  160. _____________________________________________________________________________
  161. Option or Argument   |    Function
  162. -----------------------------------------------------------------------------
  163. var                  | Name of the environment (or shell) variable to display
  164. -----------------------------------------------------------------------------
  165.  
  166. 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.
  167. 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.
  168.  
  169. export 133t_ADDRESSES=~/Addr/haxx0rs
  170. export RECIPES=~/Recipes/133t
  171.  
  172.  
  173. -Setting environment variables
  174.  
  175. 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.
  176.  
  177. export var=value
  178. (or)
  179. var=value
  180. export var
  181.  
  182. 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.
  183.  
  184. _______________________________________________________________________________________________
  185. Option or Argument   |   Function
  186. -----------------------------------------------------------------------------------------------
  187. var                  | Name of the variable to set.
  188. -----------------------------------------------------------------------------------------------
  189. 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
  190. -----------------------------------------------------------------------------------------------
  191.  
  192. 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".
  193.  
  194.  
  195. -Setting shell edit modes
  196.  
  197. 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.
  198.  
  199. To set the shell mode to vi, use the following command: set -o vi
  200. To set the shell mode to Emacs, use this command: set -o emacs
  201.  
  202. You can place either of these commands in your ".profile" file so that the mode will be automatically set at login time.
  203.  
  204. 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.
  205.  
  206. ________________________________________________________________________________
  207. (Emacs)  |   (vi)   |    (Function)
  208. --------------------------------------------------------------------------------
  209. Ctrl+P   |    K     |  Moves back one command in your history list
  210. --------------------------------------------------------------------------------
  211. Ctrl+N   |    J     |  Moves forward one line in your history list
  212. --------------------------------------------------------------------------------
  213. Ctrl+B   |    H     |  Moves back one character in the displayed command line
  214. --------------------------------------------------------------------------------
  215. Ctrl+F   |    L     |  Moves forward one character in the displayed command line
  216. --------------------------------------------------------------------------------
  217. Esc+B    |    b     |  Moves back one word
  218. --------------------------------------------------------------------------------
  219. Esc+F    |    *     |  Moves forward one word
  220. --------------------------------------------------------------------------------
  221. Crtl+A   |    0     |  Moves to beginning of line
  222. --------------------------------------------------------------------------------
  223. Ctrl+E   |    $     |  Moves to the end of line
  224. --------------------------------------------------------------------------------
  225.          |    i     |  Enter insert mode
  226. --------------------------------------------------------------------------------
  227.          |   Esc    |  Exit insert mode
  228. --------------------------------------------------------------------------------
  229.          |    a     |  Appends to line
  230. --------------------------------------------------------------------------------
  231. Esc+Del  |    X     |  Deletes backward one character
  232. --------------------------------------------------------------------------------
  233. Ctrl+D   |    x     |  Deletes forward one character
  234. --------------------------------------------------------------------------------
  235. Esc+D    |    dw    |  Delete forward one character
  236. --------------------------------------------------------------------------------
  237. Esc+K    |    D     |  Deltes forward to end of line
  238. --------------------------------------------------------------------------------
  239. Esc+.    |  Esc+_   |  Inserts last word of previous command
  240. --------------------------------------------------------------------------------
  241.  
  242. After you've mastered these command, check out the man pages (enter man bash or man ksh) for additional editing commands.
  243.  
  244.  
  245. --Ok kiddies, time to go to bed, i'll pick back up in the morning--
  246. --Ok lil boys and girls, im ready to go once again--
  247.  
  248.  
  249. -Standard environment variables
  250.  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.
  251. _______________________________________________________________________________________________
  252. Variable      |     Function
  253. -----------------------------------------------------------------------------------------------
  254. DISPLAY       |  Display location (for the X windows system)
  255. -----------------------------------------------------------------------------------------------
  256. HOME          |  Path to your home directory
  257. -----------------------------------------------------------------------------------------------
  258. HOSTNAME      |  Name of this computer system
  259. -----------------------------------------------------------------------------------------------
  260. LOGNAME       |  Your login name
  261. -----------------------------------------------------------------------------------------------
  262. MAIL          |  Path to your e-mail file
  263. -----------------------------------------------------------------------------------------------
  264. PATH          |  Command search path, colon separate list. ex:               
  265.               |  /bin:/usr/bin:/usr/local/bin/~/bin
  266. -----------------------------------------------------------------------------------------------
  267. SHELL         |  Path to default shell
  268. -----------------------------------------------------------------------------------------------
  269. TERM          |  Terminal type
  270. -----------------------------------------------------------------------------------------------
  271.  
  272. 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.
  273.  
  274. 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.
  275.  
  276. export 133t=/home/tofu/Good-files
  277. less $133t:feer.txt
  278.  
  279. To add a new directory to your current search path, enter: Path=$Path:newdir
  280.  
  281. The command adds a new directory named newdir to the nect of the path (last directory to be searched)
  282.  
  283. Directory Naming Conventions
  284. ----------------------------
  285.  
  286. A popualr practice is to name directories with a leading capital letter 
  287. (for example, "Correspondence" or "secret").  This wat, all directories displayed together in a file list (ls) and are easily identifies.
  288.  
  289. 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.
  290.  
  291.  
  292. Directory Referencing
  293. ---------------------
  294.  
  295. 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.
  296.  
  297. 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.
  298.  
  299.  
  300. Files Associated with a Program
  301. -------------------------------
  302.  
  303. Whenever you start any program, three files are associated with the program.  In Linux speak, these files are referred to as:
  304.  
  305. *stdin - For standard input
  306. *stdout - For standard output
  307. *stderr - For standard error
  308.  
  309. -Redirecting the files
  310.  
  311. 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.
  312.  
  313. ________________________________________________________________________________________________
  314. Redirection Character   |  What it does
  315. ------------------------------------------------------------------------------------------------
  316. >                       |  Redirects the output of the command to a file or device.
  317. ------------------------------------------------------------------------------------------------
  318. >>                      |  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
  319. ------------------------------------------------------------------------------------------------
  320. 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.)
  321. ------------------------------------------------------------------------------------------------
  322. <                       |  Redirects the input of the command from a file or device
  323. ------------------------------------------------------------------------------------------------
  324. |                       |  Joins two imple commands so that they work together in a more useful                                                                                                                          |  way.
  325. ------------------------------------------------------------------------------------------------
  326.  
  327.  
  328. -Connecting commands
  329.  
  330. 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.
  331.  
  332. 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   
  333. 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.
  334.  
  335. 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.
  336.  
  337. monthly | grep super
  338.  
  339.  
  340.  
  341. -Redirecting command output
  342.  
  343. 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:
  344.  
  345. monthly > monthky.output
  346.  
  347. If "monthly.output" does not exist, >> acts just like > and creates a new file name. 
  348.  
  349. 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 ".
  350.  
  351.  
  352.  
  353. -Redirecting command input
  354.  
  355. 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:
  356.  
  357. 133t < input.data
  358.  
  359. 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:
  360.  
  361. 133t <input.data> 133t.errors
  362.  
  363.  
  364. -Redirecting error messages
  365.  
  366. 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:
  367.  
  368. 133t 2> 133t.errors
  369.  
  370. 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:
  371.  
  372. 133t >> 133t.output 2> 133t.errors
  373.  
  374. 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:
  375.  
  376. 133t >133t.both 2>&1 
  377.  
  378.  
  379. --Cigarette Break--
  380.  
  381.  
  382.  
  383. File Naming Conventions
  384. -----------------------
  385.  
  386. 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.
  387.  
  388. 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.
  389.  
  390. 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.
  391.  
  392. ______________________________________________________________________________________________
  393. Lowercase letters   |  Always safe to use
  394. ----------------------------------------------------------------------------------------------
  395. Uppercase letters   |  Always safe to use, but many people reserv then for directory names
  396. ----------------------------------------------------------------------------------------------
  397. Numbers             |  Always safe to use
  398. ----------------------------------------------------------------------------------------------
  399. Underscores (_)     |  Always safe to use. (They make good word separators)
  400. ----------------------------------------------------------------------------------------------
  401. Hyphens             |  Dont use as a first chatacter
  402. ----------------------------------------------------------------------------------------------
  403. Commas              |  Always safe to use
  404. ----------------------------------------------------------------------------------------------
  405. Periods             |  Always safe to use
  406. ----------------------------------------------------------------------------------------------
  407.  
  408. Linux/Unix uses whitespace as an argument separator.  Dont use spaces in filenames
  409.  
  410.  
  411. Pathnames
  412. ---------
  413.  
  414. 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
  415.  
  416.  
  417. Shell Command Elements
  418. ----------------------
  419.  
  420. 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:
  421.  
  422. *The name of the command to run
  423. *Any command-line that you want to use
  424. *Any arguments require by the command
  425. *Instructions on how to handel the input and output data streams
  426. *Whether the command should run in its own shell, that is, "&"
  427.  
  428. For instance, heres an example of a shell command:
  429. diff -i first secont > result
  430.  
  431. *"diff", is the name of the command that you are asking th shell to run
  432. *"-i" is and option, it must be generally appear between the command name and the arguments
  433. *"first" is the first argument
  434. *"second" is the second argument
  435. *">" is a redirection operator
  436. *"result" is the name of the file where the command output is redirected.
  437. *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.
  438.  
  439. The most basic command consists of only a command name.  For example, to display the current date, type: date and press Enter.
  440.  
  441. 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.
  442.  
  443. 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.
  444.  
  445. 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.
  446.  
  447. --Cigarette Break--
  448.  
  449.  
  450. Shell Variables
  451. ---------------
  452.  
  453. 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.
  454.  
  455. 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.
  456.  
  457. 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.
  458.  
  459. Iron=133t
  460. export Iron
  461. echo Iron is $l33t
  462.  
  463. *If your login shell is Bash, zsh, or ksh, then the environment varibles in ~/.profile are used every time you log in.
  464. *The .bashrc file contains environment variables that are used as the defaul settings for the Bash shell.
  465. *The equivalent files for csh and tcsh are .login and .cshrc.
  466.  
  467. The following table shows the standard shell variables:
  468. ______________________________________________________________________________________________
  469. Shell variable     |    What it means
  470. ----------------------------------------------------------------------------------------------
  471. $?                 |  Return status of last command 
  472. ----------------------------------------------------------------------------------------------
  473. HOME               |  Pathname of your home dircetory
  474. ----------------------------------------------------------------------------------------------
  475. MAIL               |  Name of the fule to check for incomming mail
  476. ----------------------------------------------------------------------------------------------
  477. OLDPWD             |  Pathname of current directory before previous "cd" command
  478. ----------------------------------------------------------------------------------------------
  479. PWD                |  Your current directory
  480. ----------------------------------------------------------------------------------------------
  481. SHELL              | Path name of your shell
  482. ----------------------------------------------------------------------------------------------
  483.  
  484. Many common shell variables are available.  Type "set" to see your current variables and theit assigned values.
  485.  
  486.  
  487. Special Characters
  488. ------------------
  489.  
  490. 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.
  491.  
  492. *To display all your current terminal settings, type "stty -a"
  493. *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".
  494. *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.
  495.  
  496. ______________________________________________________________________________________________
  497. Special Entry       |     What it does
  498. ----------------------------------------------------------------------------------------------
  499. Enter                |  Tells the shell that your command isread to be processed.
  500. ----------------------------------------------------------------------------------------------
  501. Spacebar or tab     |  Separates words in commands.
  502. ----------------------------------------------------------------------------------------------
  503. Backspace or Delete |  Either key deletes the most recently type character. 
  504. ----------------------------------------------------------------------------------------------
  505. ;                   |  Allows you to enter multiple commands on the same line.
  506. ----------------------------------------------------------------------------------------------
  507. &                   |  Starts the command in the line preceding the & in the background.
  508. ----------------------------------------------------------------------------------------------
  509. |                   |  Connects the standard output of the command on the left to the right.
  510. ----------------------------------------------------------------------------------------------
  511. !                   |  Denotes a history reference (in Bash and tcsh only).
  512. ----------------------------------------------------------------------------------------------
  513. #                   |  Comment.  The remainder of the line is ignored by the shell.
  514. ----------------------------------------------------------------------------------------------
  515. \                   |  Takes away the special meaning of a special character that follows it.
  516. ----------------------------------------------------------------------------------------------
  517. '                   |  Disables the special meaning of characters enclosed in singe quotation.
  518. ----------------------------------------------------------------------------------------------
  519. "                   |  Disables the special meaning of chatacters enclosed in doubble quote's.
  520. ----------------------------------------------------------------------------------------------
  521. `                   |  Executes what's in the quoted string
  522. ----------------------------------------------------------------------------------------------
  523. $                   |  Introduces a reference to a shell variable.
  524. ----------------------------------------------------------------------------------------------
  525. *                   |  Matches any number of characters
  526. ----------------------------------------------------------------------------------------------
  527. ?                   |  Matches a single chatacter
  528. ----------------------------------------------------------------------------------------------
  529. [ ]                 |  Matches any single chatacter contained within the brackets
  530. ----------------------------------------------------------------------------------------------
  531. Ctrl+C              |  Sents an interrupt signal to a running program
  532. ----------------------------------------------------------------------------------------------
  533. Ctrl+D              |  Sends an eng of file to the program currently reading from the keyboard
  534. ----------------------------------------------------------------------------------------------
  535. Ctrl+U              |  Cancels the line that you are entering and allows you to start over
  536. ----------------------------------------------------------------------------------------------
  537. Ctrl+Z              |  Pauses the current program
  538. ----------------------------------------------------------------------------------------------
  539.  
  540.  
  541. --Cigarette Break--
  542.  
  543.  
  544. Startup Files
  545. -------------
  546.  
  547. 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:
  548.  
  549. _________________________________________________________
  550. Startup File    |       When Bash Reads It
  551. ---------------------------------------------------------
  552. .bash_profile   |  At login time
  553. ---------------------------------------------------------
  554. .bashrc         |  Each time a new shell is started
  555. ---------------------------------------------------------
  556.  
  557. 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:
  558.  
  559. . .special
  560.  
  561. The shell then interprets the file ans sets the variables.
  562.  
  563. The following table shows setup files for both the Bash and Korn shells.
  564.  
  565. ______________________________________________________________________________________________
  566. Bash                       |            Korn            |                Function         
  567. ----------------------------------------------------------------------------------------------
  568. /ect/profile               |        /etc/profile        |        Executed at login time
  569. ----------------------------------------------------------------------------------------------
  570. $HOME/.profile             |       $HOME/.profile       |        Executed at login time
  571. ----------------------------------------------------------------------------------------------
  572. $HOME/.bashrc              |                            |        Executed at shell startup
  573. ----------------------------------------------------------------------------------------------
  574. $HOME/.bash_logout         |                            |        Executed at logout
  575. ----------------------------------------------------------------------------------------------
  576.  
  577.  
  578. Well I had fun.  Only took me about 24 hours, and a pack of cigarettes!
  579. 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.
  580.  
  581. Greets to: 
  582. http://www.sekurity-net.com
  583. http://www.legion2000.org
  584. http://www.hcvorg.com
  585. http://www.kracked.com
  586.  
  587. Flames to:
  588. http://www.hackcity.com
  589. http://www.cyberarmy.com
  590. http://www.2600.com (Burn Kevin!)
  591.  
  592. Thanks,
  593. -Redemption
  594. (12/27/98)
  595.  
  596.