Vous êtes sur la page 1sur 42

DISK OPERATING SYSTEM

DOS is Disk Operation System. DOS is a tool which allows you to control the operation
of the PC. DOS is software which was written to control hardware.

BACKUP FILES

It is possible to lose files by mistake so, it is good practice to make backup copies of your
most valuable files on a separate diskette. Store your backup disk in a safe place . We use
the COPY command to create the backup.
An effective file naming convention is essential to keeping track of your backups.

CHANGE THE DEFAULT DRIVE

To change the default drive, simply type the letter of the your choice. The new default
will be listed in subsequent DOS prompts.
Example:
• C> A: [enter]
• Changes the default drive from C to A.
• C: [enter]
• Changes the default drive from A to C.
[enter] means that you must press the Enter Key before the format command will execute.
[Enter] is required after any DOS command, it is assumed in all commands found below.

CHDIR (CD) Change Directory Command


Once you have located the directory you want, you may move from directory to directory
using the CD command (change directory)
Example:
• C> cd furniture
• Moves you to the directory called 'FURNITURE'
• C> cd \furniture\chairs
• Moves you to the directory called 'CHAIRS' under the directory called
'FURNITURE'.
• C> cd ..
• Moves you up one level in the path.
• C> cd \
• Takes you back to the root directory (c: in this case).

COPY Command
The COPY command can be used both to copy files from disk to disk and to create a
second copy of a file on a single disk. (There are many more uses of the COPY
command, but only the basic operation is discussed here.)
Example:
• C> copy c:kermit.exe a:
• Copies the file 'KERMIT.EXE' from the C drive to the A drive and gives it the same
name.
• C> copy a:brazil1.dat b:\south\brazil2.dat
• Creates a copy of 'BRAZIL1.DAT' from drive A on drive B, putting it in the
'SOUTH' subdirectory and renaming it 'BRAZIL2.DAT'.
The key to use this command correctly is to remember that the first file specified after the
COPY command is the source file, the second is the target:ehp1 file. The source is the
file to be copied. The target will be the location and name of the new file. If the file name
and extension are omitted after the target's drive specification, the new file will have
exactly the same name as the source file.
Example:
• C:\> copy a:\myfile.txt b:
• C:\> copy c:\command.com b:com.com
• C:\> copy b:\golly.gee a:whao.boy
• C:\> copy command.* a:
• C:\> copy a:\mymap.dwg c:\maps

DIR (Directory) Command


The DIRECTORY command lists the names and sizes of all files located on a particular
disk.
Example:
• C> dir a:
• Shows directory of drive A
• C> dir b:
• Shows directory of drive B
• C> dir \agis
• Shows files in a subdirectory on drive C (default)
• C> dir
• Shows directory of drive C
• C> dir /w
• Shows directory in wide format, as opposed to a vertical listing.
All the files are listed at the screen, you can stop the display by typing CTRL-BREAK.
WILD CARD Characters(*,?)
Two little characters, '*' and '?', will make your life with computers much easier. Their
use is illustrated below.
Example:
• C> dir a:*.ex
• Lists all files on the A drive with an extension of 'EXE'.
• C> dir b:kermit.*
• Lists all files on the B drive with a filename of 'KERMIT'.
The asterisk is a wild-card character which allows the user to enter only a limited part of
a file specification to find a file. It is useful when you wish to locate a group of files with
the same filename or the same extension. On other occasions you may have forgotten part
of a file specification. You can use '*' in place of the parts of the specification you have
forgotten. Similarly, '?' permits wild-card searches keyed to single characters.
Example:
• C> dir a:labe?.com
• Lists all five-letter files with the first four letters 'LABE' and an extension of 'COM'.
• C> dir b:format.c??
• Lists all files with a filename of 'FORMAT' and an extension beginning with 'C'.
Wild-card characters can be used in combination.
Example:
• C> dir a:labe?.*
• Lists all five-letter files with the first four letters 'LABE' and any extension.
• C> dir c:*.ex?
• Lists all files with an extension beginning with 'EX'.

ERASE Command

The ERASE command deletes specified files.


Example:
• C> erase a:myfile.txt
• Erases the file MYFILE.TXT from the diskette in the A drive. If no drive
specification is entered, the system looks to delete the specified file form drive C (in
this case).
IMPORTANT WARNING: This command is easy to use, but it is the most dangerous
one you will encounter in DOS (apart form FORMAT). If you aren't careful, you may
delete a file which you--or someone else--needs. And, unless you have saved a backup of
that file, the erased file is gone for good. For this reason it is good practice to use only
complete file specifications with the ERASE command (and to keep backups of your
most valuable files). As a safety precaution, never use the wild-card characters '*' and '?'
in ERASE commands.

File-Naming Conventions

Careful file naming can save time. Always choose names which provide a clue to the
file's contents. If you are working with a series of related files, use a number somewhere
in the name to indicate which version you have created. This applies only to the filename
parameter; most of the file extension parameters you will be using are predetermined
(or reserved by DOS for certain types of file).
Example:
• WORLD.DAT
• An ATLAS*GRAPHICS file containing data for a world map. The DAT extension is
required by ATLAS*GRAPHICS.
• BRAZIL.BNB
• A boundary file of Brazil in binary form.
• BRIT1.DAT
• BRIT2.DAT
• BRIT3.DAT
• Three versions of a data file for a map of Britain.
FORMAT Command

The format command checks a diskette for flaws and creates a directory where all the
names of the diskette's files will be stored.
Example:
• C> format a:
• Formats the diskette in the A drive.
• C> format b:
After entering this command, follow the instructions on the screen. When the FORMAT
operation is complete, the system will ask if you wish to FORMAT more diskettes. If you
are working with only one diskette, answer N (No) and carry on with you work. If you
wish to FORMAT several diskettes, answer Y (Yes) until you have finished formatting
all your diskettes.

BEWARE: Executing the format command with a diskette which already contains files
will result in the deletion of all the contents of the entire disk. It is best to execute the
format command only on new diskettes. If you format an old diskette make sure it
contains nothing you wish to save.

MKDIR (MD) Make Directory Command

This command creates a new directory.


Example:
• C> mkdir mine
• Creates a directory called 'MINE'

RENAME (REN) Command

The RENAME command permits users to change the name of a file without making a
copy of it.
Example:
• C> ren a:goofy.txt pluto.txt
• Changes the name of 'GOOFY.TXT' on the A drive to 'PLUTO.TXT'.
This command is very simple to use, just remember two points: the file name and
extension must be complete for the source file and no drive specification is given for the
target. Renaming can only occur on a single disk drive (otherwise COPY must be used).

RMDIR (RD) Remove Directory Command

This command removes a directory. It is only possible to execute this command if the
directory you wish to remove is empty.
Example:
• C> rd mine
• Removes directory called 'MINE'.
Stop Execution (Ctrl-Break)
If you wish to stop the computer in the midst of executing the current command, you may
use the key sequence Ctrl-Break. Ctrl-Break does not always work with non-DOS
commands. Some software packages block its action in certain situations, but it is worth
trying before you re-boot.

DEL

Delete one or more files in the current directory. Can be used with the '*' and the '?'
wildcards.
DEL *.* will delete ALL files in the current directory, USE WITH CAUTION.
(Note: DEL cannot be used to delete directories. Use RD to remove a directory.)
DEL <VIRUS.EXE> deletes virus.exe
DEL *.JPG will delete all files with the extension JPG.
DEL MY*.* will delete all files beginning with MY and with any extension.
DEL MY??.* will delete files that are 4 characters long and begin with MY and with any
extension.
EDIT

Runs DOS EDIT (a simple text editor). Useful for editing batch files and
viewing logs. This command requires QBASIC.EXE to be present.

EDIT <VIRUSLOG.TXT> opens the file viruslog.txt and allows you to edit it.
EDIT <NEWFILE.TXT> creates a new file called newfile.txt and opens it up for you to
edit.
PRINT

Prints the specified file (if the printer is supported in DOS - many are not).
PRINT <LOGFILE.TXT>
Prints LOGFILE.TXT
RD

Remove directory. Removes a subdirectory of the current directory. The directory you
want to remove must be empty of all files. (The command can also be written as RMDIR)
RD <DIRECTORYNAME>

FIND
This command allows you to search for text within a file. Although MS-DOS itself is
not case sensitive, when typing in the string that you are looking for with the find
command, it is case sensitive.

