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 --onlinewill show available distributions. To install Ubuntu specifically, usewsl --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 ubuntuto 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 likecd ..orls.
- 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 updaterefreshes 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 withsudo 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
chmodcan be used to change file permissions. For example, usingA - Wremoves 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 -lshows updated permissions; if write is removed, it appears as a dash in the output.
- The numerical version of
chmodallows 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
lsinitiates a process that executes and displays output.
- Each process has a unique Process ID (PID); executing
pslists current processes along with their IDs.
- The command
ps auxprovides 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 nginxshows only processes related to nginx.
- The command
topdisplays 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 nginxcheck if services are running properly.
- Services can be started or stopped using commands such as
systemctl start nginxorsystemctl stop nginx.
- Reloading configurations with commands like
systemctl reload nginxapplies 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
whichcommand can be used to determine the exact path of executables likePython 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.shis 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 mvcan 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 asexport 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_namecreates 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.pyto 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,
/etccontains system-wide configuration files while/usrholds 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.