πŸ‘understanding windows Command Line Interface



This content originally appeared on DEV Community and was authored by aryan015

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

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>

How to change drive in CMD

put the drive alphabet along with colon

>c: # navigate to c
>d: # navigate to d 

How to clear the console

use cls

>cls

Navigate to folder with space

cd to naviagate to any folder( not drives)

>cd "new folder"

navigate to multiple levels

cd with complete path

>cd aryan/movies

list all files and folders

dir to list files and folders

>dir 

get clean list

dir /b it will clear the clutter

>dir /b

navigate to backward

cd .. will cause one level backward

cd .. # cd ../

navigate to multiple backward

cd / will cause root level

>cd /

how to make directory

>mkdir "folder name" # make in current directory
>mkdir "aryan khandelwal"/"folder name" # nested cmd

remove directory

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

>rmdir "file name"

remove non-empty directory

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

>rmdir /s "file name"

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

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.

command chaining (order matters)

below command will make dir and point to it.

>mkdir "hello world" && cd "hello world"

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

conditional execution

You can control your command if faliure.

>cd "hello" || echo "not exist" # incase of hello not exist it will print "not exist"

part two is coming ♥😉


This content originally appeared on DEV Community and was authored by aryan015