 Good afternoon everyone. My name is Srikanth. I work in Fossey team in IIT Bombay. It is a session about basic Linux commands, advanced Linux commands and few simple demonstrations about Android operating system and Android ADT and SDK. Why is there so much buzz about Linux? Why everyone is talking about Linux nowadays? Why not any other operating system? It's open source. Very good. Anything else? It can be more secure and it can be ported to any hardware platform. Any means not any means most of the hardware platforms which support operating system, Linux can be ported there. And what makes it Linux so special? Why not other operating systems? Why not report proprietary operating systems such as Windows or Mac on different platforms? Because they are closed source, you don't have access to the source code so that you can modify and you can port to your own hardware. And Linux intern provides you the flexibility to use your hardware as you wish, means you can download the source, you can customize the Linux source code and you can run it on your hardware. So there is a huge demand of Linux professionals in country around the world. Why because most of the countries they work on small scale devices, mobile phones, tablets. You name it. Linux is everywhere. Maybe it's there in the camera, it's there in the projector, it's there in my laptop, it's there in router, it's there in Wi-Fi. Everywhere Linux is there. Probably you don't know. Because you don't see a console there, you don't see an output there, you don't have a screen to watch. That doesn't mean that Linux is not running behind. Webcam. Most of the webcams they have Linux kernel running in backend. So there is a huge demand of Linux professionals all over the world. So what does those professionals do? Do they watch movies or play songs and they get jobs? No. They work on terminal, they run program, they execute program, they write source code, they customize Linux kernel, they write Linux drivers, source code, they modify drivers, they add patches. These are the core functionalities of one developer who is willing to work on Linux platform. As I said, beyond browsing files or watching movies, what else we can do in Linux platform? For that, let me give you an example. First of all, why we need a terminal? Why we need a Linux terminal? Let me specify about it. Because we have a nice file browser, see, this is a file browser. I can browse my files and folders, etc., etc. Why we need a terminal to access all these? I can access all these through my terminal also. But why? Because I can easily access Docs PDF. I can open Docs PDF. If you want to write a source code, I can open a source code in some editor. I can edit it. I can compile it. What is so special about terminal? What is special about this file manager? This is known as file manager. I am using Ubuntu desktop. And this is the LXDE version, light X environment. So my question is, what we can do with this file browser? I can list all the files in detail list view. I can see the descriptions. I can see the size. I can see the modified date, etc., etc. So what? Means, suppose, let me tell you the drawbacks of graphical window so that I can motivate you to use terminal. Before that, see, I will explain each and every command which I am typing now. But take is granted that these are the commands which are required in today's workshop. So these are today's folder. In Windows environment, we say folder, in Linux, we say directory. In Linux, every file, each file and each directory or any device, anything is treated as file. Clear? So when I say directory, internally Linux treated as file only. So ls command will list all the files in present working directory. So when I hit ls, it shows nothing. That means there are no files in this directory. Now what I will do? I will create some files. So with touch command, I can create empty files. I can create files using gedit also, gedit file name. I can save it. That will also create file. I can open a vi editor or emacs editor. By that also, I can create a file. But that file will not contain a, it will contain some size, default size. But with touch command, whatever file you create, the size of that file is 0 bytes. So this is for just demonstration we are doing this. Otherwise, I would have opened this with one of my favorite editor. I will show you how to work with editors. So let me create some files. So touch 1, say 1 dot txt, touch 1 dot mp3, enter. Can I play this mp3 file? Of course not. So ls-l will show the size of this file. You can see they both are 0. And anyway, if size would have been 10 mb also, by touch command if I create an dot mp3 file, that does not mean that it contains mp3 decoded file system. So I have two files in my today directory. Now same I can view from here also because my file manager is dumb. So it recognizes that dot mp3 means there is a song to play. And if I click this, it will open the default media player. But that is not true. So what is my point is, there are two files I can easily copy. I can sort. I know there are only two files. I know the properties one is 1 dot mp3 and there is 1 dot txt. So with control l, I can clear the screen or I can type c-l-e-a-r. So c-l-e-r clears the screen. It does not mean that my files are gone. My files are still there. You can view them as ls 1 dot mp3 and 1 dot txt. Now I will show you the use of terminal, how it is better than your file browser, graphical file browser. For that, let me create some 100 files, say 1, 200, how this works, just pay attention now. I will explain, say txt. For that, let me remove those 1 dot mp3 and 2 dot mp3. When I type 1 and dot and hit tab, it gives me the options available with my command. So I see there are two options that is mp3 and txt. What I can do, I can type indisval mp3 and txt that will remove both the files or what I can do is I can do 1 dot star. Star means all the files possible with 1 dot, remove all of them. It works. If I do ls, no files, control l and I have cleared the screen. Now I want to do some computing thing. So I want files from, say 1 dot 200, say mp3. So what we expect this command will give output. Of course, it is too early to ask you to expect something. It will create 100 files from 100 files as 1 dot mp3, 2 dot mp3 till 100 dot mp3. They all are useless, but just for demonstration purpose, I want to show you something. Now I will do what, touch 1 dot, 1 200 dot txt. So this will create 100 dot txt files. Why I am doing this, I will explain you. So this is my file browser. Now you can see how many files are there, 200, 100 mp3 files and 100 txt files. Now I say I am a project manager, I give a task, a simple task that I want file number, I want all mp3 files. Just copy all those mp3 files to my server. You have to write an app. Suppose in Android only, I give a task, let's see, this is a very simple task. What you have to do? There is an application which creates some random amount of files and each automatically generated file will have a proper syntax. It will not like that, it will create abc.c, then 123.txt, no. Automatically generated files, they have a pattern. So as a developer, I gave you a task that write an Android app which should copy all the txt files only from some directory to somewhere else. What you can do? You can either go open the Android file browser or Linux file browser, same as and you can copy each mp3 file or txt files manually and you can, yeah, that is an intelligent answer. I can sort it, detailed list view and let me sort it by description, correct. So now what I can do is I can press shift key and I can take up to, sorry, it started playing all 100, no, thank God. Anyway so I can, what I can do is I can select all my 100 mp3 files, right click, copy and I can paste it somewhere else, so let me change the view of this. So I can paste all my 100 files here, let me paste it, okay, so my job is done. Now you can ask me that, okay, this is so simple, I can copy 100 mp3 file by sorting them and I can easily copy them somewhere else, why I need a terminal to do that same job. Now how you do with terminal? You will copy star dot mp3 that will select all mp3 files and I will give the path of where to copy. So this will copy all my mp3 files to slash home slash Srikant, this is my home directory which you have seen just now. So in Linux when we say home, you can see the path slash home slash Srikant, okay. Already the files are there, if I do like this, it would not ask me, it will just overwrite, you will see this later. This is danger actually, you do not want like this, it should prompt me that see you have already these files, you should what you want to do, you want to overwrite these files or not, it did not ask, okay. So I have all my mp3 files here, so what I will do is, I will create few more files, such 1, 2, say 100 dot a2c dot txt. So what this command will create? This command will create how many files, 300 files, okay. Now I ask you to go to file browser, where is my today, yeah. Now I ask you to copy all mp3 files, it is easy to do, what you will do? You will again go to detail dist view, you will sort it according to description, select it, sorry if you start playing, select it, right click copy, okay, let us do it. Suppose I have these many files, suppose these are 100 files, I just copy them and I will paste back to my home destination. That is as easy as previous command, no, what I want is, I want all dot c dot txt files, I want files starting with any name, middle name should be c and last name should be txt. Now there is a problem, you see the problem because when you sort it, you cannot sort it according to middle name, can you? Probably not, I do not know how to. So now I want you to sort all the a, b, c, d, sorry, all the files which have middle name c, clear, try doing using the file browser. You can do, it will take some time. Suppose they are 300 files, what about 10,000 files, it is possible, in automated generated data there are some 1000s and 1000s of files, you cannot manually copy each of them. So let me press control l to clear, so can you, can anyone help me with the command? What command should I type? You list only files which have, yes, which have c in the middle, star dot c dot again star, sorry, dot star. So irrespective of the output format after, it may be mp3, it may be txt, I do not know, I do not remember, I do not care also. So what it will list? It will list all the files with middle name c, do it using file browser, you cannot. Now what I can do? I use copy command and I will give the path of home directory and will copy everything to home directory. Before that, let me remove all the files from home directory slash home star dot mp3, rm command is remove command. So this will remove all the mp3 files from my home directory, just to verify. So I do not have any mp3 files here. Now what I will do is, I will copy, that is what my boss told me, to copy all the dot c files which have middle name dot c and copy them to some server. So for time being it is recon. So with cd command cd dot dot, I am going to the previous directory. So as you can see the path, this tilde means home. What is home slash home slash, srikant is path for home, is not it? So tilde slash today, the directory is, if I make it icon view, you can see the directory is in home today. So you can see I have copied all the files which have middle name c. Now can you tell me why terminal is important? You can automate the jobs. See this is only one simple example, no one in anywhere will ask you to copy dot c files into some directory. There are many, many complex jobs which require some amount of programming. So in programming you cannot program the cursor to click on the file browser, open the file browser, go to that file, that file, that file, you cannot program your cursor to click every file for you. Can you, if you can, then your job is solved. I do not know how to program like that. If you can, it is very good actually, but what I know is I can write a simple shell script or a shell script we will see later, simple shell script to copy all the files which are needed by me, copying some directory or to send to server or plot a graph from that file, whatever. So I can automate the task, clear? So coming back to slides, so to just show you the, just to motivate you people that terminals are not, dumb terminals, they are not old VT100 type of terminals, I prepared the slides on terminal itself, okay. So whatever you see, it is on terminal, if I do Q, it just quits and this is TPP, terminal power point kind of, I do not know what is the extension. So what we will cover today, we will see some basic Linux commands, advanced commands, we will see user group and permission in Linux, Android, users, okay, I will come to that. Comparison between Linux and Android, Android SDK, NDK, not Eclipse because Eclipse will take lot of time. Introduction, no demo in this, emulator of Android, demo. So you already seen LS command, you already seen CD command, you have seen CP also, CP means copy. See whatever they are in square brackets, they are optional parameters, anywhere in Linux environment, whatever you write in square brackets, they mean those are optional, you may or may not use them, okay. So LS by default, prints files present in present working directory, what is present working directory, how do you know, PW, sorry, PWD, so my present working directory is HomesRecon. So by default, without any arguments, LS prints the output, now I have few flags for it, arguments, hyphen A, what is hyphen A will do, very good. So LS hyphen A will show all the hidden files also, in Linux environment, Unix environment, any file name or directory name starting with dot is a hidden file or directory, okay, let me clear it again. What is H, excellent, H means human readable format. So suppose I do LS hyphen L, L means list, detailed list view, first LS hyphen L, it will list all the files, let me remove the dot mp3 files, dot txt I think, yeah. So LS hyphen LH, suppose AD, hit tab to complete it, what is shows, 13 m means 13 megabytes, suppose I do not use H, of course I get a value, but I am not smart enough to decode it, will take some time, okay. So to make it human readable, if it is in GB, the value here will be shown in G, if it is in KB, it will be shown in K, that is human readable. What does R means, capital R, recursively, anywhere in Linux environment, unless specified otherwise, R means show recursively, copy recursively, whatever, recursively, means go inside the directory, inside the directory and copy everything, move everything like that. CD you already know, what is CD, change directory, change to some certain path, what is copy, cp, cp means copy, hyphen I means, very good, hyphen I means interactive. So we have seen that previously when I did copy star dot mp3 to home directory, it anonymously copied everything and removed my previous mp3 files, do you want that, no, maybe my previous mp3 files were more relevant than my present mp3 files, who knows. So in that case what I will do, let me go to the directory, what is the directory CD today, so I have many mp3 files here. So I want to copy star dot c dot star to say dot dot slash, what this will do, what is the previous directory here, exactly home directory, instead of giving the complete path, I can either give dot dot slash or I can give tilde. So bash will understand, bash means this terminal prompt, will understand that I am talking about the default home path, what is default home path, I am the user, default home path for me is slash home slash recap. Now I want to use the flag, now this command will not ask me anything, if at all the files are there, actually I removed those files, let me copy it again, copy back, so I can see ls tilde, it has all mp3 files something goes wrong, sorry. So now I want to use copy-i star dot c dot star to again tilde, now it asked me, overwrite this, if I type s, it will overwrite, otherwise what else p, what is p means, I do not know, if you find difficulty to remember anything, yeah, any command if you confuse that what flag to use, I do not understand the flag, you have any confusion regarding flag, there are three things you can do, first that command hyphen hyphen help, so copy hyphen hyphen help will list all the help information, so I will look for p here, so p will be preserve permission, it says preserve the specify attributes, what are attributes we will see later, so this is the one way to see, man cp will give me almost same information, but it is a manual entry, so it will have more information about the copy command or I can do info also probably, info cp. See, it is not mandatory that info and man will be available for all the commands, but most of the Linux commands, they will have man, at least man, otherwise help will be always there, any command space hyphen hyphen help will print all the help information, so hyphen p will preserve the permission, we will see later when we come to permissions hyphen are with recursively copy, so what I will do is I will make a directory, mkdir will create a directory, say hello, go to, sorry, go to hello directory, now create some random amount of files, 1 dot dot, say 22 dot secant, it will create 22 dot secant files, now I will go to parent directory that is home directory and now I want to copy dot secant files including my dot today files, see inside my dot, if you do today, there is inside today, we have 501 possibilities, I do not want to list all the possibilities, I have created a file folder, sorry directory which is hello, I want the content of today which contains some 500 files and content of hello also, that means recursively, so here comes the hyphen r, if I do copy today dot means present working directory, so where I am, I am in tilde, tilde means home, whenever in Linux we say dot, we mean present working directory, if we say dot dot that means previous directory, it says it is a directory, see it did not copy anything, are you getting this? By default it should at least copy the contents of today directory, but no, this is smart enough and it knows that, probably it does not mean to copy a directory, so why should I copy entire directory, probably you want to means the user want to copy some file only, so it will prompt in message that I am omitting the directory today, what you want to do, it is clear to mean that I want to copy something else, so I will say hyphen r, today already creates an empty directory name today in the same place, so let me remove, so I can either copy all the files inside today, sorry today hello star, this means select all the files inside today only and copy them to home directory, this will copy, if I want to copy all the directories from today and hello, which is hello, which is inside the today directory to my home, I have to make a recursively hyphen r, but can anyone tell me why it is not copying, because in home directory the today directory already exists, that is why it does not copy, move, so what is different between copy and move, move will remove the source content after copying, unless copy finishes move does not remove the source content, so you can similarly copy, control c will cancel the command and give back me the prompt, I can move today to slay say documents, so all the content of today will go inside my document folder, there is a flag in move, which is known as hyphen i, there are many flags, see if you see the slides it says with frequently used flags, the other options are given in man entry or help entry, you can just type command space hyphen hyphen help, you will get entire detailed view, if I give hyphen i now, it will ask me, it says no such directory, I already moved it, sorry I already moved it to documents, so there is no such directory to move, so actually all my files and whatever I am doing now are there in today directory, so I want to get it back all, so how to get it back, go to documents today and move it back to home, present working directory, just wake him up, okay, next comes the apropos command, how many of you used this command apropos, so this apropos will search for a command, suppose you forgot which command will list all the files, of course I do not think in your lifespan you will ever forget ls will list all the files, but suppose you forgot which command will list all the files, what you can do is, you can type apropos and I can write which command prints all files, this is stupid to write because anyway it is computer, it does not mean that I should write like this, so I will write list files, so it shows me all the possible commands which can copy content from, sorry which can show the files ls, so somewhere here our ls will be there, very smart huh, see it is not there, it is not there, so once in a while apropos also fails, so I think I just list, let us see, it is there, oh list directory contents, if you would have typed directory it would have given me this entry, but anyway you have to, it is like Google, you have to optimize your keywords so as to target your search, so make directory already seen, what does hyphen p do, make directory is important, that is why I included hyphen p, what permissions, no it will, no it will not preserve permission, suppose I have test, sorry I have today directory, inside today I have hello, I want, there should be a directory name as Srikant and there should be a directory name as awesome and there should be a directory name as, so the entire path does not exist, I want this world directory inside awesome, inside Srikant, inside hello, hello exist, is not it, so if I make directory it is a icon, if I do hyphen p, what it will do, it will create the parents, so parent directory for world is awesome, for awesome of course Srikant and Srikant has a parent directory hello, so now if you want to see today, hello Srikant, it exist, that is what I want to show you, this exist, R M command, let us move fast little bit, what is the time now, it is almost 3, so CD today, so I have so many files, R M star dot txt will remove all dot txt files irrespective of dot dot txt, it will not, this star means any dot, anything before dot txt and I want to remove star dot mp3 also, that, so it contains hello, inside hello Srikant awesome etc, let me create one file here to just demo you, one dot txt, so it contains two files now, one is file and is a directory, if I R M one dot txt, it will remove one dot txt, that is for sure, so if I do R M hello, will it remove, why, because this command will confuse, this R M means some files, but this directory, of course directory is also file, but this directory contains so many files, probably this directory is empty also, even though it will, it is not intelligent enough to decide that, okay directory is empty, let me delete it, no, what it will do, it will see, it is a directory, I want to remove it directly, it just give me the flag, check it, whether it is directory or not, then I will delete it, so if I do R M hello, I cannot delete this, so let me see what is there inside R M, just hit tap twice, you will get all dot srikant files and two directories, if I use the file size, it should be one directory, you know, somewhere it will be there, no problem, so yeah, R M hello does not work, R M hyphen r recursively remove hello works, so I do not have hello directory, I have only one file, one dot txt, why I have spent so much time in these simple commands, because these are the building blocks of any Linux based environment, if you program for android tomorrow, if you program for iOS whatever, I do not think iOS, anyway you can program, whatever, if you program for android or some desktop environment anywhere, backend of any graphical interface also are commands only, even if I show you this file browser, probably in the back end, in the source code, when I hit desktop, what it does, ls desktop and it shows all the files like this, it does not do something magical behind this, because these are also written by the people only, so in back end we have written some command, it will read that command output whatever files we got, it will show them as a graphical output with directories as a separate image and files with some certain attributes, is this clear, that is why in Linux command line is very important, you write any program in C, C++, Java, Perl, Python, whatever, bash, anywhere everywhere you need commands to execute and unless your concept is clear with command, you cannot work, so also it is better to know these commands, which top cat had helped man tail free, so it completes as a sentence also, which top cat had helped man tail free, okay, let us see which cat helped, so which will tell you, suppose I used copy no, copy is a command, which copy, it will tell me the path of the binary copy, so which space copy will show me the path of that binary, this is important sometimes, suppose you have two versions of Python installed, okay, Python 2.6, Python 2.7, it might be with C also, you have GCC 4.4, 4.4, you have GCC 4.5 also, so you do not know which GCC is executing by default, okay, what you will do, which space GCC, it will tell me which GCC is actually in the path, top, top will give you a system monitor kind of output in terminal, we have a system monitor, graphical system monitor also, just to show you that this can be done in terminal also, I am showing this and this is important because while writing codes or etc., if you are in a terminal mode and you do not, in many systems you do not have GVI x installed, so you can easily view CPUs, it shows CPU users, memory users, etc., etc., I am not going in detail of this, so what is this, next is cat, cat will catnate the files, it will show the content of a file, you can even append also, I am not going in detail, just type man cat or search Google examples for, no, in Google you have to be very specific, if you type cat you will get tons of YouTube videos, so head you also have to be very specific, what does head will do, any idea, very good, it will show the top 10 lines of a file, suppose your file contains some thousands of thousands of lines and you do not want to open, see the thousand line file, the size of the file will be around 223 MB, it will take some time to load and suppose you have some 10,000 line files and you have a program to copy the first line of each 10,000 files to some other directory or some other file, so will you open all the files, 10,000 files in complete mode, no, you will open with the head command, why you want only 10 lines, in head there is a parameter head space 1, it will open only the first line, so you are not actually opening the file completely, you are just getting the first line information and your memory is free, your RAM is free, in memory constrained devices like your tablets and mobile phones, 2 MB size of, 2 MB file size is quite big, so if you have a task similar to that, you cannot do it by opening the entire file, head will help you, so let me put something in, let me open, why to use graphical, VI is a editor, so VI 1.txt I can open, I will make mean insert mode, by default it is in command mode, if I press I or insert it will go to editing mode, just type something, so I have 3 lines, now head 1, 1.txt, head 1.txt I think hyphen n1, you can see in man entry or hyphen hyphen help entry of head, so by this command I can easily print the first line of the file, cat head is done, help already done, man is done, tail, tail of a file, free, free will show you the memory, memory means are you talking about hard disk, what do you mean by memory, by default in computing language RAM, so we are concerned about RAM, hard disk is so cheap nowadays, even RAM is cheap for desktop environment not for mobile or tablet platforms, so when I type free it shows me the memory users of memory, total memory is like this, some 18897, let us make it human readable, how to make it, so I told you there are some exceptions, so free hyphen m will print the memory in megabytes, hyphen g I think print in gigabytes, so my scale is wrong, I should print it in megabytes, so it shows me my RAM is 1845, used is oh my god, I have to clear my RAM, 1445 is used, so basic commands are over, now we come to some advanced commands, see there are tens and thousands of advanced commands and basic commands, I have chosen only those which might be helping you in programming android or programming any environment or day to day use, so first command is star, what is star? Compress, it is a compression technique, it will compress the files or directories, so star is a very big utility, it has many flags, so I have chosen some limited amount of flags so that our work should be done, so you can see the examples right away, so what I will do is I will just copy these examples, so hyphen c creates the file, hyphen f I am telling that this is a file archive.tar, foo.bar let us see, so let me create touch 2. or why touch, touch will create an empty file and when a tar an empty file there is no use, so 1.txt contains some lines, it is around 17 bytes, so let me copy 1.txt to 2.txt, so this is 3.txt, sorry copy like that, so I have 3 files 1.txt, 2.txt, 3.txt each 17 bytes, so I want to tar this, so what is the command, tar hyphen c will create a tar file, f means a file is coming right away, tar hyphen c, f what should be your output file name means the tar file name, let me give 1, 2, 3.tar and which files you want to make a tar 1.txt, 2.txt and 3.txt enter, so I have a file 1, 2, 3.tar, so bash means this terminal detects this, this is a tar file, so it changes its color, see the normal files are plain black text and this is a red text, so let me see how to make it, it is actually in bytes only, so no need to change in human readable, so it is around 1.0, 2.40, so due recognition I recommend to copy 17, 17 bytes file into a tar file which creates a not 51, at least it should create a 51 bytes of file inside means a tar file, but instead of that it has created I can give hyphen h here also, 10 k of file, more on this in spare time because I have not planned for these things because they are very core topics why it creates because there are some I nodes, there are minimum 512 bytes of size, etc, etc, etc, whatever, but this is not suitable for copying small, small files, 2, 3 files, if you have large files you can compress them and tar is not a compression utility, tar.gj, tar.vj2, they are compression formats, dot tar what it will do, it will just collect all the files and put it in a container like in a box, are you getting? Suppose I have a source of 11 GB to copy a 11 GB file using your either graphical file browser or command line file browser, it will take lot of time why you know because those 11 GB of files suppose it contains 11,000 files, each file while copying it has some header of footer information whatever, it sends it to the I node in the sphere of copying and it takes lot of time, instead of that if you put them all in a single tar file, so operating system detects as a single file and it skips many intermediate steps of each files whatever overhead is there, it directly copies the single file, so it is faster and it is easy to manage also, so if I have some 10,000 of 1.txt, 2.mp3, it is better to create in a tar file and put it everything in there or I can create a directory, I can put it there also, my next command is creating sorry it is a listing, before that I want to create, so if I put z it will create a tar.gj, I have to give the extension here, so this is a compression ls-lh123.tar.gj, it is 162 byte, earlier it was 10k, you remember, if not also I can show you, it is around 10k, so there is a compression format gj which is very commonly used, there is another compression utility known as bz2 which is even higher compression algorithm, you can just give I think j and make it bz2, I think it should create, no I have to see the help, there should be one option or flat to make it bz2, I am not spending time on that, so you can easily explore that, so what I am trying to say is, you can compress files using command line utility which is very very important, suppose you are a system admin, you have a server running somewhere in US or Canada, where there is, there are many temporary files created by Apache or some some log files etc etc daily and you have to take back up daily from server to your home machine or your own server in IIT wherever, what you will do, do you copy each file, you will write a shell script which will execute in the server probably in wherever Canada suppose, it will tar the file and send the file or you can use some rsync utility, there are many command line utility which will incrementally copy the file etc etc, so tar is very important, so tar-tvf will show the content of files, same as this, if I go to today, if I click on this, it will show me the content, so how do you see the content in command line, how do you see the content in command line, tar-tvf and 123 dot, it will show me the content of file, tar file, is it so boring, yeah it is boring I know, because these are command line utilities, see if you want to excel in Linux or any programming language, because basically most of the programming language, they support Linux environment, they are open source and someday you need to learn these things, it is better why not to start today, though it looks boring, but let me tell you this will help you a lot, jip you all know, because I think most of you have used Microsoft's own operating system for your purpose, so you can jip files like, jip file name, what should be the output of the file, space, file 1, file 2, like that, I do not want to show the demo for this, it is quite understandable, similarly you can unjip the files, oh we have not seen how to untar the files, sorry, so I have tar dot gz file, tar-x, this is the important flag, x means extract, c means create a tar, x means extract the tar, v verbose, f, it is a file, so tar-xf, whatever, my 1, 2, 3 dot tar dot gz, so I can see, actually they were already present here, so it is just over, there are flags to make it interactive, so I can make a tar-xy flag, which will ask me, this file already exists, you want to replace, you have to find it in the man page or help me, huh, grep is important, how many of you heard of grep, I am boring you people, I know, because I thought you people are not aware of Linux commands, but most of you do, good, it is actually good, so even though I will show you, grep type help or man to get list of options with this and grep is very useful tool, it can grep inside the file, grep means it can search for that pattern inside a file also, it can search that pattern in a directory, if the pattern name matches in file name, it will show that, okay, suppose I type hello, grep hello in some directory, suppose I do grep, see hello in some x, y, z paths, say tilde slash grep downloads and make it recursively, so what it will do, it will search for this pattern inside the download directory, so it says see, inside English dot cube dot word frequency, I have this file, I did not even notice, so there is a word hello, okay, so with I, you can ignore the case, so if I make it lower case also, it will ignore the case and it will print all the patterns with hello, earlier why it did not print, because I did not give the hyphen I flag, so it means if hello is present then only you print, now it says these many hello's are there with different cases, so definitely my hello is also there, so it took all caps, it ignored cases whatever, so these many hello's are present in the file, you can see one of them will be file name whatever, inside content of the file, one of is the file name, okay, can anyone has the answer for this, what are these numbers, I think it is the character number means word count, location, count of that, if required for any programming purpose then I will dig through this and I will find out, okay what is that number, for now I do not need to find that number, you can anyway find it, see there are tens and thousands of options in all the commands, it is very difficult to remember, so whatever important facts are there, I am just covering those, you can easily find, thanks for asking anyway, DF, what is DF? Man DF, disk space users, so DF, so it will open my laptop before you, it says how many partitions I have, so it has these many partitions, these are not created by user, not important now, so DF-H will make it human readable, so if it is in kilobyte it shows in kilobytes, it is in megabyte, so there is another command DU, disk usage, so what is the difference between LS-LH and DU, it is very interesting actually, so today I have 123.tar.gz, so LS-LH, 123.tar.gz gives me how much, 162 bytes, so no need of human readable flag also, it gives me 162 bytes, so with DU command also I can find it, DU-H 123.tar.gz, see the difference, it shows me how much, okay, but actually what is the size of these files, they are 162, but due to block size of my disk partition, whatever file system I am using, I am using ext4, maybe the minimum block size it detects is 4k, so disk usage, it will tell me that whatever disk I am using for these 3 files, in a way this is also very relevant, probably I have a hard disk of 4kb and I am trying to copy 4 files which are of say 163 bytes only, but it will say hard disk full, because my disk users say 4kb, probably not, because it will accommodate up to 4k of files, the minimum unit is 4k, it will accommodate up to 4k of files, so it shows that 4k is the disk block, minimum block, okay, SH will summarize the output, so let us see the use of SH, so if I want DU-SH it will summarize, can give the path of directly today, it says 44k, recursively, it will summarize everything, collect the information until 44k of memory, disk users, disk I am using for today, so there are few more advanced commands, have you heard of mount command, probably yes, because you are very smart people, so mount will show all the mounted partitions, okay, so when you connect a pen drive in your Linux machine, what it does, okay, first it creates a node in slash dev slash sdb or sdc, okay, I told you that in Linux everything is treated as files only, so that node I need to mount somewhere, mount means I need to, if I want to access the files present in that node I have to provide a path for it, file system for it, so I can give the node of that and destination it will mount there and it happens automatically in most of the Linux distributions, so if I attach the pen drive it will automatically mount it to slash media slash xyz, okay, so it shows me the different mounted partition, to mount from command line you need a root access for the system, what do you mean by root access, root access means administrative privileges, okay, so this is the example I am not showing this example, there are many options you can easily explore, okay, as I already told you whatever commands I have sorted out, these all are important for android administration, android system properties, android system administration kind of things, so setting environment is also very important, what is environment, I am getting this recant whether it Linux is somewhere set, otherwise I would have got something at the rate something, okay, when I type ls it knows where the ls is, how it knows because the environment is set, so where the ls is how to know h, ls, bin, ls, so how does it know it is in bin, ls because there is an bash environment set for this, so how to know where the environment, what is the environment, just eco, eco means print, dollar, dollar is variable, path variable, so it will print, oh my god I have so many paths, so it will print all the available paths for my bash environment, what does it mean, what is the significance of this tell me, because already my paths are set, why I need to give a custom paths for everything, suppose exactly, suppose you downloaded a package which contains some binaries and you do not want to put those binaries in your slash bin, slash user bin which are the default system locations where the binaries are available, your application does not allow, you do not have sudo access support, sudo means root access, you do not have a root access to see, to copy in, so slash means root partition, main partition of the Linux, it contains many directories like boot, CD ROM, dev, home, etc, etc and among these directories you have access to only home directory inside home, cd slash ls, cd home is one user because this is my laptop, if you have multiple users, it will have a multiple directories here of each user having its own. Now what I am going to make a point is you do not have access to other directories like this directory bin, it contains binaries, you want to see ls slash bin, these are my binaries and here is my ls command, this is already set by distribution, Linux distribution whatever distribution I am using, these paths are already set, I do not have to worry about it, to copy a, my binary suppose vi hello dot c, let me write one small hello program, I am in wrong directory, I do not have permission to write here, so I have to go into Shrekan, so vi hello dot c, so if I do cc, cc means gcc, default whatever gcc is used, hello dot c, it will create a a dot out file, and if I run dot slash a dot out it says hello, now but if I write a dot out from here, already set this path home, my home is already in the system path, let me move this a dot out to today, let me go into today, so I have a dot out here, if I type a dot out, no tab completion, if I do a dot out it says it is not a binary, it is not in the path whatever no such file or directory, if I have root permission what I can do, I can copy this a dot out to my bin folder and if I put this in bin folder I can execute, then I can execute permission denied, I have root permission to my system anyway, so I can copy, but is it a right way, because suppose you are a Linux administrator, you have some 100 users, is it safe to give root permission to all 100 users, so that they can copy their a dot out files there, so what I will do is, I will set my path to this directory, what is this directory today, and this path is local to myself, so there is a directory known as bash rc, hidden directory in my home folder, v i dot bash rc, so you can see there are lot of customized options are available, so these are the binaries which are not available in the slash bin or slash user bin, but they are located somewhere in my home, you can see like homes, you cannot jdk bin, I did not install jdk from my repositories, I did not do abgate install, I downloaded jdk and jdk, I entered it, I installed whatever the way was, and I gave this path to my home, so whenever my system reboots, probably if I put this in some rc file it will execute or I have to just source this file, so it will just export this, so I am going in much detail, I should not go like that, so let me do export, I told you about the environment variables, we started from there, export path equals to slash, what is the present, which directory I want to make, slash home, slash recon, slash today, so my binary is in today directory, dollar path, this will I think append the present path to my previous path variable, so you already know what is my previous path variable, big list, so now where I am, I am in home, my a dot out is not here, is it here? No, if I type a dot out, it works, why? Because it is in my path, so this is the one example I shown, there are many environment variables which you can set by exporting it, so inside IIT you have seen proxy, every time you visit a site you need a proxy authentication to give, so I give the proxy authentication inside my bash rc, so I do not have to give proxy, export proxy every time from my command line, so this command is not persistent, if I close this terminal this is gone, to make it persistent what I will do, I will put this command inside my dot bash rc, that is the local dot bash rc, so pipe will redirect your present commands output to some other output, other command, you can redirect it, suppose where is my any my ppt dot tpp, so cat my ppt dot tpp, cat will print the content of my tpp file, what is tpp file, my presentation file and it exits and it gives me a prompt back, what I want to do is I want to pipe it, pipe means I do not want to print it here, I want to pipe it to somewhere and I want to search one term inside this, so what I will do I will grep, you know already grep, so grep that pattern name, suppose in my ppt I forgot somewhere I have written srikan, is it, no sleepy I have written somewhere, that I remember, these are small files so I can visually verify that, but if it is a very big file and you should write inside a program, suppose your program demands that you should find some coland dot coland dot some pattern inside that file from some 10000 files, each file you have to search that pattern and you have to copy somewhere else or you have to write another file and put those patterns in each line, so in that case this command will help you, so what you will do, you will write instead of dot tpp you will give us some, inside a self strip you will write one variable for this and that variable act as a each file in that and if you will put it in a fall loop it will take all the files, search that put it inside another file, compilation how many of you compiled from source in Linux, so for any compilation process in mostly in Linux we have three step procedure for compilation, see Linux is all about source isn't it, so whenever you install a distribution suppose I have ubuntu desktop, when I download 700 mb of ubuntu desktop ISO, what I download, am I downloading source, we are not downloading source at all, we are downloading binaries, source is also available alternatively you can download the source also from the repositories, but most all the operating system they ship binaries only, why because user should not take pain of compiling all the source of complete operating system for his machine, if the machine architecture is known suppose you have 64 bit computer or ARM based computer whatever, if your architecture is known why you should bother, you should just download a binary which should work, I have forgot where I have cd copy back, so inside direct fb, so these are source file I downloaded direct fb, direct fb is a frame buffer, so compiling anything from source have at least three steps in Linux environment, first step is configuring the source is checking the dependencies of source whether whatever packages, whatever libraries required for compiling those source package is available in the machine or not, if not it will give some error, you have to verify that error, you have to install those libraries, those development files etc, then you have to make, it is a three step process dot slash configure, you will check whether see already this configure file is somewhere here, so what this file contain, it contains dependencies check, it will check to install direct fb a frame buffer device is required, some ls command is required, some xyz is required, it will check whether all those are installed, gcc is required, so dot slash configure will execute this bash script and it is checking now, so it is checking for lde, this, this, this, this, this, if everything found, I suppose it won't fail, of course it didn't fail, so according to this configure file my source, my system has sufficient libraries and packages to compile this direct fb package source, next is make, it will take lot of time, I am not doing this, after make you have to accidentally paste, after that you have to make install for that you need root permissions, so as to install in system parts slash bin or slash user bin like that, if not you can stop at make and you can give the path of this directory where bash are, so you can export your path to this directory and it will, the binary will work from here itself, okay, are we done? Yeah, file permissions, okay, permissions, we just see basic permissions first, so when we did ls-n, let me go to my favorite directory, so ls-l123.tar, so it shows me some information, so what does this first hyphen show, is it a file or a directory and these are arranged in triplets, so these three characters, these three characters and these three characters, so hyphen means it's a file of course, it has read write permission for home user and there is no execute permission for user, read write permission for group, what does this one mean, shows links or number of files which is linked to, or total number of files, not linked to anything, if I give ls-l to some directory, it will show all the, it will give the number of files inside the directory, if not linked somewhere else, who is Srikanth, is the user and who is Srikanth here, whenever you create a file by default the attributes are you are the user and you are the group member, you can change this and this is your content of, sorry size of file, number of bytes, so when you created, when last modified and the file name, suppose I want to give permission of this foo.sh, foo.sh, so instead of foo.sh I will use something else, so ch-mode is command to change the permission, you can code it like numbers also, you can give some binary numbers, you might already know, but I will do this thing, u is user, group and others, for all I want to give plus x, means execute permission for which file, 123.tar file, now ls-l 123.tar, how to remove the, like that, okay, now the user is Srikanth, there are many other users in system, though I have only single user computer, only Srikanth is the only user of this computer, but many files they have some other, like if you are running Apache server, there will be user either Apache or WW data, okay, so if I want to change the user, sorry, user or group to Apache user, how you will change ch-own, there is a command in next slide, plus we will add, just I have seen this, instead of writing, oh I was so stupid, you can easily write instead of u-g-o-a, for all, five permissions, try changing to ch-own, 123.tar, first you have to give the, not permitted, why, because I do not have, actually this is, this is not my group, I am not listed in this group, and I am not root as well, if I am root I can change it, so though I changed it, now let list ls-l 123.tar, you can see the group is WW data, so any other user around the world, if my laptop is connected to internet, and this file is exposed, and he is accessing through Apache, probably he can read the content, because group has read write permission, any other user other than Apache can't, actually I think, there are many other ways also, but to give you a simple example, you cannot read from outside, that is it.