Linux Tutorial For Beginners | Complete Linux Course for DevOps

Linux Tutorial For Beginners | Complete Linux Course for DevOps

Final Video and Raw Files Backup

Data Safety Concerns

  • The speaker informs Harry that the final video and all raw files are on a pen drive, emphasizing the importance of careful uploading due to data safety concerns.

Urgent Situation

  • A sense of urgency is introduced as someone frantically searches for their stick (lathi), indicating a chaotic environment.

Coding Basket Private Limited's Demand

High Stakes Scenario

  • The speaker reveals they were sent by Coding Basket Private Limited with a threat regarding a pen drive that could cause a loss of ₹50 crores if not handled properly. They mention being offered ₹1 lakh for this task.

Moral Dilemma

  • The speaker suggests splitting the money but pleads for freedom, asking to donate the money to charity instead, questioning the significance of what's on the pen drive.

Introduction to Linux Tutorial

Educational Content Overview

  • The speaker introduces a YouTube tutorial about Linux, stating it will cover everything from basics to advanced topics, making it accessible even for beginners.

Importance in Modern Era

  • Emphasizes that managing virtual machines has become crucial in today's AI era, highlighting Linux's relevance across various tech roles like software developers and DevOps engineers.

Understanding Linux

Definition and Functionality

  • Linux is described as an open-source operating system kernel that facilitates direct communication between hardware components and software applications.

Misconceptions Clarified

  • Clarifies that while often referred to as an operating system, technically, Linux is just a kernel; distributions combine this kernel with other software components to create functional operating systems.

Reasons to Learn Linux

Critical Skill Set

  • Learning Linux is essential due to its widespread use in servers and infrastructures; it's particularly favored for its open-source nature which eliminates licensing costs.

Popular Distributions

  • Mentions popular distributions like Ubuntu and Fedora while noting that discussions around "Linux" typically refer to specific distributions rather than the kernel itself.

Historical Context of Linux Development

Origins

  • Traces back to 1969 when Dennis Ritchie and Ken Thompson developed Unix at Bell Labs, leading to foundational ideas in multi-user systems and multitasking capabilities.

Linus Torvalds' Contribution

  • In 1991, Linus Torvalds began developing his own operating system inspired by Minix; he released it as open-source in September 1991 after initial hobbyist efforts gained traction.

Adoption of Linux by Major Companies

Rise in Popularity

  • By 2003, Android was built on top of the Linux kernel after Google acquired Android Inc., showcasing how significant companies adopted Linux for privacy reasons over other operating systems.

Setting Up Online Linux Servers

Affordable Options

  • Discusses how beginners can purchase affordable online VPS (Virtual Private Server), emphasizing security benefits associated with using an open-source OS like Linux without incurring costs.

Recommended Hosting Provider

  • Recommends Hostinger as an affordable platform for VPS hosting while explaining how users can maintain their local computers free from heavy workloads by utilizing online servers instead.

Step-by-Step VPS Setup Guide

Choosing Plans

Guides viewers through selecting appropriate plans on Hostinger’s website while ensuring they apply discount codes during checkout for better deals on services offered.

Installation Process Overview

Describes setting up Ubuntu versions during server configuration steps while stressing the importance of choosing LTS (Long Term Support).

Accessing Your Server

Explains SSH access methods allowing users remote command execution capabilities within their rented VPS environments effectively.

Virtual Machine Setup Using VirtualBox

Introduces VirtualBox installation process enabling users running Windows or MacOS platforms creating independent virtual machines capable of running different OS configurations seamlessly.

Windows Subsystem for Linux: An Overview

Introduction to WSL

  • Windows Subsystem for Linux (WSL) is a crucial tool that allows users to obtain a Linux environment instantly within Windows without creating a virtual machine or installing Linux on an actual machine.

Installing WSL

  • To install WSL, open the Windows terminal as an administrator and run the command wsl --install. This will initiate the installation process of WSL.
  • The installation downloads version 2.7.12 of WSL along with a default Linux distribution, which in this case is Ubuntu.

