As I prepare for CompTIA's A+ Certification I will post my revision notes here.

Friday, February 03, 2006

DOS System Tools

DEFRAG - Microsoft includes a Disc Defragmenter utility with its operating systems. Disc fragmenters are used to help arrange the data on hard discs in chronological order, this makes reading data from disc faster due to the way the hard drive read-write heads need to pass over the disc to read the data stored. An update was made in Windows 98, which placed most commonly accessed data nearer the beginning on the drive to speed up access even more.

C:\>defrag /?
Usage:
defrag [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text


FORMAT - Windows includes a format utility used to prepare a floppy disc or hard drive for use with Windows. Formatting a drive will effectively erase any data or programs stored on the disc. You have been warned!

The Format command has a fair number of switches to enable it to correctly format a disc, whether it be a floppy disc or hard disc, on Windows XP or in DOS. The format command will allow you to format a drive in a number of file systems, FAT16, FAT32 or NTFS (Until I cover this topic see this link for more information on choosing a file system). It will allow you to create compressed drives if it is supported by the file system. Here is the full FORMAT help in Windows XP:

C:\C>format /?
Formats a disk for use with Windows XP.

FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] [/C] [/X]
FORMAT volume [/V:label] [/Q] [/F:size]
FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors]
FORMAT volume [/V:label] [/Q]
FORMAT volume [/Q]

volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
/FS:filesystem Specifies the type of the file system (FAT, FAT32, or NTFS).
/V:label Specifies the volume label.
/Q Performs a quick format.
/C NTFS only: Files created on the new volume will be compressed
by default.
/X Forces the volume to dismount first if necessary. All opened
handles to the volume would no longer be valid.
/A:size Overrides the default allocation unit size. Default settings
are strongly recommended for general use.
NTFS supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K.
FAT supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
(128K, 256K for sector size > 512 bytes).
FAT32 supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
(128K, 256K for sector size > 512 bytes).

Note that the FAT and FAT32 files systems impose the
following restrictions on the number of clusters on a volume:

FAT: Number of clusters <= 65526
FAT32: 65526 <>

Format will immediately stop processing if it decides that
the above requirements cannot be met using the specified
cluster size.

NTFS compression is not supported for allocation unit sizes
above 4096.

/F:size Specifies the size of the floppy disk to format (1.44)
/T:tracks Specifies the number of tracks per disk side.
/N:sectors Specifies the number of sectors per track.


FDISK and DISKPART - Both FDISK and DISKPART allow users to create or delete partitions on their hard disks. Creating or deleting partitions on a drive will erase all data on those partitions.

Paritions allow you to logically divide up your hard disk. These partitions will appear as different drives in Windows and are very useful for allowing you to separate your operating system and your data, which is useful if you ever need to reinstall your operating system and leave your data intact. Click here for more information on partitioning.

FDISK is available for use in MS-DOS, Window 95, 98 and Windows ME. FDISK was replaced in Windows 2000 and XP in favour of DISKPART which is more powerful allowing the user to run scripts to create predefined partitions.

ComputerHope.com provides some examples for using both FDISK and DISKPART commands.


SYS - The SYS command will copy the Windows systems files to a volume to allow that volume become bootable. This command is only available on MS-DOS, Windows 9x operating systems.

The SYS command is useful for making a bootable floppy disk that has already been formatted without the /S FORMAT switch. If you need to format the disk as well then the FORMAT /S command will format and then copy the system files in one command.

The following DOS command would copy:

  • command.com
  • io.sys
  • msdos.sys
  • drvspace.bin
from the C drive to the A drive providing the disk in A: is Windows formatted.

C:\>sys a:


Wednesday, February 01, 2006

DOS network utilities

There are several important DOS commands which are very useful for troubleshooting network problems.

WINIPCFG - This command is used on Windows 9x systems to display network adapter information such as IP address, subnet mask, default gateway, MAC address, DNS and DHCP settings. You can also release and renew DHCP settings with this Windows graphical user interface. This command was replaced with IPCONFIG in Windows NT/2000/XP.

IPCONFIG - This utility performs the same task as WINIPCFG in Windows NT, 2000 and XP, however it has a command line interface.
Useful switches are:
  • Ipconfig/Release - releases your IP from your network adapter back to the DHCP server
  • Ipconfig/Renew - requests a new IP address from the DHCP server
  • Ipconfig/All - Shows detailed configuration
TRACERT - This command allows you to look at the network path a packet takes on its way from one point to another. Using this command you can diagnose which points of a network are causing traffic bottlenecks.
Useful TRACERT switches are:
  • Tracert /D - Specify NOT to resolve IP addresses using DNS
  • Tracert /H - Max hop count to travel to reach target
  • Tracert /W - Timeout period in milliseconds for each response
