Learning Basic of Command Line
Tags: commandline, juststarting, onlybasic
Published: 2021-05-22 06:07:24

## What is a Command Line?

It's provides a way of interacting with your computer, without the need of a GUI like file explorer.

The command line varies for Windows and Mac, so for explaining, I will use a common platform called [Hyper Terminal](https://hyper.is/).

### Installation MacOS

- Download Hyper from the above link and Unzip it.
- Move it to application folder.

### Installation Windows

- Download Hyper from the above link
- Run setup.exe
- Install [GitBash](https://git-scm.com/downloads), to use Bash.
- While installing Git Bash make sure you have Git Bash checked in Windows Explore Integration options, and keep all default options, then restart your computer.
- Now, we have to manage the Hyper Configurations, for that please go to [this site](https://gist.github.com/coco-napky/404220405435b3d0373e37ec43e54a23)
- Copy the details.
   ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu3ovq9ngo1khnq0fuak.png)
- Now after opening preferences, replace what is in the text file with what you copied in the git gist, now save it.
- Reopen hyper.
- Now to check type the following in your hyper terminal

```bash
echo $SHELL
```

- It should return `/bin/bash` if it is installed correctly.

## What is Bash, Understanding Command Line

Kernel is the base of the computer system on which everything operates(In Layman Language).

Shell is like a cover or shell(pun 😆), which shields or covers the kernel from the user. Shell, provides a interface between user and kernel. It provides two types of interface, GUI which is the File Explorer and Terminal or Command Line. 

Bash is a type of shell. BASH = Bourne Again Shell after Mr. Bourne. Bash  Shell is a CLI ( Command Line Interpreter) for the Unix System. A lot of systems run on UNIX such as Linux, a lot of servers(such as a node development server), and even MacOS. But, windows uses DOS instead of Bash. This is the reason we aren't directly using the command line provided by windows.

Command Line provides greater control over your computer hardware, it is also easier and faster. We can also view hidden folders with the help of command line.

## Command Line Techniques

### List

- It displays all the files at your given location

```bash
$ls
```

For eg- ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lfyannkoje392xqlxqvs.png)

The `~` sign shows where your current location is.

### Change Directory

- It helps in changing your current location, to one location down

```bash
$ls
(Shows whrere you can go) 

$cd <where to go>

```

For eg-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5opwuknm8zlkd59kv8nx.png)


- We can also go a level above by using

```bash
$ cd ..
```

- We can also specify the full path of where to go

```bash
$cd <Superparent>/<Parent>/<Child>
```

For eg-![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cq49lz17y5n85fhzhrom.png)


### Make Directory

- It is used to make a new directory or folder at the desired location

```bash
$mkdir <Directory Name>
```

For eg- ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23oiet72aifq028oe49b.png)


### Creating A File

- It is used to make a file.

```bash
$Touch Text.txt
```

### Opening a file

- For Windows

```bash
$start Text.txt
```

- For MacOS

```bash
$open Text.txt
```

### Delete Files and Folders(***Please Use These Commands wisely, as it can delete important files***)

- For Files

```bash
$rm Text.txt
$rm * (Removes all the files of the folder)
```

- For Folders

```bash
$rm -r AllDocs/
```

### Clear Previous Lines

```bash
$clear
```

### Exiting The Terminal

```bash
$exit
   OR
$logout
```

### Learn More?

If you want to learn more about command line this is what I recommend-

[https://www.learnenough.com/command-line-tutorial](https://www.learnenough.com/command-line-tutorial)