Additionally, this command is used to find text within a file, not the actual file itself. If
you are wanting to search or find a file with a particular name, use the dir command.

Users who are running Microsoft Windows 2000 or Windows XP should also consider
using the improved findstr command.

SYNTAX

Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.


/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
"string" Specifies the text string to find.
[drive:][path]filename Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the prompt or piped from
another command.

Examples

find /c "REM" c:\autoexec.bat

The above example would find any "REM" statement in the autoexec.bat.

find /v /c "&*fake&*" programs.txt

List each line not containing "&*fake&*", because it's very unlikely any file would
contain this string of text this would give you an accurate line count of the file.

Useful DOS Commands For Computer Technicians


The below is the list of DOS commands that are particularly useful to technicians
repairing computers:

NETWORKING

IPCONFIG – Windows IP Configuration

This is the DOS command tell you the IP settings for the current computer such as
• what your current IP is
• what subnet/gateway you are on.
• It is great for troubleshooting.
Here are the two most useful commands for ipconfig and usage:
ipconfig /release – This will release any IP information that the computer was given and
make your IP address 0.0.0.0
ipconfig /renew – This will ask any DHCP servers (usually your modem/router) for a new
IP address.

PING – Check a connection or computer

Ping is used to check the health of a connection. The ping command will tell whether
• A network device is responding and
• How fast it is running.
• The ping tool can also be used to convert a web address into an IP (eg.
www.google.com = 74.125.19.99).

NETSTAT – Displays current TCP/IP connections

netstat is also a DOS command that will display what connections are currently active on
the system. Useful for spotting programs calling back to base such as spyware.

FILE MANAGEMENT

TYPE – Open texts files

This is also a DOS command similar to Unix’s cat command. This command will display
the contents of a text file in DOS as read-only.

Syntax:
type c:\sometextfile.txt

ATTRIB – Make hidden files visible

Attrib command will tell the attributes of a file, such as whether its a system file or its
hidden. This is especially useful to technicians because critical files such as the boot.ini is
a hidden system file:
attrib -H c:\boot.ini – To unhide the boot.ini
attrib -S c:\boot.ini – To make remove its system file attribute

FIND – Advanced file search

The find command is a very powerful one with many options such as the ability to search
for something, but exclude certain files. The following command will find all files with
.pdf in their name on C:\
dir c:\ /s /b | find ".pdf"
For more information in this command and its usage, type find /?

MOVE – Move files

We can also use it to move only certain files.


For example, to get all the PDF’s out of a folder and move them to another location, but
leave all other file types alone,
move *.pdf c:\WorkPDFs\

TREE – View the tree structure

We can also use this command to make prints of the directory structure by sending the
information to a text file with the following command
tree > textfile.txt

SYSTEM

SYSTEMINFO – Displays information about the system

systeinfo will display information about the system such as the name, version, uptime,
specifications and patches installed.

CHKDSK –

This command can check a disk and attempt to recover data in bad sectors.
chkdsk /f /r – This will check a disk for errors and try and fixes information from bad
sectors
chkdsk /x – Forces the volume to dismount first.

BATCH FILE

Batch files allow MS-DOS and Microsoft Windows users to create a lists of commands to
run in sequence once the batch file has been executed. For example, a batch file could be
used to run frequently run commands, deleting a series of files, moving files, etc. A
simple batch file does not require any special programming skills and can be done by
users who have a basic understanding of MS-DOS commands.
A good example of a batch file for someone who is more familiar with Windows or the
MacOS is to think of a batch file as a shortcut in Windows or an icon on the MacOS.
Much like a shortcut, batch files could be used to run one or more commands and/or
programs through the command line.
Another example of a very well known batch file is the autoexec.bat, which is a simple
boot file loaded each time the computer is loaded on MS-DOS and early Windows
computers. This batch file contained all the necessary commands and programs used to
run MS-DOS and Windows each time the computer booted.

CREATION OF BATCH FILES:

FOR DOS USERS:

To create a basic batch file in MS-DOS, follow the below steps that tells how to create a
basic batch file.
Open an MS-DOS command window or get to MS-DOS. At the MS-DOS prompt, type:
edit test.bat and press enter.

If typed properly, you should now be in a blue screen. Within the screen, type:

pause
dir c:\windows
dir c:\windows\system

Once the above three lines have been typed in, click File and choose exit; when prompted
to save, click "Yes." Users who do not have a mouse cursor can accomplish this same
task by pressing ALT+F to access the file menu, then pressing "X" to exit, and pressing
enter to save changes.
Once you are back at the MS-DOS prompt, type: test and press enter. This will execute
the test.bat file and begin running the file. Because the first line is pause, you will first be
prompted to press a key. Once you press a key the batch file will run line-by-line; in this
case, listing the files in the windows and windows\system directories.
If you wish to add more lines to this batch file you would simply type "edit test.bat" to
edit the file again.
Additional information about the MS-DOS edit command can be found on our edit
command page. Some versions of MS-DOS and bootable diskettes may not have the edit
command; if this is the case, you would either need to obtain the edit.com file to access
this file or use the copy con command.

FOR WINDOWS USERS:

A Windows user can still use the above MS-DOS steps if they wish to create a batch file.
If, however, you're more comfortable using Microsoft Windows or your operating
system, you can use any text editor, such as Notepad or Wordpad, to create your batch
files, as long as the file extension ends with .bat. In the below example we use the
Windows notepad to create a batch file.
Click Start
Click Run
Type: notepad and press enter.
Once notepad is open, type the below lines in the file or copy and paste the below lines
into notepad.

@echo off
echo Hello this is a test batch file
pause
dir c:\windows
Click File and click Save; browse to where you want to save the file. For the file name,
type "test.bat", and if your version of Windows has a "Save as type" option, choose "All
files", otherwise it will save as a text file. Once all of this has been done click the Save
button and exit notepad.
Now, to run the batch file, simply double-click or run the file like any other program.
Once the batch file has completed running it will close the window automatically.

PAINT

Paint is an application software formerly known as Paintbrush for Windows. It is a


simple graphics painting program that has been included with all versions of Microsoft
Windows. It is often referred to as MS Paint or Microsoft Paint. The program opens and
saves files as Windows bitmap (24-bit, 256 color, 16 color, and monochrome, all with the
.bmp extension), JPEG, GIF (without animation or transparency, although the Windows
98 version, a Windows 95 upgrade, and the Windows NT4 version did support the latter),
PNG and TIFF (without the multiple pages). The program can be in color mode or two-
color black-and-white, but there is no grayscale mode. For its simplicity, it rapidly
became one of the most used applications in the early versions of Windows—introducing
many to painting on a computer for the first time—and still has strong associations with
the immediate usability of the old Windows workspace
The above figure shows Microsoft paint application. It consists of various menus:
1. File
2. Edit
3. View
4. Image
5. Colors
6. Help

Paint is also used to draw figures using various tools for drawing rectangles, squares,
lines and writing texts. It also facilitates with color tool box for using standard or 256
colors.

FILES & FOLDER ORGANIZATION

There are two basic types of items that need to be organized on the computer,.

• The first, a folder, is an object that can hold multiple files or documents. (Folders
are sometimes referred to as directories.) On the computer screen, a folder most
often looks like a yellow or blue paper file folder.
• The second type of object is a file, which may be a picture, a document, a video
clip, or other piece of data. A file often has a small icon or picture associated with
it.
NAMING FILES AND FOLDERS

In the old DOS days of computing, file names followed a strict naming structure -- eight
characters, a period, and three more characters; spaces could not be used. Now the newer
Windows operating systems have finally caught up to their Mac brethren by allowing
longer file names. Windows file and/or folder names can contain up to 215 characters,
including spaces. Just try to keep your file names to 20-30 characters, if you can. Short
file names are still easier to use, and some programs may have trouble interpreting
extremely long file names.
File names are generally followed by a period and three letters, called an extension. In
most cases, the program that you are using will automatically add the extension. You may
or may not see the extension depending on the way your computer is set up. One
important thing to know when naming files and/or folders: names cannot contain the
following characters: / : * ? " < > | .These are also known as special characters.

FILING SYSTEM

First, you will want to set up an organization system by creating folders to hold your files
and documents. The idea here is for you to have a plan and to follow it. You can choose
any type of scheme that fits the way that you work. You may want to create folders for
the various types of work that you do, such as home, office, financial, etc. Or you might
want to separate your folders by the type, contact, or company giving them titles such as
Utilities, Inventory, Clients, Prudential, Dean Witter, etc.

