Some Basic Commands of Command Prompt

1.cd\ Go to the top of the directory tree.

  • CD (Change Directory): Change the current folder or navigate to another folder.
C:\Users\LillianSIYIN>cd\
C:\>

2.cd.. Go back to one folder up.

C:\Users\LillianSIYIN>cd..
C:\Users>

3.e: Directly accesses to another drive (e drive).

C:\Users\LillianSIYIN>e:
E:\>

4.cd /d ... Changes the drive and the directory at the same time.

C:\Users\LillianSIYIN>cd /d e:\windows
E:\windows>

5.dir View the contents of a folder.

E:\SA>dir
   Volume in drive E has no label.
   Volume Serial Number is B8E7-1B00
   Directory of E:\SA
 03/30/2017  11:22 AM    <DIR>          .
 03/30/2017  11:22 AM    <DIR>          ..
 02/21/2017  02:33 PM       107,276,552 Enterprise Architecture.zip
 10/26/2016  08:15 PM    <DIR>          term1
 01/11/2017  05:48 PM    <DIR>          term2
 03/30/2017  11:22 AM    <DIR>          term3
               1 File(s)    107,276,552 bytes
               5 Dir(s)  35,814,080,512 bytes free
E:\SA>

6.mkdir ... or md ... (make directory) Creates a new folder or makes a new directory

C:\>md my_folder
C:\>

NOTE:

  • All these commands depend on the current location in the Command Prompt.
    Eg, if you are on the “C:” drive and type mkdir test, test will be created at “C:” drive.
  • Otherwise, is to type the complete path of the new folder.
    Eg, if you are at “C:” drive and you want to create my_folder in “E:”,type mkdir e:\my_folder.
C:\>md e:\my_folder
C:\>

7.ren ... (rename) Rename files and folders.

E:\SA>ren term1 TermOne
E:\SA>

8.copy ... ... Allow to copy files from one location to another.

You will receive a confirmation of the operation as below:

D:\Photos>copy IMG_0462.JPG e:\IMG_0462.JPG
        1 file(s) copied.

D:\Photos\about me>

NOTE: If you are copying within the same directory, don't have to put the path.

C:\Users\LillianSIYIN\Desktop>copy idea.docx idea.txt
        1 file(s) copied.

C:\Users\LillianSIYIN\Desktop>

9.xcopy /s /i ... ... (rename) Rename files and folders.

  • The /s parameter will ensure that all the directories and sub-directories will be copied, except the ones that are empty.
  • The /i parameter will create a new directory if the destination folder doesn't exist and will copy all the files.
E:\>xcopy /s /i e:\travel "c:\Users\LIN SIYIN\Desktop"\travel
E:\travel\abc.txt
1 File(s) copied
E:\>

10.del ... (delete) To delete all the files from the specified folder.

E:\>del travel
E:\travel\*, Are you sure (Y/N)? y
e:\>

NOTE:

  • To also delete hidden files from the folder, must add the /h parameter.
  • The del cammand doesn’t work for deleting the folder (view E:\>dir and E:\travel>dir):
E:\>dir
  Volume in drive E has no label.
  Volume Serial Number is B8E7-1B00
  Directory of E:\
04/05/2017  11:01 AM    <DIR>          OCBC
03/30/2017  11:27 AM    <DIR>          others
11/14/2016  03:41 PM                40 product key.txt
03/30/2017  11:22 AM    <DIR>          SA
04/05/2017  05:49 PM    <DIR>          travel
01/11/2017  05:54 PM    <DIR>          Unity
               1 File(s)             40 bytes
               5 Dir(s)  35,814,080,512 bytes free

E:\>cd travel
E:\travel>dir
 Volume in drive E has no label.
 Volume Serial Number is B8E7-1B00
 Directory of E:\travel
04/05/2017  05:49 PM    <DIR>          .
04/05/2017  05:49 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  35,814,080,512 bytes free

Some useful DEL combinations that are worth mentioning:

  1. DEL *.DOC - delete all .dco files (you can use any file extension);
  2. DEL Test*.* - delete all files beginning with Test;
  3. DEL *.* - delete ALL files from the current folder.

11.RD (remove directory) Delete the empty folder.

  • The RD command can only delete an empty folder.
E:\>RD travel
The directory is not empty.

E:\>del travel
E:\travel\*, Are you sure (Y/N)? y

E:\>RD travel

E:\>dir
 Volume in drive E has no label.
 Volume Serial Number is B8E7-1B00

 Directory of E:\

