Skip to main content

Day 2 : Basics of Linux

Updated 3 min readMarkdown
Day 2 : Basics of Linux

Day2: Introduction to Linux

What is Linux?

  1. Linux is an open-source operating system, It is a freely available operating system that can be installed on a wide range of devices such as desktops, servers, smartphones and tablets, supercomputers etc.

  2. An operating system (OS) is a system of software that manages computer hardware, software resources and provide common services for computer programs.

Linux File System Hierarchy - In Linux everything is represented as a file including a hardware program the files are stored in a directory and every directory contains a file with a tree structure that is called file system hierarchy.

  1. /home - It creates home directory for other user.

  2. /root - home directory for root user.

  3. /boot - It contains bootable files for linux.

  4. /etc - Contains all configuration files.

  5. /user - By default software is installed in this directory.

  6. /bin - It contains command used by all users.

  7. /sbin - It contains command used by only root user.

  8. /opt - Optional application software packages.

  9. /dev - Essential device files.

  10. /mnt - Temporarily mounted file systems.

Features of Linux

  1. Open source

  2. Secure

  3. Simplified updates for all installed software.

  4. Light weight

  5. Multiple Distribution(Fedora,Debian,RedHat)

Basic Linux Commands

  • / Is your root directory.

  • ~ Is your home directory.

  • uname : It show name of kernal (OS).

  • uname -r : It show version of kernal.

  • clear : Is use for clear screen.

  • whoami : It shows currently login user name.

  • date : It shows time and date.

  • cal : Show this month's calendar

  • history : It show list of previously used command.

ubuntu@ip-172-31-205-241:~$ uname
Linux
ubuntu@ip-172-31-205-241:~$ uname -r
5.15.0-1028-aws
ubuntu@ip-172-31-205-241:~$ date
Mon Mar 27 11:59:37 UTC 2023
  1. ls - The most frequently used command in Linux to list directories

  2. pwd - Print working directory command in Linux

  3. cd - Linux command to navigate through directories

  4. mkdir - Command used to create directories in Linux

  5. cd .. - Change the directory to one step back.

  6. cd ../.. - Change directory to 2 lavels back.

  7. mv - Move or rename files in Linux

     ubuntu@ip-172-31-205-241:~$ whoami ubuntu 
     ubuntu@ip-172-31-205-241:~$ touch my_file.txt 
     ubuntu@ip-172-31-205-241:~$ ls 
     my_file.txt 
     ubuntu@ip-172-31-205-241:~$ pwd
     /home/ubuntu 
     ubuntu@ip-172-31-205-241:~$ mkdir linux 
     ubuntu@ip-172-31-205-241:~$ ls 
     linux my_file.txt 
     ubuntu@ip-172-31-205-241:~$ cd linux 
     ubuntu@ip-172-31-205-241:~/linux$ pwd 
     /home/ubuntu/linux 
     ubuntu@ip-172-31-205-241:~/linux$ cd .. 
     ubuntu@ip-172-31-205-241:~$ ls 
     linux my_file.txt 
     ubuntu@ip-172-31-205-241:~/linux$ mv ../my_file.txt .
     ubuntu@ip-172-31-205-241:~/linux$ ls
     my_file.txt
    

    Listing commands

    ls - The most frequently used command in Linux to list directories

    ls -a - you can see the whole list of files, including the hidden files.

    ls -l - The ls command will only display the files.

    ls -d */ - If you only want to display the sub-directories excluding all other files, you can use this command

    ls -g - If you don't want to display the owner information in your list

    ls -lg - f you don't want to display the group information in your list

    ls ../ - This command contains the list of the parent directory.

Linux Command to Create a Nested Directory :

command to create a nested directory is : mkdir -p A/B/C/D/E

-p is for no error if existing, make parent directories as needed

tree command is used to show the nested directory.

ubuntu@ip-172-31-205-241:~$ mkdir -p A/B/C/D/E 
ubuntu@ip-172-31-205-241:~$ tree
.
├── A
│   └── B
│       └── C
│           └── D
│               └── E
├── dir
│   ├── dir1
│   └── dir2
├── linux
│   ├── linux
│   └── my_file.txt
└── snap
    └── tree
        ├── 18
        ├── common
        └── current -> 18
14 directories, 2 files

Thanks For Regarding*! :)*

Pooja Patil

About the author

  • Hey!! I am a Pooja Patil. I started writing articles on DevOps and cloud journey. My purpose is share the concept knowledge that i learn. the task that i perform regarding Devops. Welcome to my Blog!!!

No comments yet. Be the first to comment.

More from this blog