The Tree Structure

Most computer file configurations use a tree structure, which is sometimes referred to as
a nested arrangement. The tree has one trunk with many branches. The branches have
many smaller branches, and the smaller branches have many leaves. Consider your hard
disk like the trunk of a tree. Most computers only have one hard disk. Just as some trees
have two or three trunks, a computer may also have two or three hard disks or one hard
disk that is broken up in several parts. Right now, however, we will only talk about the
main hard disk. In Windows computers, it is usually labeled C:
To get to the hard disk in Windows, just double-click on My Computer, then click on the
C: Drive (It may have a similar name, such as Local Drive C:). Once you have opened
the hard disk folder, you will see that it already has other folders inside of it. To create a
new folder, click on the word File in the menu at the top of the screen. Then choose New
and then Folder. A new folder will appear with the name "New Folder" highlighted. Just
type in the name that you would like to give the folder, and the words "New Folder" will
disappear. The title that you typed will appear under the folder. If, for some reason, the
folder still reads "New Folder," simply right-click on the folder, choose Rename, and
retype the name again.
A folder may contain other folders. If you have created a new folder called Finances, you
may want to have several folders in that folder called Bank, Stocks, Bonds, etc. A folder
labeled Home may have folders inside labeled Record Inventory, Household, Utilities,
etc. To create a folder within a folder, simply open (double-click) a folder before you
choose the File-New Folder option.
You can also move folders by dragging them from one place to another. For instance, if
you create a folder in your Home folder and then decide that it should have been in your
Investment folder, you can simply highlight the folder by clicking on it and then drag it
onto the Investment folder. Remove your finger from the mouse when the folder is over
the Investment folder and it will be added to the Investment folder.

Default Folders

Every time you write a letter or create a spreadsheet or a presentation, you are creating a
file. When you save that file, unless you stipulate otherwise, the program you are using
puts the file into a certain folder. That folder is the default folder for the application that
you are using. Many Windows programs, especially Microsoft programs like Word,
Works, and Excel use a folder called My Documents as the default folder. It is often a
good idea to keep your files in the My Documents folder and simply create sub-folders in
My Documents to suit your needs. Newer versions of Windows also use folders labeled
My Downloads and My Music as the default folders for various applications.
You can change the default folder by looking through the menus at the top of the screen.
The location of the default folder is most often found in the Tools menu. For instance, in
Microsoft Word, the default folder is found in the Tools menu under Options on the File
Location tab.

THE VI UNIX EDITOR

