OS/2 Command Reference

While OS/2 has a graphical interface, it is also possible to run OS/2 entirely from the command line. Even when you use the graphical interface it is sometimes useful to perform some functions from the command line. What follows is a list of commands available within OS/2.

In the following command list | indicates alternatives of which one should be specified, () indicates optional parameters any or all of which may be omitted, and [] indicates optional parameters at least one of which must be specified. With the exception of these characters all other special characters and uppercase letters should be typed exactly as shown (although lowercase may be used).

ANSI ON|OFF
Enables or disables the processing of ANSI control sequences. ANSI control sequences usually begin with a control character and are used to redefine keys on the keyboard, control the cursor, or change display colour attributes.
 
ATTRIB [+A|-A +H|-H +R|-R +S|-S] filename (/S)
Changes the file attributes associated with the specified file(s). The /S switch extends the filenames matched to corresponding filenames in any sub-directories.
 
BACKUP source target (/A /D:mm-dd-yy /F:nn /L:filename /M /S /T:hh:mm:ss)
Creates a backup of the specified source to the specified target location. Backup can span multiple floppies if required. The /A switch appends to an existing backup. You can backup only files modified after a specified date and time using the /D and /T switches. The /F switch allows you to use unformatted disks for the backup and will format them during the backup. The /L switch defines the name of the backup log, if not specified then BACKUP.LOG will be used. To only backup modified files use the /M switch. To include sub-directories in the backup use the /S switch.
 
BOOT /DOS
Reboots the computer to DOS. Use 'BOOT /OS2' to swap back.
 
CD|CHDIR path
Change to the specified directory.
 
CHCP nnn
Allows you to swap between two code pages specified in config.sys.
 
CHKDSK path (/F(:0|1|2|3) /V /C)
Produces a status report on the files contained i the specified path. You can fix any errors found using the /F switch (with HPFS you can also specify what level of errors to fix). The /V flag will list all of the files found. To recover files on an HPFS partition when the system was left in an inconsistent state use the /C switch.
 
CLS
Clears the screen or command window.
 
CMD
Start a new command processor. To return to the original command processor use 'EXIT'.
 
COMP file1 file2
Compare two files and report any differences.
 
COPY source target (/A /B /F /V)
Copies one or more files to a new location. The /A switch indicates that files are ASCII format and copy will only proceed to the first end-of-file mark. The /B switch indicates that the file is binary format and end-of-file marks within the file will be ignored. To avoid losing extended attributes where the destination may not support them use the /F switch. The /V switch can be used to verify the correctness of the copy.
 
CREATEDD
Creates a dump disk.
 
DATE mm-dd-yy
Set the system date.
 
DDINSTAL
Use this command to install device drivers from the command prompt.
 
DEL|ERASE filename (/N /P)
Deletes the specified file(s). The /N switch bypasses the "Are You Sure?" message that usually appears while the /P switch has the computer ask the question for each file individually.
 
DETACH command
Run the specified command in the background in a separate session.
 
DIR path (/W /F /A[+A|-A +H|-H +R|-R +S|-S] /B /L /N /O[D|-D|E|-E|G|-G|N|-N|S|-S] /P /R /S)
Displays the contents of the specified directory. The /W switch displays five filenames across each line instead of giving them a separate line each. The /F switch fully qualifies all filenames. The /A switch restricts the list to files having the specified attributes. To remove the heading and summary information use the /B switch. The /L switch displays all names in lowercase. To display directories on FAT partitions using the HPFS layout use the /N switch. The /O switch can be used to change the sort order to date order (earliest first), date order (latest first), alphabetical order by file extension, or the reverse, directories before files, or after files, alphabetical order by name, or the reverse, by size (smallest first) or by size (largest first). To pause when the window fills use the /P switch. To display file long names on a FAT partition use the /R switch. To extend the listing to include sub-directories use the /S switch.
 
DISKCOMP source target
Compares two disks (of the same size and density) and reports any differences.
 
DISKCOPY source target
Copies one disk to another of the same size and density.
 
EAUTIL datafile holdfile (/S /R /J /O /M /P)
Detach and save extended attributes so that they can be reapplied after using the file with a program that doesn't recognise extended attributes. Use the /S switch to create the hold file or the /R switch to replace the current contents of the hold file. The /J switch will reconnect the extended attributes to the file. The /O switch will replace extended attributes in the file with those in the hold file while the /M switch will merge them. Use the /P switch to keep the original copy of the extended attributes.
 