User Experience with Command Line

  • Users transitioning from Windows to Linux often face challenges due to differences in command line interfaces; commands in Linux and Mac are more similar compared to those in Windows.
  • WSL was developed for individuals wanting to practice or test Linux while remaining within their Windows environment.

Recommendations and Limitations

  • While following this tutorial, it’s recommended to use either a virtual machine or an actual server for better performance; however, using WSL is also acceptable despite potential issues arising from its limitations.
  • If problems occur while using WSL, it may be due to operating within the confines of WSL rather than on a physical or virtualized Linux machine.

Completing Installation and Initial Setup

  • After successful installation, running wsl --list --online will show available distributions. To install Ubuntu specifically, use wsl --install ubuntu.
  • A system reboot may be required after installation before you can start using your new distribution effectively.

Using Ubuntu on WSL

Launching Ubuntu

  • After rebooting and opening the terminal again, if no distributions are installed yet, re-run the command wsl --install ubuntu to download and set up Ubuntu.
  • Once installed successfully, launching Ubuntu through WSL provides access to all standard Linux commands just like on any regular server setup.

Basic Commands in Ubuntu

  • Users can execute basic commands such as pwd (print working directory), history, and navigate directories using commands like cd .. or ls.
  • With sudo privileges granted by entering your password when prompted, users can update packages (sudo apt update) or install software like Python (sudo apt install python3).

Understanding Limitations of WSL

Comparison with Virtual Machines

  • It’s important to note that WSL does not replace a full-fledged Linux machine; it serves merely as an interface for running Linux applications within Windows.
  • For long-term usage of Linux systems where performance matters significantly—especially regarding networking—using VMs or dedicated servers is advisable over relying solely on WSL.

Installing VirtualBox on macOS

Downloading VirtualBox

  • For macOS users interested in setting up VirtualBox, begin by searching "download VirtualBox" online which leads you directly to Oracle's download page.

Installation Steps

  • Select the appropriate version based on your hardware architecture (e.g., Apple Silicon), then proceed with downloading and installing by following prompts including entering your password when requested during installation.

Creating Your First VM

Setting Up a New VM

  • After installation completion, launch VirtualBox and create a new VM by selecting "New," naming it appropriately (e.g., My First VM), then choosing the ISO image file downloaded earlier for Ubuntu setup.

Configuring Resources

  • Adjust settings such as RAM allocation (30 GB recommended), video memory (100 MB), CPU cores (20 CPUs suggested), ensuring optimal performance before starting your VM instance.

Navigating Within Your New Environment

Using Basic Commands

  • Now that you have access to either an online server or local virtual machine running Ubuntu/Linux OS , it's time to start utilizing basic commands necessary for navigating through directories efficiently .
  • Understanding why learning these skills is essential today revolves around how most modern virtual machines operate primarily on linux platforms especially given current trends towards AI & data processing .

Understanding Command History and Navigation in Linux

Using Arrow Keys for Command Execution

  • Short commands can be executed quickly, but for longer commands, users can utilize the arrow keys to navigate through command history.
  • By pressing the up or down arrow keys, users can retrieve previous commands without retyping them.

Navigating Linux Paths

  • To access the root directory, type a folder name preceded by a slash (/) indicating the root path.
  • The tilde (~) symbol represents the home directory of the current user; it can be accessed using cd ~.
  • If typing is difficult, users can copy and paste special characters like tilde from Google search.

Special Directory Shortcuts

  • The dot (.) refers to the current directory while double dots (..) refer to the parent directory.
  • Users can navigate directories using these shortcuts effectively; for example, cd .. moves one level up.

Creating New Users in Ubuntu

Importance of Non-root User Accounts

  • Managing a Linux machine typically starts with logging in as a root user; however, it's recommended to create non-root user accounts for regular tasks.

Steps to Create a New User

  • After logging into SSH as root, use sudo adduser <username> to create a new user account.
  • Setting passwords during user creation requires entering and confirming the password twice.

Switching Between Users

Logging In as Different Users

  • Use su - <username> to switch from root to another user account seamlessly.