The Vi Unix Editor is the standard UNIX command line editor and if you’re planning on
doing some configuring of a Unix Server you will definitely need to use the VI editor
especially when you’re running a Command Line only operating system.
This hub will go through the basics of using the Vi unix editor, opening, creating, saving
and writing to a file as well as the different modes for the Vi Editor. I will also go
through common problems people have with the Vi editor especially the annoying
problem when logging into your server using a SSH client such as Putty, where you find
that the backspace key doesn’t work or the arrow keys simply return letters.
Unix Vi Editor Modes
- Command mode – This is the basic mode of the Vi editor and can be accessed by
opening a file using “vi file.conf”. Letters and combination of letters will be interpreted
as commands.
- Insert Mode – The Insert mode as it sounds allows you to edit text and insert your own
text into configuration files. Depending on how your Unix system is setup you can either
navigate using the arrow keys and regular windows keyboard or use the following. Press
the INSERT key on your keyboard to enter this mode.
- INSERT IMAGE, ordinarily you can use the regular keyboard functions otherwise
use these ones. Paste bigger list onto a copy code thing
- Line Mode – The line mode can be entered by pressing ESC and then type colon (J
From here you can either save the file, save and quit , or quit without saving changes.
:wq write the file to disk and quit
:q! quit without saving any changes
:w! newfile write all lines from the entire current file into the file 'newfile', overwriting
any existing newfile
:n,m w! newfile write the lines from n to m, inclusive, into the file newfile, overwriting
any existing newfile

Common Problems when using Vi Editor


- Backspace function not working
- Arrow keys return A, B, C , alpha functions
- Keys generally acting strange and muddled
- Errors when using Putty or SSH client to remotely access server

File Names
For every file you create, you must supply a name. In Unix, the following characters have
special meaning, so you should avoid using them in file names:
/ \ " ` ' * | ! ? ~ $ < > &
File names may be between 1 and 255 characters long, but you will find that short,
descriptive names are easiest to use. File names should not contain spaces. Instead of
spaces, use underscores or periods to separate names made of multiple words, as follows:
mail.Jan annual_report unix_tips
Also, Unix distinguishes between uppercase and lowercase letters. For example, Unix
would treat these as three different files:
project1 Project1 PROJECT1
Create a File With a Text Editor
Text editors let you enter, edit, and re-arrange text in files. Uniform Access computers
support several text editors including Pico , vi, and others. If you are a beginning Unix
user, you might prefer Pico to vi for the following reasons:
• Pico is easier to learn and use.
• Pico contains online help text and lists the most commonly used commands at the
bottom of each screen.
• Pico is designed for worry-free exploration.
To create a new file using the Pico text editor, enter:
pico file
Note: the p in the pico command is lowercase.
This starts the Pico text editor and opens a blank file. Pico assigns to that file the name
you specify. Use your keyboard to add text to the file.
To save a file and exit the Pico text editor:
1. Press <Control>x
This means hold down the Control key, while you press the x key.
2. In response to the question:
Save before leaving (y/n)?
Type y
3. In response to the prompt:
Filename to write:
Press <Return> or enter a new name.
To re-open and edit a file with the Pico text editor, enter:
pico file
Where file is the name of the file you want to edit.

List Your Files

To list the files in your current directory, use the ls (list) command. At the system prompt
(e.g., mead%), enter:
ls
Your list might resemble the following:
mail murphy.law phone.dir sport.quote
For more on the ls command, see List the Contents of a Directory

Copy a File

To copy a file, use the cp (copy) command. Enter:


cp file1 file2
This creates a copy of file1 and names it file2.
To copy a file to a different directory, enter:
cp file directory
This creates a copy of the file you specify in directory the you specify.
For more information on directories, see Working With Directories.

Change the Name of a File

To change the name of a file, use the mv (move) command. Enter:


mv file1 file2
This changes the name of file1 to file2.
View a File

To view a file, use the more command. Enter:


more file
This starts the more program, which lets you view the file you specify one screen at a
time. Use <Spacebar> to scroll forward one screen, <Return> to scroll forward one line,
and q to quit the more program. To search for a word in the file, type / followed by the
word and then press <Return>.

Delete a File

To delete a file, use the rm (remove) command. Enter:


rm file
This permanently removes the file you specify. A safe way to give the rm command is
with the -i option. With the -i option, you are prompted before a file is permanently
removed.
To require a prompt before a file is deleted, enter:
rm -i file
In response to the prompt, enter y to remove the file or n to keep the file.

Basic vi Commands Table

All commands in vi must be preceded by pressing the “Escape” key. Most commands are
case sensitive.

CURSOR MOVEMENT

arrow keys :generally work as expected


page up/down :generally work as expected

nh :left n spaces (n indicates a number and is optional)


nj :right n spaces (n indicates a number and is optional)
nk :up n spaces (n indicates a number and is optional)
nl :down n spaces (n indicates a number and is optional)

^F :forward one screen (^ indicates the “Control” key)


^B :back one screen (^ indicates the “Control” key)

0 :(zero) beginning of line


$ :end of line
H :beginning of top line of screen
L :beginning of last line of screen
:1 :beginning of file
G :end of file
INSERTING TEXT

i :insert text before cursor


a :append text after cursor (does not overwrite)
I :insert text at beginning of line
A :append text at end of line

r :replace the character under the cursor with next character typed
R :overwrite characters until end of line

o :(lowercase “o”) new line after the current line


O :(uppercase “O”) new line before the current line

DELETING TEXT

dd :deletes current line


ndd :deletes next n lines
D :deletes from cursor to end of line
x :deletes current character
X :deletes previous character

FILE MANIPULATION

:w file :writes changes to file (file is optional, default is current file)


:w file :overwrites file (file is optional, default is current file)
:f name :renames current file to name

:q :quits edit session when no changes have been made


:q! :quits edit session and discards changes
:wq :writes changes to current file and quits edit session

MISCELLANEOUS

u undo the last command made to a line


. repeat the last command made to a line

nyy yank n lines to buffer (n indicates a number and is optional)


ynw yank n words to buffer (n indicates a number and is optional)
p puts yanked or deleted text after cursor
P puts yanked or deleted text before cursor

:r file inserts file at current cursor position


LINUX FILES AND FILE PERMISSION

Linux files are setup so access to them is controlled. There are three types of access:
1. read
2. write
3. execute
Each file belongs to a specific user and group. Access to the files is controlled by user,
group, and what is called other. The term, other, is used to refer to someone who is not
the user (owner) of the file, nor is the person a member of the group the file belongs to.
When talking about setting permissions for "other" users to use, it is commonly referred
to as setting the world execute, read, or write bit since anyone in the world will be able to
perform the operation if the permission is set in the other category.

File names and permission characters

File names can be up to 256 characters long with "-", "_", and "." characters along with
letters and numbers. When a long file listing is done, there are 10 characters that are
shown on the left that indicate type and permissions of the file. File permissions are
shown according to the following syntax
Example:drwerwerwe
There are a total of 10 characters in this example, as in all Linux files. The first character
indicates the type of file, and the next three indicate read, write, and execute permission
for each of the three user types, user, group and other. Since there are three types of
permission for three users, there are a total of nine permission bits. The table below
shows the syntax:

1 2 3 4 5 6 7 8 9 10
File User Permissions Group Permissions Other Permissions
Type Read Write Execute Read Write Execute Read Write Execute
d r w e r w e r w e

Character 1 is the type of file: - is ordinary, d is directory, l is link.


Characters 2-4 show owner permissions. Character 2 indicates read permission, character 3
indicates write permission, and character 4 indicates execute permission.
Characters 5-7 show group permissions. Character 5=read, 6=write, 7=execute
Characters 8-10 show permissions for all other users. Character 8=read, 9=write, 10=execute
There are 5 possible characters in the permission fields. They are:
r = read - This is only found in the read field.
w = write - This is only found in the write field.
x = execute - This is only found in the execute field.
s = setuid - This is only found in the execute field.
If there is a "-" in a particular location, there is no permission. This may be found in any field
whether read, write, or execute field.
Examples
Type "ls -l" and a listing like the following is displayed:
total 10
drwxrwxrwx 4 george team1 122 Dec 12 18:02 Projects
-rw-rw-rw- 1 george team1 1873 Aug 23 08:34 test
-rw-rw-rw- 1 george team1 1234 Sep 12 11:13 datafile
Which means the following:
Type and # of Files's File's Size in Date of last Filename
Permission field Links Owner Group Bytes modification
| | | | | | |
drwxrwxrwx 4 george team1 122 Dec 12 18:02 Projects
The fields are as follows:
1. Type field: The first character in the field indicates a file type of one of the
following:
d = directory
l = symbolic link
s = socket
p = named pipe
- = regular file
c= character (unbuffered) device file special
b=block (buffered) device file special
Permissions are explained above.
2. Links: The number of directory entries that refer to the file. In our example, there
are four.
3. The file's owner in our example is George.
4. The group the file belongs to. In our example, the group is team1.
5. The size of the file in bytes
6. The last modification date. If the file is recent, the date and time is shown. If the
file is not in the current year, the year is shown rather than time.
7. The name of the file.

Set User Identification Attribute

The file permissions bits include an execute permission bit for file owner, group and
other. When the execute bit for the owner is set to "s" the set user ID bit is set. This
causes any persons or processes that run the file to have access to system resources as
though they are the owner of the file. When the execute bit for the group is set to "s", the
set group ID bit is set and the user running the program is given access based on access
permission for the group the file belongs to. The following command:
chmod +s myfile
sets the user ID bit on the file "myfile". The command:
chmod g+s myfile
sets the group ID bit on the file "myfile".
The listing below shows a listing of two files that have the group or user ID bit set.
-rws--x--x 1 root root 14024 Sep 9 1999 chfn
-rwxr-sr-x 1 root mail 12072 Aug 16 1999 lockfile
The files chfn and lockfile are located in the directory "/usr/bin". The "s" takes the place
of the normal location of the execute bit in the file listings above. This special permission
mode has no meaning unless the file has executed permission set for either the group or
other as well. This means that in the case of the lockfile, if the other users (world
execute) bit is not set with permission to execute, then the user ID bit set would be
meaningless since only that same group could run the program anyhow. In both files,
everyone can execute the binary. The first program, when run is executed as though the
program is the root user. The second program is run as though the group "mail" is the
user’s group.

For system security reasons it is not a good idea to set many program's set user or group
ID bits any more than necessary, since this can allow an unauthorized user privileges in
sensitive system areas. If the program has a flaw that allows the user to break out of the
intended use of the program, then the system can be compromised.

Directory Permissions

There are two special bits in the permissions field of directories. They are:
• s - Set group ID
• t - Save text attribute (sticky bit) - The user may delete or modify only those files in
the directory that they own or have write permission for.

Save text attribute

The /tmp directory is typically world-writable and looks like this in a listing:
drwxrwxrwt 13 root root 4096 Apr 15 08:05 tmp
Everyone can read, write, and access the directory. The "t'' indicates that only the user
(and root, of course) that created a file in this directory can delete that file.

To set the sticky bit in a directory, do the following:


chmod +t data
This option should be used carefully. A possible alternative to this is
1. Create a directory in the user's home directory to which he or she can write
temporary files.
2. Set the TMPDIR environment variable using each user's login script.
3. Programs using the tempnam(3) function will look for the TMPDIR variable and
use it, instead of writing to the /tmp directory.

Directory Set Group ID

If the setgid bit on a directory entry is set, files in that directory will have the group
ownership as the directory, instead of than the group of the user that created the file.

This attribute is helpful when several users need access to certain files. If the users work
in a directory with the setgid attribute set then any files created in the directory by any of
the users will have the permission of the group. For example, the administrator can create
a group called spcprj and add the users Kathy and Mark to the group spcprj. The
directory spcprjdir can be created with the set GID bit set and Kathy and Mark although
in different primary groups can work in the directory and have full access to all files in
that directory, but still not be able to access files in each other's primary group.

The following command will set the GID bit on a directory:


chmod g+s spcprjdir
The directory listing of the directory "spcprjdir":
drwxrwsr-x 2 kathy spcprj 1674 Sep 17 1999 spcprjdir
The "s'' in place of the execute bit in the group permissions causes all files written to the
directory "spcprjdir" to belong to the group "spcprj" .
Examples
Below are examples of making changes to permissions:
chmod u+x myfile Gives the user execute permission on myfile.
chmod +x myfile Gives everyone execute permission on myfile.
chmod ugo+x myfile Same as the above command, but specifically specifies user, group
and other.
chmod 400 myfile Gives the user read permission, and removes all other permission.
These permissions are specified in octal, the first char is for the user,
second for the group and the third is for other. The high bit (4) is for
read access, the middle bit (2) os for write access, and the low bit
(1) is for execute access.
chmod 764 myfile Gives user full access, group read and write access, and other read
access.
chmod 751 myfile Gives user full access, group read and execute permission, and
other, execute permission.
chmod +s myfile Set the setuid bit.
chmod go=rx myfile Remove read and execute permissions for the group and other.

Below are examples of making changes to owner and group:


chown mark test1 Changes the owner of the file test1 to the user Mark.
chgrp mark test1 Changes the file test1 to belong to the group "mark".

Note: Linux files were displayed with a default tab value of 8 in older Linux versions.
That means that file names longer than 8 may not be displayed fully if you are using an
old Linux distribution. There is an option associated with the ls command that solves this
problem. It is "-T". Ex: "ls al -T 30" to make the tab length 30.

Umask Settings
The umask command is used to set and determine the default file creation permissions on
the system. It is the octal complement of the desired file mode for the specific file type.
Default permissions are:
• 777 - Executable files
• 666 - Text files
These defaults are set allowing all users to execute an executable file and not to execute a
text file. The defaults allow all users can read and write the file.

The permission for the creation of new executable files is calculated by subtracting the
umask value from the default permission value for the file type being created. An
example for a text file is shown below with a umask value of 022:
666 Default Permission for text file
-022 Minus the umask value
-----
644 Allowed Permissions
Therefore the umask value is an expression of the permissions the user, group and world
will not have as a default with regard to reading, writing, or executing the file. The umask
value here means the group the file belongs to and users other than the owner will not be
able to write to the file. In this case, when a new text file is created it will have a file
permission value of 644, which means the owner can read and write the file, but members
of the group the file belongs to, and all others can only read the file. A long directory
listing of a file with these permissions set is shown below.
-rw-r--r-- 1 root workgrp 14233 Apr 24 10:32 textfile.txt
A example command to set the umask is:
umask 022
The most common umask setting is 022. The /etc/profile script is where the umask
command is usually set for all users.

Red Hat Linux has a user and group ID creation scheme where there is a group for each
user and only that user belongs to that group. If you use this scheme consistently you
only need to use 002 for your umask value with normal users.

IPCONFIG
Configure IP (internet protocol configuration)
Syntax

IPCONFIG /all Display full configuration information.

IPCONFIG /release [adapter]


Release the IP address for the specified adapter.

IPCONFIG /renew [adapter]


Renew the IP address for the specified adapter.

IPCONFIG /flushdns Purge the DNS Resolver cache.

IPCONFIG /registerdns Refresh all DHCP leases and re-register DNS names.

IPCONFIG /displaydns Display the contents of the DNS Resolver Cache.

IPCONFIG /showclassid adapter


Display all the DHCP class IDs allowed for adapter.

IPCONFIG /setclassid adapter [classid]


Modify the dhcp class id.
If the Adapter name contains spaces, use quotes: "Adapter Name"
wildcard characters * and ? allowed, see the examples below

The default is to display only the IP address, subnet mask and default gateway for each
adapter bound to TCP/IP.

For Release and Renew, if no adapter name is specified, then the IP address leases for all
adapters bound to TCP/IP will be released or renewed.

For Setclassid, if no ClassId is specified, then the ClassId is removed.


Examples:
> ipconfig ... Show information.
> ipconfig /all ... Show detailed information
> ipconfig /renew ... renew all adapters
> ipconfig /renew EL* ... renew any connection that has its
name starting with EL

> ipconfig /release *Con* ... release all matching connections,


eg. "Local Area Connection 1" or
"Local Area Connection 2"

> ipconfig /setclassid "Local Area Connection" TEST


... set the DHCP class ID for the
named adapter to = TEST

NETSTAT.exe

Display current TCP/IP network connections and protocol statistics.


Syntax
NETSTAT [options] [-p protocol] [interval]

Key
-a Display All connections and listening ports.
-e Display Ethernet statistics. (may be combined with -s)
-n Display addresses and port numbers in Numerical form.
-r Display the Routing table.
-o Display the Owning process ID associated with each connection.

-b Display the exe involved in creating each connection or listening port.*


-v Verbose - use in conjunction with -b, to display the sequence of
components involved for all executables.

-p protocol
Show only connections for the protocol specified;
may be any of: TCP, UDP, TCPv6 or UDPv6.
If used with the -s option then the following protocols
may also be specified: IP, IPv6, ICMP,or ICMPv6.

-s Display per-protocol statistics. By default, statistics are


shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
(The v6 protocols are not available under 2k and NT4)
The -p option may be used to display just a subset of these.

interval Redisplay statistics, pausing interval seconds between


each display. (default=once only) Press CTRL+C to stop.

NMAP

Short for network mapper, nmap is a network exploration tool and security / port scanner.

Syntax

nmap [Scan Type(s)] [Options] {target specification}

TARGET SPECIFICATION:
-iL Input from list of hosts/networks
-iR Choose random targets
--exclude <host1[,host2] Exclude hosts/networks
[,host3],...>
--excludefile Exclude list from file
<exclude_file>
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM TCP SYN/Connect()/ACK/Window/Maimon scans
-sN/sF/sX TCP Null, FIN, and Xmas scans
--scanflags <flags> Customize TCP scan flags
-sI <zombie Idlescan
host[:probeport]>
-sO IP protocol scan
-b <ftp relay host> FTP bounce scan

PS

Reports the process status.

Syntax
ps [-a] [-A] [-c] [-d] [-e] [-f] [-j] [-l] [-L] [-P] [-y] [ -g grplist ] [ -n namelist ] [-o
format ] [ -p proclist ] [ -s sidlist ] [ -t term] [ -u uidlist ] [ -U uidlist ] [ -G gidlist ]

-a List information about all processes most frequently requested: all


those except process group leaders and processes not associated with a
terminal.
-A List information for all processes. Identical to -e, below.
-c Print information in a format that reflects scheduler properties as
described in priocntl.
The -c option affects the output of the -f and -l options, as described
below.
-d List information about all processes except session leaders.
-e List information about every process now running.
-f Generate a full listing.
-j Print session ID and process group ID.
-l Generate a long listing.
-L Print information about each light weight process (lwp) in each
selected process.
-P Print the number of the processor to which the process or lwp is bound,
if any, under an additional column header, PSR.
-y Under a long listing (-l), omit the obsolete F and ADDR columns and
include an RSS column to report the resident set size of the process.
Under the -y option, both RSS and SZ will be reported in units of
kilobytes instead of pages.
-g grplist List only process data whose group leader's ID number(s) appears in
grplist. (A group leader is a process whose process ID number is
identical to its process group ID number.)
-n namelist Specify the name of an alternative system namelist file in place of the
default. This option is accepted for compatibility, but is ignored.
-o format Print information according to the format specification given in format.
This is fully described in DISPLAY FORMATS. Multiple -o options
can be specified; the format specification will be interpreted as the
space-character-separated concatenation of all the format option-
arguments.
-p proclist List only process data whose process ID numbers are given in proclist.
-s sidlist List information on all session leaders whose IDs appear in sidlist.
-t term List only process data associated with term. Terminal identifiers are
specified as a device file name, and an identifier. For example, term/a,
or pts/0.
-u uidlist List only process data whose effective user ID number or login name is
given in uidlist. In the listing, the numerical user ID will be printed
unless you give the -f option, which prints the login name.
-U uidlist List information for processes whose real user ID numbers or login
names are given in uidlist. The uidlist must be a single argument in the
form of a blank- or comma-separated list.
-G gidlist List information for processes whose real group ID numbers are given
in gidlist. The gidlist must be a single argument in the form of a blank-
or comma-separated list.
Examples
ps
Typing ps alone would list the current running processes. Below is an example of the
output that would be generated by the ps command.
PID TTY TIME CMD
6874 pts/9 0:00 ksh
6877 pts/9 0:01 csh
418 pts/9 0:00 csh
ps -ef
Display full information about each of the processes currently running.
UID PID PPID C STIME TTY TIME CMD
hope 29197 18961 0 Sep27 ? 00:00:06 sshd: hope@pts/87
hope 32097 29197 0 Sep27 pts/87 00:00:00 -csh
hope 7209 32097 0 12:17 pts/87 00:00:00 ps -ef
ps -l
Displays processes including those that are in a wait state, similar to the below example.
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0T0 12308 29722 0 80 0 - 16136 finish pts/0 00:00:00 pico
0R0 12530 29722 0 80 0 - 15884 - pts/0 00:00:00 ps
4S0 29722 29581 0 80 0 - 16525 wait pts/0 00:00:00 bash

TOP
Display Linux tasks.

Syntax

top -hv | -bcisS -d delay -n iterations -p pid [, pid ...]

The traditional switches '-' and whitespace are optional.


-b Batch mode operation
Starts top in 'Batch mode', which could be useful for sending output
from top to other programs or to a file. In this mode, top will not
accept input and runs until the iterations limit you've set with the '-n'
command-line option or until killed.
-c Command line/Program name toggle
Starts top with the last remembered 'c' state reversed. Thus, if top was
displaying command lines, now that field will show program names,
and visa versa. See the 'c' interactive command for additional
information.
-d Delay time interval as: -d ss.tt (seconds.tenths)
Specifies the delay between screen updates, and overrides the
corresponding value in one's personal configuration file or the startup
default. Later this can be changed with the 'd' or 's' interactive
commands.
Fractional seconds are honored, but a negative number is not allowed.
In all cases, however, such changes are prohibited if top is running in
'Secure mode', except for root (unless the 's' command-line option was
used). For additional information on 'Secure mode' see topic 5a.
SYSTEM Configuration File.
-h Help
Show library version and the usage prompt, then quit.
-i Idle Processes toggle
Starts top with the last remembered 'i' state reversed. When this toggle
is Off, tasks that are idled or zombied will not be displayed.
-n Number of iterations limit as: -n number
Specifies the maximum number of iterations, or frames, top should
produce before ending.
-u Monitor by user as: -u somebody
Monitor only processes with an effective UID or user name matching
that given.
-U Monitor by user as: -U somebody
Monitor only processes with a UID or user name matching that given.
This matches real, effective, saved, and filesystem UIDs.
-p Monitor PIDs as: -pN1 -pN2 ... or -pN1, N2 [,...]
Monitor only processes with specified process IDs. This option can be
given up to 20 times, or you can provide a comma delimited list with
up to 20 pids. Co-mingling both approaches is permitted.
This is a command-line option only. And should you wish to return to
normal operation, it is not necessary to quit
and and restart top -- just issue the '=' interactive command.
-s Secure mode operation
Starts top with secure mode forced, even for root. This mode is far
better controlled through the system configuration file (see topic 5.
FILES).
-S Cumulative time mode toggle
Starts top with the last remembered 'S' state reversed. When
'Cumulative mode' is On, each process is listed with the cpu time that it
and its dead children have used. See the 'S' interactive command for
additional information regarding this mode.
-v Version
Show library version and the usage prompt, then quit.
Examples
When operating top, the two most important keys are help ('h' or '?') and quit ('q') key.
Alternatively, you could simply use the traditional interrupt key ('^C') when you're done.

LS

Lists the contents of a directory.

Syntax

ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s]
[-t] [-u] [-x] [pathnames]