EXIT
Closes the current command processor session.
 
FDISK (/QUERY /CREATE:name /DELETE /SETNAME:name /SETACCESS /STARTABLE /FILE:name)
Create or delete partitions on a hard disk. To list all existing partitions use the /QUERY switch. To create a partition use the /CREATE switch which also allows you to optionally name the partition. To delete a partition use the /DELETE switch. The /SETNAME switch can be used to change the name of an existing partition. Only one primary partition can be visible at any one time and you can change which this is using the /SETACCESS switch. To define a partition as startable (when it contains an operating system) use the /STARTABLE switch. You can process fdisk commands from a response file using the /FILE switch. There are also sub-switches on this command to limit the scope of the switches: /NAME:name specifies the partition name, /DISK:n specifies the number of the hard disk, /FSTYPE:x specifies the file system, /START:m specifies the partition start position, /SIZE:m specifies the size of the partition, /VTYPE:n specifies the type of partition, /BOOTABLE:s specifies the bootable status of the partition and /BOOTMGR indicates that the partition is intended to contain the OS/2 boot manager.
 
FDISKPM
This opens a mouse and window based program that performs the same functions as the fdisk command but using selection menus in place of the command line switches.
 
FIND "string" filename (/C|/N /I /V)
Search the specified file(s) for exact matches to the specified string. To get a count of the lines that contain the string use the /C switch. The /N switch will display the line number of each match. To ignore case use the /I switch. The /V switch reverses the search reporting lines that do not contain the search string or the count of lines not containing the string.
 
FORMAT drive: (/ONCE /4 /F:nnn /FS:name /L /N:sectors /T:nnn /V:label)
Formats the specified drive. The /ONCE switch stops the command asking if you want to format further disks after the first is formatted. To format a 360k floppy in a 1.2Mb drive use the /4 switch (if you still have any 360k disks or a 1.2Mb drive). You can specify the disk capacity using the /F switch. To format using a different file system use the /FS switch. You can use the ?N and ?T switches to specify the capacity of a floppy disk in sectors and tracks. To name the disk use the /V switch.
 
HELP ON|OFF|messagenumber|book topic
You can turn a help line at the top of the screen on and off with this command as well as displaying help on a particular error message or book and topic.
 
KEYB layout subcountry
This command can be used to change the keyboard layout. Use only with full screen OS/2 sessions.
 
KEYS ON|OFF|LIST
You can retrieve and reuse commands you have previously typed using this command.
 
LABEL drive text
You can change the name attached to a disk in the specified drive using this command.
 
MAKEINI OS2.INI|OS2SYS.INI
Recreate one of the two OS/2 startup files.
 
MD|MKDIR path\newdirectory
Makes a new directory within the specified path.
 
MODE
Configures peripherals attached to your computer. The parameters and switches that are specified on this command vary depending on the peripheral that you are configuring.
 
MORE
Display information one page at a time.
 
MOVE source target
To move a file from one location to another.
 
PATCH filename (/A)
Apply IBM supplied patches to your system.
 
PICVIEW filename (/MET /PIF /P /S)
View picture files. If the picture is in a meta file specify the /MET switch. If the picture is a picture interchange file specify the /PIF switch. Use the /P switch to print the file. To display the picture viewer in its default position use the /S switch.
 
PMREXX filename (arguments)
Provides a windowed environment to accept input to and display output from REXX.
 
PRINT filename (/D:device /B /C /T)
Print the specified file. Use the /D switch to specify the printing device. To print binary files use the /B switch. To cancel printing a single file use the /C switch or use the /T switch to cancel all printing.
 
PROMPT text
Use this command to change the appearance of the command prompt.
 
PSTAT (/C /S /L /M /P:id)
This command gives you information on current processes and threads (/C), system semaphores (/S), dynamic link libraries (/L), and shared memory (/M). If no switches are specified then the report will contain information on all types. To display information about a specific process only use the /P switch.
 
RD|RMDIR path
Deletes the specified directory.
 
RECOVER filename|drive
This command can be used to recover files from a disk that has bad sectors.
 
REN(AME) oldname newname
Changes the name of the specified file.
 
