Python command line

In this tutorial, you will learn how to use command line. How you can create, copy, move files and folder from one location to another location using terminal.

Open your vscode and press “cntrl+~ “key to enter into terminal. This terminal is a git bash that we have integrated with vscode. You can test these command as written below:

(note: In linux we treat everything as files or folder. Like if we have a drive in windows system in linux we create LVM which are treated as folder)

  • Cd : by cd command we enter into directory.
    Ex: if we want to move from c drive to e drive.

Pwd : shows you present at location/path of the directory.
Ex:-

Mv : to move the directory from one directory/file to another directory.
Ex: mv <source file/folder> <destinationfolder/path>

mv demo_directory/test.py workspace/

Cp: to copy the file/directory to another directory.
Ex: cp -var <source file/folder> <destination folder/path>
cp -var demo_directory/test.py workspace/newfolder/

Mkdir: to make a new directory.

Ex: mkdir john sara albert

(above command will create 3 directories named john sara albert in existing location)

If you want to make a directory having space between them you can do this by following way
mkdir “ python practice”

  • rm: To remove a file.
    Ex:  $  rm <file name>

    rm test.txt

  • rm -fr: To delete directory.
    $  rm -fr workspace

ls : to view the details of all the folder.

touch: to create a file.

  • Clear: to clear the screen.
    Ex:   clear
  • Code: to start write code in .py file
    Ex: code hello.py

After entering above written command, a new screen will be displayed upside with name of .py file, we will write our program here as shown in following screen.