-a Shows you all files, even files that are hidden (these files begin with a
dot.)
-A List all files including the hidden files. However, does not display the
working directory (.) or the parent directory (..).
-b Force printing of non-printable characters to be in octal \ddd notation.
-c Use time of last modification of the i-node (file created, mode changed,
and so forth) for sorting (-t) or printing (-l or -n).
-C Multi-column output with entries sorted down the columns. Generally this
is the default option.
-d If an argument is a directory it only lists its name not its contents.
-f Force each argument to be interpreted as a directory and list the name
found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a;
the order is the order in which entries appear in the directory.
-F Mark directories with a trailing slash (/), doors with a trailing greater-than
sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing
vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix
address family sockets with a trailing equals sign (=).
-g Same as -l except the owner is not printed.
-i For each file, print the i-node number in the first column of the report.
-l Shows you huge amounts of information (permissions, owners, size, and
when last modified.)
-L If an argument is a symbolic link, list the file or directory the link
references rather than the link itself.
-m Stream output format; files are listed across the page, separated by
commas.
-n The same as -l, except that the owner's UID and group's GID numbers are
printed, rather than the associated character strings.
-o The same as -l, except that the group is not printed.
-p Displays a slash ( / ) in front of all directories.
-q Force printing of non-printable characters in file names as the character
question mark (?).
-r Reverses the order of how the files are displayed.
-R Includes the contents of subdirectories.
-s Give size in blocks, including indirect blocks, for each entry.
-t Shows you the files in modification time.
-u Use time of last access instead of last modification for sorting (with the -t
option) or printing (with the -l option).
-x Displays files in columns.
-1 Print one entry per line of output.
pathnames File or directory to list.