PING - The ping command is a very useful command which allows you to test network connectivity with another host.

E.g.

C:\>PING www.pc-technician.net

Useful PING switches include:
  • Ping /T - Pings host until user stops the command using Control+c
  • Ping /A - Resolves addresses using DNS (This can slow the ping process considerably)
  • Ping /I - Specify Time To Live (TTL) , default TTL is 251
  • Ping /L - Specify packet size to send, default 32 bytes
NSLOOKUP - This utility is used to query the Domain Name System (DNS) servers directly to check the system is resolving names properly.

E.g.

C:\>NSLOOKUP www.pc-technician.net
Server: adnslookup.net
Address: 62.241.163.200

Non-authoritative answer:
Name: pc-technician.net
Address: 213.232.107.153
Aliases: www.pc-technician.net

Other network related MS-DOS commands can be found on ComputerHope.com.

CHKDSK and SCANDISK DOS Commands

CHKDSK and SCANDISK are disk-checking utilities. CHKDSK was replaced with SCANDISK in MS-DOS 6.2 and features a Windows graphical user interface. It is much more powerful than CHKDSK.
Where CHKDSK could report or fix lost clusters by referencing the File Allocation Table (FAT), SCANDISK can also repair these errors for compressed and uncompressed discs. SCANDISK can also perform a disc surface scan and automatically fix errors if the user has specified this option.

Retrieving typed commands with DOSKEY

There's a handy DOS utility called DOSKEY in MS-DOS 5 and above, which allows you to keep a history of typed commands in DOS. It also saves the administrator time typing commands that have recently been issued.

If you need to run a command you issued previously you can simple navigate through this history of commands and re-run the command. You can do this by using the up and down arrow keys to move one command at a time, page up and page down keys to go to the start or end of the history, or start typing and press F8 to search your previously typed commands.

To see a list of the commands DOSKEY has a history for use the /History switch.

E.g.

c:\>DOSKEY /History

To clear the history of DOSKEY press or reinstall DOSKEY using the /Reinstall switch.

For an extentive list of switches and examples see the Microsoft documentation on DOSKEY.

Tuesday, January 31, 2006

COPY, DISKCOPY and XCOPY DOS commands

MS-DOS includes several commands for copying data. DISKCOPY was used primarily used for copying floppy disks, both formatting and copying can be achieved by the command. DISKCOPY however tries to make an identical copy of the data sector by sector, which will result in an unsuccessful copy if their are any bad sectors present on the destination disk.
The XCOPY command differs from the COPY command in that it allows you to copy folders, directories and files. It also buffers the copying which makes it much better for network copying. XCOPY also includes more switches relating to archiving, setting read-only attributes, copying system files, and the ability to copy files modified after a specified date.
All the required switches can be found from each tools help command by typing the command followed by /?.

E.G. COPY /?

Wireless Router Configuration - Real World Scenario

A friend of mine asked me to help set-up their wireless router for them. I soon found out it was going to be more than just a normal wireless set-up configuration when I discovered it had been configured previously and locked down.

The set-up as I found it consisted of:
  • ADSL wired router with built-in switch, DHCP server (functioning correctly)
  • Wireless router with built-in switch, DHCP server, Firewall etc (locked out and secured, no passwords or WEP keys)
  • Some RJ45 network cables
  • An AOL broadband ASDL account
  • No hardware manuals
Before I could even begin to configure the wireless system I first had to find out how to unlock the router. Since I didn't have the manual I had to track one down. Thanks to Google and the manufacturers name and product code this was fairly easy.

Most reputable hardware manufacturers' have all the manuals and drivers of their hardware on their own website, if you have no luck with this method a search for the product or product code normally provides unofficial sites which contain the info you're after.

I found the manufacturer's website and located the customer support section. After selecting several fields to narrow my search I found the manual for the router.



The router (A Sitecom model) has a reset switch on the back, which when pressed while the machine is turned on reboots the machine, but if you hold the reset switch down while starting the machine up it resets the routers configuration to the factory settings.

Once this was reset I was able to browse to the routers config using a web browser pointed to 192.168.0.1.

Now the next thing I had to sort out is which box was going to be the DHCP server. Since this isn't your average wireless set-up it required a little more thought than normal. The system was working perfectly through the wired ASDL router and this was using DHCP, so it made sense to disable DHCP on the wireless router and let the wired router provide this service.

I logged into the router and ran the set-up wizard, I skipped the ASDL screen since the wired router was providing this service. After the config, which assumed I wanted it to be a DHCP server too, I had to find the option in another menu and turn it off.

