Basics of Linux

Basics of Linux

Contents:

What is Linux?

Linux File system hierarchy.

Distribution of Linux

List of Basic commands

Use cases

What is Linux?

Linux is a free and open-source operating system (OS) kernel that serves as the foundation for a wide variety of operating systems.Linux is a special kind of operating system that's popular because it's free, customizable, and powerful.

  1. Operating System: Think of Linux as the traffic controller for your computer. It manages all the different parts like the screen, keyboard, and programs.

  2. Open Source: Imagine if you had a recipe for your favorite dish that you could share with anyone. Linux is like that – its recipe is open for everyone to use, change, and improve.

  3. Customizable: Do you know how you can change the wallpaper or theme on your phone? With Linux, you can change almost anything to make your computer look and work just the way you want.

  4. Variety of Flavors (Distributions): Linux comes in different versions called "distributions" or "distros" for short. It's like getting different flavours of ice cream – each one has its own features and looks, but they all use the same core ingredients.

  5. Command Line: Instead of using only buttons and clicks, Linux lets you talk to your computer using commands. It's like giving orders to a robot – you type what you want, and it does it for you.

  6. Software Heaven: You know how you can download apps on your phone? Linux has a place called a "repository" where you can easily get tons of software for free.

  7. Stability and Security: Linux is like a superhero for your computer's safety. It's built to be really strong against viruses and crashes.

  8. Usage: Linux is used in lots of places, from regular laptops to big servers that run websites. Even Android phones use a version of Linux!

Linux File system hierarchy

Here's a simplified overview of the main directories you'll find in a typical Linux file system:

/

  • Root Directory: The top-level directory of the file system from which all other directories branch off.

/bin

  • Binaries: Contains essential user binary files (programs) that must be present for the system to boot and run.

/boot

  • Boot Loader Files: Holds files needed to start the Linux operating system, including the Linux kernel.

/dev

  • Device Files: Represents peripheral devices like hard drives, USB drives, and keyboards as files.

/etc

  • Configuration Files: Contains system-wide configuration files and directories.

/home

  • User Home Directories: Contains the personal directories of each user with a login account.

/lib

  • System Libraries: Holds essential shared library files and kernel modules needed for the binaries in /bin and /sbin to function.

/media

  • Removable Media: Used as a mounting point for removable media like CD-ROMs, USB sticks, and external hard drives.

/mnt

  • Mount Directory: Temporarily mounts filesystems, such as network filesystems or additional hard drives.

/opt

  • Optional Software: Contains add-on applications from individual vendors.

/proc

  • Process Information: A virtual filesystem providing access to kernel and process information as files.

/root

  • Root Home Directory: The home directory of the root user (the system administrator).

/sbin

  • System Binaries: Contains essential binaries related to system administration and maintenance.

/sys

  • System Files: Another virtual filesystem that provides information about devices, drivers, and some kernel features.

/tmp

  • Temporary Files: Used for storing temporary files by the system and users.

/usr

  • User Programs: Contains the majority of user utilities and applications, including /usr/bin for binaries, /usr/lib for libraries, /usr/local for locally compiled software, and /usr/share for shared data.

/var

  • Variable Files: Holds variable data like logs (/var/log), mail, and spool files that grow in size.

Distribution of Linux

A Linux distribution, often called a distro, is a version of the Linux operating system that contains the Linux kernel along with a package of additional software and tools.Here's a breakdown of some key aspects of Linux distributions:

  • Ubuntu: Known for its ease of use and installation, making it a popular choice for beginners. It’s widely used for desktops, servers, and cloud.

  • Fedora: Offers the latest software and features, making it popular among developers and enthusiasts.

  • Debian: Known for its stability and security, it’s the foundation for many other distros, including Ubuntu.

  • CentOS (now shifting to CentOS Stream): A free version of Red Hat Enterprise Linux (RHEL), known for its stability and long-term support, often used in server environments.

  • Arch Linux: Targets experienced users who want to customize their system from the ground up.

  • Linux Mint: Based on Ubuntu, it's known for being user-friendly and for providing a more traditional desktop experience.

List of Basic commands

  1. ls: List files and directories in the current location. Example: ls

  2. cd: Change directory (move to a different folder). Example: cd Documents

  3. pwd: Print the current working directory (shows your current location). Example: pwd

  4. mkdir: Create a new directory (folder). Example: mkdir NewFolder

  5. touch: Create an empty file. Example: touch myfile.txt

  6. cp: Copy files or directories. Example: cp file.txt /newlocation

  7. mv: Move or rename files or directories. Example: mv oldname.txt newname.txt

  8. rm: Remove (delete) files or directories. Example: rm file.txt

  9. echo: Display text on the screen. Example: echo "Hello, Linux!"

  10. cat: Display the contents of a file. Example: cat myfile.txt

  11. grep: Search for a specific pattern in files. Example: grep "keyword" file.txt

  12. man: Display the manual (help) for a command. Example: man ls

  13. chmod: Change permissions of files or directories. Example: chmod +xscript.sh

  14. sudo: Run a command with superuser (admin) privileges. Example: sudo apt-get update

  15. df: Display disk space usage. Example: df -h

  16. ps: List running processes. Example: ps aux

  17. kill: Terminate a process. Example: kill PID

  18. ifconfig: Display network interface information. Example: ifconfig

  19. ping: Test network connectivity to a server. Example: pinggoogle.com

  20. wget: Download files from the web. Example: wgethttps://example.com/file.txt

Use cases

  1. To create file--

  2. To create a directory- mkdir

  3. To see hidden files-

  4. To Remove directories along with all their contents recursively.

  5. Creating a nested directory: