Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Linux 101 - Introduction to Linux and Command Line

Linux 101 - Introduction to Linux and Command Line

Anmoldeep Singh Arora

May 15, 2021
Tweet

More Decks by Anmoldeep Singh Arora

Other Decks in Education

Transcript

  1. After the session, we shall be Clear about: 1. What

    is Linux ? 2. Where is Linux Used ? 3. What is Kernel 4. Windows vs Linux 5. And lots of hands on :) Slides will be shared later, but not our way of delivering it :)
  2. What is Linux? Just like Windows and MacOS, Linux is

    an operating system (OS) Technically, Linux -> Kernel (Low-level OS) | GNU/Linux -> Linux kernel + GNU Software collection (Libre software) | Linux Distribution -> Linux kernel + GNU Software collection + Desktop environment and additional software Hence a Linux distribution is a complete OS
  3. Linux vs Windows Linux Windows • Open-source • Free •

    Relatively more secure • Transparent • Respects privacy • Contribute ◦ Documentation ◦ Features ◦ Bug Fixes • Available in source code and binary • Closed-source • Paid • Relatively less secure • No transparency • <Privacy not found> • Cannot contribute directly apart from reporting bugs • Available in only binary • Often known as BSOD *_*
  4. Linux vs Windows Linux Windows You can control what is

    updated and EVEN STOP ALL UPDATES!!!
  5. What is CLI? • CLI stands for command line interface

    • Terminal in Linux whereas Command Prompt/Powershell in Windows Terminal - The Force of Linux • An interface to give commands to the OS, more often referred to as a terminal emulator. It allows us to interact with the shell. • Types - gnome-terminal, konsole, xterm, rxvt, kvt, nxterm, and eterm So, what is a shell? • The shell is a program that takes commands from the keyboard and gives them to the OS to perform. • Types - bash(most common), ksh, tcsh, zsh
  6. Gentle Introduction to the Linux shell Shell basically is a

    communication interface between you and the OS. In UNIX-based systems there are two types of shells : 1. Bourne shell (which we will be exploring). 2. The C shell. Bourne shell also has various subcategories like : • Korn shell (ksh) • Bourne shell (sh) • Bourne-again shell (bash) ---- Most common, available by default on most systems • Z shell (zsh) ---- This one looks beautiful when customized!
  7. Gentle Introduction to the Linux shell Commands Overview • Basics

    & Navigation • File Manipulation • System commands • Network commands • Searching, Piping and Redirection • Hardware Info • Users and Permissions • Install packages and Other utilities
  8. Basics and Navigation 1. pwd -> pwd (print working directory)

    shows the current directory (basically, the folder) you’re in 2. cd -> The most basic command of all time, cd (change directory) means change directory 3. ls -> ls (list) list down all the content inside the directory 4. Flags -> A flag is anything prefixed with a dash (-) or double dash (--) that follows the command name 5. tree -> Visualize a directory in a tree structure 6. clear / reset / Ctrl + L -> Typing clear or reset or input any of the key combinations mentioned will get your terminal clean and wiped up 7. man -> If see a new command you’ve never heard of or happen to forget, use man to find out 8. sudo command -> sudo (superuser do) is used to execute commands with admin privileges
  9. File Manipulation 1. ./filename -> Execute a locally stored file

    2. mkdir -> mkdir (make directory) is used to create a directory 3. mv -> To move files, the command mv (move) is used 4. rm -> rm (remove) removes files, CAUTION: cannot be undone 5. touch -> To create new (empty) files, use touch 6. cp -> To copy a file from one place to another or to make a copy of the file in same directory 7. echo -> echo prints out whatever you say to it 8. Displaying contents of a file -> cat, head, tail 9. tar/unzip -> Used to work with archives and compressed files
  10. System commands 1. uname -a -> Displays basic system information

    such as OS, Kernel, architecture etc. 2. hostname -> Displays the system host name (system name) 3. whoami -> Displays who you are logged in as (user name) 4. date -> Displays current system date and time 5. cal -> Displays the current month and day 6. uptime -> Displays how long your system has been running with load average
  11. 1. ip a -> Displays information about all network interfaces

    2. ping -> ping commands sends a request to a host to establish a connection 3. host -> Performs IP lookup on the domain name 4. whois -> Retrieves more information about a domain 5. wget -> wget (World Wide Web Get) is a very powerful utility to download files from an online service 6. netstat -> Netstat displays various network related information such as network connections, routing tables, interface statistics etc. 7. netcat -> Often referred to as a Swiss army knife of networking tools, this command can assist you in monitoring, testing, and sending data across network connections Network commands
  12. 1. grep -> Read as "apply the print command on

    all lines matching the given regular expression". Extremely powerful tool to search for content in files 2. locate -> locate is used to find all instances of a file 3. find -> find is a more aggressive search tool than locate with more options and features 4. | (Pipe) -> It redirects the output of the LHS command to the input of RHS command Syntax: command1 | command2 | command3 5. Redirections -> Similar to pipe, but instead of passing output to another command, they save the o/p to a file or read contents from a file Types -> 1. > 2. < 3. >> 4. << Searching, Piping and Redirection
  13. 1. dmesg -> Displays bootup messages, useful to troubleshoot device

    boot errors 2. lsblk -> Displays block device related information, ex: hard disk, flash drives etc. 3. lsusb -> Displays a list of attached USB devices 4. inxi -> Prints whole lot of information about the hardware, including vendor details, device driver configuration etc, in a readable format 5. fdisk -> Shows disk partition, sizes, and types 6. du -> Displays disk usage in current directory 7. mount -> Mounts a device at specified location 8. umount -> Unmount a mounted device Hardware
  14. 1. id -> Displays the active user's info 2. last

    -> Shows the last logins 3. Permissions • Types of permission - read (r), write (w), and execute (x) • Arrangement - - --- --- --- dir/file user group others 4. chmod -> chmod (change mode) is used to change permissions of files and directories 5. chown -> chown (change owner) is used to change ownership of a file or directory Users and Permissions
  15. 1. apt-get -> Default package manager for Debian based systems

    such as Ubuntu 2. dpkg -> Used to install, remove and provide info about .deb packages Other utilities 1. history -> Shows the complete history of your terminal commands 2. alias -> Set up custom aliases for various commands 3. htop -> System monitor (explicit install) 4. neofetch -> Shows the system info in a beautiful format (explicit install) Install Packages and Other Utilities
  16. Open Files vim <filename> Eg: To start editing press ‘i’:

    To exit edit mode, press ‘Esc’ key
  17. Exit vim ( with and without Save) While in view

    mode (out of insert mode) • To exit: Press ‘:’ then ‘q’ (stands for quit vim) • To save: Press ‘:’ then ‘w’ (stands for write file) • To save & exit: Press ‘:’ then ‘wq’ (stands for write then quit) Notice ‘wq’ NOT ‘qw’
  18. Challenge #1 • Clone react by git clone https://github.com/facebook/react •

    Find and navigate to react-client • Find src directory by listing and navigate into it • Show current directory path • Using relative paths, find and navigate to react-server/src
  19. Challenge #2 • Make this directory structure using mkdir one-liner

    • Make an empty file in child1 and subchild2 • Copy the file in subchild2 to child3 with a different name • Move the file in subchild2 to subchild4 with a different name • Remove the child2 directory
  20. Challenge #3 • Navigate to the react directory • In

    README.md file, find the lines containing the word Taylor • Save the output of above command in a file taylor.txt using piping and redirection • Append this file with a line “Lines found”
  21. Challenge #4 • Make a bash script by name hello.sh

    • Place just one echo command in it with your favourite text • Give all permissions to the user and group, and only read permission to others • Execute the file
  22. Or the way you want it to be ;P This

    desktop belongs to Arpan, our beloved Speaker of the day :)
  23. Tools and steps to look for 1. Install zsh or

    z-shell and make it as default shell. 2. For customizing terminal to fullest, you need zsh framework, for ex. Oh-my-zsh.(you can install this framework using this guide - https://github.com/ohmyzsh/ohmyzsh) 3. After installing framework, you can use plugins to customize terminal, like if you want to change theme, you can use powerlevel10k. And if you face problem while using it, they made it easy to uninstall like an easy breakup
  24. Awesome Resources • Beautiful website to learn step by step

    - https://linuxjourney.com/ • Awesome Linux - https://github.com/inputsh/awesome-linux • The Complete Linux Course - https://www.youtube.com/watch?v=wBp0Rb-ZJak • Linux commands cheat sheet - https://linoxide.com/guide/linux-cheat-sheet.png • Good place to learn shell scripting - https://linuxcommand.org/ • Another worthwhile resource - https://github.com/learnbyexample/Linux_command_line • Getting Started with Git and Github - https://anmoldeep1509.medium.com/first-steps-to-git-and-github-fda904959256
  25. Thank you to these folks for making this session possible

    😊 Arpan Adlakhiya Linkedin Pushkar Kukde Linkedin Devanshu Vaidya - Linkedin Anmoldeep Singh Arora Linkedin