# Day -02

## Linux

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1688827372133/b50d664b-f223-4d58-aa09-63612a2d0b7b.png align="center")

Linux is a Unix-like open-source operating system. The first official release, Linux 0.01, came out on September 17, 1991, and since then, numerous versions and distributions have been released, with the latest release (Linux Mint 21.1) in 2022.

### Basic Linux commands:

1. **pwd -** This command is used to check the present working directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689092302589/75f165ff-9942-42ae-a791-202d44311992.png align="center")
    
2. **ls** - This command is used to list all the files or directories, including hidden files, in the current directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689092327416/10c863de-de3e-48e2-be33-e3073597d54c.png align="center")
    
    **Extensions** that can be used along with "**ls**" command:
    
    **\-a**: It displays all the hidden files in the directory
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689092347735/4b3ae3a8-72a9-4468-afe3-27af13ad6817.png align="center")
    
    **\-l:** It gives a long listing of files
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104116363/44089cd9-3189-4aa6-8881-0028337a60eb.png align="center")
    
    **\-R**: It gives a recursive listing including the contents of all subdirectories and their subdirectories and so on.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104138654/9720ebab-2050-42e1-866b-393bc8ae4cb3.png align="center")
    
    **\-t:** It lists all the files or directories in order of time when they were last modified (not in alphabetical order).
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104169804/c8f9589b-f553-46f6-8e7e-2c50585bd6c7.png align="center")
    
    \-**r:** It lists the files in reverse order.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104202203/c6e8e46f-d9eb-428b-abf1-9ea0fdd9ae39.png align="center")
    
    **\-i**: It displays all the files with their index numbers.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104226739/24b1fba6-70d9-4a64-9b7a-63f2fba82847.png align="center")
    
    **\*.sh:** It displays all the files ending with .sh present in the present directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104424135/c0d7e70f-0465-45bb-9fff-079d91ad869a.png align="center")
    
    **\-d\*/:** It displays all the directories in the directory you are currently at.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104659804/3a710ee4-76da-470d-be4a-3ddfa3ed20eb.png align="center")
    
3. Commands to navigate directories:
    
    **"cd &lt;path\_of\_the\_directory&gt;"**: It navigates the user to the specified directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104734421/b8a7a43b-2c34-44b6-b390-246337124037.png align="center")
    
    **"cd .."**: It changes the directory to the previous directory from the directory you are currently in.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104810694/ff27bf03-a442-45ac-837d-05c173246690.png align="center")
    
    **"cd ../.."**: It changes the directory to two previous directories up from the directory you're currently in.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104888614/3b6aad7b-9bfe-4f8f-a518-e90689978d31.png align="center")
    
    **"cd -"**: It navigates to the previous directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104923739/52256a6c-ec23-4d67-b92b-4a8dec939f39.png align="center")
    
    **"cd ~"**: It navigates to the home directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689104950533/4feb93a1-da5a-4caa-86ed-0f3a6db1b4ff.png align="center")
    
    **"cd 'Dir name with space' or cd Dir\\ name\\ with\\ space"**: It is used to list the directories names with spaces.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689109533544/f1f17864-d391-49e8-be60-c6c46b19f7fa.png align="center")
    
4. Commands to create directories:
    
    **"mkdir &lt;desired\_directory\_name&gt;":** It creates a new directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110115940/3d0b9a15-1e86-48bd-abef-eaf8b8b1ca83.png align="center")
    
    **"mkdir .&lt;Newfolder&gt;"**: This will create a new hidden directory with the name Newfolder.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110154452/03e492c8-82ce-47b1-8d17-2da813dc22ba.png align="center")
    
    **"mkdir A B C D E"**: This will create multiple directories.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110253089/175d5107-c3b6-4cfc-b0bd-ba85e788a3a9.png align="center")
    
    **"mkdir -p A/B/C/D/E"**: This will create nested directories.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110278478/e38d0b4f-0e6c-4ade-8fe5-ab0cae0ef78a.png align="center")
    
5. Commands to delete directories:
    
    **"rmdir &lt;dir\_name&gt;"**: This will delete the directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110346600/5b089de2-31c0-48f5-84e5-c0bd5f961986.png align="center")
    
    **"rm -r &lt;dir\_name&gt;"**: This will delete all the files and directories inside the dir\_name directory recursively.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689111459973/9f6f3387-fb07-4e53-89c7-e55ee139a160.png align="center")
    
    **"mkdir -m 700 &lt;newdir&gt;"**: This will set the permission while creating the directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689110436232/8de53a15-1a79-415a-bc1d-68e3f21a54df.png align="center")