Limitations of Regular Users

  • Regular users may not have permission to execute certain commands like package updates unless granted sudo privileges.

Package Management in Ubuntu

Understanding APT Package Manager

  • APT (Advanced Package Tool), is used for installing software packages on Ubuntu systems efficiently.

Updating Packages

  • Running sudo apt update refreshes available package listings without upgrading installed software versions.

Installing Software Packages

  • To install software such as Apache 2, use sudo apt install <package-name>, which prompts confirmation before proceeding with installation.

Managing User Permissions and Groups

Purpose of Groups in Linux

  • Groups are created to manage permissions collectively rather than individually when multiple users require similar access rights.

Adding Users to Groups

  • Use sudo groupadd <groupname> followed by adding users with sudo usermod -aG <groupname> <username> for efficient permission management.

Checking Group Membership

  • Verify group memberships using commands that display which groups each user belongs to within the system.

Understanding Linux Permissions and Commands

Changing File Permissions with chmod

  • The command chmod can be used to change file permissions. For example, using A - W removes write permissions from all users.
  • To remove write permission only for the owner, use U - W. It's important to note that "owner" refers to the user who owns the file.
  • After modifying permissions, running ls -l shows updated permissions; if write is removed, it appears as a dash in the output.
  • The numerical version of chmod allows setting permissions using numbers (e.g., 435), where each digit represents read, write, and execute permissions for owner, group, and others respectively.
  • Using the command chmod 435 filename, you can set specific permissions based on calculated values derived from read (4), write (2), and execute (1).

Processes in Linux

  • A process is defined as a running program; for instance, typing commands like ls initiates a process that executes and displays output.
  • Each process has a unique Process ID (PID); executing ps lists current processes along with their IDs.
  • The command ps aux provides detailed information about all processes running under different users including CPU and memory usage statistics.
  • You can filter process outputs using pipes; for example, combining ps aux | grep nginx shows only processes related to nginx.
  • The command top displays real-time resource usage by processes; pressing 'q' exits this view.

Managing Services in Linux

  • A service runs continuously in the background without user intervention; examples include web servers like nginx which need to remain active for hosting websites.
  • Systemd is commonly used as a service manager in many Linux distributions. Commands like systemctl status nginx check if services are running properly.
  • Services can be started or stopped using commands such as systemctl start nginx or systemctl stop nginx.
  • Reloading configurations with commands like systemctl reload nginx applies changes without stopping the service entirely—important for maintaining uptime during updates.

Environment Variables

  • Environment variables store configuration settings accessible globally within shell sessions. An example is $HOME, which points to the user's home directory.
  • Shell variables are local to individual shell sessions while environment variables persist across child processes created from that session.
  • The PATH variable contains directories where executable files are located; this allows users to run programs without specifying full paths.

Understanding the Linux Shell and Command Execution

Command Lookup Process

  • When executing a command like ls, the shell searches for it in various directories until found, illustrating how Linux handles command execution.
  • The which command can be used to determine the exact path of executables like Python 3, helping users understand where commands are sourced from.

Bash Scripting Basics

  • A bash file (e.g., harry.sh) is created to execute a series of commands sequentially, showcasing basic batch scripting concepts.
  • Batch scripting includes control structures such as if statements, loops, and allows writing syntax similar to programming languages.

Making Scripts Executable

  • After creating a script, it must be made executable using the command chmod +x harry.sh, enabling its execution.
  • If an error occurs stating "command not found," it indicates that the current directory isn't in the PATH variable; thus, using ./harry.sh is necessary to run scripts located in the current directory.

Managing File Permissions and Moving Files

Moving Files with Permissions

  • Attempting to move files may result in permission denied errors; using sudo mv can bypass these restrictions when necessary.
  • After moving a script into another directory (like /home/harry/dev), executing it confirms successful relocation and functionality.

Updating Environment Variables

  • To add new paths to the existing PATH variable without losing previous entries, use: export PATH=$PATH:/new/path.
  • This method appends new directories while preserving existing ones, ensuring all binaries remain accessible during sessions.

