Professional Documents
Culture Documents
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.
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.
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
ERASE Command
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.
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).
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
If a pathname is not specified, FIND searches the text typed at the prompt or piped from
another command.
Examples
The above example would find any "REM" statement in the autoexec.bat.
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.
NETWORKING
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 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 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
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 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
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 /?
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
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.
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.
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 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.
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.
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 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
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.
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
Delete a File
All commands in vi must be preceded by pressing the “Escape” key. Most commands are
case sensitive.
CURSOR MOVEMENT
r :replace the character under the cursor with next character typed
R :overwrite characters until end of line
DELETING TEXT
FILE MANIPULATION
MISCELLANEOUS
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 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
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.
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.
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.
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 /registerdns Refresh all DHCP leases and re-register DNS names.
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.
NETSTAT.exe
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.
-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.
NMAP
Short for network mapper, nmap is a network exploration tool and security / port scanner.
Syntax
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
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 ]
TOP
Display Linux tasks.
Syntax
LS
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.
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
==Example==
or in a script "bash":
#! / bin / bash
This is line 2
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
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.
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.
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
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
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.
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
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
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 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.