Bash tutorial

11 - Basics of the common UNIX and Linux text editors

===============================================================================
11 - Basics of the common UNIX and Linux text editors.
===============================================================================

Here we go with the text editors vi, ed and emacs.
ed is just explained for historical reasons.

-------------------------------------------------------------------------------
                       Most commonly used VI commands
-------------------------------------------------------------------------------

Here we go with the vi commands, these are unlogical but still good to know
because all computers doesn't have emacs, joe, pico and so on.
Solaris / SunOS comes default with vi as only text editor.
Vi has 2 basic modes, command mode and edit mode, you change between them
by pressing the Esc button, and to start to edit a file you must have a
free line, which you get by pressing, Esc followed by `o`.
vi is bound to be the hardest and most confusing text editor to learn,
and it has LOTS of commands, I included just a few of the most used
commands.

So here we go with the vi commands:

Inserting text

esc + i                 insert text informant of the cursor
esc + a                 append text after the existing text
esc + O                 opens new line above the current line
esc + o                 opens new line under current line (insert mode)

Deleting text

esc + x                 deletes one character
esc + 5x                deletes five charters
esc + dw                deletes a word
esc + 5dw               deletes five words
esc + dd                deletes the whole line
esc + D			deletes the line from cursor and forward
esc + d)                deletes the sentence from cursor and forward
esc + d(                deletes the sentence from cursor and backwards
esc + u                 undelete

Note: esc + d) or d( removes the sentence from cursor and forward/backwards
until it reaches a dot "."

Moving around in VI:

Make sure you are in command mode and the following letters will do:

j               moves you down
k               moves you up
h               moves you left
l               moves you right

(more...)

10 - Other Frequently asked questions with answers

===============================================================================
10 - Other Frequently asked questions with answers.
===============================================================================

Q: How can I play an .au file ?
A: The file suffix .au means it's an audio file, so you can either do
   the same as for mp3's: mpg123 file.au
   or you can (since .au files are raw audio): cat file.au > /dev/dsp
   or: cat file.au > /dev/audio

Q: What exactly is bash ?
A: If you have read this tutorial you would know ... it's a shell type.

Q: I wanna make some sub-directory's to /usr/local/ but I'm to lazy to write
   almost the same line over and over again, is there any easier way ?
A: Yes there is: mkdir /usr/local/{dir1,dir2,dir3}

Q: I have a dir with files like this: file.1 file.2 file.3 etc.
   is there any way I can list say, file.3, file.4, file.6, file.9 only
   without using grep ?
A: Yes there is: ls file*[3469]*

Q: I want to remove some files with wildcards included in the command
   (rm -rf .??*), is there any way I can see what the command will remove
   before I actually do the command ?
A: Yes there is: echo rm -rf .??*

Q: How can I remove file names that are/have special characters like a file
   named:  -!?* !!?
A: Do this: rm ./-!?* !!?
   The ./ makes sure it will look in the current directory, and the
   (back slashes) will make sure that the special characters special meaning
   is over looked, so they are treated just like any other character.

Q: I accidently deleted something on my system, is there any way
   of getting it back ?
A: Yes there is, read this file /usr/doc/HOWTO/mini/Ext2fs-Undeletion
   (or /usr/doc/HOWTO/mini/Ext2fs-Undeletion.gz)
   This is also good knowledge if someone *hacks* your system
   and think they are safe just because they deleted the logs.
   Or you can download a program called 'recover' from www.freshmeat.net

Q: How do I compile my kernel ?
A: Read this file:  /usr/doc/HOWTO/Kernel-HOWTO

(more...)

9.5 - Basic Linux/Unix commands and operation continued


ls
  this is the most basic of all basic commands to know.
  ls lists the contents of a directory, if you type just `ls`
  it will list the contents of the current directory, but it can also
  be used as `ls /way/to/some/other/dir/` to list the contents of
  some other directory, ls has alot of arguments which are:
  -a, --all
  do not hide entries starting with .
  -A, --almost-all
  do not list implied . and .. 

  -b, --escape
  print octal escapes for nongraphic characters 

  --block-size=SIZE
  use SIZE-byte blocks
  -B, --ignore-backups
  do not list implied entries ending with ~ 

  -c
  sort by change time; with -l: show ctime 

  -C
  list entries by columns 

  --color[=WHEN]
  control whether color is used to distinguish file
  types.  WHEN may be `never', `always', or `auto' 

  -d, --directory
  list directory entries instead of contents 

  -D, --dired
  generate output designed for Emacs' dired mode
  -f
  do not sort, enable -aU, disable -lst
  -F, --classify
  append indicator (one of */=@|) to entries 

  --format=WORD
  across -x, commas -m, horizontal -x, long -l,
  single-column -1, verbose -l, vertical -C 

  --full-time
  list both full date and full time 

  -g
  (ignored) 

  -G, --no-group
  inhibit display of group information 

  -h, --human-readable
  print sizes in human readable format (e.g., 1K 234M 2G) 

  -H, --si
  likewise, but use powers of 1000 not 1024 

  --indicator-style=WORD
  append indicator with style WORD to entry names:
  none (default), classify (-F), file-type (-p) 

  -i, --inode
  print index number of each file 

  -I, --ignore=PATTERN
  do not list implied entries matching shell PATTERN 

  -k, --kilobytes
  like --block-size=1024 

  -l
  use a long listing format 

  -L, --dereference
  list entries pointed to by symbolic links 

  -m
  fill width with a comma separated list of entries 

  -n, --numeric-uid-gid
  list numeric UIDs and GIDs instead of names 

  -N, --literal
  print raw entry names (don't treat e.g. control
  characters specially) 

  -o
  use long listing format without group info 

  -p, --file-type
  append indicator (one of /=@|) to entries 

  -q, --hide-control-chars
  print ? instead of non graphic characters 

  --show-control-chars
  show non graphic characters as-is (default) 

  -Q, --quote-name
  enclose entry names in double quotes 

  --quoting-style=WORD
  use quoting style WORD for entry names:
  literal, shell, shell-always, c, escape 

  -r, --reverse
  reverse order while sorting 

  -R, --recursive
  list subdirectories recursively 

  -s, --size
  print size of each file, in blocks 

  -S
  sort by file size 

  --sort=WORD
  extension -X, none -U, size -S, time -t, version -v
  status -c, time -t, atime -u, access -u, use -u 

  --time=WORD
  show time as WORD instead of modification time:
  atime, access, use, ctime or status; use
  specified time as sort key if --sort=time 

  -t
  sort by modification time 

  -T, --tabsize=COLS
  assume tab stops at each COLS instead of 8 

  -u
  sort by last access time; with -l: show atime 

  -U
  do not sort; list entries in directory order 

  -v
  sort by version 

  -w, --width=COLS
  assume screen width instead of current value 

  -x
  list entries by lines instead of by columns 

  -X
  sort alphabetically by entry extension 

  -1
  list one file per line 

  --help                 display this help and exit
  --version              output version information and exit 

  Some good examples are:  

  ls -la
  ls -laF
  ls -laF --color
  ls -d */
  Also see earlier in this tutorial about the `alias` command
 -------------------------------------------------------------------------------
 lsattr
  list attributes, this command lists a files file system attributes.
  For more info see: man lsattr
 -------------------------------------------------------------------------------

(more...)

9 - Basic Linux/UNIX commands and operations


This section is about Linux and UNIX basic commands and operations, and some
  other explanations and tricks, since this is not a command bible,
  I'll explain each command breafly, with alot of help from the
  man pages and the --help argument (let's all thank the maker for cut & paste).
  Then again, I've seen files that have claimed to be UNIX command bibles
  that are even breafer and hold less commands... though most of the authors
  of those seems to be totally uncapeble of handling a UNIX and cant even spell,
  one of the worst examples I've seen was something like this:
  "The UNIX bible, in this phile is all the UNIX commandz j00 need"
  And after that was a list of commands without arguments... needless to say
  is also that 99% of all UNIX commands were missing.
  Anyway, enough of me making fun of those people now, and on with the tutorial.
  (Which isn't a UNIX command bible, just a note)
  I will refer to "*nix" here, and that means any sort of UNIX system,
  Linux, BSD, Solaris, SunOS, Xenix and so on included.
 ------------------------------------------------------------------------------
 Here are the basic *nix commands, with breaf explanations.
 ------------------------------------------------------------------------------
 adduser
  Syntax: adduser [arguments] <user>
  And can be used with the following arguments:
  -u uid
  -g group
  -G group,...
  -d home directory
  -s shell
  -c comment
  -k template
  -f inactive
  -e expire mm/dd/yy
  -p passwd
  Then there are a few arguments with no explanation:
  -o, -m, -n, and -r
  So say that you wanna add a user named "user" with password "resu"
  belonging to the group root with / as home directory using /bin/tcsh
  as shell, that would look as this:
  adduser -p resu -g root -d / -s /bin/tcsh user
 ------------------------------------------------------------------------------
 alias
  The alias command set's an alias, as this: alias du='du -h'
  This means that whenever you type: du
  it will really do: du -h
  Typing alias by it self will display all set aliases. 

  For more information on the alias command do: help alias
 ------------------------------------------------------------------------------
 apropos
  apropos checks for strings in the whatis database. say that you
  are looking for a manual page about the `shutdown` command.
  Then you can do: apropos shutdown
  for more information, do: man whatis
  Or: man apropos 

 ------------------------------------------------------------------------------
 awk
  awk is a text formatting tool, that is HUGE, it's actually a whole
  language, some say it's not totally wrong to say that awk is not
  far off from a scripting version of C.
  However I wouldent go as far as to say that there resemblance
  is that great.
  awk's most common use is about the same as 'cut', and it works like
  this: awk [argument-1] [argument-2] ....
  Here's some example's of converting an URL:
  echo "http://www.bogus.com/one/two.htm" | awk -F'/' '{print $3}'
  This will return: www.bogus.com
  The -F will set a delimiter, and the '{print $3}' will print the
  third feild, separated by the delimiter, which is www.bogus.com,
  because there is 2 slashes, which makes the second slash the second
  feild, and so www.bogus.com is the third feild.
  Here's another example:
  echo "http://www.bogus.com/one/two.htm" | awk -F'/' '{print $(NF)}'
  This will return: two.htm
  The -F set's the delimiter, which once again is /, but this time
  we have used $NF which always resembles the last feild.
  Another example with NF is this: 

  echo "http://www.bogus.com/one/two.htm" | awk -F'/' '{print $(NF - 1)}'
  This will return: one
  Because $(NF - 1) means the last feild minus one feild, which always
  will be the next last feild.
  You only have to use the ()'s around variables when you do something
  with them like here "$(NF - 1)", but you can use $(var) all the time
  if you want.
  Here's another example: 

  echo "http://www.bogus.com/one/two.htm" | awk -F'/' '{print $3 "/" $(NF - 1)}'
  This will return: www.bogus.com/one
  It will first print out the third feild separated by /'s, which is
  www.bogus.com, then it will print a /, and then it will print out
  the next last feild which is one. 

  Here is a very shoer final example of awk:
 echo "http://www.bogus.com/one/two.htm" | awk '{ while  ( $(1) ) print }'
  This will return: "http://www.bogus.com/one/two.htm" forever.
  The "while ( $(1) )" means that as long as there is first feild,
  it will print the line line.
  And since there will always be a first feild it will continue
  forever.
  while in awk works as this: while ( condition ) action  

  As I said, awk is huge and is actually a whole language, so
  to explain all of it it would need a tutorial of it's own.
  So I will not go any deeper into awk here, but you can as always
  read it's manual page which is quite large.
  So, for more info do: man awk  

  ------------------------------------------------------------------------------
 basename
  basename will strip directory and suffix from filenames.
  This command only have the two following flags:
  --help      display this help and exit
  --version   output version information and exit
  It works like this:
  alien:~$ basename /usr/local/bin/BitchX -a
  BitchX
  alien:~$ basename http://www.domain.com/path/to/file.html
  file.html
  alien:~$
  For more info do: man basename
 ------------------------------------------------------------------------------
 bc
  A precision calculator, can be used with the following arguments:
  -l     Define the standard math library.
  -w     Give warnings for extensions to POSIX bc.
  -s     Process exactly the POSIX bc language.
  -q     Do not print the normal GNU bc welcome.
  -v     Print the version number and copyright and quit.
 -------------------------------------------------------------------------------
 BitchX
  BitchX is usually not default on any system, but it's the far
  msot advanced IRC client to *nix.
  BitchX started as a script to ircii (ircii is irc2 an extended
  irc protocol, also EPIC which is more bareboned then BitchX is
  made from ircii), until BitchX got hard coded to the protocol
  in C, by panasync I belive.
  BitchX has alot of arguments but can be executed without any
  arguments.
  This is the synatx: BitchX [arguments] <nickname> <server list>
  And here are the arguments anyway:
  -H <hostname>	this is if you have a virtual host.
  -c <#channel>	auto join a channel, use a  infront of the #
  -b		load .bitchxrc or .ircrc after connecting to a server
  -p <port>	connect on port (default is 6667)
  -f           	your terminal uses flow controls (^S/^Q),
  so BitchX shouldn't
  -F           	your terminal doesn't use flow control (default)
  -d		dumb terminal mode (no ncurses)
  -q		dont load the rc file ~/.ircrc
  -r <file>       loads file as list of servers to connect to
  -n <nickname>	set the nickname to use
  -a              adds default servers and command line servers
  to server list
  -x          	runs BitchX in "debug" mode
  -Z              use NAT address when doing dcc
  -P              toggle check pid.nickname for running program
  -v		show client version
  -B              fork BitchX and return you to shell. pid check on.
  -l <file>    	loads <file> in place of your ~/.ircrc
  -L <file>    	loads <file> in place of your .ircrc and
  expands $ expandos 

  The most common way of starting BitchX is this, say that you want
  to have the nick 'Bash' on server irc.bogus.com, then you can do:
  BitchX Bash irc.bogus.com 

  There is so much to say about BitchX that it would need a tutorial
  of it's own, I'm currently writing a BitchX script, so maybe
  I'll write a BitchX tutorial some time =)
 -------------------------------------------------------------------------------
 bzcat
  bzcat will uncompress a .bz2 file 'on the fly' as it cat's it.
  the actual file will remain compressed after bzcat has displayed
  the contents.
  bzcat has to my knowlidge only one switch, and that's
  -s, that uses less memory.
  bzcat works like this: 

  bzcat file.bz2
  This can be good if you wanna search something in a text file
  that has been bzip2'd.
  Examples:
  bzcat file.bz2 | grep 'text string'
  bzcat file.bz2 | wc -l
 -------------------------------------------------------------------------------
 bzip2 

  Compression tool, compresses harder then the standard gzip.
  bzip2 can be used with the following arguments:
  -h --help           print this message
  -d --decompress     force decompression
  -z --compress       force compression
  -k --keep           keep (don't delete) input files
  -f --force          overwrite existing output files
  -t --test           test compressed file integrity
  -c --stdout         output to standard out
  -q --quiet          suppress noncritical error messages
  -v --verbose        be verbose (a 2nd -v gives more)
  -L --license        display software version & license
  -V --version        display software version & license
  -s --small          use less memory (at most 2500k)
  -1 .. -9            set block size to 100k .. 900k
  Normally used as: bzip2 -d file.bz2 (to decompress a file)
  or bzip2 -z file (to compress a file) 

  -------------------------------------------------------------------------------
 cat
  cat followed by a filename will bring the contents of the file
  out to the screen (stdout), and can be used with the following
  arguments:
  -A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonblank output lines
  -e                       equivalent to -vE
  -E, --show-ends          display $ at end of each line
  -n, --number             number all output lines
  -s, --squeeze-blank      never more than one single blank line
  -t                       equivalent to -vT
  -T, --show-tabs          display TAB characters as ^I
  -u                       (ignored)
  -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
  --help               display this help and exit
  --version            output version information and exit
 -------------------------------------------------------------------------------
 cc
  C compiler, can be used with ALOT of arguments, do a man cc to find
  out just how many, it's normally used to compile a .c source file to an
  executable binary, like this:
  cc -o program program.c
 -------------------------------------------------------------------------------
 cd
  change directory, works as this:
  cd /way/to/directory/I_want_to/be/in/
  No further explanation needed.
 -------------------------------------------------------------------------------

(more...)

8 - The Init and system scripts

===============================================================================
8 - The Init and system scripts.
===============================================================================

In this section I will cover the system V init, which is the most used
init in Linux.
Beside the Syst V inti, there are also the BSD init, which is used by
Slackware and Debian and in some smaller distributions of Linux.
The rest, as far as I know, uses the Syst V init.
There are not so much difference of the two, I'll try to cover the
differences later.
The example and files here are taken from SysVinit-2.78-6 & initscripts-5.27-37
which is compatible in some ways with the BSD init, I'll come back to that
later.

So here we go:

-------------------------------------------------------------------------------

The basic Syst V init comes with the following commands & devices: 

/dev/initctl		This is the init controll device.
/sbin/halt		This is to shut down the system.
/sbin/init		This is to change the init runlevel.
/sbin/killall5		This will kill everything but the script that runs it.
/sbin/pidof		This will get the PID of a Process name.
/sbin/poweroff		This will power down the system.
/sbin/reboot		This will reboot the system.
/sbin/runlevel		This will tell the init runlevel.
/sbin/shutdown		This will shut down the system.
/sbin/sulogin		This is the single user mode login.
/sbin/telinit		This is the init process control initialization.
/usr/bin/last		This shows who was in the system last.
/usr/bin/lastb		This is about the same as last.
/usr/bin/mesg		This is to toggle writeble mode on your tty.
/usr/bin/utmpdump	This dumps a file for utmp (this lacks documentation)
/usr/bin/wall		This sends a message to all ttys.

And then the init needs the following extra files/dirs and commands from
the initscripts package:

/bin/doexec		This lets you run a program under another name.
/bin/ipcalc		This lets you manipulate IP addresses.
/bin/usleep		This sleeps for microseconds.
/etc/X11/prefdm		This is the display manager preferrence file for X.
/etc/adjtime		This is the Kernel Clock Config file.
/etc/init.d		BSD init compatibilety directory.
/etc/initlog.conf	This is the initlog configuration file.
/etc/inittab		This is the main init configuration file.
/etc/modules		This is where the kernel loads modules from at boot.
/etc/ppp/ip-down	This is a script for dialup internet connections.
/etc/ppp/ip-up		This is a script for dialup internet connections.
/etc/profile.d/inputrc.csh	Shell Key bindings for csh and tcsh.
/etc/profile.d/inputrc.sh	Shell Key bindings for sh and bash.
/etc/profile.d/lang.csh		Language files - i18n stuff for csh and tcsh.
/etc/profile.d/lang.sh		Language files - i18n stuff for sh and bash.
/etc/profile.d/tmpdir.csh	Set temporary directory for csh and tcsh.
/etc/profile.d/tmpdir.sh	Set temporary directory for sh and bash.
/etc/rc.d/init.d/functions	Functions for scripts in init.d
/etc/rc.d/init.d/halt		Runlevel 0 (shutdown/halt) script.
/etc/rc.d/init.d/kheader	Script to regenerate the /boot/kernel.h file.
/etc/rc.d/init.d/killall	Script to make sure everything is shut off.
/etc/rc.d/init.d/mandrake_everytime	Mandrake specific stuff.
/etc/rc.d/init.d/mandrake_firstime	Mandrake post install stuff.
/etc/rc.d/init.d/netfs		Mounts network filesystems.
/etc/rc.d/init.d/network	Bring up/down networking.
/etc/rc.d/init.d/random		Script to help random number generation.
/etc/rc.d/init.d/rawdevices	Device stuff for applications such as Oracle.
/etc/rc.d/init.d/single		Single user script (runlevel 1)
/etc/rc.d/init.d/sound		Launch sound.
/etc/rc.d/init.d/usb		Launch USB support.
/etc/rc.d/rc.local		Boot time script, (like autoexec.bat in DOS).
/etc/rc.d/rc.modules		Bootup script for modules.
/etc/rc.d/rc.sysinit		Main system startup script.
/etc/rc.d/rc0.d/S00killall	Runlevel 0 killall script link.
/etc/rc.d/rc0.d/S01halt		Runlevel 0 halt script link.
/etc/rc.d/rc1.d/S00single	Runlevel 1 single script link.
/etc/rc.d/rc2.d/S99local	Runlevel 2 local script link. (rc.local)
/etc/rc.d/rc3.d/S99local	Runlevel 3 local script link. (rc.local)
/etc/rc.d/rc4.d			Runlevel 4 directory.
/etc/rc.d/rc5.d/S99local	Runlevel 5 local script link. (rc.local)
/etc/rc.d/rc6.d/S00killall	Runlevel 6 killall script link.
/etc/rc.d/rc6.d/S01reboot	Runlevel 6 reboot script link.
/etc/rc.local			BSD init compatibilety file.... ?
/etc/rc.sysinit			BSD init compatibilety file.... ?
/etc/rc0.d			BSD init compatibilety directory.
/etc/rc1.d			BSD init compatibilety directory.
/etc/rc2.d			BSD init compatibilety directory.
/etc/rc3.d			BSD init compatibilety directory.
/etc/rc4.d			BSD init compatibilety directory.
/etc/rc5.d			BSD init compatibilety directory.
/etc/rc6.d			BSD init compatibilety directory.
/etc/sysconfig/console		Directory for console stuff, like the keymap.
/etc/sysconfig/init		Basic init boot configurations.
/etc/sysconfig/network-scripts/ifcfg-lo		Network config for localhost.
/etc/sysconfig/network-scripts/ifdown		Turning off interfaces script.
/etc/sysconfig/network-scripts/ifdown-post	Post stuff for ifdown.
/etc/sysconfig/network-scripts/ifdown-ppp	Turning off ppp.
/etc/sysconfig/network-scripts/ifdown-sl	Turning off SLIP.
/etc/sysconfig/network-scripts/ifup		Turning on interfaces script.
/etc/sysconfig/network-scripts/ifup-aliases	Turning on alias interfaces.
/etc/sysconfig/network-scripts/ifup-ipx		Turning on IPX.
/etc/sysconfig/network-scripts/ifup-plip	Turning on PLIP.
/etc/sysconfig/network-scripts/ifup-post	Post stuff for ifup.
/etc/sysconfig/network-scripts/ifup-ppp		Turning on ppp.
/etc/sysconfig/network-scripts/ifup-routes	Turning on routes.
/etc/sysconfig/network-scripts/ifup-sl		Turning on SLIP.
/etc/sysconfig/network-scripts/network-functions     Functions for the scripts.
/etc/sysconfig/rawdevices	Raw device bindings.
/etc/sysctl.conf		System Control configurations.
/sbin/consoletype		This prints the console type.
/sbin/getkey			Prints the key strokes....
/sbin/ifdown			Application for the previous config files.
/sbin/ifup			Application for the previous config files.
/sbin/initlog			Logs msgs and events to the system logger.
/sbin/installkernel		Installs a kernel (not for manual use).
/sbin/minilogd			* Totally lacking documentation.
/sbin/netreport			Reports changes of the network interface.
/sbin/ppp-watch			Application used by ifup-ppp.
/sbin/service			Can send commands to all services etc.
/sbin/setsysfont		Sets the system font.
/usr/bin/listhome		Lists the users home directorys.
/usr/sbin/detectloader		Detect the current boot loader.
/usr/sbin/supermount		Automatic mount/umount application.
/usr/sbin/sys-unconfig		System reconfiguration tool.
/usr/sbin/usernetctl		User Network interface control application.
/var/log/wtmp			Previously logged in users entrys.
/var/run/netreport		Directory for the netreport application.
/var/run/utmp			Currently logged in users entrys.

So what do you really need to know of all that ?

Well, here's the simple basics of how it works and what you need to remember.

The /etc/inittab is already explained.

(more...)

7 - Networking

===============================================================================
7 - Networking.
===============================================================================

Linux is known to be one of the best networking operating systems in the
world, perhaps even THE best, unfortionally it's not the easiest OS to
set up a good network in, but I hope that this section will make
exclamation marks out of some question marks.

-------------------------------------------------------------------------------

The first thing you need to do networking is 2 computers and
network cards attached with a crossed network cable, or connected via a hub,
with normal network cable (doh?).

The next step is to make sure the network cards work properly.

Make sure you have the networking support compiled into the kernel, you need
to have the following checked in the kernel (example is from the Linux 2.2.14
kernel, using `make menuconfig`, you can read more about how you
compile/recompile your kernel in /usr/doc/HOWTO/Kernel-HOWTO):

General setup  --->
	[*] Networking support
Networking options  --->

	[*] Kernel/User netlink socket
	[*] Network firewalls
	<*> Unix domain sockets
	[*] TCP/IP networking
	[*] IP: advanced router
	[*] IP: firewalling
	[*] IP: transparent proxy support
	[*] IP: masquerading
	[*] IP: ICMP masquerading
	[*] IP: aliasing support
	<*> IP: Reverse ARP
	[*] IP: Allow large windows (not recommended if <16Mb of memory)
Network device support  --->
	[*] Network device support
	Ethernet (10 or 100Mbit)  --->
		[*] Ethernet (10 or 100Mbit)
		(In here find your network card and check it.)
Filesystems  --->
	[*] /proc filesystem support

Then you add this line in your /etc/rc.d/rc.local

echo "1" > /proc/sys/net/ipv4/ip_forward () at boot time

(more...)

6 - Customize your system and shell

===============================================================================
6 - Customize your system and shell.
===============================================================================

This section is dedicated to how you can customize your system in various
ways, this section was never planned to be in this tutorial, but since
I have received so many questions on how to do all this, I might as well
include it in the tutorial. 

-------------------------------------------------------------------------------

First of I'm going to explain the local settings, this means the settings
that will only affect a single user and not the whole 'global' system.
And the most logical way to start this is (I think) to talk about the shell.

-------------------------------------------------------------------------------

At the very top of this tutorial you will find the various types of shells,
default for most systems is /bin/bash, this is set in the /etc/passwd file
so a normal user can not change that.

What a normal user can do if he wants to use another shell is to start it from
his ~/.bashrc file.
So say now that you feel the urge to run tcsh, then just add the
line /bin/tcsh in your ~/.bashrc, this may be done by doing:
echo "/bin/tcsh" >> ~/.bashrc
personally I prefer the standard bash.

But if you do have root (super user) access to the system, you can change
the shell type correctly in the /etc/passwd file.

here's a user account with /bin/bash from /etc/passwd

User:x:500:500:my real name:/home/user:/bin/bash

And here the same line changed to /bin/tcsh (tenex C shell)

User:x:500:500:my real name:/home/user:/bin/tcsh 

(more...)

5 - Practical Scripting Examples

===============================================================================
5 - Practical Scripting Examples.
===============================================================================

I'd first like to add a note which you already probably knows:
./ == look in current directory instead of the "PATH".
To give that an example, say now that you have a script in your home
directory called "ls" or "dir", how would you execute that without
getting the contents of the directory ?
well, that's why you use "./"  before a name to execute it if it's in the
current directory.
../ == previous directory (one directory further up towards "/" then you are
currently in), this can be used as this, say that you have a script called
"script" in "/home/user/" and you are standing in "/home/user/nice/" and
you don't want to leave the directory but still want to execute the script.
Then you do, "../script" and if you are in "/home/user/nice/blah/" you
you would do, "../../script" ----- "../../" == 2 directory's back.
Get the idea ?

Anyway, now to the practical examples, which are working scripts for
various purposes, to give an idea about what you can do with shell scripting.
New things previously not explained will show up in this section, but
I will explain them as we go along.

Let's start with simple examples and move on to harder parts.
As for first I'll stick to useless scripts =) just for illustration.
Explanation on the scripts follow after them, as usual.
So here we go on that.

(more...)

4 - Other techniques

===============================================================================
4 - Other techniques.
===============================================================================

Now let's move on to a little bit more advanced shell scripting.
Actually it's not that advanced, just more hard to keep in order, but let us
leave that to the head of the beholder..... errr
Anyway, let's not make this harder then it is, so here we go, with a script
example:

-------------------------------------------------------------------------------
#!/bin/bash

> file1.c

cat >> file1.c << EOF
#include <stdio.h>
int main ( void )
{
  printf("Hello worldn");
  return 0;
}
EOF

cc file1.c -o file1 || gcc -o file1 file1.c
./file1

rm -f file1.c file1

exit 0

-------------------------------------------------------------------------------

And here as follows, is an semi-english translation of the script:

echo nothing to file1.c to create it.

cat to file1.c what comes here after in between the "EOF"'s
// --- a short hello world program in C code --- //

try if there is a 'cc', if not then use 'gcc'
Execute the newly compiled file

remove file1.c and file1

exit the script.

(more...)

3 - Beginning techniques

===============================================================================
3 - Beginning techniques.
===============================================================================

First off I'm going to show how to count in bash or how to use your command
line as a calculator, which is really easy and useful.

alien:~$ echo $[ 4 * 2 ]
8
alien:~$

or another example:

alien:~$ echo $[ 10 + 5 ]
15
alien:~$

Easy ? .... I think it is =)

The internal calculator can also be used like this: 

alien:~$ echo $(( 10 + 5 ))
15
alien:~$

The second way of using the internal shell calculator is here just
so you dont get confused if you see it used that way sometime.

(more...)

2 - Where to start

===============================================================================
2 - Where to start
===============================================================================

You should always start with very simple scripts that you really don't have
any practical use for but still *could* be of practical use =)

As for first let's make what we already know to a *real* executable script.
Open a text editor (name the file myscript.sh) and type this:

#!/bin/bash

echo -n "password: "
read pass
echo "Your pass is $pass"

save & exit --- then do this command: chmod u+x myscript.sh
Then we can execute it:

	alien:~$ ./myscript.sh
	password: <type what you want>
	Your pass is <what you typed>
	alien:~$

The "#!/bin/bash" at the start of the file is to let the script know what
shell type it should use.

The "chmod u+x myscript.sh" is to make it executable.
(change-mode user+execute-right-on myscript.sh) ..... read the manual pages
on chmod for more info on it =)

-------------------------------------------------------------------------------

Take alot of time to play around in your system, open files, figure out
what they do (but don't edit or remove them).

Take time also to learn some good text editor, that's important.
Learn, emacs or vi, those are by most people considerd the absolutly best,
but jed, joe, elvis, pico or any simple editor like that will do
just fine for now.

emacs and vi are explained later in this tutorial.

(more...)

1 - What you already know. (should know)

=========================== Aliens Bash Tutorial ==============================
--------------- Written by Billy Wideling <-> alien@koping.net ----------------
===============================================================================

First you probably need to read a UNIX command bible to really understand this
tutorial, but I will try to make it as clear as possible, there is about
100-150 UNIX commands explained later in this tutorial.
You are to have some UNIX experience before starting on this tutorial, so
if you feel that you have UNIX/Linux experience feel free to start to learn
here.
What I included here is general shell scripting, most common other things
and some UNIX commands.
Here's the most common shell types:

bash  = Bourne again shell
sh    = shell
csh   = C shell
tcsh  = Tenex C shell (not tab-completion-extended C shell)
tclsh = Tcl shell
ksh   = korn shell
ash   = a shell
bsh   = bourne shell ? (in most Linux distributions it's a link to /bin/ash)
zsh   = the Z shell (it's what it's manual page tells about it .. :/ )

===============================================================================

1 - What you already know. (should know)

===============================================================================

Here we go, bash scripting is nothing more then combining lots of UNIX commands
to do things for you, you can even make simple games in bash
(just UNIX commands) or as in normal cases, batch files to control things
in your computer.

(more...)