The next issue was the IP address of the machine. This is normally set by the ISP when ADSL connects, however the wired router is performing that task in this scenario, so I had to set a manual IP address for the machine, which had to be outside the DHCP range of the wired router.

The last setting I had to make was the default gateway, this had to point to the IP address of the wired router.

Having completed the configuration and tested it, I went on to enable 128bit WEP security, lock the router configuration menu with a username and password, and disable SSID broadcasting.

Sunday, January 29, 2006

MS-DOS Managing Files, Folders and Directories

In modern versions of Windows opening the command prompt can be achieved by navigating Start > Run and typing CMD and hitting return.

When the MS-DOS command prompt opens, your "logged" path will probably look something like the one below.

C:\Documents and Settings\Administrator>

We're going to want to change that to C:\>. To change your logged path to the root of the current drive use the CD \ command. Your logged path should now be:

C:\>

We're now going to create a new directory called PC-Technician to do this we need to use the make directory command MD.

C:\> MD PC-Technician

Using Windows Explorer check to see that the new folder has been created in the root of your C drive. We're now going to use the DOS Edit program to create a text file in our new directory. Navigate to the new directory first, then type edit.

C:\> CD PC-Technician
C:\PC-Technician>edit

Using the DOS edit program type a few words and save the file in the PC-Technician subfolder as hello.txt. We're now going to view the contents of hello.txt using the Type command.

C:\PC-Technician>type hello.txt
hello!!!
hello!!!
hello!!!
hello!!!
hello!!!

We're now going to create a subfolder within PC-Technician called TextFiles and copy hello.txt to the folder.

C:\PC-Technician>md TextFiles

C:\PC-Technician>tree
Folder PATH listing
Volume serial number is 0000006E 608B:D4C0
C:.
????TextFiles

C:\PC-Technician>cd TextFiles

C:\PC-Technician\TextFiles>copy c:\PC-Technician\hello.txt
1 file(s) copied.

The two new commands introduced here are the Tree command which depending on your logged path displays a graphical representation of the subfolders (and files using /F switch) below the current folder. I used this to check the MD command had created the new subdirectory. I then navigated to the TextFiles subdirectory and used the Copy command to copy the text file into the new folder.

Using Windows Explorer you'll see that because we copied the text file we now have two copies, one in the PC-Technician folder and one in TextFiles. So we're now going to remove the copy we made and move the text file to the TextFiles folder instead.

C:\PC-Technician\TextFiles>del hello.txt

C:\PC-Technician\TextFiles>move c:\PC-Technician\hello.txt

C:\PC-Technician\TextFiles>cd ..

C:\PC-Technician>tree /f
Folder PATH listing
Volume serial number is 0000006E 608B:D4C0
C:.
????TextFiles
hello.txt

Now lets rename the hello.txt file using the ren command.

C:\PC-Technician\TextFiles>ren /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

C:\PC-Technician\TextFiles>ren hello.txt goodbye.txt

C:\PC-Technician\TextFiles>cd ..

C:\PC-Technician>tree/f
Folder PATH listing
Volume serial number is 0000006E 3C5D:DA4D
C:.
????TextFiles
goodbye.txt

Ok, to finish the tutorial we'll remove all the files and directories we just created using the delete DEL and remove directory RD commands.

C:\PC-Technician>cd \

C:\>rd PC-Technician
The directory is not empty.

C:\>cd PC-Technician

C:\PC-Technician>cd TextFiles

C:\PC-Technician\TextFiles>del *.*
C:\PC-Technician\TextFiles\*.*, Are you sure (Y/N)? y

C:\PC-Technician\TextFiles>cd ..

C:\PC-Technician>rd TextFiles

C:\PC-Technician>cd \

C:\>rd PC-Technician

The del *.* command is used here to delete all files within a directory. The * wildcard is used twice to match any file with any extension. In this instance we could have used del *.txt or simply del hello.txt to achieve the same result.

The above example showed that the del command will not delete folders that contain files or other folders. There is a command however that will do this. On Windows 2000 and XP you can use the rmdir command with the /s switch, on Previous versions of Windows you can use the deltree command to achieve the same objectives. The following commands were run on a Windows 2000 machine:

C:\>deltree /?
'deltree' is not recognized as an internal or external command,
operable program or batch file.

C:\>rmdir /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S

C:\>rmdir PC-Technician
The directory is not empty.

C:\>rmdir PC-Technician /s
PC-Technician, Are you sure (Y/N)? y

To clear the screen and exit type cls and then exit to close the command prompt.


Note: The commands used in this tutorial won't necessarily be compatible with versions of DOS prior to v7 (Windows 95).