Understanding Persistent Environment Variables

Session Persistence

  • Environment variables set during a session are temporary; they disappear once the session ends unless saved in configuration files like .bashrc.
  • To make variables permanent across sessions, they must be added to .bashrc, which loads automatically upon starting a new terminal session.

Editing .bashrc for Permanent Variables

  • Use text editors like Vim or Nano to edit .bashrc; adding lines such as export FRIEND="Rohan" ensures variables persist after closing terminals.

Introduction to Archiving and Compression

Definitions of Archiving vs. Compression

  • Archiving combines multiple files into one container without necessarily reducing size; compression reduces file size significantly.

Using tar for Archiving

  • The command tar -cf archive.tar folder_name creates an archive of specified folders/files without compressing them initially.

Automating Tasks with Cron Jobs

What are Cron Jobs?

  • Cron jobs automate scheduled tasks on Linux systems; useful for repetitive tasks like daily backups at specific times (e.g., 8 AM).

Scheduling Cron Jobs

  • Users can create cron jobs by editing their crontab with commands like crontab -e, allowing them to specify timing and tasks easily.

Creating a Simple Python Program to Log Current Time

Writing the Basic Program

  • The speaker begins by stating they will create a simple Python program using vm main.py to log the current time into a file.
  • A basic Python script is written that outputs the current time into a file named time.txt. The speaker demonstrates saving and executing this script.
  • After running the script, they check for the existence of time.txt, confirming it contains the current time.

Setting Up Cron Jobs

  • The speaker discusses using cron jobs to automate running their Python script. They reference an image found on Google related to crontab configuration.
  • An explanation of crontab fields follows: minute, hour, day of month, month, and day of week are detailed with examples for each field.

Utilizing Crontab Guru

  • The speaker introduces "crontab.guru," a helpful website for understanding cron job syntax and scheduling commands effectively.
  • They demonstrate how to set up a cron job that runs daily at 4:05 AM by filling in appropriate fields on crontab.guru.

Configuring Cron Jobs for Specific Times

Scheduling Commands

  • Instructions are provided on how to schedule commands using specific times and dates within crontab settings.
  • The speaker emphasizes setting correct parameters in crontab for desired execution timing (e.g., every minute).

Testing Cron Job Execution

  • They attempt to run their Python script via cron but initially do not see expected output in time.txt.
  • After correcting command paths in their crontab entry, they wait to verify if the cron job executes correctly.

Understanding Linux Directory Structure

Exploring Linux Directories

  • Transitioning from scripting, the speaker explores various important directories within Linux such as /etc, /usr, and /tmp.
  • Each directory's purpose is explained; for example, /etc contains system-wide configuration files while /usr holds user-related programs and libraries.

Temporary Files Management

  • Discussion includes managing temporary files stored in /tmp, emphasizing that these should only contain non-essential data due to automatic cleanup by the OS.

Hosting Multiple Websites on One Server

Setting Up Nginx Web Server

  • The speaker outlines steps taken to install Nginx on their server using package management commands like sudo apt update.
  • Confirmation of successful installation is shown through checking Nginx service status.

Creating HTML Websites

  • Demonstrating website creation, they navigate into web directories (/var/www) where HTML files will be hosted.

Editing Website Content

Modifying HTML Files

  • Instructions are given on editing HTML files directly within Nginx’s directory structure. Changes made reflect immediately upon refreshing the browser.

Transferring Files Between Local Machine and Server

Using FileZilla for File Transfers

  • The speaker introduces FileZilla as an efficient tool for transferring files between local machines and servers seamlessly.
  • Steps include downloading FileZilla client suitable for Mac or Windows systems before connecting it with server credentials.

This structured summary captures key insights from each section of the transcript while adhering strictly to timestamp rules.

Turn any video into a summary like this

YouTube links, meetings, lectures. With transcripts, search, and chat.

Video description