04/05/2017  11:01 AM    <DIR>          OCBC
03/30/2017  11:27 AM    <DIR>          others
11/14/2016  03:41 PM                40 product key.txt
03/30/2017  11:22 AM    <DIR>          SA
01/11/2017  05:54 PM    <DIR>          Unity
               1 File(s)             40 bytes
               4 Dir(s)  35,814,080,512 bytes free

E:\>

12.How to launch an application?

To run a program from the Command Prompt, you need only to navigate to the folder that contains the executable and type the program’s name.
For example, if you want to launch Paint , go to C:\Windows\System32 and you will find the executable called mspaint.exe. Then write mspaint.exe or simply mspaint and press Enter. Both commands and paint can be seen.

C:\Windows\System32>mspaint.exe
C:\Windows\System32>

13.How to get help in Command Prompt

  1. help A list with all available commands will be displayed:
C:\Windows\System32>help
For more information on a specific command, type HELP command-name
ASSOC          Displays or modifies file extension associations.
ATTRIB         Displays or changes file attributes.
BREAK          Sets or clears extended CTRL+C checking.
BCDEDIT        Sets properties in boot database to control boot loading.
CACLS          Displays or modifies access control lists (ACLs) of files.
CALL           Calls one batch program from another.
CD             Displays the name of or changes the current directory.
CHCP           Displays or sets the active code page number.
CHDIR          Displays the name of or changes the current directory.
CHKDSK         Checks a disk and displays a status report.
CHKNTFS        Displays or modifies the checking of disk at boot time.
CLS            Clears the screen.
CMD            Starts a new instance of the Windows command interpreter.
COLOR          Sets the default console foreground and background colors.
COMP           Compares the contents of two files or sets of files.
COMPACT        Displays or alters the compression of files on NTFS partitions.
CONVERT        Converts FAT volumes to NTFS.  You cannot convert the
               current drive.
COPY           Copies one or more files to another location.
DATE           Displays or sets the date.
DEL            Deletes one or more files.
DIR            Displays a list of files and subdirectories in a directory.
DISKPART       Displays or configures Disk Partition properties.
DOSKEY         Edits command lines, recalls Windows commands, and
               creates macros.
DRIVERQUERY    Displays current device driver status and properties.
ECHO           Displays messages, or turns command echoing on or off.
ENDLOCAL       Ends localization of environment changes in a batch file.
ERASE          Deletes one or more files.
EXIT           Quits the CMD.EXE program (command interpreter).
FC             Compares two files or sets of files, and displays the
               differences between them.
FIND           Searches for a text string in a file or files.
FINDSTR        Searches for strings in files.
FOR            Runs a specified command for each file in a set of files.
FORMAT         Formats a disk for use with Windows.
FSUTIL         Displays or configures the file system properties.
FTYPE          Displays or modifies file types used in file extension
               associations.
GOTO           Directs the Windows command interpreter to a labeled line in
               a batch program.
GPRESULT       Displays Group Policy information for machine or user.
GRAFTABL       Enables Windows to display an extended character set in
               graphics mode.
HELP           Provides Help information for Windows commands.
ICACLS         Display, modify, backup, or restore ACLs for files and
               directories.
IF             Performs conditional processing in batch programs.
LABEL          Creates, changes, or deletes the volume label of a disk.
MD             Creates a directory.
MKDIR          Creates a directory.
MKLINK         Creates Symbolic Links and Hard Links
MODE           Configures a system device.
MORE           Displays output one screen at a time.
MOVE           Moves one or more files from one directory to another
               directory.
OPENFILES      Displays files opened by remote users for a file share.
PATH           Displays or sets a search path for executable files.
PAUSE          Suspends processing of a batch file and displays a message.
POPD           Restores the previous value of the current directory saved by
               PUSHD.
PRINT          Prints a text file.
PROMPT         Changes the Windows command prompt.
PUSHD          Saves the current directory then changes it.
RD             Removes a directory.
RECOVER        Recovers readable information from a bad or defective disk.
REM            Records comments (remarks) in batch files or CONFIG.SYS.
REN            Renames a file or files.
RENAME         Renames a file or files.
REPLACE        Replaces files.
RMDIR          Removes a directory.
ROBOCOPY       Advanced utility to copy files and directory trees
SET            Displays, sets, or removes Windows environment variables.
SETLOCAL       Begins localization of environment changes in a batch file.
SC             Displays or configures services (background processes).
SCHTASKS       Schedules commands and programs to run on a computer.
SHIFT          Shifts the position of replaceable parameters in batch files.
SHUTDOWN       Allows proper local or remote shutdown of machine.
SORT           Sorts input.
START          Starts a separate window to run a specified program or command.
SUBST          Associates a path with a drive letter.
SYSTEMINFO     Displays machine specific properties and configuration.
TASKLIST       Displays all currently running tasks including services.
TASKKILL       Kill or stop a running process or application.
TIME           Displays or sets the system time.
TITLE          Sets the window title for a CMD.EXE session.
TREE           Graphically displays the directory structure of a drive or
               path.
