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...)