 Good morning everyone. So, I am Srikanth. Today we are going to see three topics. The first one is basic Linux, the command line tools etcetera. And the second topic is version control and third one is documentation. The second and third are I think the most important for this summer internship. And I assume that the first one which is basic Linux you have some bit of knowledge is it ok. How many of you use Linux day to day means you install Linux on your laptop and fair enough very good. I am really happy and relaxed now. So let us start with the basic Linux. So what we are going to come cover in this one hour so the schedule would be say this is now 940. So by 1040 we will finish basic Linux after I think a tea break is there after we will start for one hour then version control session and after the remaining time would be dedicated to documentation. So this is documentation I prepared for this today's session. So these are the topics which we are going to cover now. First the basic Linux and why Linux. So why there is so much buzz about Linux means what happens suddenly in past 10 years that the whole paradigm is shifting to open source software. So as you most of you are using Linux as operating system. So I think you are already motivated that why we use Linux. So even though if you are not let me brief you for a while. So Linux is used everywhere almost three fourth of the world computers servers sorry not computers in general servers web servers they use Linux operating system. Linux based operating system Linux in general as kernel. So whenever we say Linux it is not Linux. Let me tell you do not pronounce it as Linux because Linux torbles who build this Linux kernel project he does not like it it is actually pronounces Linux. So Linux comes under GNU project. So GNU is a recursive term Gunu not Unix it's a recursive term. So GNU project it is established by Richard Stahlman he is the founder of free software foundation. So the free software foundation the aim of the free software foundation was to build a free operating system free in the sense not price not not the cost free as the freedom. What kind of freedom you get with the proprietary operating system tell me means you use windows also some of you might have used Mac also. So do you get these freedoms which Linux offer the freedom like you can redistribute the source code you can browse the source code you can modify the source code you can do business with the application suppose you own you use open source software you downloaded a version of open source software copy you compiled it and you try to give services with that no issues you can start a business with that if you have a plan for startup go with open source projects you can just take the open source code you can modify you can compile and redistribute you can make money with that. So there are no boundaries at all so means why Stahlman wanted this kind of approach why not the traditional approach in which people make software they just ship the binaries and they earn money because this is all money ecosystem right means if you are writing software you should earn some money. So the ideology of Richard Stahlman was he insisted that there should not be any reinvention of wheel suppose for example if someone would have already released not someone let us say Microsoft if they would have already released the Microsoft word which is the best software of Microsoft so far then the world would have been a better place why there are reasons suppose some developers who want to build some applications over Microsoft word so the Microsoft word is totally controlled by Microsoft cooperation you can't download the source you can't modify the source you can't add plugins to it you can't resale it you can't redistribute it you have to have a particular license from Microsoft in cooperation then only you can use it and that is not the case in India we download a copy we share the copy we go to different websites and download pirated one but that's not happening in the rest of the world and it will not happen in India also in coming time. So if Microsoft would have released the source code of Microsoft word for example people could make better products using that source code it's people who have built over it it's suppose there is an open source equivalent for Microsoft word which is LibreOffice or OpenOffice so they wrote the source code from scratch it's they have to write everything from the beginning which Microsoft already have done in the past if they would have shared the source code people have built even better products using that and Microsoft still would have earned billions using Microsoft word because tell me how many people's actually download the source code and compile Microsoft word there are only five to less than five percent programmer or developers among all the users who use Microsoft word it's not that every user will download the source code and he will modify and he will compile it etc the other benefit with open source software which Richard Stallman coined is it gives you a security suppose you might have heard about Heartbleed bug in the recent time have you heard that SSL certificate bug if it would have been from a proprietary software non open source software that bug would not have been exposed and people would have not been successful in fixing that bug because that is SSL is a such a important piece of code piece of software which is used in day-to-day every project so it carries a huge amount of responsibility so with open source software SSL as an open source library open SSL people have seen it fixed it and next day they release the updated version just think the same scenario with some close source software you couldn't seen the Richard Stallman's third philosophy came from openness of Internet so when in 1994 when the Internet was Internet consortium was set up Microsoft was in hurry of making it again proprietary and everything close and everything Microsoft incorporation and everything Internet Explorer related but people from open source well they opposed they fought against it and that's the reason why you have this beautiful Internet with everything open and you can just right click and view the source of HTML page you can view the source of JavaScript everything otherwise it will be in a different place so the open source matters if some website ask for your username and password and it do some malicious job in the background you can't do anything if the doors are closed if the doors are open you can actually debug the web page and you can see what kind of suppose similar to just think of a link suppose you click on a link if that link inside the in the background that link contains a JavaScript code which actually goes to some other website instead of what the link is shown there then your private data is compromised okay if it is open source you can right click some some developer with view the source he will see okay see this website is doing some bad work is actually running a JavaScript in the background and he is sending my private data to somewhere else so that helps us to be protected so we will start with the Guru project so outlines of Guru project which we have already discussed now the freedom to run the project for any purpose the freedom to study how the program works adapt it for your need okay access the source code in a precondition for this okay the freedom to redistribute copies this is the biggest freedom I would say because industries like Red Hat if you are aware Red Hat is the biggest contributor in Linux kernel okay they make lot of source code patches in Linux kernel they build software they test it they fix the bugs they hire people and they spend lot of their money in their R&D purpose so they redistribute the copies the freedom to improve the program and release your improvements to the public that's it so these four freedoms are very important for any Guru project so the reason Linux is powerful today because of these four ideologies what I believe what industries believe what people believe across the world is if you see a paragraph shift from 2004 even the servers Linux is dominated over the server era that we all know that most of the server run Linux Apache etc. world's 90% of super computer they run Linux undoubtedly many of the space programs they also use open source software they don't admit it openly but there are proofs that NASA event European Space Agency they all use open source software at some flat some way and after the Android project the Linux kernel has become more robust and more approachable to end user since so far if it runs on Linux say sorry so far it runs on servers which actually for normal people doesn't matter much you don't go to server and you don't fix the things in a day-to-day basis but a phone which you use on day-to-day basis which runs a Linux kernel that matters to you and with a prop if you see a shift from Nokia's dominance to complete dissolved with Microsoft the reason it happened because of Android and other open source projects so Nokia didn't see that coming so they didn't follow that okay the open source has prob power to sabotage their empire so they lost the war and because open source project see the projects coming nowadays like Ubuntu phone Ubuntu mobile Ubuntu desktop there are projects like Sailfish OS their projects like Firefox OS their products at Android of course is market even these open source product will grow in coming days so you will see most of if you go to Kickstarter.com almost all the computer projects are open source nature because of see most of the short startups they use open source most of the giants like Google they use open source Google use all their servers with Linux Facebook runs Linux IBM run Linux Samsung TI they all contribute to Linux kernel now so it's the best time to shift to Linux if you haven't made your mind yet so what is Linux kernel so Linux kernel is a program yet another program like you use Microsoft Word you use open office you use Firefox so Linux kernel is also a project similar to that don't confuse so when we say Linux operating system we are actually saying Guru Linux operating system Guru is the bigger tree bigger project and Linux is just part of it you understand Guru is the entire ecosystem Guru is the license Guru is the concept so Guru has various components Guru has file system-based programs like Firefox etc etc Guru has a kernel kernel which is a core program a statically compiled C program which manages system resources like memory CPU scheduling etc so Linux kernel is also a system program which is a C program which is a statically compiled C binary which weighs around 4 to 40 MB size and that's it but the kernel is the main component of any operating system so that's why people used to call it Linux so there are more than thousand known distributions of Linux so what are distributions so distributions are the packages so Linux is the kernel so kernel you can't run kernel on a laptop directly you need programs so what are the programs programs see kernel runs in a privileged mode kernel runs in a root level okay it manages the system processes manages the CPU it manages Ios it manages various things but you don't see those things what you see you see is Firefox you see PDF reader you see different app you see you run videos etc right those are user programs these are those are user program user and programs and those program which run in user space they communicate to kernel you don't communicate to kernel these programs communicate to kernel and the packages of all such programs and some configuration files which some way affect the Linux kernel they are known as distributions so the most popular distribution among Linux is Ubuntu and Fedora Linux Mint Linux Mint is actually fork of Ubuntu so these are very popular operating system and if you haven't switched to anyone you could straight away go to Ubuntu.com and download the latest version of Ubuntu and use it straight away so this is one of the Linux Mint desktop modern desktop so these applications what do you mean by applications so applications could be a simple C program when you compile it you get a binary when you dot slash run that program you get some output say hello world that is an application do you agree yes that is an application we are running this browser Firefox web browser that is an application we are running this xpad notepad this is an application this entire desktop this Ubuntu desktop as a whole is an application the underneath kernel is an application see don't confuse with the different levels of application but they are all applications they are some level of programming done to them and they are some binary they have some libraries but they are applications the Linux kernel is also an application the only difference is Linux kernels runs in the beginning and it has the privileges of system that's it so broadly we can divide applications in two ways one is graphical applications others are command line applications see when you run on a terminal an LS command that is also an application so LS is not a not a magic word which Linux understand and print your all the list of files LS is an application someone wrote the code for LS he compiled it and you run that application that's why similarly the graphical applications include Firefox your other things etc whatever you see visually so broadly we can divide two kind of application one is text based which is command line application the other is x window based which is graphical application so in Linux the graphical environment desktop is known as x window desktop okay same applications used in both for command line tool also that means on terminal also you might have same application or similar application on a graphical window also you might have same application for example I open g edit g edit is a text editor similar to your notepad so these are graphical text editor okay very easy to use we know all the commands we know how to move cursor and we know how to arrange the things so here I will write hello world and now I decide what is the equivalent not equivalent what is a similar application and command line there could be many so I like Vim Vim is a advanced text editor you can view so I start Vim or let me say vi 1.txt that means Vim 1.txt open Vim a file new file 1.txt and I write hello world so this one and this one they both are same but what is the difference both are applications one is running on terminal that is Linux terminal application and other one is Linux graphical application what next yes shell and bash this is very important you should you must understand what is a shell and what is bash so shell is a user interface to access operating system so is it a shell what we are running now is the desktop environment whatever you are seeing is it a shell yes it is also a shell because is the interface to the operating system what is the operating system the Linux kernel is the operating system so this is a graphical shell you can say okay so this is not a command line shell is a graphical shell the command line shell would be if you do control alt f1 on your Linux laptop I won't do it because that will switch to the console which won't be visible on the screen so if you do control alt f1 that will switch to a virtual console not virtual say console so console is a shell console is a command line shell the shell is in user interface for communicating with operating system so we have graphical shells which we are running now and we have command line shells which are when you access the virtual terminals instead of going to virtual terminal we have terminal emulators so you understand the word emulator right which emulates certain programs so if I press control alt f1 so I switch to a terminal which is a black screen you won't see any windows here and you won't get the projection also but this is a terminal emulator so this also gives me a command line interface to my operating system but this is running inside an x-window system this is running inside a graphical shell do you agree so these are emulator program this is not a real program this is an emulator program but you can run all the commands which you would have run in command line shell actual shell actual text based shell so the most popular shell is a generic name so there are many programs which known as shells like there is a born shell there is born again shell so the born again shell that is bash b a s h is the most common and default shell for your Linux operating system so shell if you see is a user interface to access an operating system so generally operating system search use either command line interface which you get when control alt f1 or graphical interface which is entire desktop that's it so we work with the cli based so instead of switching to control alt f1 I will just do with the terminal emulator because that won't be projected on the projector so bash is known by bash is just a shell which is very advanced and it comes pre-installed so what bash can do what any shell can do at least it can interpret what to type what is shell shell is an interpreter first of all whatever text you type it converts your ASCII keystrokes into some meaningful computer computers what I say bits and bytes it is get processed then it reads them it spits out the output so that's a duty of a text based shell which is a terminal now so bash is also as I said text based shell like Unix shell it's supposed file name wild carding which you will see piping command substitution variable control structure condition testing these things we will see an example next to this so more details you can find on find on wiki page okay the most important question is why command line tools how many of you think that it's it's complete wastage of time to learn command line tools actually I used to think that means we have and one guy there and yes it it makes sense man we have developed so many graphical applications then why to bother for command line tools don't we agree means it it makes clear logic that whatever tools we have for LS you just open a file browser it will do LS for you so this is the LS and you can see visually the files right you want to RM RM is removed file just create click it and just delete RM or right click it delete RM select all files delete right click delete so we have lot of flexibility why why to bother about the command line tools in fact most of the servers people don't install x-window system they install only command line version of the operating system what is the reason have you thought about it okay I accept that answer he says it gives direct control to the operating system fine what kind of direct control means but that you can do from here also right you can go and click on the file right click see the properties if you want metadata there should be some strong motivation exactly very nice less amount of resources are required because this graphical system this graphical x-window system these works on client server model so there is a x server running in the background and these are clients these windows whatever you see this file browser this web browser these are windows okay these windows they communicate to local server which is a x server and they get response and etc there are visual libraries there are fonts there are icons which gets loaded whenever you open a x-window system that take resources that take CPU that take RAM fine we have lot of RAM nowadays for GB RAM 8 GB RAM we have quad-core processors in mobile phone itself so why to bother as that makes sense right we have lot of RAM even with this full system running what RAM I am using I can just show you free hyphen m I am using only 1657 out of my 4 GB RAM why to bother I have to 2 GB RAM space left so that answer is correct of course correct but I want a special answer and that is visible here I don't want to show you tell me just think you have seen people using command line tools like if you go to an interview probably they might ask you this question why use command line tools why still in the 21st century people are using command line tools yes be specific what kind of wastage you're talking resources okay so his answer is suppose I am running only 3 and 4 application that's why my RAM is 16 something if I run 10 application my RAM get might get full and if I use command line tool then my RAM still would have lot of space to use that is acceptable but that's not the actual case why we use command line tools those are supporting factors but not the main factor have you heard of bash scripts shell scripts bash scripts okay so what are they and let's come to this discussion see if you are running two window systems X window systems for example in this we are running a firefox can I send the output of this firefox suppose I reload a page I want the output of the reload page to go to my g-edit text editor is it possible you got my point I just do control R that will reload the page and I want the output of the page that will be the same text I want that text in where g-edit I want that text to be automatically come and pasted here is it possible no means you can write a superhuman program and you can do something something and it is possible right it is not impossible in software but why bother but there are applications in command line in which you can directly share data among the applications so suppose I so suppose I load a there are command line web browsers also okay so if I run a command line web browser I can simply redirect the output text to a file or a g-edit that I can do but not in the graphical X window system so what does it mean how does it help this gives you a freedom to communicate among the program without writing any extra code and that's a big deal you understand suppose you have four programs suppose I have a excel sheet or the CSV file in which there are four columns and I want to search the names recant associated with the third column and I want to find out the marks which he got in the second and third column for example and I want to replace it everywhere and I want to add dates whatever whatever etc things without using without opening a X window system but using a command line tools I can simply combine multiple commands and I can simply do it but with graphical window you can't actually you have to manually select each cell manually select the secant manually select his mark then use some tools or some script for excel to convert it etc so that is the first and important thing for command line of course the RAM and CPU the resources what he said application can be called inside a cell script efficiently and that's the main usp of bash or shell programs you can't call Firefox to open in fact the modern-day Firefox and Google Chrome they open in X window system but they provide the command line interface also so you can just use fire Google Chrome hyphen hyphen window one hyphen hyphen URL name so it will open that URL in window one but think of a scenario in which you can't program it in a shell script you can't say in a shell script that ok open Google Chrome whatever content the Google Chrome contains just pipe it to some Firefox then open then find a word from that Firefox text search some particular text and open a another window with YouTube and search for the keyword and get me the most viewed video for example this is my project this is my program which my boss asked me to do that ok I give you 10 websites 10 web pages you need to find this keyword from those 10 web pages sort them according to most likelihood search a YouTube video search find out the tags find out most viewed videos and give me the result what you will do you will go and visit each web link every time 10 pages manually control f find the search again you search in another window and find the YouTube top results is that what you do you can do but it's not a smart way to do for 10 10 links it's ok for thousand links what you will do you can't you simply can't you say I quit so with bash you can do that simply what you can do you can open a links links is a command line web tool web browser what you can do links spit the entire page search the page there is a other command for searching the page grip is the command grip the keyword again open a YouTube window in Firefox that is that will do even you can do a lot of things I'm just even an example to motivate you so that is the beauty of command line tools so it gives you immense power with scripting so most of the server admins web admins system admins they are experts in bash shell scripting so we'll concentrate on text based applications so as you are already motivated so I won't waste much of your time so we'll start with first command is man man is not human or man is not opposite of woman it's not that man is a manual ok man means man pages manual pages man page of what some command so the most frequent command which we use is LS for example LS means list files so this gives you the list of all so this is the man page of LS manual page so this give you detailed description of what all command line flags it has and what is the use of those flags it's a big document and if you have patience you can go through the easier way to access a help is LS hyphen hyphen help so this will give you a stripped down version of man page which will contain what you require so if you can see this has direct flags which gives you the entire result that hyphen R is reverse hyphen capital R is recursive recursive is important you will see and this gives you a stripped down version as I said so these are the two main mainly used help commands and the self tutor help command is apropos ok so we are here now apropos copy so what is apropos copy what is apropos you know what is apropos you don't know very good I also don't know what I will do I will do man apropos search the manual pages names and descriptions ok simple suppose on a fine day you forgot which command do the listing of files someone asked you and you forgot and even you can't act that you forgot what you will do you will silently do man apropos and find out but will apropos tell you which command man apropos will tell you which command to use to list files no see the list files ls start with l so you actually you correlate l with list right so it's easy to remember some way but there are such commands which doesn't start with the same character so when you go deeper you will find some commands like say SSH ok so what does SSH do I forgot I forgot even you forgot what for SSH is used so what you can do for simple let's see for I forgot how to list files so what I will do list files apropos list files it doesn't guarantee hundred percent correct result so in this case it failed if you see I forgot how to list files so I asked apropos apropos is a command line tool which search all the man pages and give you the result so my search term was list files so I know ls is the list file but I don't see ls here what I see I see gvfs hyphen ls but no ls word ls etc let me search again with only list now I get a huge list alphabetically ordered and now I see my ls smart huh no so apropos can help you it's not that it guarantees that you will find that command but if you are desperate you forgot and we are very desperate okay I want to know that what is that come you will go through all those commands and you find out which command was your command so use a better search term and you can of course guarantee a better result so these are the three help tools which comes in with your command line tool so other tools are so now we will see these tools so as you know cd is change directory no need to explain pwpw is present working directory ls is list files mkdir is touch is good touch is create new file but what is different between touch and other file file creating programs it creates a 0 kb file so other file file suppose you open and g edit and you close it what will happen it will g edit will write some headers in that file so that size of the file won't be 0 kb but when you create with touch command it is actually 0 kb file rm is remove files mv is move or rename so I am not repeating those and you can if you want those things are listed here with example you can easily follow through so we will come to the next one which is read search and find so you are aware of these commands as well cat less head tail it sounds like a story cat less head tail okay this include a cat itself find grep pipe most of the terms are means human readable and something you can correlate with so you know what is cat cat is on catinating files it will just print the content of file on the standard output what is standard output whatever comes on the screen the output of a command is standard output or standard error it's not that whatever you see on the screen it's output only it could be error output also so there are three different streams in Linux one is std out which is standard output std error which is standard error the issue with bash is it shows not issue what we say you want to see the errors right suppose you compile the C program and you don't see the errors on terminal you are seeing it is getting redirected somewhere what is the use standard error also comes on the standard out which is this screen itself and the other is standard in standard in is what user types or what user redirects from some other file or some other command it's standard input so cat if I do this it says cat etc lsb release cat etc bash rc it will open both the files next to each other and it will exit the terminal see it give me a command prompt back so like that so it doesn't wait or doesn't give you any other option with that of course you can do you can cat and you can redirect to a file it will create a file but I won't recommend you to create files using cat less so what is less less is also a text viewing program which allows you to browse the text or navigate among the text file efficiently for example I open less slash etc slash bash dot bash rc this is the system wide bash configuration file so we are running bash right so etc folder contains the configuration files and system files for all the users on the system so this is my personal laptop so I am the only user so if it would have been a classroom system there might be 10 users so all 10 users default bash configuration configuration means how this terminal will look what you want to print here how many lines you want what is the line spacing you want etc etc ok so let's if I do it will open the file in some viewable form and it doesn't leave the prompt like cat so what you can do you can just hit enter and you can just view what other things you can do you can just simply do slash and you can search for a term say fancy directly give you the fancy suppose you want to find how many fancy terms are there in this file you press n none form so only one fancy term suppose let me find if there are so many so I do n n n so it just browse through all the if command so this is the usefulness of less command so to quit less just type q ok next is head head again let's go with the same file as the name suggests head means it will print the top of the file what is the use of it I have less I can open with Vim also I can open with cat also what is the use of head can anyone tell me just think it's a very obvious answer yes why first 10 lines I can view the first 10 lines with less also yes but why means from less I can see all the lines I can browse through the lines right see there might be how many of you are from ok all from engineering background there could be files of size with 10 MB 20 MB text files if you go to biotechnology department and you see some genetic code they they compile to a text file ok it contains some protein sequences so those files they become 10 MB 20 MB 40 MB text files plain text files so if you try to open those text files in Vim or in less it will take some amount of RAM time also and suppose you want to you have an requirement you have 10,000 of those files and you have to just change the date in the first line of all those files what you will do normally without bash it's a hell of a job you will go to every file and just change the date of date in the first line and you will 10,000 means you just understand imagine with bash what you can do you can just use head command because head doesn't load entire file in the buffer head just load whatever you specify in the command line plan so if I specify head hyphen n1 means it will just load first line that might be some 0.1 kb for 10,000 files it will load some 10 MB in the RAM that's it very fast one second done now I will redirect that output all the things I will put it in a fall loop for all the files what you do I will use some commands like said ok said is a text replacement command I will say said find the date command in the first line of whatever coming through the fall loop and replace with this present date said will do for me and it will end the loop two lines done how much time it will take hardly one second one second to change 10,000 page 10,000 files I can show you those examples if time permits at the end but that efficient bash is and that efficient head command is similarly a tail command otherwise you want to change in the last line same it's not that it's only used for scalable purpose for 10,000 files or 20,000 files it can be used for day to day use also means suppose you have a big file you don't want to open entirely just do head to open first few lines that's it find so find is a very important tool and I am sure most of you have not used find efficiently how many of you use find command one so I will just copy paste the command to save time what it says see you can do of course man find or find half and half and help anytime I am telling find command that go to my download directory what does this tilde means tilde means my home directory in Linux operating system I must have told you this in the beginning PWD is my present working directory which is home suppose I go to downloads now my PWD is downloads for type CD I am already I am redirected to my home home home why because the CD command is mapped to move to this directory without any arguments suppose there is a if you type CD space hyphen what it will do it will take you to the previous directory downloads directory so if I do CD tilde what does it mean it will again move me to my home directory so tilde means it's a shortcut for home directory suppose you are writing a program and you are sending that program to your client and you don't know clients username you can't call him and ask him no hey tell me your username I am writing a shell script doesn't seems nice what you will do you will just type tilde in the program so wherever tilde comes your bash all expands it to the user's home who where the user is wherever he is nice fine control D to close that window so I am saying go to my home and downloads hyphen I name hi I means ignore case name means the next argument what are coming is the actual name which I want to find it says slash star dot pdf hyphen size plus 4m as this is very easy to understand hyphen size plus 4m means a file which is a 4m view or more and star dot pdf means star is a wild card okay bash understand wild card wild card we have seen in the beginning I told you in the bash property says it can expand wild cards etc the star means all the files one more thing I forgot in the beginning in linux or guno linux systems everything is a file now you'll see how everything could be a file is monitored is a file yes is keyboard is a file yes is your serial port you as a port is a file yes and there is a term in linux environment if it is not a file it's a process that's it that's simple to understand if anything not in the system if anything in the system is not a file is definitely a process nothing else because everything is a file fine so this star is a wild card and it's a special character and we need to add this slash so to escape the special character so this is important so wherever you see special character you have to add slash to not to confuse bash that okay this star means something else star means star otherwise bash will think this star means star itself try to find a file name with star.pdf but we don't want star.pdf right you want all files which end with .pdf for this find command find is not intelligent enough to escape the star by itself so you need to add this slash so when I run this command what I find so I cancel the command because I got what I needed so it spits out whatever there in my download directory and whatever file pdf file with 4mb or above you want to verify how it is 4mb or above maybe this command is not working properly I want to find du is disk uses and hyphen h is print the values in human readable form otherwise by default we print in bytes we have to calculate okay this this this okay 4kb not smart so if you do like this I just copy this and paste it I am saying that du is the disk uses find the size of this page pdf it is how much 6.5mb so it is above 4mb right that means my find command can sort everything which is plus 4mb or above just think this thing with your graphical file browser can you specify here that out of all 10,000 files give me files which are pdf and give me files which are 4mb or above you can't actually maybe there are some regular expression you can use but no with regular expression you can't specify size what most you can do is you can sort them according to size you can sort according to type and you can visually then select them correct one more reason why bash is good so find is done so next is grep and py so how many of you used grep wow so grep is a text search tool so it can browse through with text content and it can find the keywords whatever you give to grep command grep can do a lot more it can it can narrow down your search with regular expression you understand regular expressions right don't worry regular expression are not a big deal you can just go through some youtube video and you can easily learn regular expression it's it's just a pattern means you can just mention a pattern and you can just narrow down your search with a pattern suppose my pattern involves file name space file name space something special character dot pdf so regular find can't find it so you need a regular expression to catch the empty spaces so that you can tell find that okay I want this so let's find grep in this page if you already know this I don't think make some sense so grep by default prints the line which matches the text it doesn't print everything and just highlight nobody nobody so what I wanted I wanted nobody in ETC password so ETC is a directory I told you it contains system files so password doesn't mean that it stores your password there no so only one line contain nobody fine so grep can do lot more than that suppose I want four lines after nobody wherever you find nobody just print two more lines after that what I will do hyphen a to a means print after two lines whatever find you do similarly you can do B means before two lines and just see it it it prints on the standard output and exits what does it mean it means that you can script the grep command using a bash because see if it doesn't leave the terminal you can't script it right just imagine a program like less less you can't use it in your script because less by default doesn't give you the terminal prompt unless you press Q you can't come out of the less application but this grep application comes out of the search fine what next to find recursively this is very important this is really very important and I bet most of you going to appreciate this suppose you are using you are developing an Android app and you forgot where is that function in which file is that function suppose you downloaded someone else code ok and you want to know where is the Wi-Fi enable command for example what you will do you will open it in eclipse you will do find and you will see all the files in eclipse also you won't get accurate means easy to browse data suppose you have again I give you 10 files 10 projects and among all 10 projects you don't remember which project is the Wi-Fi enable command is what you will do you will enable open all those projects in eclipse and find out no you can simply do grep-r how grep-r will recursively find your search term in the entire directory suppose your entire directory name is project inside project you have 10 more directories and inside those 10 more directories there are 100 more directories and somewhere in those hundred of more directories there is a term known as in a file known as Wi-Fi enable and that term and that file is important to you you can't open eclipse and search those things every time right grep-r suppose my term is say Srikant and I don't know where Srikant appears in ETC so ETC is a big directory I will do like this so ETC is a system file so it says permission denied you understand I am a Srikant user I am not a root user so it says permission denied but if you see grep has found few entries which it has marked with red 1 2 3 4 5 6 many entries in fact and it has Srikant I know which file contains Srikant how it shows ETC group dot org there is a Srikant which line 27 is that line or character number ETC group there is Srikant so you can directly open that file and you can find out so this is very very useful tool I use it on day to day basis and there is no replacement for this command you can okay there is a instead of writing grep-r some in Ubuntu they have already mapped grep to r grep so whenever you type r grep it redirects to grep-r okay if I do r grep same thing it will print the same result what next pipe so pipe is one of the most important things the pipe means you can pipe the output of one command to input of other command as I told you in the beginning that the beauty of command line tools is you can add different applications with each other without writing extra code okay what is the big deal let us see simple example is suppose ls-l prints me all these okay I do not want all of these I want to know control l to clear the screen grep so this thing is pipe which is just next to your right side above the shift button grep index so what I am doing ls is a different command different application grep is a different application I am sending the output of ls-l to home grep and grep as a shell program it knows that whatever comes from standard input or through a pipe I can accept it okay enter so it prints the index.html so these are very simple example you can do it for many complex ones also because you can simply do grep in that index.html file and it will print the same result fine let's move to next segment who am I will print you the current user w will print too narrow okay no problem w will print you the present logged in man w show who is logged in three can't is logged in so because I resize the window so it can't fit the output of w inside this window ch more and ch own this is very important ls-l1.txt it says this first field is to tell whether it's a file or directory if nothing is written that means it's a file if d is written it's a directory this triplet this triplet and this triplet they are they carry different users and different groups the first one is user that is Srikanth the second triplet is group which is also Srikanth by default any file you create you are in the same group of that owner and the third triplet sorry is others others means anyone anyone in the world who has the access to the system so by default others have read permission group has read write permission and user has read write permission so suppose you have an executable file can you execute right away with these permissions no you have to set executable bit how to set suppose I want to set ch mode for user suppose I want to set for user control l clear screen u plus x who is the user Srikanth is the user for which file index dot html done ls-l index dot html so now user has permission to execute to remove the permission execute permission what I will do u minus x so this can be done with a numbers also you can specify this this entire triplets they represent 7 okay in binary so 1 1 1 is rwx now it is rwx it is 7 this is rw 0 that means 110 2 bits are high and 1 bit is nothing so 110 is what 6 so 76 and this is 100 which is 4 so 764 so in binary you can say 764 if I want to change the permission ch mode 764 of course it will do the same let me change it let me do 75 765 what does it mean exactly for others it should set the execute bit let's see see for others we have set the execute bit fine okay ch own ch own is owning the files by default I own the file now I want no let me I am leaving the company I am leaving my job I want to transfer my ownership to some other new user who ever comes what I will do I know there is a user akash created in my machine so I will do ch own index akash dot akash means user is akash group is also akash to which file index dot htmi I can't do it because you need root permission to do that only administrator can change the ownership but changing the permission of a file of own file you can do but you can't transfer your ownership to someone else arbitrary without asking administrator so here comes our first important administrative command is sudo sudo means run this command this particular command with root privileges without actually getting into root what does it mean you can get into root you know how if I do su in switch user root I can enter the password I can get to root so but I don't want to do to switch to root and then change the permission then come back I don't want to do and root is a system admins sold user means root user is different and each individual user could also be given root privileges with some limitations so what I will do is sudo same command sudo I give the password done so now if I see so now the file has permission sorry ownership akash and akash it's no longer for Shrikant but as we have given permission to others because Shrikant can read the file and Shrikant can execute the file because Shrikant can't write the file you want to verify let me verify g edit index dot html who am I I am still Shrikant I am not akash so g edit index dot html can I write it can I save it see it says read only you can't you can execute it but read it you can't write to it so let come to the network and installations so network commands are very important you know so ping is the most useful network command you use ping to find out whether your network is up or down okay the ping hyphen c means just ping for five bytes and just quit the program otherwise ping will continue the operation so 127 dot 0 dot 0 dot 1 is your local host so it will always respond right so let's change it I think ping I don't think we need to run it is pinging this IP and it will exit after five yes next is IF config this will print what networks you are using and what all network interfaces you have is also helpful for debugging network errors if any next is W get as the name suggests you can get a file from internet or local file or anything local file means local network file so why W get you can easily download from Firefox write it downloads with W get you have for a large files you can resume the downloads in between suppose you are downloading a ISO file open to ISO file of 700 800 MB and in between your internet connection lost what will happen your ISO is got corrupted and you have to redo the entire download but with W get you can simply add a flag W get hyphen c it will continue from wherever you lost the data and file name so beyond this you can do lot more things W get is very famous for downloading or cloning the entire websites you understand that so if you want to download all the images and files from a website you can use W get hyphen a hyphen b some some flags are there give the URL of that website and may be in hour or two you can download and clone the entire website is it legal no see the images and videos could be copyright protected the HTML files and JS file CSS file they are open source you can download them but the images could be some copyright protected images but with this command even the PDFs if they are not smartly monitored by web admin or webmaster you can simply download or clone the entire website some thousand PDFs etc and you can do whatever you want SSH is again a very important command and how many of you use SSH before very good I'm surprised and happy so SSH is secure shell so we already understand what is shell right what is shell shell is a user interface to operating system and which shell we are talking by default our own desktop shell if you are working with your laptop this is your shell if you are working with my desktop this is my shell suppose I want to log into your laptop how do I do I can use SSH secure shell so I can log into some other shell also and this is very important suppose most of the servers whatever we have suppose I work for this Fossi project Fossi.in our server is located in US we don't go to US and do whatever you want or we don't tell US people that do this is this this is we want what we do we SSH from here to our servers we change make the changes and then we exit so we are logging to our differential so SSH hyphen y means you can export the windows also graphical windows and suppose Shrikan that the rate 10.101.11.108 this is one of my lab machine and can I connect yes see this is on different machine how do you know it's a different machine it's running Ubuntu 12.04.4 and which version I am running you can just see cat slash etc slash lsb release I am running 14.4 so this is a different machine what is the IP IP is 10.101.11.10 so I mean different machine now so what else I can do Shrikan let that Leo that machine I named as Leo so I can change I can become root I can do everything whatever I am doing on my machine because I have access now so this comes handy suppose you are in hostel and at the night something you have to do with your lab machine you can simply SSH to your lab you can download your files or you can edit some files and that makes life simpler to copy files using secure from remote machines or copy from remote machine to your machine we use scp okay the syntax for scp is given here scp-r-r means recursively so recursively get some file which file etc udev from which shell from this shell root at the local host slash temp so root at the local host means this machine only so if I run this command this will ask for my root password and from slash temp directory it will copy this file but I don't want this I want from some other machine you can just follow the syntax if you get lost somewhere just do man scp scp-r-r help that's it now come to last section these are small small utilities which are very very important say a file what is a file command for the past one and half of you were seeing LS LS etc etc LS is an application it's a command line application how to know file LS it says 64-bit executable version this this is dynamically linked it's not statically linked for GNU this version GNU Linux this version build is this SA1 means shach xm is this one and whatever information so this proves that it's a binary file it's not a text file it's not a cell script which is doing the job okay the file is very useful command you can just tell file index dot html it says html document asky characters asky text what else file slash dev slash hda1 hda1 is my hard disk partition it's a block device correct so each type of file has an attribute and with the file command you can read that attribute and tell that what kind of file it is it's very handy df-h h is human readable means it will print all your partitions so I have this hda1 partition which is 92 GB this much used this much free I have these many virtual file systems I have another physical partition slash dev slash hda5 which is of 358 GB and which is mounted in slash stacon slash tough okay so df will print your file system table so what all file system you have it will show similarly the mount command will print what all mounted what do we know mount first of all when you insert a pen drive in your laptop it's get to somewhere here slash media slash secant and somewhere here it will appear okay suppose you have pen drive name name as transient it will appear here how automatically because your Linux kernel detects your USB hard drive and there are you dev you dev programs which will mount the device mount the device means put the device node your pen drive is something like this HDB your hard disk was hda you remember your pen drive will be next one next character HDB and HDB is a block is a file device you can't just read write to it okay you need to put this HDB somewhere inside a file system so to view and copy the files so this HDB will get automatically mounted with to wear somewhere here Ls slash medias secant somewhere here so that's what mount means you can unmount also you can even connect your pen drive and you can unmount the pen drive without even removing it export export is also very important on suppose you have some local binders with you what do you mean by local binders suppose you just rotate bash script let me give you a small example of bash script also so one dot is my simple bash script skrimetry hash sorry hash skrimetry bin bash eco hello shrieker okay so this I would open a vi text based editor the first line tells that to use which bash there could be multiple versions of shells as I told you shell is a universal concept there are multiple shells like bond shell C shell K shell bash so we are telling the script to we are telling actually terminal to use which bash or which shell so I am telling it to use this shell and where it is it is in this path slash bin bars suppose for some reason I want to use another shell so I know there is another shell also installed in my system which is SH so I have to write it here like this but in the most of the cases if you do not write this first command the default shell is bash now I run this as bash one dot SH hello shrieker the prints eco means the sprint whatever there okay so but this one dot SH if I type just like this it says doesn't found why what because it is not in the system path because my terminal my bash doesn't know that where is the binary where is the executable file and where are all the executable files you can just echo a dollar path dollar path is a shell variable built in shell variable just that holds all the system paths so it prints all my system paths so the shell try to look for one dot SH in these many locations but it couldn't find so it tried to see it in user lib light dm user local S bin everywhere it tried failed what I will do I can simply modify modify my path variable bash path variable to look for my binary also my path also so now I know this one dot SH is in my home directory but I don't want to make my home directory to an executable path because whatever directories I have it all become an executable it all becomes in a system path which is bad so so this command export export command is very handy so this will export the path of this slash temp slash bin directory temporary for this session if you want it permanently you have to include this command where in your bash RC and where is your bash RC Vim dot bash RC this is my every user has own bash RC and for all the users there is an bash RC which is in ETC bash dot bash RC so for my local directories I can open this bash RC I can go to end I can add this export path path and if I exit and if I okay let me exit source source means reload the configuration file which configuration file bash RC to this presentation enter loaded now if I move 1 dot SH to where slash temp slash bin the directory doesn't exist what I will do mkdir slash what temp slash bin now what I will do move 1 dot SH to slash temp slash bin I know this is the path which I just added to my bash RC this should be my system path if I type 1 dot SH now it should appear let me equal dollar path now yeah temp dot bin is there and why it is not loading for some reason slash temp bin 1 dot SH okay it's not been executable you have to make the file executable is it an executable file no so how to make it executable ch mode plus x plus x means by default it will take the user you can you can write this also u plus x which file slash temp bin 1 dot SH now if you do ls-ifnl it turns green also and it shows it's executable now if you type 1 dot SH it shows tap completion if you write 1 or 2 character and hit tap twice it will show all the possible commands available with that 1 dot SH that's it so this has become the system path now fine so this concludes our oh my god I took 1 hour 20 minutes okay so next topic is version control you will start after 5 minutes