The below tables are an attempt to compare typical DOS and Linux command line interface commands. As a point of interest, the data for this page is held in a Google Documents spreadsheet, and as being referenced Loghound PlusKit "GTable" command in RapidWeaver.
Entering Commands
action | linux | dos | comments |
---|---|---|---|
Get command help. | man <some command> | help, command /? | man system is well-developed and most apps have a man file. |
Find related commands. | apropos <some search string> | No DOS equivalent. | |
Flip through entered commands. | Arrows ^ and v | Arrows ^ and v | |
Show command history. | history | doskey /h | |
Set a command alias. | alias name=command | doskey name=command | Use ~/.bashrc to set permanently in *nix. |
Clear the screen. | clear, ctrl-l | cls | |
Trap ctrl-break or trap signals. | trap | break on |
Starting and Quitting
action | linux | dos | comments |
---|---|---|---|
Start Windows or X-Windows. | startx | win | |
Reboot system. | shutdown -r now | reboot | |
Exit the shell. | exit, exit 0 | exit, exit0 | |
Get operating system or shell version. | uname -a, cat /etc/issue | ver |
Working with Disks
action | linux | dos | comments |
---|---|---|---|
Check and repair drive file system. | fsck, debugfs | scandisk, defrag | |
Show disk usage. | du -s | chdisk | |
Tool to partition a hard drive. | fdisk | fdisk | |
Mount a drive letter to a folder/directory on your hard drive. | mount | subst X: C:\directory\path | |
Format a drive file system. | mke2fs | format |
Setting the Environment
action | linux | dos | comments |
---|---|---|---|
List environment variables. | set, env | set | |
Set an environment variable. | export variable=value, setenv, or variable=value | set variable=value | |
Show the contents of an environment variable. | echo $variable | echo %variable% | |
Display text on screen. | echo text | echo text | |
Display the system search path. | echo $PATH | PATH | |
Append a directory to the system search path. | PATH=$PATH:/dir | PATH %PATH%;C:\DIR | Setting the path allows you to run commands without thinking about where their executable file is. |
Set the style of the command prompt. | export PS1='\h(\u)\W> ' | PROMPT $p$g | Much more complexity is possible in both flavors of OS, here. |
Getting System Info
action | linux | dos | comments |
---|---|---|---|
Show and set the system date and time. | date | date, time | |
Show free memory on system. | free, top | mem | |
List information about running processes. | ps -aux | tasklist | |
Print computer's name. | hostname | hostname, net name | hostname is DNS-related, whereas the Windows net name command shows netbios info. |
Show system info. | lsdev, procinfo | msd | Lsdev and procinfo do not work on Linux VPSs sometimes due to the way disks are provisioned. |
Working with Files and Directories
action | linux | dos | comments |
---|---|---|---|
Change directory. | cd | cd | |
Store directories for reference. | cd -, pushd /path/to/target, popd | pushd, popd | Pushd and popd are available for newer Windows versions. |
List directory contents with some detail. | ls -l (or use ls -lF)(-a all files) | dir | The "bare" directory list commands are inherently different in display characteristics. |
List directory contents in compact mode. | ls | dir /w | |
List directory contents, oldest files first. | ls -tr | dir *.* /o-d | |
List files and size. | ls -ls | dir *.* /v /os | Notice you are stringing together args in Linux after the dash, but that you have to put in additional slashes and args in DOS. |
List size of directory contents. | du -h | sort -rn, du -hsc * –block-size=M | (treesize) | Du or diskusage is common, but the switches will be different so do a "man du" to find out more in your *nix. Treesize is an excellent GUI version of du for Windows. |
List directory contents recursively. | ls -R | dir /s | |
List including hidden files. | ls -a | dir /aa | |
Create a semi-graphical "tree" view of folders and sub-folders. | tree | tree | Use tree with more to get page-by-page output, and space-bar through the pages. I.e.: $ tree | more |
Make a new directory. | mkdir | mkdir, md | |
Create a file or directory link. | ln | (assign, subst) | Neither assign nor subst are really much like ln. |
Remove a directory. | rmdir | rmdir, rd | |
Display current location. | pwd | chdir | |
Remove a file. | rm -iv | del, erase, rmdir /s | |
Remove directory and its contents. | rm -R | deltree | Deltree is Win 95. |
Copy a file. | cp -piv | copy | Of course you can just cp a file in Linux, as well. |
Copy a directory and all its subcontents. | cp -R | xcopy | |
Rename or move a file. | mv -iv | rename, move | |
Show the contents of a file. | cat | type | |
Show the contents of a file, one page at a time. | more | more | |
Sort data alphabetically or numerically. | sort | sort | |
Find a string in a file. | grep | find, findstr | |
Compare two files and show differences. Also see comm, cmp, mgdiff and tkdiff. | diff | comp, fc | |
Set or change file permissions. | chmod | attrib | DOS has hidden switch; use mv to .somename to make a file hidden in *nix. |
Print a file. | lpr | ||
Line mode editor | ed | edlin | |
Edit a text file. | [editor] filename – where editor can be nano, pico, vi, emacs etc. | edit filename.txt | In *nix, editors are a religion because the are used so heavily for systems administration tasks. Pico was the editor that came with the Pine mailer, and nano is a standalone pico variant. Many swear by simple vi or complex emacs, though. |
Backup and Restore
action | linux | dos | comments |
---|---|---|---|
Backup or Restore files. | tar -cvf, tar -xvf, mdir, mcopy, ditto, cpio | backup, restore | |
Backup files to a folder. | tar -cvf /path/to/storage files | backup files X:\ | |
Restore files from a folder. | tar -xvf /path/to/storage files | restore X:\ files | |
Compress or uncompress files and folders. | tar, zip, gzip, bzip | pkzip | Note, tar just concatenates files together for easy manipulation, and is often used before compression. |
Batch and Shell Scripting
action | linux | dos | comments |
---|---|---|---|
Call another script from within a batch file or shell script. | source somescript, . somescript, sh somescript | call command /c (or cmd) somescript |
Scheduling
action | linux | dos | comments |
---|---|---|---|
Schedule a command or script to run on a schedule. | crontab -l, crontab -e | at |
Network Commands
action | linux | dos | comments |
---|---|---|---|
Send icmp packets to a network host. | ping | ping | |
Show routes and router hops to given network destination. | traceroute | tracert | |
Display or configure network interfaces. | ifconfig | ipconfig, winipcfg | You cannot configure the network from the command line in Windows, like you can with ifconfig in *nix. Use Control Panel. |
Get netbios or dns info for the host. | nslookup, dig | nbtstat | NetBIOS is a Windows and DOS affair. |
Print the current routing table. | route -n | route print | |
List startup background services or daemons. | chkconfig –list |grep on | net start | |
service some-service start|stop | net start|stop some-service | ||
Show mounted or connected shares and filesystems. | df | net share, net use |
Communications
action | linux | dos | comments |
---|---|---|---|
Send a messenger popup message to a Windows PC. | smbclient -M win-hostname | net send win-hostname "some message" | |
Send message to another *nix user. | talk |
Working with Users
action | linux | dos | comments |
---|---|---|---|
List who is logged in. | who | ||
List how many users are currently logged in. | who | wc -l | ||
Show the current user account. | whoami | set | There is a whoami command for Windows available in the Resource Kit. Or, you can use set to list the environment variables, of which the username is one. |
Show who is logged in and what they are doing. | w | net session | |
Show a list of a user's processes. | ps -u account_name | (Task Manager) |