Examples
ls -l
In the above example this command would list each of the files in the current directory
and the files permissions, the size of the file, date of the last modification, and the file
name or directory. Below is additional information about each of the fields this
command lists.
Permissions Directories Group Size Date Directory or file
drwx------ 2 users 4096 Nov 2 19:51 mail/
drwxr-s--- 35 www 32768 Jan 20 22:39 public_html/
-rw------- 1 users 3 Nov 25 02:58 test.txt
Below is a brief description of each of the above categories shown when using the ls -l
command.
Permissions - The permissions of the directory or file.
Directories - The amount of links or directories within the directory. The default amount
of directories is going to always be 2 because of the . and .. directories.
Group - The group assigned to the file or directory
Size - Size of the file or directory.
Date - Date of last modification.
Directory of file - The name of the file or file.
• ls ~
List the contents of your home directory by adding a tilde after the ls command.
• ls /
List the contents of your root directory.
• ls ../
List the contents of the parent directory.
• ls */
List the contents of all sub directories.
• ls -d */
Only list the directories in the current directory.

FILE HANDLING IN LINUX


One of the most common errors of learning scripts bash on GNU / Linux is to read a file
line by line, is to use a loop "for" (for line in $ (cat file.txt) do. ..), which in this example
leads to an assessment for li not every word of the file.

Sample output with a loop "for":


for line in $ (cat file.txt) do echo "$ line" done
This
is
the
row
No
1
This
is
the
row
No
2
This
[...]

The solution is to use a loop "while" coupled with the internal read.

But it is possible to get me the result with a loop "for" provided to change the value of the
variable $ IFS (Internal Field Separator, internal field separator) before starting the loop.

WHILE LOOP

The loop "while" remains the most appropriate and easiest way to read a file line by line.
Syntax

while read line


do
command
done <file

==Example==

The starting file:


This is the No. 1 line
This is line 2
This is the line # 3
This is the line n ° 4
This is the line # 5

The instructions from the command line:


while read line; do echo-e "$ line \ n" done <file.txt

or in a script "bash":
#! / bin / bash

while read line


do
echo-e "$ line \ n"
done <file.txt

The output on the screen (stdout):


This is the No. 1 line

This is line 2

This is the line # 3

This is the line n ° 4

This is the line # 5

SETTING PASSWORD IN LINUX

It is entirely possible from a structured file (like an address book or / etc / passwd for
example), retrieve the values of each field and assigned to several variables with the
command "read" . Be careful to properly assign the variable IFS "good field separator
(space by default).

Example:
#! / bin / bash

while IFS =: read user pass full uid gid home shell
do
echo-e "$ full: \ n \
Username: $ user \ n \
UID: \ t $ uid \ n \
GID: \ t $ gid \ n \
Home: \ t $ home \ n \
Shell: \ t $ shell \ n \ n "
done </ etc / passwd

CHKCONFIG IN LINUX

chkconfig - updates and queries run level information for system services

SYNOPSIS
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name

DESCRIPTION

chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d


directory hierarchy by relieving system administrators of the task of directly
manipulating the numerous symbolic links in those directories.
This implementation of chkconfig was inspired by the chkconfig command present in
the IRIX operating system. Rather than maintaining configuration information outside of
the /etc/rc[0-6].d hierarchy, however, this version directly manages the symlinks in
/etc/rc[0-6].d. This leaves all of the configuration information regarding what services
init starts in a single location.
chkconfig has five distinct functions:
1. Adding new services for management,
2. Removing services from management,
3. Listing the current startup information for services,
4. Changing the startup information for services, and
5. Checking the startup state of a particular service.

LOG FILES

Log files are files that contain messages about the system, including the kernel, services,
and applications running on it. There are different log files for different information. For
example, there is a default system log file, a log file just for security messages, and a log
file for crony tasks.
Log files can be very useful if you are trying to troubleshoot a problem with the system
such as trying to load a kernel driver or if you are looking for unauthorized log in
attempts to the system. This chapter discusses where to find log files, how to view log
files, and what to look for in log files.
Some log files are controlled by a daemon called syslogd. A list of log messages
maintained by syslogd can be found in the /etc/syslog.conf configuration file.
Locating Log Files

Most log files are located in the /var/log directory. Some applications such as httpd and
samba have a directory within /var/log for their log files.
Notice the multiple files in the log file directory with numbers after them. These are
created when the log files are rotated. Log files are rotated so their file sizes do not
become too large. The logrotate package contains a cron task that automatically rotates
log files according to the /etc/logrotate.conf configuration file and the configuration files
in the /etc/logrotate.d directory. By default, it is configured to rotate every week and keep
four weeks worth of previous log files.

Viewing Log Files

