COMMAND LINE BASICS

Upendra Pratap Kushwaha
Upendra Pratap Kushwha
2 min readMay 7, 2020

This blog post is part of our course Python Tutorial for Ultimate Beginners

Feeling scared of the command line? You’re not alone. We have this image of developers staring intently at a black screen. That black screen or window is the command-line interface (CLI), where you’re able to enter commands that your computer will run for you.

The second thing to know is that you won’t be able to use the mouse to move the cursor within Terminal or Command Prompt. This means no searching or highlighting text with the cursor. Everything is done on the keyboard and therefore keyboard shortcuts are your new best friends.

Open the command-line interface

Windows

Go to Start menu → All Programs → Accessories → Command Prompt.

OS X

Go to Applications → Utilities → Terminal.

Linux

Open the programs menu and search for “Terminal”. You can also open the terminal by pressing CTRL + ALT + T on your keyboard.

Your first command

$ whoami upendra

As you can see, the computer has just printed your username.

Basic

Each operating system has a slightly different set of commands for the command line, so make sure to follow instructions for your operating system. Here we are using the syntax of Linux and OS X.

1. Current directory

When do you want to know where are we now, right? Use `pwd` to see your current directory.

$ pwd /Users/upendra

2. List files and directories :

List Directory or known as ls. With this command, you can list the content of a directory.

$ ls Applications Desktop Downloads Music ...

3. Change the current directory

Often you will have to navigate through directories. cd the command to change your current directory to the destination specified within the command. Say you want to go to a folder named newDirectory, you type:

$ cd newDirectory

You can navigate directly to the sub-directory of newDirectory, like so:

$ cd newDirectory/sub-dir

To head back to the previous directory or go one level up of the current directory, type:

4. Create directory

mkdir, This command creates a new directory with the specified name. The following command, for example, will create a new directory named newDirectory.

$ mkdir newDirectory

5. Exit

That’s it for now! You can safely close the command line now. Let’s do it the hacker way.

Summary

Here is a summary of some useful commands:

These are just a very few of the commands you can run in your command line, but you’re not going to use anything more than that today.

If you’re curious, ss64.com contains a complete reference of commands for all operating systems.

Ready?
Let’s dive into Python!

What next?

Getting Started and Installing Python3

Originally published at https://blog.upendra.tech on May 7, 2020.

--

--

Upendra Pratap Kushwaha
Upendra Pratap Kushwha
0 Followers

Software Engineer — Machine Learning — Python, AWS, SQL