TYPE           Displays the contents of a text file.
VER            Displays the Windows version.
VERIFY         Tells Windows whether to verify that your files are written
               correctly to a disk.
VOL            Displays a disk volume label and serial number.
XCOPY          Copies files and directory trees.
WMIC           Displays WMI information inside interactive command shell.

For more information on tools see the command-line reference in the online help.

C:\Windows\System32>
  1. Type help followed by the name of that command or type the command’s name followed by the /? parameter: Looking into a specified command.
C:\Windows\System32>help cd
Displays the name of or changes the current directory.

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

  ..   Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current
directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as
the on disk names.  So CD C:\TEMP would actually set the current
directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
the name with quotes.  For example:

    cd \winnt\profiles\username\programs\start menu

is the same as:

    cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

C:\Windows\System32>

or

C:\Windows\System32>copy /?
Copies one or more files to another location.

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  /D           Allow the destination file to be created decrypted
  destination  Specifies the directory and/or filename for the new file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file with a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /L           If the source is a symbolic link, copy the link to the target
               instead of the actual file the source link points to.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

C:\Windows\System32>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末榨为,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子衣形,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,402評論 6 499
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蹦骑,死亡現(xiàn)場離奇詭異晴玖,居然都是意外死亡冕杠,警方通過查閱死者的電腦和手機矛洞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,377評論 3 392
  • 文/潘曉璐 我一進(jìn)店門葬燎,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人缚甩,你說我怎么就攤上這事∫ぐ睿” “怎么了擅威?”我有些...
    開封第一講書人閱讀 162,483評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長冈钦。 經(jīng)常有香客問我郊丛,道長,這世上最難降的妖魔是什么瞧筛? 我笑而不...
    開封第一講書人閱讀 58,165評論 1 292
  • 正文 為了忘掉前任厉熟,我火速辦了婚禮,結(jié)果婚禮上较幌,老公的妹妹穿的比我還像新娘揍瑟。我一直安慰自己,他們只是感情好乍炉,可當(dāng)我...
    茶點故事閱讀 67,176評論 6 388
  • 文/花漫 我一把揭開白布绢片。 她就那樣靜靜地躺著滤馍,像睡著了一般。 火紅的嫁衣襯著肌膚如雪底循。 梳的紋絲不亂的頭發(fā)上巢株,一...
    開封第一講書人閱讀 51,146評論 1 297
  • 那天,我揣著相機與錄音熙涤,去河邊找鬼阁苞。 笑死,一個胖子當(dāng)著我的面吹牛祠挫,可吹牛的內(nèi)容都是我干的那槽。 我是一名探鬼主播,決...
    沈念sama閱讀 40,032評論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼茸歧,長吁一口氣:“原來是場噩夢啊……” “哼倦炒!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起软瞎,我...
    開封第一講書人閱讀 38,896評論 0 274
  • 序言:老撾萬榮一對情侶失蹤逢唤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后涤浇,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體鳖藕,經(jīng)...
    沈念sama閱讀 45,311評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,536評論 2 332
  • 正文 我和宋清朗相戀三年只锭,在試婚紗的時候發(fā)現(xiàn)自己被綠了著恩。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,696評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡蜻展,死狀恐怖喉誊,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情纵顾,我是刑警寧澤伍茄,帶...
    沈念sama閱讀 35,413評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站施逾,受9級特大地震影響敷矫,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜汉额,卻給世界環(huán)境...
    茶點故事閱讀 41,008評論 3 325
  • 文/蒙蒙 一曹仗、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧蠕搜,春花似錦怎茫、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,659評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽啼器。三九已至,卻和暖如春俱萍,著一層夾襖步出監(jiān)牢的瞬間端壳,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,815評論 1 269
  • 我被黑心中介騙來泰國打工枪蘑, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留损谦,地道東北人。 一個月前我還...
    沈念sama閱讀 47,698評論 2 368
  • 正文 我出身青樓岳颇,卻偏偏與公主長得像照捡,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子话侧,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,592評論 2 353

推薦閱讀更多精彩內(nèi)容