TW Tech Glossary - Misplaced your bible? Well here it is! This truly took a while to complete and should be used by all from beginners to advance techies. Look into it, you won't be sorry. (Very Resourceful)
Types of Attacks on Web Servers - I think we hit the mother-load of server security information in this article people. We urge, every server admin as well as those looking to get into server and network security to not miss out on this article. You may already be experiencing attacks and wouldn't even know. And we like to point out that this article has no views against the "White-Hat Hacking Community." It is strictly on information basis and does not pose any personal views what so ever.
Apache Web Server - Best we can say about this article is that it is merely a bried preview of what an Apache Server is and what it can do. A must for any network admin or any webmaster.
Internet Security and Acceleration (ISA) Server - This weeks article discusses the nitty gritties of Server and Network Security and how to implement them.
Types of Servers - Ever wonder what types of things servers take part in? Ever wonder the possibilities? Well read all about it here in this weeks article. A good 10 minutes reading for all you future potential system admins.
Most Common TCP Ports - TCP ports will popup almost with any application you use wether it is ICQ or FTP. It will soon be realized how good its knowledge is once you yourself will start applying it in day to day tech use.
Web Server Error Messages - Many times these errors have more to do with the Web servers you're trying to access rather than something being wrong with your computer. Here is a list of error messages you might encounter while surfing the Web and their respective meanings to help you figure out just what the problem is.
Brief History of UNIX - Unlike DOS, Windows, OS/2, the Macintosh, VMS, MVS, and just about any other operating system, UNIX was designed by a couple of programmers as a fun project, and it evolved through the efforts of hundreds of programmers, each of whom was exploring his other own ideas of particular aspects of OS design and user interaction. In this regard, UNIX is not like other operating systems, needless to say…
Crash Proofing Your Computer - This is a list of nine very useful tips to Crash Proof your computer.
Types of Servers 2 - One of most important type of server is cluster servers. Software that enables clustering of servers is installed into a computer. Clustering servers also serve as load balancing servers between two computers. This is a common small business server. Clustering servers are used to avoid server failover. Server failover is the capability to shift to another standby server if the main server fails.
Ubuntu in Place of Windows - Most people think of Linux as something only for geeks and computer power users. However, we have come to see various flavors of LinuxOS being sold in major retail stores in the last few years and we also see a trend being set online. In this article, we're simply going to single out only one of many Linux flavors known as Ubuntu.
What is Unix?
Due to its portability, flexibility, and power, UNIX has become the leading operating system for workstations. Historically, it has been less popular in the personal computer market, but the emergence of a new version called Linux is revitalizing UNIX across all platforms.
UNIX was one of the first operating systems to be written in a high-level programming language, namely C.
Pronounced yoo-niks, a popular multi-user, multitasking operating system developed at Bell Labs in the early 1970s. Created by just a handful of programmers, UNIX was designed to be a small, flexible system used exclusively by programmers.
Tips
Copying an Entire Directory Structure
The Unix tar command provides an easy and effective way to copy an entire directory structure. For example, to copy the directory ~/projects/codered to ~/backups/codered
$ cd ~/backups
$ mkdir codered
$ CD codered
$ tar cfv - -C ~/projects codered | tar xvpf -
This will create an exact duplicate of the codered directory in the ~/backups directory. The permission lists for each file and directory will be preserved and symbolic links will continue to point to the correct files.
What directory am I working in?
If you forget which directory you are currently working in try using the pwd command. Pwd lists the full path to the working directory.
$ pwd
/usr/home/bobd/project1/
Use the find and grep commands together to create a powerful searching tool.
The find command searches for files by filename and the grep command searches for text string within a file. Used together, they are a powerful searching tool. For example, suppose you are looking for a document you wrote earlier in the year. You don't remember its name or what directory it is located in but you know it contains the string elephant. Use find to recursively search through all files in your home directory. Use the -exec option to execute the grep command on all files found.
$ find ~ -name '*' -exec grep -l 'elephant' \{\} \;
~/africa/animals.txt
The document animals.txt located in the directory Africa contains the string elephant.
Use the IP Loopback Address to Check for TCP/IP Networking
Virtually any UNIX machine using TCP/IP networking supports the IP loopback address 127.0.0.1. When a machine is told to connect to 127.0.0.1, it will connect to itself. One of the first steps in troubleshooting a network problem is to ping the loopback address.
$ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.053 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.056 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.044 ms
^C--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.044/0.051/0.056/0.005 ms[1]
If ping responds with a message like ping: no answer... or 100% packet loss there is no TCP/IP networking functioning on the machine. The address 127.0.0.1 will work even if the machine is not physically connected to a network so the ping 127.0.0.1 command only checks that TCP/IP is installed and configured well enough for basic functionality.
Using Nohup
Use the nohup command to keep a process running in the background after you logout.
$ nohup cmd &
For example, suppose you use the tar command to backup the /docs directory to a tape, /dev/rmt/0
$ tar cvf /dev/rmt/0 /docs > tar_log &
In this example, standard output is redirected to the file tar_log. If you logout before the command finishes executing, it will stop the process and your backup will not be completed. However, precede the tar command with the nohup command and the backup will finish even if you logout.
$ nohup tar cvf /dev/rmt/0 /docs > tar_log &
Enter multiple commands on a single line.
You can enter multiple commands on a single line by separating them with a semicolon. For example,
$ date; pwd ; ls
Tue Jan 9 22:17:57 CST 2001
/usr/home/liz
file1 file2 file3 sdir1
file4 anotherfile ddir
executes the date command, followed by the pwd command followed by the Ls command.
Use tee to simultaneously save command output in a file and see it on the screen.
The tee command duplicates standard input then sends one copy to standard output and saves another in a file. Tee is typically used with a pipe. For example,
$ find . -name '*.txt' -print | tee txtlist
./todo.txt
./note.txt
./proj1/dirlist.txt
./proj1/notes/note1.txt
./proj1/notes/note2.txt
./proj1/notes/note3.txt
./proj2/dirlist.txt
searches an entire directory structure for files whose filenames end with .txt and saves the output in the file txtlist while simultaneously printing the output to the screen.
Tee can also be used to view the intermediate output from a group of commands linked by pipes. For example,
$ grep -i 'urgent' err_log | tee todo | wc -l
9
Searches for the string urgent in the file err_log using the grep command and saves the output in the file todo as well as piping it to the wc (word count) command. There are 9 lines in the err_log file that contain the string urgent.
Use your shell's history function to save typing.
Most shells provide a history function to reexecute commands without retyping them.
If you use the c-shell, tc-shell, bash or z-shell, type
!string
to reexecute the most recent command that begins with string. For example,
% find . -name '*' -print > flist
creates a file named flist in the current directory that contains a file listing. After running other commands
% cat f1
% CD ~/proj1
you can rerun f ind without retyping the entire command.
% !fi
Use CTRL-d to cancel a login.
Ever telnet, rlogin or ftp to the wrong machine? Use CTRL-d instead of a username to cancel the login.
$ telnet wrong.machine.com
Trying wrong.machine.com...
Connected to wrong.machine.com.
Escape character is '^]'.
FreeBSD/i386 (wrong.machine.com) (ttyp4)
login: CTRL-d
Connection closed by foreign host.
Use the touch command to create an empty file.
The touch command normally updates the access and modification time of a file. Used with a filename that does not exist, touch will create an empty file named filename.
$ Ls newfile
Ls: newfile: No such file or directory
$ touch newfile
$ Ls newfile
newfile
This can be useful before using output redirection or when writing shell scripts.
Trouble spelling a word? Use the look command to find it in the dictionary.
Not sure how to spell a word? The look command will help.
look pattern
Look will search the system word file for words starting with pattern. It is a good way to check spelling. For example, say you're not sure if the correct spelling of the word success is success or sucess. Try
$ look suc
succeed
success
successful
succession
...
Use the cal command to generate a calendar for a given month and year.
For example,
$ cal 1 2002
January 2002
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Note that you must use the four-digit year. Use cal without specifying a month or year to get the current month.
Recursively Change File Permissions
You can recursively change file permissions using the find and chmod commands. For example, to change the file permissions for all files in the private directory and all of its subdirectories so that no one but you has access use the following commands.
$ CD ~/private
$ find . -name '*' -exec chmod go-a \{\} \;
To change the file permissions starting from your home directory so that others have no access use the following command.{\} \;
$ Find ~ -name '*' -exec chmod o-a \
Be careful if you have a web page. If others have no access to the web page files then they can't load your pages in their browser.
You can use more advanced features of the find command to search for files and change permissions. For example, search for any files that have write access for the group or others and remove them.
$ Find ~ -perm -002 -exec chmod o-w \{\} \;
$ find ~ -perm -020 -exec chmod g-w \{\} \;
Use Info-ZIP to uncompress Windows zip files on a UNIX system.
The zip compression and archiving standard is commonly used to store and distribute Microsoft Windows files. Because Windows is such a commonly used operating system, UNIX users may find they need to create or uncompress (i.e. unzip) a zip archive to share documents. Fortunately, the Info-ZIP organization provides a free UNIX version of the zip and unzip programs. They can be downloaded as source or ready-to-run binaries for several different UNIX flavors. After installation, unzip can be used to uncompress a zip file. For example,
$ unzip pictures.zip
uncompresses files in the zip archive named pictures.zip into the current directory. Unzip will create subdirectories if necessary. Use the -d option to specify a directory other than the current directory.
$ unzip pictures.zip -d /tmp
Use the -l option to list the contents of the zip archive without uncompressing.
$ Unzip -l pictures.zip
Zip can be used to create a zip archive which Windows users can easily unzip. For example,
$ zip code.zip *.c
creates a zip archive named code.zip that contains all of the files in the current directory whose filenames end with .c. If you want to include entire directory structures in your zip archive use the -r (recursive) option. For example,
$ zip -r code.zip cdir
includes the entire directory structure beginning with cdir in the zip archive code.zip.
Other commands that come with the Info-ZIP utilities allow you to unzip files as part of a pipe, create self-extracting archives and encrypt archives for security.
Compiling a program
Most of the compilers on UNIX machines will automatically compile, assemble and link your code. You can use command line options to specify otherwise.
The compile component of a compiler will check the source code for syntax errors. If there are no errors the assembler creates an object file (.o). The compiler links the object file to any specified libraries and creates an executable.
Using the Fortran compiler as an example, the basic syntax for a compile command is:
f77 [options] source-filename
FORTRAN source code files have ".f" as a suffix. C programs end in ".c", C++ in ".C" and Pascal in ".p". Object files end in ".o" and libraries end with ".a".
The simplest compile statement would have a format as follows:
f77 file.f
The above statement would create an executable file called a.out. If you want your executable to be called something else, then you can use the "-o" option for the compiler. In the following example, the executable will be called "myprog".
cc myprog.c -o myprog
Options such as "-o" are common to most UNIX compilers. For more information on the options available for a compiler see the man page for the specific compiler (i.e., "man f77" or "man cc").
If there are several source files, the files can be compiled together, provided that the source code with the "main" procedure is listed first.
f77 -o myprog1 main.f sub1.f sub2.f
To run the executable created above, type myprog1.
If executables run incorrectly, or not at all
If the source code compiles without errors, yet does not run correctly, you will need to debug the programs. There are many UNIX debuggers available, including dbx, x11ups and gdb. To be able to use a debugger you must compile your source code with the "-g" option. This tells the compiler to create an object file with some additional symbolic information that will be used by the debugger.
cc -g filename.c -o filename
The dbx debugger can be used to debug C, FORTRAN, Pascal and, in some instances, C++ code
How do I print a UNIX man page?
On most systems the following command syntax will work.
man cmd | col -b | ul -t dumb | lprFor example,
$ man Ls | col -b | UL -t dumb | lpr
will print the manual page for the Ls command. Similar command syntax can be used to save manual page output in a plain text file that can be viewed with a text editor or printed. For example,
$ man Ls | col -b | UL -t dumb > ls.txt
creates a file ls.txt that contains the output from the man Ls command in plain text.
Also, see the Online Man Pages document for links to HTML formatted man page for various UNIX flavors.
jdate: today's date in English
A convenient way on inserting the date in my favourite format in any document: e.g. in vi, typing "!!jdate", or the ex equivalent ":r!jdate", inserts "Sunday 21st October 2001".
#!/bin/sh
set `date +'%A %d %B %Y'`
day=$2
case $day in
01) day=1;;
02) day=2;;
03) day=3;;
04) day=4;;
05) day=5;;
06) day=6;;
07) day=7;;
08) day=8;;
09) day=9;;
esac
case $day in
1?) day=$day"th";;
*1) day=$day"st";;
*2) day=$day"nd";;
*3) day=$day"rd";;
*) day=$day"th";;
esac
echo $1 $day $3 $4
whattime: the time in various time zones
#!/bin/sh
for i in Europe/Dublin Europe/Berlin US/Eastern US/Central US/Mountain US/Pacific
do
export TZ=$i
case $1 in
"") echo "`date` $i";;
*) echo "`date` $i" | grep $1;;
esac
done
overwrite: overwrite one file with another
#!/bin/sh
#overwrite: overwrite file with o utput of command
#note: must use redirection of input from file in command if required
opath=$PATH
PATH=/bin:/usr/bin:/usr/local/bin
case $# in
0|1) echo 'Usage: overwrite file cmd [args]' 1>&2; exit 2
esac
file=$1; shift
new=/tmp/overwr1.$$; old=/tmp/overwr2.$$
trap 'rm -f $new $old; exit 1' 1 2 15
export PATH=$opath;
if "$@" > $new
then
cp $file $old
trap '' 1 2 15
cp $new $file
else
echo "overwrite: $1 failed, $file unchanged" 1>&2
rm -f $new $old
exit 1
fi
rm -f $new $old
Job Control
List Jobs that are currently running and the status: jobs
Move a job to the background for processing: bg ##[enter] (## would be a valid job number)
Move a job to the foreground for processing: fg ##[enter] (## would be a valid job number
Shell Tricks
To display the hostname in the shell prompt do the following:
sh
add PS1=`\hostname`#\ to the .profile file
ksh
tcsh
FreeBSD 4.5 sets the telnet session to try to "auto login" when connecting to things like Cisco routers.
To disable this "feature" you can do one of the following:
Type this command - echo default unset autologin >> ~/.telnetrc
Type this command - telnet -K somehost.somenet
Security versus Integrity
Security is a question of how easy it is for unauthorised users to access the machine, or the data stored on the machine. Walking away from an active terminal is a breach of security.
Integrity is a question of how safe the data is on the machine. Users who leave incomplete updates on their terminals are a potential danger to data integrity.
Shutting Down
Always shut down your UNIX machine cleanly. The power switch and reset button are for emergencies, not convenience.
Teach your users to log out of the machine when they have finished work. If they simply turn their terminal off, they may not close their login session; this leaves a large hole in the security and integrity of the system.





