DEV Community

Cover image for 🍑understanding windows Command Line Interface
aryan015
aryan015

Posted on

🍑understanding windows Command Line Interface

A little command line crash course
tip:

  1. use tab for avoid writing complete name.
  2. use up/down arrow key for recently used command.

How to exit from the cmd

>exit
Enter fullscreen mode Exit fullscreen mode

how to terminate any running process

ctrl+c will cause termination of any running operation and will bring you to command line prompt.

get help with particular command

>help <command-name>
Enter fullscreen mode Exit fullscreen mode

How to change drive in CMD

put the drive alphabet along with colon

>c: # navigate to c
>d: # navigate to d 
Enter fullscreen mode Exit fullscreen mode

How to clear the console

use cls

>cls
Enter fullscreen mode Exit fullscreen mode

Navigate to folder with space

cd to naviagate to any folder( not drives)

>cd "new folder"
Enter fullscreen mode Exit fullscreen mode

navigate to multiple levels

cd with complete path

>cd aryan/movies
Enter fullscreen mode Exit fullscreen mode

list all files and folders

dir to list files and folders

>dir 
Enter fullscreen mode Exit fullscreen mode

get clean list

dir /b it will clear the clutter

>dir /b
Enter fullscreen mode Exit fullscreen mode

navigate to backward

cd .. will cause one level backward

cd .. # cd ../
Enter fullscreen mode Exit fullscreen mode

navigate to multiple backward

cd / will cause root level

>cd /
Enter fullscreen mode Exit fullscreen mode

how to make directory

>mkdir "folder name" # make in current directory
>mkdir "aryan khandelwal"/"folder name" # nested cmd
Enter fullscreen mode Exit fullscreen mode

remove directory

careful deleted items won't be recoverable from recycle bin♻
🚮

>rmdir "file name"
Enter fullscreen mode Exit fullscreen mode

remove non-empty directory

careful deleted items won't be recoverable from recycle bin♻

>rmdir /s "file name"
Enter fullscreen mode Exit fullscreen mode

create a file with pre-content

# cmd #1
# below cmd will create a filename.txt with "" inside it.
>echo "" > filename.txt
# cmd #2
>copy con filename.txt
happy halloween
happy Christmas
# ctrl+z and enter to save
Enter fullscreen mode Exit fullscreen mode

del files

not reversable

>del /p file.txt # delete file.txt with confirmation
>del /P *.txt # it will delete all files in current dir with confirmation. Omitting it might cause fatal damage.
Enter fullscreen mode Exit fullscreen mode

command chaining (order matters)

below command will make dir and point to it.

>mkdir "hello world" && cd "hello world"
Enter fullscreen mode Exit fullscreen mode

sequential execution

suppose there is not folder 📁 with the name aryan k. The second command will run regardless of first command execution.

>cd "aryan k" & echo "" > file.txt
# it will create file.txt in current folder
Enter fullscreen mode Exit fullscreen mode

conditional execution

You can control your command if faliure.

>cd "hello" || echo "not exist" # incase of hello not exist it will print "not exist"
Enter fullscreen mode Exit fullscreen mode

part two is coming ♥😉

Top comments (0)