Sei sulla pagina 1di 8

Command's Purpose

MS-DOS

Linux

Basic Linux Example

Copies files

copy

cp

cpthisfile.txt/home/thisdire

Moves files

move

mv

mvthisfile.txt/home/thisdire

Lists files

dir

ls

ls

Clears screen

cls

clear

clear

Closes shell prompt

exit

exit

exit

Displays or sets date

date

date

date

Deletes files

del

rm

rmthisfile.txt

"Echoes" output to the


screen

echo

echo

echothis message

Edits text files

edit

gedit([a])

geditthisfile.txt

Compares the contents


of files

fc

diff

difffile1file2

Finds a string of text in


a file

find

grep

grepword or phrase thisfile.t

(if
diskette is inA:)

mke2fs

/sbin/mke2fs/dev/fd0 (/dev/fd0

Displays command
help

command/?

man

Creates a directory

mkdir

mkdir

mkdirdirectory

Views contents of a file

more

less([b])

lessthisfile.txt

Renames a file

ren

mv([c])

mvthisfile.txtthatfile.txt

Displays your location

chdir

pwd

pwd

Formats a diskette

formata:

of A:)
or info

mancommand

Command's Purpose

MS-DOS

Linux

Basic Linux Example

in the file system


Changes directories
with a specified path
(absolute path)

cdpathname

cdpathname

cd/directory/directory

Changes directories
with a relative path

cd..

cd..

cd..

Displays the time

time

date

date

Shows amount of RAM


in use

mem

free

free

Entering Commands
ACTION

LINUX

DOS

COMMENTS

Get command
help.

man <some
command>

help, command /?

Find related
commands.
Flip through
entered
commands.
Show command
history.
Set a command
alias.
Clear the screen.
Trap ctrl-break
or trap signals.

apropos <some search


string>
Arrows ^ and v
Arrows ^ and v

man system is welldeveloped and most apps


have a man file.
No DOS equivalent.

history

doskey /h

alias name=command doskey


name=command
clear, ctrl-l
cls
trap
break on

Starting and Quitting

Use ~/.bashrc to set


permanently in *nix.

ACTION

LINUX

DOS

COMMENTS

Start Windows or X-Windows.


Reboot system.
Exit the shell.
Get operating system or shell
version.

startx
shutdown -r now
exit, exit 0
uname -a, cat /etc/issue

win
reboot
exit, exit0
ver

Working with Disks


ACTION

LINUX

Check and repair drive file system.


Show disk usage.
Tool to partition a hard drive.
Mount a drive letter to a
folder/directory on your hard
drive.
Format a drive file system.

fsck, debugfs scandisk, defrag


du -s
chdisk
fdisk
fdisk
mount
subst X:
C:\directory\path
mke2fs

DOS

COMMENTS

format

Setting the Environment


ACTION

LINUX

DOS

List
environment
variables.
Set an
environment
variable.
Show the
contents of an
environment
variable.
Display text on
screen.
Display the
system search
path.
Append a
directory to the
system search
path.

set, env

set

COMMENTS

export variable=value, set variable=value


setenv, or variable=value
echo $variable

echo %variable%

echo text

echo text

echo $PATH

PATH

PATH=$PATH:/dir

PATH %PATH
%;C:\DIR

Setting the path allows


you to run commands
without thinking about
where their executable

ACTION

Set the style of


the command
prompt.

LINUX

DOS

COMMENTS

export PS1='\h(\u)\W> ' PROMPT $p$g

file is.
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.
Show free memory
on system.
List information
about running
processes.
Print computer's
name.

date

date, time

free, top

mem

ps -aux

tasklist

hostname

Show system info.

lsdev,
procinfo

hostname, net hostname is DNS-related, whereas the


name
Windows net name command shows
netbios info.
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

Change directory.
Store directories
for reference.
List directory
contents with
some detail.

cd
cd
cd -, pushd
pushd, popd
/path/to/target, popd
ls -l (or use ls -lF)(-a dir
all files)

List directory
contents in
compact mode.
List directory
contents, oldest
files first.
List files and size.

ls

dir /w

ls -tr

dir *.* /o-d

ls -ls

dir *.* /v /os

COMMENTS

Pushd and popd are available for


newer Windows versions.
The "bare" directory list
commands are inherently
different in display
characteristics.

Notice you are stringing together

ACTION

LINUX

DOS

COMMENTS

args in Linux after the dash, but


that you have to put in additional
slashes and args in DOS.
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 size of
du -h | sort -rn, du
directory contents. -hsc * --blocksize=M

(treesize)

List directory
contents
recursively.
List including
hidden files.
Create a semigraphical "tree"
view of folders
and sub-folders.
Make a new
directory.
Create a file or
directory link.
Remove a
directory.
Display current
location.
Remove a file.

ls -R

dir /s

ls -a

dir /aa

tree

tree

mkdir

mkdir, md

ln
rmdir

(assign, subst) Neither assign nor subst are


really much like ln.
rmdir, rd

pwd

chdir

rm -iv

Remove directory
and its contents.
Copy a file.

rm -R

del, erase,
rmdir /s
deltree

cp -piv

copy

Copy a directory
and all its
subcontents.
Rename or move a
file.
Show the contents
of a file.
Show the contents
of a file, one page

cp -R

xcopy

mv -iv

rename, move

cat

type

more

more

Use tree with more to get pageby-page output, and space-bar


through the pages. I.e.: $ tree |
more

Deltree is Win 95.


Of course you can just cp a file
in Linux, as well.

ACTION

at a time.
Sort data
alphabetically or
numerically.
Find a string in a
file.
Compare two files
and show
differences. Also
see comm, cmp,
mgdiff and tkdiff.
Set or change file
permissions.
Print a file.
Line mode editor
Edit a text file.

LINUX

DOS

sort

sort

grep

find, findstr

diff

comp, fc

chmod

attrib

lpr
print
ed
edlin
[editor] filename - edit
where editor can be filename.txt
nano, pico, vi, emacs
etc.

COMMENTS

DOS has hidden switch; use mv


to .somename to make a file
hidden in *nix.

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

Backup or
Restore files.
Backup files to a
folder.
Restore files from
a folder.
Compress or
uncompress files
and folders.

tar -cvf, tar -xvf, mdir, backup,


mcopy, ditto, cpio
restore
tar -cvf /path/to/storage backup files
files
X:\
tar -xvf /path/to/storage restore X:\
files
files
tar, zip, gzip, bzip
pkzip
Note, tar just concatenates files
together for easy manipulation,
and is often used before
compression.

Batch and Shell Scripting

DOS

COMMENTS

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

Schedule a command or script to run on a


schedule.

crontab -l, crontab -e at

COMMENTS

Network Commands
ACTION

LINUX

DOS

COMMENTS

Send icmp packets ping


to a network host.
Show routes and
traceroute
router hops to given
network destination.
Display or
ifconfig
configure network
interfaces.

ping

Get netbios or dns


info for the host.
Print the current
routing table.
List startup
background services
or daemons.

nslookup, dig

nbtstat

route -n

route print

Show mounted or
connected shares
and filesystems.

tracert

ipconfig,
winipcfg

You cannot configure the network


from the command line in Windows,
like you can with ifconfig in *nix.
Use Control Panel.
NetBIOS is a Windows and DOS
affair.

chkconfig --list | net start


grep on
service some- net start|stop
service start|stop some-service
df
net share, net
use

Communications
ACTION

LINUX

DOS

Send a messenger popup


smbclient -M win- net send win-hostname
message to a Windows PC. hostname
"some message"

COMMENTS

ACTION

LINUX

Send message to another


*nix user.

talk

DOS

COMMENTS

Working with Users


ACTION

LINUX

List who is
who
logged in.
List how many who | wc -l
users are
currently logged
in.
Show the
whoami
current user
account.

Show who is
w
logged in and
what they are
doing.
Show a list of a ps -u
user's processes. account_name

DOS

COMMENTS

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.

net session

(Task
Manager)

Potrebbero piacerti anche