美文网首页
基础 Windows 命令行

基础 Windows 命令行

作者: 采叶小火 | 来源:发表于2020-04-01 07:52 被阅读0次

    我的博客文章,原文就写成英文的了,姑且搬过来简书,应该也没人看,我就不翻译了。我相信各位的英文可以的 :)

    原文链接:https://mikelyou.com/2020/01/04/basic-cmd/
    转载请保留这个链接,多谢!

    This article briefly introduced the common usage of command line.

    During the building of my blog, I encountered the command line. Though solved the tasks at that time, I know nearly nothing about the command line. So today I am going to figure out what the basic command line can do for me.

    Due to huge workload and little importance, not grapghs to illustrate.

    Introduction to command line

    What is the command line?

    The command line, appears as cmd, is a handful tool that let you communicate directly with computer. It can perform some tasks much quicker than normal ways, and sometimes is the only way, like when you launch the jekyll serve. And it is cool.

    It looks like DOS, but has little to do with DOS.

    Access the command line

    There are two ways to access the command line.

    • Method 1. Press Win + R to open Run → type cmd and Enter.

    • Method 2. Press Win to open Start menu → type cmd and click Command Prompt (here you can run as Admin).

    And then you should see the window of cmd.exe.


    Now we have launched the cmd.exe, what can we do next?

    Below I will introduce several things we can do with command lines.

    Common Commands about directories and files

    Now we have launched the cmd.exe, what can we do next?

    Below I will introduce several things we can do with command lines.

    cd

    By default, the cmd.exe is at directory of C:\WINDOWS\system32 or C:\Users\Username. You can see it once you open the cmd.exe.

    If we want to search files or run programs in another directory, we have to change the directory to there.

    Use cd NEW_PATH to change directory to NEW_PATH.

    If NEW_PATH is at a drive other than C:, assuming it is E:, we need to change drive before that.

    E:              # change drive
    cd E:\NEW_PATH  # change directory
    

    You can see the directory changes at the begining of tht new lines that pops up.

    dir

    List all the files and sub-directories in current directory.

    mkdir

    Use mkdir DIRNAME to create a new directory named DIRNAME

    rmdir

    Use rmdir DIRNAME to remove directory named DIRNAME.

    Only empty directory can be removed. Trying to remove a nonempty directory will generate an error message.

    del

    Use del FILENAME.extension to delete file named FILENAME.extension.

    help

    If you don't know what command is avaliable, type help to see all commands.

    Common commands about Windows systems

    ping

    Use ping command to check the responding time bwetween an IP and your computer.

    ping mikelyou.com
    ping 185.199.110.153  # IP of mikelyou.com
    

    You can check the IP of an website by this way as well.

    ipconfig

    Use ipconfig to reveal many network data of your computer.

    systeminfo

    Use systeminfo to see information about your Windows system.

    shutdown

    I don't know where I can use these...

    shutdown -s         # system will shutdown in 1 minute
    shutdown -s -t 3600 # system will shutdown in 3600 seconds
    shutdown -a         # cancel shutdown command
    

    Save commands as batch file

    Save frequantly used command lines as batch file can free ourselves from typing the same words again and again. To do this, we just need to:

    1. Create a .txt file.
    2. Write some commands and save.
    3. Change the extension to .bat.

    Now we have created an batch file. Double-click it and it will run as command lines in the directory of this batch file.

    For Example, I cerated a batch file with content as

    E:
    cd E:\GitHub\mikelyou.github.io
    jekyll serve
    

    And next time when I want to launch the jekyll serve, I can simply double-click this batch file, rather than open the command line and type those long words.

    References

    This article is Mike Lyou's original work and may not be reproduced without permission.

    相关文章

      网友评论

          本文标题:基础 Windows 命令行

          本文链接:https://www.haomeiwen.com/subject/shznuhtx.html