Use this link along with coupon code "HARRYVPS" to get the best discount deal from Hostinger: https://hostinger.com/HARRYVPS Download Handbook: https://www.codewithharry.com/notes#handbooks Crontab Website: https://crontab.guru/ Data Science Course: https://www.codewithharry.com/courses/the-ultimate-job-ready-data-science-course Data Analytics Course: https://www.codewithharry.com/courses/the-ultimate-job-ready-ai-powered-data-analytics-course Python Course: https://www.codewithharry.com/courses/complete-python-bootcamp-learn-python-from-scratch WebDev Course: https://www.codewithharry.com/courses/the-ultimate-web-dev-course C Course: https://www.codewithharry.com/courses/ultimate-c-course-english ➡️ Skit Credits: Directed & Shot by: Pawan Pal & Team Lead Cameraman: Rahul Pal Assistant Director: Izhan Ahmad Editing, Music & Sound Design: Izhan Ahmad Editing (Tutorial): Rohan Das Supporting Actor: Shayan Hunter TimeStamps: 00:00:00 Skit 00:05:00 Introduction 00:05:58 What is Linux 00:08:31 History of Linux 00:12:06 Getting an Online Linux Server 00:18:44 Installing Linux Through VirtualBox on Windows 00:26:58 Installing Linux Through WSL in Windows 00:32:23 Installing Linux Through VirtualBox on Mac 00:36:23 Basic Linux Commands 00:54:35 Creating Users 01:00:55 Package Management 01:07:22 Groups and Permissions 01:19:17 Processes and Services 01:33:30 Environment Variables, Path and bashrc 01:53:31 Archives and Compression 02:01:44 Cronjobs 02:12:24 Understanding Linux Filesystem 02:17:05 Understanding Nginx 02:22:58 Using Filezilla to transfer files 02:26:33 Conclusion Download Handbook (Alt link): https://cwh-full-next-space.fra1.cdn.digitaloceanspaces.com/YouTube/linux_handbook.pdf ➡️ Download Notes and CheatSheets: https://www.codewithharry.com/notes/ ➡️ Udemy Python Course: https://goharry.in/python ➡️ Checkout Data Science The Ultimate Job Ready Data Science Course: https://www.codewithharry.com/courses/the-ultimate-job-ready-data-science-course ➡️ Data Science (International Students): https://buy.stripe.com/9B65kF3790jS2kCeiZ1gs04 ➡️ Career Advice: If you are into college and C/C++/Java is being taught, p lease continue with it. Here are my respective videos/playlists: Learn C Programming: https://www.youtube.com/watch?v=aZb0iu4uGwA Learn C++ Programming: https://www.youtube.com/playlist?list=PLu0W_9lII9agpFUAlPFe_VNSlXW5uE0YL Learn Java Programming: https://www.youtube.com/playlist?list=PLu0W_9lII9agS67Uits0UnJyrYiXhDS6q But if you are not in college and want to learn programming, then I would suggest you to start with Python. Also if you are a beginner and want to learn programming, start with Python. It is beginner-friendly and has a large community for support and a lot of jobs. If you're serious start with my Udemy course in English. Its updated + has a lot of projects. Here is the discounted link which will get you this course for less than ₹400-500. I request you to leave a review if you have enrolled: Udemy Course: https://goharry.in/python After you finish this course, you can start with Data Science. It is a very profitable field to get into and has a lot of job opportunities. You can learn Data Science through my "Ultimate Job Ready Data Science Course". It is a complete course that covers everything you need to know to get a job in Data Science. Here is the discounted link to the course that will get you this course for ₹2899: Data Science Course: https://www.codewithharry.com/courses/the-ultimate-job-ready-data-science-course ➡️ Follow Me On Social Media ► Website (Created Using Next.js): https://www.codewithharry.com ► Facebook: https://www.facebook.com/CodeWithHarry ► Instagram: https://www.instagram.com/CodeWithHarry/ ► Twitter: https://twitter.com/CodeWithHarry ► English channel: https://www.youtube.com/channel/UC7btqG2Ww0_2LwuQxpvo2HQ Comment "#HarryBhai" if you read this 😉😉