Most log files are in plain text format. You can view them with any text editor such as Vi
or Emacs. Some log files are readable by all users on the system; however, you must be
logged in as root to read most log files.
To view system log files in an interactive, real-time application, use the Log Viewer. To
start the application, go to the Main Menu Button (on the Panel) => System Tools =>
System Logs, or type the command redhat-logviewer at a shell prompt.
The application only displays log files that exist; thus, your list might differ from the one
shown in Figure 28-1. To view the complete list of log files that it can view, refer to the
configuration file, /etc/sysconfig/redhat-logviewer.
By default, the currently viewable log file is refreshed every 30 seconds. To change the
refresh rate, select Edit => Preferences from the pull-down menu. The window shown in
Figure 28-2 will appear. In the Log Files tab, click the up and down arrows beside the
refresh rate to change it. Click Close to return to the main window. The refresh rate is
changed immediately. To refresh the currently viewable file manually, select File =>
Refresh Now or press [Ctrl]-[R].
To filter the contents of the log file for keywords, type the word or words you are looking
for the Filter for text field, and click Filter. Click Reset to reset the contents.
You can also change where the application looks for the log files from the Log Files tab.
Select the log file from the list, and click the Change Location button. Type the new
location of the log file or click the Browse button to locate the file location using a file
selection dialog. Click OK to return to the preferences, and click Close to return to the
main window.

Examining Log Files

Log Viewer can be configured to display an alert icon beside lines that contain key alert
words. To add alerts words, select Edit => Preferences from the pull-down menu, and
click on the Alerts tab. Click the Add button to add an alert word. To delete an alert
word, select the word from the list, and click Delete

CREATING USER ACCOUNTS


When a computer is used by many people it is usually necessary to differentiate between
the users, for example, so that their private files can be kept private. This is important
even if the computer can only be used by a single person at a time, as with most
microcomputers.Thus, each user is given a unique username, and that name is used to log
in.
There's more to a user than just a name, however. An account is all the files, resources,
and information belonging to one user. The term hints at banks, and in a commercial
system each account usually has some money attached to it, and that money vanishes at
different speeds depending on how much the user stresses the system. For example, disk
space might have a price per megabyte and day, and processing time might have a price
per second.
Creating a user
The Linux kernel itself treats users are mere numbers. Each user is identified by a unique
integer, the user id or uid, because numbers are faster and easier for a computer to
process than textual names. A separate database outside the kernel assigns a textual
name, the username, to each user id. The database contains additional information as
well.
To create a user, you need to add information about the user to the user database, and
create a home directory for him. It may also be necessary to educate the user, and set up a
suitable initial environment for him.
Most Linux distributions come with a program for creating accounts. There are several
such programs available. Two command line alternatives are adduser and useradd; there
may be a GUI tool as well. Whatever the program, the result is that there is little if any
manual work to be done. Even if the details are many and intricate, these programs make
everything seem trivial. However, Section 11.2.4 describes how to do it by hand.

PINE

Pine is a user agent designed for novices; it includes news-reading capability and built-in
support for the IMAP remote-mail protocol. A lot of people swear by it for new users.
You find its impoverished command set, limited configurability and native editor hard to
take. It has excellent built-in IMAP support. Pine respects the EDITOR/VISUAL
convention

What is Data Security?


In simple terms, data security is the practice of keeping data protected from corruption
and unauthorized access. The focus behind data security is to ensure privacy while
protecting personal or corporate data.
Data is the raw form of information stored as columns and rows in our
databases, network servers and personal computers. This may be a wide range of
information from personal files and intellectual property to market analytics and details
intended to top secret. Data could be anything of interest that can be read or otherwise
interpreted in human form.
However, some of this information isn't intended to leave the system. The
unauthorized access of this data could lead to numerous problems for the larger
corporation or even the personal home user. Having your bank account details stolen is
just as damaging as the system administrator who was just robbed for the client
information in their database.
There has been a huge emphasis on data security as of late, largely because of the
internet. There are a number of options for locking down your data from software
solutions to hardware mechanisms. Computer users are certainly more conscious these
days, but is your data really secure? If you're not following the essential guidelines, your
sensitive information just may be at risk.
Encryption
Encryption has become a critical security feature for thriving networks and active home
users alike. This security mechanism uses mathematical schemes and algorithms to
scramble data into unreadable text. It can only by decoded or decrypted by the party that
possesses the associated key.
(FDE) Full-disk encryption offers some of the best protection available. This technology
enables you to encrypt every piece of data on a disk or hard disk drive. Full disk
encryption is even more powerful when hardware solutions are used in conjunction with
software components. This combination is often referred to as end-based or end-point full
disk encryption.
Strong User Authentication
Authentication is another part of data security that we encounter with everyday computer
usage. Just think about when you log into your email or blog account. That single sign-on
process is a form authentication that allows you to log into applications, files, folders and
even an entire computer system. Once logged in, you have various given privileges until
logging out. Some systems will cancel a session if your machine has been idle for a
certain amount of time, requiring that you prove authentication once again to re-enter.
The single sign-on scheme is also implemented into strong user authentication systems.
However, it requires individuals to login using multiple factors of authentication. This
may include a password, a one-time password, a smart card or even a fingerprint.
Backup Solutions
Data security wouldn't be complete without a solution to backup your critical
information. Though it may appear secure while confined away in a machine, there is
always a chance that your data can be compromised. You could suddenly be hit with a
malware infection where a virus destroys all of your files. Someone could enter your
computer and thieve data by sliding through a security hole in the operating system.
Perhaps it was an inside job that caused your business to lose those sensitive reports. If
all else fails, a reliable backup solution will allow you to restore your data instead of
starting completely from scratch.

FIREWALLS

If you have been using the Internet for any length of time, and especially if you work at a
larger company and browse the Web while you are at work, you have probably heard the
term firewall used. For example, you often hear people in companies say things like, "I
can't use that site because they won't let it through the firewall."
If you have a fast Internet connection into your home (either a DSL connection or a cable
modem), you may have found yourself hearing about firewalls for your home network as
well. It turns out that a small home network has many of the same security issues that a
large corporate network does. You can use a firewall to protect your home network and
family from offensive Web sites and potential hackers.
Basically, a firewall is a barrier to keep destructive forces away from your property. In
fact, that's why its called a firewall. Its job is similar to a physical firewall that keeps a
fire from spreading from one area to the next. As you read through this article, you will
learn more about firewalls, how they work and what kinds of threats they can protect you
from.

How Firewalls does works?


Firewalls provide protection against outside attackers by shielding your computer or
network from malicious or unnecessary Internet traffic. Firewalls can be configured to
block data from certain locations while allowing the relevant and necessary data through
They are especially important for users who rely on "always on" connections such as
cable or DSL modems.

Type of firewall

Firewalls are offered in two forms: hardware (external) and software (internal). While
both have their advantages and disadvantages, the decision to use a firewall is far more
important than deciding which type you use.
• Hardware - Typically called network firewalls, these external devices are
positioned between your computer or network and your cable or DSL modem.
Many vendors and some Internet service providers (ISPs) offer devices called
"routers" that also include firewall features. Hardware-based firewalls are
particularly useful for protecting multiple computers but also offer a high degree
of protection for a single computer. If you only have one computer behind the
firewall, or if you are certain that all of the other computers on the network are up
to date on patches and are free from viruses, worms, or other malicious code, you
may not need the extra protection of a software firewall. Hardware-based
firewalls have the advantage of being separate devices running their own
operating systems, so they provide an additional line of defense against attacks.
Their major drawback is cost.
• Software - Some operating systems include a built-in firewall; if yours does,
consider enabling it to add another layer of protection even if you have an
external firewall. If you don't have a built-in firewall, you can obtain a software
firewall for relatively little or no cost from your local computer store, software
vendors, or ISP. Because of the risks associated with downloading software from
the Internet onto an unprotected computer, it is best to install the firewall from a
CD or DVD. Although relying on a software firewall alone does provide some
protection, realize that having the firewall on the same computer as the
information you're trying to protect may hinder the firewall's ability to catch
malicious traffic before it enters your system.

ELECTRONIC INFECTIONS

We hear about many different forms of electronic infection. The most common are:
• Viruses - A virus is a small piece of software that piggybacks on real programs.
For example, a virus might attach itself to a program such as a spreadsheet
program. Each time the spreadsheet program runs, the virus runs, too, and it has
the chance to reproduce (by attaching to other programs) or wreak havoc.
• E-mail viruses - An e-mail virus travels as an attachment to e-mail messages, and
usually replicates itself by automatically mailing itself to dozens of people in the
victim's e-mail address book. Some e-mail viruses don't even require a double-
click -- they launch when you view the infected message in the preview pane of
your e-mail software.
• Trojan horses - A Trojan horse is simply a computer program. The program
claims to do one thing (it may claim to be a game) but instead does damage when
you run it (it may erase your hard disk). Trojan horses have no way to replicate
automatically.
• Worms - A worm is a small piece of software that uses computer networks and
security holes to replicate itself. A copy of the worm scans the network for
another machine that has a specific security hole. It copies itself to the new
machine using the security hole, and then starts replicating from there, as well.