REPLACE filename targetdrive (/A /S /P /R /W /U /F)
Replaces files on the target drive with files of the same name copied from the source drive. Use the /A switch to copy all files from the source that don't exist on the destination drive. To update existing files use the /S switch. The /P switch will prompt before replacing each file. To replace read-only files use the /R switch. To wait for a floppy to be inserted use the /W switch. To only replace older files use the /U switch. To ensure that extended attributes are retained use the /F switch.
 
RESTORE source target (/P /M /B:mm-dd-yy /A:mm-dd-yy /E:hhmmss /L:hhmmss /S /N /F /D)
The restore command is used to restore files that were backed up by the backup command. The /P switch will prompt before restoring each file. To restore only changed files use the /M switch. You can restore only files modified before a specified date and time using the /B and /E switches or later using the /A and /L switches. To include sub-directories in the restore use the /S switch. To restore files that no longer exist on the target use the /N switch. To ensure that extended attributes are retained use the /F switch. To list files without restoring use the /D switch.
 
SETBOOT (/T:x /T:NO /M:m /Q /B /X:x /O:name)
You can configure the OS/2 boot manager using this command to specify the timedelay before booting the default operating system (/T), the mode of the startup menu (/M), set the system startup index (/X) or establish the operating system to be booted (/O). You can also use the /Q switch to query the current settings and the /B switch to shut down and reboot.
 
SORT (/R /+column)
Sorts supplied data in ascending sequence. To sort in descending sequence use the /R switch. To sort on a position other than column one specify the /+ switch. Use the redirection operators < and > to specify the input and output files.
 
SPOOL (/D:device /O:device /Q)
Redirects printer output from one device to another. The /D switch specifies the input device and the /O switch the output device. To query existing redirections use the /Q switch.
 
START (/K /C /N /F /B /PGM"name" /FS /WIN /PM /DOS /MAX /MIN /I)
Starts an OS/2 program in a new OS/2 session. The session start a new CMD.EXE which will close when the program completes execution if the /C switch is specified or will close if the /K switch is specified. No new CMD.EXE will be started if the /N switch is specified. The started program can be run in the foreground using the /F switch or in the background using the /B switch. The /PGM switch identifies the program to be run. You can run the program full screen (/FS), in an OS/2 window (/WIN), as a program manager application (/PM), or as a DOS program (/DOS). Windowed applications can be started with the window minimized (/MIN) or maximized (/MAX). Use the /I switch to inherit environment variables from CONFIG.SYS instead of from the current session.
 
SYSLEVEL
Displays the current OS/2 service level.
 
SYSLOG (/S /R /P:filename /W:x)
Look at or print the system log. To suspend logging use the /S switch and to restart logging use the /R switch. To redirect logging to a different file use the /P switch. You can change the size of the log file using the /W switch.
 
TIME
Change the system time.
 
TREE drive (/F)
Displays the directory structure on the specified drive. If the /F switch is specified then all files will be listed as well.
 
TYPE filename
Display the contents of the specified file.
 
UNDELETE path,maxsize (/L /S /A /F)
Recover files that have been deleted (provided that you have SET DELDIR= in your CONFIG.SYS). To list files available to be recovered without recovering them use the /L switch. To include sub-directories use the /S switch. To recover all available files without confirmation use the /A switch. The /F switch will make all deleted files unrecoverable.
 
UNPACK filename targetpath (/V /F /N:filename /SHOW)
Decompresses files from the OS/2 installation disks. Use the /V switch to verify the files have decompressed correctly. To ensure that extended attributes are retained use the /F switch. To decompress a specific file use the /N switch. To display a list of files available to be decompressed use the /SHOW switch
 
VER
Display the OS/2 version number.
 
VERIFY ON|OFF
Confirms that files written to disk have been written correctly.
 
VIEW filename topic
Display the contents of an online reference manual.
 
VOL drive
Displays the disk volume label and serial number.
 
XCOPY source destination (/A /M /D:mm-dd-yy /P /S /E /V /F)
This command copies groups of files or directories. To copy files with the archive attribute set without changing the attribute use the /A switch or to reset the attribute use the /M switch. The /D switch restricts the copy to those files created or changed on or after the specified date. To prompt for each file use the /P switch. The /S switch will copy sub-directories unless they are empty while the /E switch will even copy empty sub-directories. To verify the copy use the /V switch. To ensure that extended attributes are retained use the /F switch.
 

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate