Day 2: Introduction to Linux & Basic Commands

ยท

3 min read

Day 2: Introduction to Linux & Basic Commands

Table of Contents

  1. ๐ŸŒ History of Linux

  2. ๐Ÿง What is Linux?

  3. ๐Ÿš€ Basic Linux Commands

    • File Commands

    • Directory Commands

๐ŸŒ History of Linux

  1. Early 1990s: A guy named Linus Torvalds creates a basic computer program (kernel) as a hobby. He shares it with others.

  2. 1991: Linus releases the first version of his program called "Linux." It's like a heart for a computer, but it needs more parts to work well.

  3. 1990s-2000s: Many people join Linus and add those missing parts (software). They create different versions (distributions) of Linux, like Ubuntu and Red Hat.

  4. 2000s: Linux becomes popular for servers and later for smartphones (Android is based on Linux).

  5. Today: Linux is everywhere โ€“ from your phone and computer to big servers and even space missions. People keep improving it together.

๐Ÿง What is Linux?

Linux is the core of many operating systems. It's open-source, meaning anyone can see, change, and share its code. Imagine it as a super customizable, reliable engine that powers servers, desktops, and even smartphones.

Why is Linux awesome?

  • Stable: Rarely crashes.

  • Secure: Hard to hack.

  • Flexible: Customize it to your liking.

In a nutshell, Linux gives you control and reliability. ๐Ÿ› ๏ธ

Key Parts of Linux:

  • Applications: Tools like web browsers and games.

  • Shell: A translator that executes your commands. Bash is a popular one.

  • Kernel: The brain managing resources.

  • Hardware: Physical components like the hard drive and CPU.

๐Ÿš€ Basic Linux Commands

File Commands:

  1. Create a New File:

      touch filename
    

    Example: touch myfile.txt

  2. Copy a File:

      cp source file destination
    

    Example: cp file1.txt /path/to/destination

  3. Move/Rename a File:

      mv oldfilename newfilename
    

    Example: mv oldfile.txt newfile.txt

  4. Remove/Delete a File:

      rm filename
    

    Example: rm unwantedfile.txt

  5. View Contents of a File:

      cat filename
    

    Example: cat myfile.txt

  6. Edit a File:

      nano filename
    

    Example: nano myfile.txt

Directory Commands:

  1. Create a New Directory:

      mkdir directoryname
    

    Example: mkdir mydirectory

  2. Navigate to a Directory:

      cd directoryname
    

    Example: cd mydirectory

  3. List Files and Directories:

      ls
    

    Example: ls

  4. List All Files and Directories (Including Hidden):

      ls -a
    

    Example: ls -a

  5. Copy a Directory and its Contents:

      cp -r sourcedirectory destination
    

    Example: cp -r dir1 /path/to/destination

  6. Move/Rename a Directory:

      mv olddirectory newdirectory
    

    Example: mv olddir newdir

  7. Remove/Delete an Empty Directory:

      rmdir directoryname
    

    Example: rmdir emptydir

  8. Remove/Delete a Directory and its Contents:

      rm -r directoryname
    

    Example: rm -r unwanteddir

  1. Check Your Present Working Directory:

    The pwd command allows you to identify the current directory you are working in. Simply type pwd and press Enter to display the full path.

      $ pwd
      /home/username/documents
    
  2. List All Files and Directories (Including Hidden Ones):

    To list all files and directories in your current location, use the ls command. Adding the -a flag displays hidden files as well.

      $ ls -a
      .  ..  file1.txt  file2.txt  .hidden_directory
    

    The . and .. entries represent the current and parent directories, respectively.

  3. Create a Nested Directory:

    Building a nested directory structure is straightforward with the mkdir command. For example, to create a nested directory path A/B/C/D/E, use the following command:

      $ mkdir -p A/B/C/D/E
    

    The -p flag ensures that parent directories are created if they don't exist.

Happy Learning ๐Ÿ˜Š!

ย