SPYWARE

It is a category of computer programs that attach themselves to your operating system in


nefarious ways. They can suck the life out of your computer's processing power. They're
designed to track your Internet habits, nag you with unwanted sales offers or generate
traffic for their host Web site. According to some estimates, more than 80 percent of all
personal computers are infected with some kind of spyware. But before you chuck your
computer out the window and move to a desert island, you might want to read on. In this
article we'll explain how spyware gets installed on your computer, what it does there and
how you can get rid of it.
Some people mistake spyware for a computer virus. A computer virus is a piece of code
designed to replicate itself as many times as possible, spreading from one host computer
to any other computers connected to it. It usually has a payload that may damage your
personal files or even your operating system.
Spyware, on the other hand, generally isn't designed to damage your computer. Spyware
is defined broadly as any program that gets into your computer without your permission
and hides in the background while it makes unwanted changes to your user experience.
The damage it does is more a by-product of its main mission, which is to serve you
targeted advertisements or make your browser display certain sites or search results.
Most of us get spam every day. Some of us get a little, and some of us get a lot, but if you
have an e-mail account it is always there. For example, this morning, here's one that came
to my inbox:
Subject: Adobe
Suppose we tell you that you could really lose up to 82% of your unwanted body fat and
keep it off in just a few months, would you be interested? We certainly hope so! Please
visit our web site - Click here!
Obviously this is spam, yet it made it through the spam filters and I opened it because the
subject line made it unknowable whether it was spam or not.
Spam is incredibly annoying, especially in large quantities. If you have a public e-mail
address you can receive hundreds of spam messages for every legitimate message that
arrives. Even with good filters, some of the spam makes it through. And filters can
sometimes delete messages that you really do want to receive. Spam is free speech run
amok.

WIFI

A wireless network uses radio waves, just like cell phones, televisions and radios do. In
fact, communication across a wireless network is a lot like two-way radio
communication. Here's what happens:
• A computer's wireless adapter translates data into a radio signal and transmits it
using an antenna.
• A wireless router receives the signal and decodes it. The router sends the
information to the Internet using a physical, wired Ethernet connection.

• The process also works in reverse, with the router receiving information from the
Internet, translating it into a radio signal and sending it to the computer's wireless
adapter.
• The radios used for WiFi communication are very similar to the radios used for
walkie-talkies, cell phones and other devices. They can transmit and receive radio
waves, and they can convert 1s and 0s into radio waves and convert the radio
waves back into 1s and 0s. But WiFi radios have a few notable differences from
other radios:
• They transmit at frequencies of 2.4 GHz or 5 GHz. This frequency is considerably
higher than the frequencies used for cell phones, walkie-talkies and televisions.
The higher frequency allows the signal to carry more data.
• They use 802.11 networking standards, which come in several flavors:
1. 802.11a transmits at 5 GHz and can move up to 54 megabits of data per second. It
also uses orthogonal frequency-division multiplexing (OFDM), a more efficient
coding technique that splits that radio signal into several sub-signals before they
reach a receiver. This greatly reduces interference.
2. 802.11b is the slowest and least expensive standard. For a while, its cost made it
popular, but now it's becoming less common as faster standards become less
expensive. 802.11b transmits in the 2.4 GHz frequency band of the radio
spectrum. It can handle up to 11 megabits of data per second, and it uses
complementary code keying (CCK) modulation to improve speeds.

DUAL BOOTING

Multi-boot or Multi-booting is the act of installing multiple operating systems on a


computer, and being able to choose which one to boot when switching on the computer
power. The term dual-booting refers to the common configuration of only two operating
systems. The program which makes multi-booting possible is called a boot loader.

A popular multi-boot configuration is a dual-booting mixed-OS system in which Linux is


one of the secondary (or primary) installations. In terms of business strategy, Windows
does not facilitate or support multi-boot systems, other than allowing for partition-
specific installations, and no choice of boot loader is offered. However, most current
Linux installers accommodate this problem, although some prior knowledge of partitions
is desirable.
The basic concept involves partitioning a disk, to accommodate each planned installation,
including separate partitions for data storage or backups. The partitions should be done
with a Windows partitioning tool (diskpart, Disk Management.

GHOST.exe

The file Ghost.exe program was distributed as a harmless screen saver created by Access
Softek. This program which contained advertising information, opened a window to show
a Halloween scene. It was complete with flying ghost and a graveyard.

TOP DOWN APPROACH Vs BOTTOM UP APPROACH

Top Down Approach

Top Down approach is to start implementing Presentation Layer and then implement the
Business Logic.

Advantage:
• Easy to visualize functionality.
• Sense of completeness in the requirement.
• Easy to show the progress of development.
Disadvantage:
• UI driven approach hence high possibility of redundant business logics.
• Since an UI is readily available no developer would write a Unit test cases.
• No Concrete layer to rely on, as both presentation & Business Logic keep evolving.
• Lack of concrete test suits to ensure one layer is tied up.
Bottom Up Approach

Bottom Up approach is to start with the concrete business logic and its test case and
proceed with presentation Implementation.

Advantage:
• Solid Business Logic, hence zero redundancy
• Good Unit test case can be written to validate changes.
• Developer has only option to use unit testing tools to test the Logic.
• Easy to manage changes and modification.
Disadvantage:
• Effort involved to write test cases.
• Progress of implementation cannot be show very effectively.

DIFFERENCE BETWEEN OOP(OBJECT ORIENTED PROGRAMMING) AND


POP (PROCEDURE ORIENTED PROGRAMMING):

S.NO OOP(OBJECT ORIENTED POP (PROCEDURE


PROGRAMMING) ORIENTED
PROGRAMMING)
1. Object Oriented While procedural
Programming (OOP) languages - especially C -
formalizes approaches that allow object oriented
were developed using techniques to be used, they do
procedural languages such as not require it, and they don't
data hiding, inheritance, stop you from violating the
functional isolation, message precepts. For example, in a
passing, and run-time binding. nicely written set of functions
The Object Oriented approach that hide their data, it is easy
(OO for short) certainly has its enough to expose some as
advantages, but it is no magic public variables or via pointers.
bullet that suddenly makes Messy code then usually
complex and reliable systems evolves that deals with the
easy to develop, deliver, and internal data all over the
support. program rather than in isolated
functions designed specifically
to work with the data. If major
reworking of the data model is
required later, the whole
program will need to be
reviewed and rewritten rather
than just a small set of interface
and data management routines.

2. Data Oriented Function Oriented


3. Data Security No data security
4. Objects Based Language Function Based Language

Object Oriented Programming (OOP) formalizes approaches that were developed


using procedural languages such as data hiding, inheritance, functional isolation, message
passing, and run-time binding. The Object Oriented approach (OO for short) certainly has
its advantages, but it is no magic bullet that suddenly makes complex and reliable
systems easy to develop, deliver, and support.
While procedural languages - especially C - allow object oriented techniques to be
used, they do not require it, and they don't stop you from violating the precepts. For
example, in a nicely written set of functions that hide their data, it is easy enough to
expose some as public variables or via pointers. Messy code then usually evolves that
deals with the internal data all over the program rather than in isolated functions designed
specifically to work with the data. If major reworking of the data model is required later,
the whole program will need to be reviewed and rewritten rather than just a small set of
interface and data management routines.
Modern object oriented languages emphasize data and method encapsulation and
provide a structure that makes it easier to avoid the kind of spaghetti code that makes
large programs so hard to maintain, but there is no such thing as a perfect solution. C++
is object oriented, but it is still easy enough to get you into trouble by exposing data
publicly or provide pointers to data. C++ and Java provide clean and powerful ways of
designing and implementing classes, but now instead of a spaghetti of methods calling
each other it is fairly easy to end up with a mess of classes, inheritance paths, objects,
methods, overridden methods, and so on ad infinitum until the result is a rats nest that is
just as hard to maintain as any poorly designed procedural language program. Revising
the internal data model can end up being an expensive process as you track all of the
derived classes and over-ridden methods, custom special cases and hidden paths to
implementations.
Lack of a good design or lack of the discipline to follow the design and revise it when
needed leads to similar problems, whether you are coding in a procedural language or
an object oriented language.