// guide to making CMD.exe act more like a linux shell // // by droops // // http://infonomicon.org If you are like me you get tired of keying 'ls' in CMD.EXE and getting a: 'ls' is not recognized as an internal or external command, operable program or batch file. I do this almost everyday, so i wrote this quick file to have a quide for setting up windows to be better for me. Most of us are going to have to touch windows boxen and we might as well make the best of it. First off here are some basics, when you type a command into CMD.EXE, it first looks for an .com then a .exe then a .bat in the local directory. If it doens't find what it wants there, it looks other places. Those other places can be found by issuing the 'path' command in CMD.EXE. Now we are going to take the %SystemRoot%/system32 directory which can be called different things (look in your path) and add some files to it. That way when we execute our new commands from CMD.EXE they will be found and run. Many of the *nix commands have counterparts in the windows world. For example 'ls' is the same as 'dir /w/p' So all we need to do is to write a simple batch file to solve the ls problem. Open up CMD.EXE and go to %SystemRoot%/system32. Then type 'edit ls.bat' to open up the text editor and enter the following data. @dir /w /p Then save it and you have a batch file that will allow you to type ls instead of dir /w/p. The @ keeps CMD.EXE from echoing back dir /w/p, which is a good thing. you need to do this for all *nix commands that you use that have a windows counterpart. ie: vi = edit cp = copy mv = ren and so on, you only need to do this for things that you are going to need. Now rememeber how to do this, as we are going to have to do it for all of the commands that don't have a windows equivalent that comes with a default windows install. Now there are lots of commands that I use on *nix that dont have an equivalent in the default install of windows. So how do we get them? There is a utility package called PsTools located at: http://www.sysinternals.com/Utilities/PsTools.html This contains cool things like PsKill and PsList that take the place of kill and ps. Go download this package and put the files in your %SystemRoot%/system32 directory. Then either rename them or make a batch file to execute them. ie: kill.bat contains @pskill A complete list of what this package contains is: * PsExec - execute processes remotely * PsFile - shows files opened remotely * PsGetSid - display the SID of a computer or a user * PsKill - kill processes by name or process ID * PsInfo - list information about a system * PsList - list detailed information about processes * PsLoggedOn - see who's logged on locally and via resource sharing * PsLogList - dump event log records * PsPasswd - changes account passwords * PsService - view and control services * PsShutdown - shuts down and optionally reboots a computer * PsSuspend - suspends processes * PsUptime - shows you how long a system has been running since its last reboot Wow thats alot, but there is more. There is another package called UnxUtils located at: http://unxutils.sourceforge.net/ This package is really quite good and includes a ls.exe that will be excuted instead of your ls.bat. I usually don't copy over ls.exe as i can modify ls.bat esier to make it do as I want. A complete listing of the files is here: [.] [..] agrep.exe ansi2knr.exe basename.exe bc.exe bison.exe bunzip2.exe bzip2.exe bzip2recover.exe cat.exe chgrp.exe chmod.exe chown.exe cksum.exe cmp.exe comm.exe compress.exe cp.exe csplit.exe cut.exe date.exe dc.exe dd.exe df.exe diff.exe diff3.exe dircolors.exe dirname.exe du.exe echo.exe egrep.exe env.exe expand.exe expr.exe factor.exe fgrep.exe find.exe flex.exe fmt.exe fold.exe fsplit.exe gawk.exe gclip.exe gplay.exe grep.exe gsar.exe gunzip.exe gzip.exe head.exe id.exe indent.exe install.exe join.exe jwhois.exe less.exe lesskey.exe libfl.a libfl.lib linux.txt ln.exe logname.exe ls.exe m4.exe make.exe makedepend.exe makemsg.exe man.exe md5sum.exe mkdir.exe mkfifo.exe mknod.exe mv.exe mvdir.exe nl.exe od.exe paste.exe patch.exe pathchk.exe pclip.exe pr.exe printenv.exe printf.exe pwd.exe recode.exe rm.exe rman.exe rmdir.exe sdiff.exe sed.exe seq.exe shar.exe sleep.exe sort.exe split.exe stego.exe su.exe sum.exe sync.exe tac.exe tail.exe tar.exe tee.exe test.exe touch.exe tr.exe type.exe uname.exe unexpand.exe uniq.exe unrar.exe unshar.exe unzip.exe uudecode.exe uuencode.exe wc.exe wget.exe wget.hlp which.exe whoami.exe xargs.exe yes.exe zcat.exe zip.exe You can also change your prompt to be more helpful if you need. To find out what your prompt is capable off doing, issue this command. prompt /? This is what is displayed in windows 2000: $A & (Ampersand) $B | (pipe) $C ( (Left parenthesis) $D Current date $E Escape code (ASCII code 27) $F ) (Right parenthesis) $G > (greater-than sign) $H Backspace (erases previous character) $L < (less-than sign) $N Current drive $P Current drive and path $Q = (equal sign) $S (space) $T Current time $V Windows 2000 version number $_ Carriage return and linefeed $$ $ (dollar sign) To change your prompt to just the current date type: prompt $D Don't forget a space at the end, or your commands will be running into your prompt. Now this will only change the current CMD.EXE. When you close it out, your prompt will be the default again. To change it perminately you need to add a new User Variable. Under 2000 you need to hold down the Windows Key and then hit Pause/Break. Then go to the Advanced Tab' > Enviromental Variables > NEW (top one). For the Variable Name put 'PROMPT' and for the Variable Value put whatever you want your command prompt to be. Something that I love from the *nix world is tab completion. CMD.EXE has that although its not always enabled. This is very easy to change. Type 'regedit' in CMD.EXE and it will open up the registry editor. Then go to: HKEY_LOCAL_MACHINE> SOFTWARE> Microsoft> Command Processor> CompletionChar and HKEY_LOCAL_MACHINE> SOFTWARE> Microsoft> Command Processor> PathCompletionChar Then change these values to 9 with the hexidecimal radio button selected. When you click ok, the next time you open CMD.EXE you will have tab completion. Another addition to CMD.EXE is the windows resource kits. Each version of NT, 2000, 2003, and XP has one. Find more information about them at: http://www.microsoft.com This is something else cosmetic, but I don't like to click on 'Start > Run' instead I make good use of my Quick Launch Bar. (right next to Start Menu) I always drag a copy of CMD.EXE down there and then i change the target for it to '%SystemRoot%\system32\cmd.exe /k' (right click > properties) the /k tells CMD.EXE not to display the version and copywrite information. There are tons these resources on the internet for command line tools for windows. Here is another one: http://www.cmdtools.com/ Now there are lots of other thing that you can change. This t-file was on changing functionality of CMD.EXE. If you want to change the look of the thing, you can go get econsole or console at these fine websites: http://www.corion.net/econsole/index.html http://sourceforge.net/projects/console/ Look at the pretty screenshots here: http://www.corion.net/econsole/screens/colors_2.gif http://www.corion.net/econsole/screens/v0.99m2.jpg Shouts to Phizone for going over this for spelling, shouts to all the fans of Infonomicon Radio, and shouts to everyone who is involved with twatech.org