# Day 2 - Basic Linux Commands

# ➡Listing commands

`ls option_flag arguments` \--&gt; list the sub directories and files avaiable in the present directory

Examples:

* `ls -l`\--&gt; list the files and directories in long list format with extra information
    
* `ls -a` \--&gt; list all including hidden files and directory
    
* `ls *.sh` --&gt; list all the files having .sh extension.
    
* `ls -i` \--&gt; list the files and directories with index numbers inodes
    
* `ls -d */` --&gt; list only directories.(we can also specify a pattern)
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748451997671/98e5e90a-d0ae-446a-b6e9-1e5a4f9faea1.png align="center")

# ➡Directoy commands

* `pwd` --&gt; print work directory. Gives the present working directory.
    
* `cd path_to_directory` --&gt; change directory to the provided path
    
* `cd ~` or just `cd` \--&gt; change directory to the home directory
    
* `cd -` --&gt; Go to the last working directory.
    
* `cd ..` --&gt; change directory to one step back.
    
* `cd ../..` --&gt; Change directory to 2 levels back.
    
* `mkdir directoryName` --&gt; to make a directory in a specific location
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452082786/98d046de-0545-4460-916f-0ebe6fb2820e.png align="center")

```bash
mkdir newFolder  #make a new folder 'newFolder'
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452118020/9e82ce4a-4011-4734-b224-2126afd1f178.png align="center")

```bash
mkdir .NewFolder  #make a hidden directory (also . before a file to make it hidden)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452188122/446b2256-d6ee-4574-94d4-7c6e1e0d76da.png align="center")

```bash
mkdir A B C D   #make multiple directories at the same time
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452242767/300044e4-44bf-45e6-92c4-87b638d7c3c9.png align="center")

```bash
mkdir /home/user/Mydirectory   # make a new folder in a specific location
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452261798/1bf30483-f56a-4c49-bf20-1e95f8ca6986.png align="center")

```bash
mkdir -p  A/B/C/D     # make a nested directory
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748452284443/c617ac08-6765-4bce-9b0c-d3b0982cd27c.png align="center")
