======================== Why to learn Linux OS ? ======================== 1) In Real-Time, all devops tools will be installed on linux machines. Ex: jenkins, docker, k8s, jfrog, nexus, sonar, ELK... 2) Database servers will be instaled on Linux machines. 3) Application deployment will happen in linux machine 4) Application log files will be stored in linux machine ========================= What is Operating System ========================= => OS is a software which acts as mediator between users and computers. => Without OS we can't use any computer. => We have several Operating systems in the market Ex: Windows, Unix, Linux, Mac, android, IOS etc.. ============= Windows OS ============= => Developed by Microsoft => Licensed software => Single user based OS => Security is very less (anti virus s/w required) => It is GUI based OS => It is recommended for personal use Ex: watch movies, play games, prepare docs, online classes, coding etc.... =========== Linux OS =========== => Community based OS (free and open source) => Multi User based OS => Security is very high => Linux supports both GUI and CLI => Highly recommended for business systems Ex: DB servers, App servers, DevOps tools... ============== Linux History ============== => Linux OS developed by "linus torvalds" in 1991 (Li)nus Torvalds + Mi(nux) = Linux => He released Linux OS into market with free of cost. => Many companies downloaded linux os source code and modified according to their requriement and released into market with different names those are called as Linux Distributions. Ex : Ubuntu, Red Hat, Cent OS, Kali, Debina, SUSE, FEDORA... Note: We have 200+ linux distributions in the market. ================== Environment Setup ================== 1) Download and install Linux OS in a computer directley 2) Install Linux as Guest OS using Virtual Box. 3) Create Linux VM in cloud (AWS) ============== Assignment =============== 1) Create AWS Free Tier account 2) Create Linux VM in aws cloud and connect with that using SSH Client s/w (git bash / mobaxterm/ putty) Reference Videos : https://www.ashokit.in/yt-content/cloud-tutorials ==================== Linux Architecture ==================== 1) Shell 2) Kernel 3) Hardware components ================ What is shell ? ================ => Shell is a mediator between users and kernel => When we execute linux command then shell will convert that command into kernel understandable format. =================== What is kernel ? =================== => Kernel is mediator between shell and hardware components => Kernel is core component of Linux OS => Kernel is responsible to convert shell given instructions into system hardware components. ================== Linux File System ================== => In linux vm everything will be represented as a file only => Linux machine entryponint is (/) root / (root) - /home - /bin - /etc - /opt - /usr - /temp - /mnt ============================================================ /home : It contains user home directories Note: For every user account, one home directory will be available like below. ec2-user : /home/ec2-user john : /home/john smith : /home/smith ashok : /home/ashok /etc : It contains system related configuration files /opt : It is used to install software packages (ex: java, tomcat, mvn) /usr : It is used to host software applications /var : It is used to host static websites (html pages) ================ Linux Commands ================ whoami : display currently logged in username pwd : print working directory date : display current date cal : display current month calendar cal 2050 : display 2050 year calendar ===================================== Working with Files and Directories ===================================== cd : change directory cd cd .. ls : list files ls ls -l (alphabetical order) ls -lr (reverse of alphabetical order) ls -lt (latest files on top) ls -ltr (old files on top) ls -la (hidden files) ls -l (print dir content) mkdir : To create directory mkdir java mkdir devops aws rmdir : To remove directory (empty directories) rmdir touch : To create empty files touch f1.txt touch f2.txt f3.txt f4.txt rm : To remove files and non-empty directory rm rm -rf cat : create file with data + append data + print file data // create new file with data cat > f1.txt // append data to file cat >> f1.txt // print file data from top to bottom cat f1.txt // print data with line nos cat -n f1.txt tac : print file data from bottom to top cp : copy data from one file to another file cp f1.txt f2.txt Note: To copy data from more than one file we should use cat command cat f1.txt f2.txt > f3.txt mv : rename files and directories + move from one location to another location mv f1.txt ashokit.txt mv f2.txt devops/ wc : word count. It is used to print no.of lines, no.of words and no.of chars available in the file wc f1.txt ============= Text Filters ============= head : To print first 10 lines of the file head f1.txt head -n 30 f1.txt head -n 50 f1.txt tail : To print last 10 lines of the file tail app.log tail -n 50 app.log tail -n 100 app.log tail -f app.log grep : global regular expression print => It is used to search for keywords in the file // print lines which contains Exeception keyword grep 'Exception' app.log // ignore case-sensitive grep -i 'Exception' app.log // print along with line numbers grep -n 'Exception' app.log // print lines which doesn't contains Exception keyword grep -v 'Exception' app.log ============= Text Editors ============= => We will use 'vi' (visual editor) $ vi Note: If file already available it open existing file only, if file not available it will create and open that file. => Visual Editor works in 3 modes 1) Command mode (read file data) 2) Insert Mode (press 'i' in keyword) 3) Esc Mode (press 'esc' in keyboard) => When we are in insert mode we can save and close the file using below options Save changes and close file => press :wq Ignore changes and close file => press :q! ==================== Networking Commands ==================== ifconfig : To get ip address of machine wget : To download files from internet syntax : wget Ex : wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.102/bin/apache-tomcat-9.0.102.zip curl : To send HTTP request to URL syntax : curl Ex : curl https://dummyjson.com/quotes/random ping : To check network connectivity Syntax : ping ping www.google.com ping 192.168.1.101