 course of Unix for testers and this course series of Unix for testers it is basically purely for from software testing point of view okay so if you are a software tester and if you are looking for to learn Unix basically in fact as a software tester we should know few basic things like every software tester should basically know about Unix, Unix processes, Unix commands, every software tester should know about databases how you can interact with database like basics of SQL and those stuff so these are some general things which every software tester should know right so out of that Unix is one of the things as I said okay so in this particular course I'm going to talk about Unix concepts for manual testing point of view and in advance in in addition to that what I'm going to talk is how we can automate all those Unix processes with the help of a third party API of Java or C sharp and by using a putty tools by creating a batch file so that what you can do is you can achieve fluent test automation like if if you have some web UI on the front side and you are creating some data and then you have something some batch execution Unix batch execution in between and then you have something else which you are verifying and if you have done some automation on web UI but you are still stuck with something for your Unix processes in between then this is the perfect place where I'm going to talk how we can automate all those processes okay or even in fact you can take a very small example of file processing system where you have Unix system which is which is taking some file from source system and processing it and giving it to another source system or doing it some something with that specific data what he has processed okay so I'm going to talk about how we can automate such a kind of processes so that you can achieve end-to-end test automation and we can have a CICD compliant projects okay so that's what I'm going to talk in this particular course okay so this is just a quick course introduction as I said what I'm going to talk in this course all Unix manual concepts required for manual testing point of view and the similar things how we can automate so that we can incorporate all the things in my test automation framework with the help of a couple of things as I said using putty tools and using an API which can be incorporated in my test automation framework you can take this course okay as I said any manual tester or anyone who want to start their career in testing or any automation testers who want to automate the Unix processes what they have so that to achieve end-to-end test automation they are perfect to take this course okay and what you can learn at the end of this course so at the end of this course you are going to learn all Unix concepts which are required from testing point of view could be any processes any commands or about shell scripts and many other stuff which is required from day-to-day life of software testing professional okay and again there are some sections where I'm going to talk about how you can automate the things automate the processes how we can execute the command automatically or execute the shell script or do sptp operations and arrest of the stuff automatically and how you can basically incorporate all these automated stuff into your test automation framework okay so that's what I'm going to talk and this is what you can expect from this course okay and finally what is not a part of this course is basically uh shell scripting is not a part of this course because writing a shell scripting is purely a job of a data stage developer or a Unix developer whatever we call okay so that is that is not a part of this particular course okay there are some prerequisite okay you should have basic computer knowledge that everyone should have I believe basic testing concept okay so I'm assuming since you have browsed to this particular course you should have some basic testing concepts right what testing is what are the types of testing and how to do testing and a few few basic steps you should know and if you have basic knowledge of Java that is very good okay because we are going to talk about how we can automate the concepts with the help of Java right but even if you don't know that is fine because Java is not a rocket science we can learn it very easily and I have explained in such a way right so that is a prerequisite good to have but even if you don't have I think you can manage it you should be able to manage it basically okay so these are some course prerequisites what what I see from this particular course point of view now I'll walk you through this course content very quickly introduction I'll talk about how much Unix is needed for software testers then I'm going to create a Unix instance on Google cloud which I'm going to use for practice you can create it for your own if you don't have any for practice then how we can connect to basically that Unix server which I have on my Google cloud using putty and vncp for file transfers then what are the manual and automated process we do as a software tester in Unix then what are the various commands which we need as a software testing point of view like searching then moving in between directories then we have many other commands like processes or some file operations and many many other stuffs then we'll talk about how to create a basic shell script or a shell script then some file permission how we can execute a shell script and rest other stuff and then I'll talk about then I'll start basically moving towards automation part okay then I'll I'll show you like how we can automate all this stuff like sending file to Unix server popping file to the Unix server getting file to you from over to my local machine or executing the shell script or executing any command basically from shell script from my particular code okay so I'm going to automate all these things basically with the help of batch file right I'm going to create a batch file and then I'm going to execute that batch file from Java code in fact you can execute that batch file from any programming language or even you can you can execute that batch file from any scriptless test automation tool because that's a batch file you are going to double click on it and that's it it will get executed okay so that is one approach how I'm going to achieve the automation the second approach to achieve the automation is with the help of some libraries we have okay so I'm going to use Java library in this case which is jsch okay so by using that library again I'm going to achieve the same processes like sending the file that is uploading the file single file multiple file again downloading single file uploading file executing the shell script then checking the presence of file and a few other stuff I'm going to talk okay so and basically if I'm using jsch like if I if I'm if I'm going to automate these things using a Java library it will be very easy for me to incorporate the things into my test automation framework if I'm using basically Selenium okay Selenium with Java that's that will become pretty easy but if you are not using Selenium then in that case maybe you can go to my first approach where I'm going to create a batch file and execute the things okay because it will be suited to any test automation framework okay and if you're using a C sharp nothing to panic we have some sss library for a C sharp as well so I have not explained it in this particular course content but it will be on the similar line at all okay and finally I'm going to talk about some sample interview questions for on Unix basically and basically from testing point of view okay so these are the course content which I'm going to cover as a part of this Unix for testers okay so I hope you guys enjoy this video series I'm looking for your feedback thank you welcome to the course of Unix for tester by which I'm going to talk about all the Unix concepts like went for manual tester and automated how you can automate basically all those concepts like running your shell script and doing a sub tp operations executing commands which we can incorporate basically in your test automation framework so that we can achieve your end-to-end test automation and in fact we can use it along with any test automation tool okay so let us focus and talk about architecture of Unix okay so let me switch to my paint and let me tell you something okay so and when I say architecture what comes in my mind how my particular operating system will be interacting with hardware and other stuff right so let us say I have my hardware at the central place okay I have just my hardware okay now when I say hardware it is my hard disk that is my RAM it is my processor and other stuff what in all IO operations can happen like how my printer connected or some multimedia devices are connected and many other things okay so all those are my hardware okay so now as a user I cannot go to my hard disk and I can copy files from one location to another or I cannot directly connect my pen drive to the hard disk and go to hard disk and copy file from hard disk to pen drive or I cannot go and execute any command and and stuff I cannot do directly right so in order to interact with hardware okay there is something and okay that's something is it's my Unix kernel okay what is this Unix kernel and all I talk in a shortly give me a second Unix kernel okay now what is this Unix kernel so basically this kernel is the basically the hub of operating system it is responsible for allocating time memory and other stuff and all I'll talk about that shortly okay now I can again due to some reason I cannot directly go and interact with hardware that I already explained and on the on the top of hardware there is something called as Unix kernel which can interact with hardware but again I cannot interact with Unix kernel because it is at a very high level which is responsible for handling all the file operations communication operations based on the system called what it gets from operating system because Unix kernel is not the operating system now on the top of Unix kernel there is something called as shell okay there is something called as shell and shell is something we will be interacting with okay so whatever we do so like whatever I do like I execute some command or I do compile my programs like whatever operations I do with my Unix system so all that stuff I'm going to do on shell script okay so basically this is how the complete architecture of my Unix is okay so hardware I have at the central place I cannot interact with hardware so I have something in between that which is Unix kernel which is responsible basically for allocating the time and memory to the programs which I'm going to execute for my shell okay and your Unix kernel is also responsible for file storing communication in response to system calls and many many other stuff okay and again as I said earlier I cannot directly go to my Unix kernel and execute my commands or do the compile compilation things and other things I cannot do that so in between that we have one more thing called as shell which basically acts as an interface in between user and kernel okay so this is what I have drawn and let me show you the same give me the same I missed the ppt here it is okay so I mentioned the same thing over here like I have hardware at the central place then I have Unix kernel which is basically as I said again responsible for performing various things allocating time memory handling system calls file store and rest of the stuff and first that we have kernels interface I said kernel interface which is basically my shell okay and which is the kind of interface in between my user as a me as a user and my operating system kernel okay so and then on the top of shell I can run various utility programs okay various application program utility programs whatever I want to do with my Unix system okay let us understand it in better way we have something called as kernels okay so if you see my presentation again okay I have something called as Unix kernel okay we all know hardware that's fantastic we all know ram we all know how to send rest of the stuff let us try and understand what is Unix kernels okay and what it is for so Unix kernel is basically used to schedule the program basically manage the data file access and storage enforcing security and performing all hardware access related things okay so in short I can say like the kernel is the lowest layer of my operating system so my operating kernel and my shell both are the part of my operating system only because I'm going to install my operating system onto the hardware but both are separate component me as a user to me as a user okay so kernel is basically the lowest layer of my operating system and it accounts for hardware devices data storages executing other regularly scheduled tasks okay so this layer is basically machine dependent okay because my it depends on hardware to hardware unlike rest of the operating system and I can say like individual tasks that user performs constitute separate processes so it's the process sorry it's the responsibility of kernel to constitute or to create the process based on user request okay the users usually run many processes concurrently during the normal operation because Unix is multi-user multi-tasking operating system okay now next what I want to show you is the init program okay so whenever you put your operating system init is a very first program uh which kernel uh events okay so init I'm going to talk about init in one of the video where I'll talk about commands various commands okay so let's skip it as of now and then on the top of kernel we have something called a shell okay so shell um so if we work with windows operating system I have good graphical user interface which I can work with I can browse the folders I can browse my uh view uh sorry uh web browser uh for multiple websites I can play a video I can again I can do many stuff okay likewise in Unix we have shell only to interact with my Unix operating system okay uh in short to interact with kernels which will do all the things for me like as I said scheduling the program managing file executing the things and blah blah blah all the stuff shell is just a medium to just a medium in between kernel and myself because I don't understand the language of kernel kernel don't understand me so shell is the medium okay uh so shell presents uh each user a prompt which is my terminal it interprets command type by user whatever command command I typed into uh command prompt or my terminal like I use ls to get a list or I use copy command move command um sage mode command and I execute shell scripts and many many other things I do right so to interpret the command what I'm trying to execute what I'm trying to enter uh that's the duty of shell and shell will convert that to my kernel so that kernel can execute that those things on my hardware shell is basically provide again a user or programming environment users of operating system do not interact directly with kernel because of this incapability okay user commands are sent to the kernel via shell as I said this part of the operating system is a high level programming language that interpret user commands execute the appropriate programs and the request to the kernel and deliver the resulting output to the user I can get back my output uh from the on the same terminal right the shell is an interface that let you customize your user environment and automate the complex operation for which unix is made up of okay made up for right um basically there are uh that that is what basically the shell is and we have different types of shell okay so basically we have uh c shell which is also known as uh buckler buckler's shell which is for bst buckler software distribution and we have many other shells like t shell taco shell then we have born shell we have uh corn shell and many other things those are the type of shell but we do not care about those things okay so this is what the architecture of unix is okay let me switch to my presentation over here again uh just to pick over you what I just thought I have a hardware in the place in the center uh which is my ram hard disk and rest of the stuff I cannot go and directly interact with my hardware so uh there should be something which understands the language of hardware or which can communicate with hardware that is the part of in fact that is the uh complete uh duty of my operating system but in operating system in unix in unix terminology it is divided basically in two things unix kernels and shell okay so unix kernel is basically uh this is that is the lowest layer of operating system and it is responsible to uh interact with my hardware and something in between user and me okay and that something is called as a kernel interface which is a shell in this case okay so whatever I do in unix I do it on shell because I can understand what shell is saying and um I suppose sorry I cannot but I do go and interact with kernel because we are unable to uh interact with each other so whatever I do like I execute uh any shell script or the utility programs given by unix or all the I can install all the compilers and interact with that I can do all the things on shell okay so that's basically I wanted to talk as the architecture of unix okay so in my next video I'll be talking in detail about the different utility programs what uh testers use in their day to day life um that means in short various commands and then we see about shell script then we'll see how we can use putty basically being a city and uh all those stuff and then we'll move to the automation part like how we can automate all the things what we do as a manual testers like file transfer from here and there then um executing the shell script verifying the files and many other things right so we'll be doing it in two way using uh putty uh tools and by using uh external apis like we have some apis for java some api for sisha and we have many other things okay so that's sort of the complete aim for this video course is okay so stay tuned thank you hello welcome back welcome to the course of unix for tester um unix manual concepts which are required for manual testing basically and how we can automate all those concepts like um executing various commands and in next terminal uh shell scripts and rest of the stuff okay set tp operations and all uh so that we can incorporate uh those automated things in your test automation framework for example sir linia so without further delay let's start with our very first video unix introduction okay so we all know unix is basically operating system and originally we do not see any ui so when unix come in front of us we we just see a unix terminal okay just like my how my command prompts look like okay so basically unix is operating system and which was born um in late 1960 or 1960 i believe and it was originally began with one man project which was led by ken thompson of bell labs okay and it has since grown to become most widely used operating system for various usages various purposes which we are going to talk in short in next few minutes okay so in the time since unix was first developed so as i said in 1960 it has gone through many different generations and even mutations okay so some differs substantially from original versions like the one which are your under bsd which is work less software distribution or your linux and others are still contain the major portion that are based on the original unix source code which was developed okay so on internet you can find a history of unix what in all generation it has so it went through many generations but the very first one was in 1960 okay so now okay and i have mentioned over here is unix is multi user multitasking operating system okay so before that let us understand quickly what is operating system though in everyone have studied what is always in their college days and we know this is operating system just like my microsoft windows which is just the kind of interface in between my computer hardware and me as a human being okay so operating system is just like a it is just a program which start up when you turn on your computer and turn underneath all other programs okay without it nothing would happen at all because they cannot go to my RAM to my hard disk and tell okay go ahead and run this program no i cannot do that i represent between that which is my operating system and simple term i can say that an operating system is a manager it manages all the available resources on computer from the CPU to memory to hard disk accesses okay so the task of the operating the task the operating system must perform like controlling your hardware could be running your applications and managing data and files on your hard disk or hard drive okay like copying the things deleting the things moving removing all those things okay running the applications like like running the job running any kind of software running applications running processes browser games and blah blah blah many things we have okay so that's basically what my operating system is okay now let us come to the point what i have mentioned over here is what is multi-user and multitasking operating system so i'm saying here is unix is multi-user multitasking operating system because it allows multiple user to use the computer system simultaneously right unlike how my old versions of computers are like i have my dos operating system or i can take an example of windows earlier one windows version like 3.1 which were single user single process operating system unlike that this is multi-user multi-process operating system okay so before i talk about this multi-user multi-process multitasking operating system let me talk quickly about two more things which is single user and single tasking okay single user and single tasking operating system okay so basically they allows only one user to run at a time on your computer system okay and user can execute or run only one process at a time okay that is what your single user and single process operating system is okay and for example we have dos operating system in which you can have only single user and you can only execute single process at a time or we have very older windows version like windows 3.1 just for an example but now what is as well we used off that is one of the latest example we have over here okay then next one is single user and multitasking operating system our single user multi-process operating system which basically from the name itself we can use now it basically allows a single user to use the computer system but user can run multiple processes at the same time okay that is what my single user multitasking operating system is and for example we have os2 which is kind of one example of this single user multitasking operating system now let us come back to the one what I have mentioned over here multi-user and multitasking operating system as I said allows multiple users to use the same computer operating system simultaneously and to run each user can run multiple processes at the same time which is what my unix or windows version does okay that's what unix is multi-user multi-tasking operating system now next point I said is in unix everything is about files and processes so in unix I'm talking about these things in detail in my next video just a short introduction everything is about files and processes so in unix everything you see is about files and processes like whatever hardware is connected or anything which my cpu perform everything is files and processes okay so even directories that is my folders which store files they are termed as files only okay so that's what everything is about files and processes I'm going to talk about this in detail okay and it is over 30 years old unix is over 30 years old and it's popularity and users are still high okay and why it is because we we all know it is very faster and if you want to have any operation or processes related to let us see if you want to perform your file processes or trigger some jobs or many many many usages we have which I'm going to show you that's very popular okay it has a large number of application okay there are numerous amount of applications available for unix operating system okay they ranges from the commercial applications such as CAD Maya then your word perfect to many free applications okay that's that is what it's making more popular that is less resource intensive okay okay before that like there are many free applications and even free operating systems we have the various free versions of operating system which we have which I'll tell you shortly I said there is very less resource intensive in general most of the unix installation tends to be much less demanding on system resources so even if you you will notice in my one of the video where I'm going to create my unix environment on Google cloud so it is just taking me like less than half minute or less than 15 second to get my unix environment get created for me right so it is very less resource intensive I can get it very quickly that's very number very less number of resources it needs basically to start in many cases the old family of computer that can barely run on windows more than sufficient to run the latest version on Linux okay because it is very less resource intensive as I said internet development okay much of the backbone of internet is run by unix servers okay many of the most general web servers run on unix with Apache web server and other free application so even though we don't see them they exist okay and next I want to talk about okay before I talk about unix usages let me talk about flavors of unix okay so basically there are two categories under unix the very first one is open source and the second one is proprietary okay these are the two categories so under proprietary is we have some operating system which you might have heard like we have solaris we have iris then we have mac os okay and we have double of morse okay these are proprietary version then there are many open source operating open source is nothing but your source code is readily available and it is free to modify okay so we have some versions like the very first one is we have free dsd buckless software distribution then this is basically one open source unix version now we must be knowing that linux is just a copy of unix okay so even you can use the your linux distribution to perform all the processes or all the things what you want to do in unix okay so you can say linux is just a flavor of unix you can say just a free flavor of unix okay and we all know we have different linux operating systems like we have red hat we have debian we have sis we have slack ware and many more we have okay so that's what the different flavors of unix we have we have open source which are free to use and we have proprietary versions like solaris iris and mac and could be many others okay so and it just guided just like in pro in proprietary we have good support and we have few more extra features but it is not like we cannot achieve them with the open source version what we have like free dsd another uh free linux distribution like red hat and a few other that's perfectly possible now what are the different unix usages okay so i mentioned over here the three different usages like user support tools so it has a user various user support tools for example uh it has a tax processing tools like vi editor or sed or awk which is a kind of programming language itself it has a productivity application which we will be talking about so it has a very um in fact many user support uh the main purpose of inix is to work with files to work with processes create the process execute the processes process the files and this kind of stuff okay the second point i mentioned is programmer support tools so programming language and the compilers like cc++ java are available for your unix distributions okay uh you can create a shell script as i said the main purpose is uh create the files process the file using shell script uh likewise the the the only two things processes and files okay and that is what we can achieve with the help of shell script which is the main thing which we do in unix okay and we can use personal software processes version control uh revision version controls and many other things uh finally i mentioned unix other server so in unix we can um on unix we can create our own web servers or mail server application server and so in most of the organization uh if you say what is my application server so even if you don't see it but when you say am i application server in maximum of the cases your application server is in unix okay so apart from i just mentioned three over here but apart from that there could be many number of uh applications or he suggests what unix have okay now let me talk about architecture okay i'm i'm taking pause over here i'll continue about architecture in next video thank you hello welcome back welcome to the course of unix for testar uh and this video i'm going to talk about uh what happens when you type any command or execute any shell script into unix or linux terminal okay so we also what happens like whenever we want to deal with uh operating system unix operating system what we do is we just type the open the terminal type the commands and uh we get the response okay but let's understand the what happens in packing basically okay so let me go to my okay not pad and okay so we all know my computer computer understand the language of zeros and ones right which is binary language and everyone knows that right so it's called basically binary language so in early days of computing instructions are provided using binary language which is very difficult for all of us to read and write so in os uh that is unix in this case there are special program called a shell okay so these shells are basically used to translate my command english like command into binary language which is which is zeros and ones okay so let us see okay let me show that to you in paint basically okay so let us say i have uh let us say i am typing any my command okay so my let us say it is my command or my shell script let us say i'm opening the terminal and i have typed one command or i have typed some shell script and i want to execute that okay so what happens when i hit enter onto the terminal my command goes to uh shell okay command goes to your shell could be linux or unix shell whatever depending on the operating system which you are using now there are multiple types of shell which uh we have like uh bond shell bond shell t shell okay we have many uh number of types of shell uh what shell your operating system has basically you can get that by using this command called as eco shell okay so it is giving me like i'm using bash shell so that means i have i'm using bond shell which is freeware basically and almost all maximum of the unix and linux versions are using this particular shell okay so what happens whenever i hit any command it goes to shell specifically to bash in my case because i'm using bash shell right so let us say i'm typing some command called ls or let us say could be date or i'm executing any shell script right then what happens whenever i hit enter it will get sent to my um bash that is shell right and next okay what now what is the function of shell or bash in my case okay it is to convert it to uh binary language which my uh kernels understand right like if i'm giving like ls or date then what this shell or bash will do it will convert in terms of uh sorry english language which is the language of ones and zeros which i don't know how it converts that is the role of shell what is doing okay so what this particular uh shell will do it will convert it to the binary language okay now once it is converted to the binary language okay what will happen is it will be sent to uh something called as my kernels okay linux or unix kernels okay and basically what happens is kernels interact with my hardware directly so after kernel with my hardware whatever hardware i have my machine has kernel is interacting with that hardware directly okay so let's take an example i'm executing simple command called as ls or date onto my terminal let us say i type ls and i get some output on my screen so internally what happens this ls uh i know it is ls to get list of command but my kernels which is the last layer of my operating system do not understand what ls is so this ls will get converted into the binary language which kernels can understand okay and kernel will send that binary data which is converted which is equivalent converted of that ls command to my kernels and kernel will kernel understand it basically and kernel will send it to the like do it whatever uh he wants to do basically and he will give the response back again in binary language then the function of my shell or bash comes in the picture and it will convert it into the language which as a human i can understand or my operating system uh front user can understand and then it will give me the result of this one whatever um command i'm typing based on that right so this is basically how your unix or linux uh terminal operating system works basically whenever you hit any command okay so uh the important part is shell over here which converts your by uh command or shell script into binary language which kernels can understand and kernels do whatever you want to do and in a sense the response back again in binary language again uh the role of shell is there which converts it to human readable which i can understand with no operating system impact can understand so that is basically how uh what happens when uh you type any command or execute any shell script in unix or linux terminal more main important role is of shell script that is conversion to uh computer understandable language which is binary language of zero then once okay so that's it for this video thank you welcome back friends uh in this video series of unix for tester um the manual concepts and how we can automate all those manual concepts as a part of our test automation i'm going to talk on uh how to create a unix instance on google cloud which i'll be using it for my practice purpose okay so if you already have some unix instance which you are using in your organization or if you have a linux machine or if you have any virtual machines set upon your windows environment that's perfectly fine you can go ahead and use that but if you do not have any of these uh the better way rather than using virtual machines is to use uh any uh virtual machine on cloud platform okay so in this case i'm going to use google cloud platforms okay so i'm going to show you how we can use uh google cloud cloud platform for creating a unix instance and which we will be using for our practice in the whole this video series okay so uh the first step is to log into console.cloud.google.com let me switch to my chrome and let me log in console.cloud.google.com here i am and as soon as i log in i see some uh my home page okay but if you are doing it first time you will not see that if you are logging it first time you might see uh let us see console.cloud.google.com and let us say i'm going to log in first time okay so okay so even i have it here give me a second let me log in with another email id okay so here i have uh used this id first time for logging into console.cloud.google.com so if you are doing it first time very first time you will see this kind of prompt okay so i'm going to click on i agree and i'm going to click on agree and continue you may uh read all these agreements terms and conditions and next you can you need to sign up for this free trial which is for 12 months with three three hundred dollar credit and whenever you use any application like let us say if you're using any vm or any cloud storage cloud sql or any uh engines like kubernetes engine you're going to deploy something or anything like whatever components you use on uh cloud they are going to charge you for that okay so for this first three hundred dollar uh google it not going to charge you anything because they have given you a free trial and let us try it for free now so you need to fill up some form okay i have selected my country i clicked on i agree and continue and in the next now it is asking you to fill some information okay so you can go ahead and fill this information and you can fill your card detail and click on start your free trial okay it will start your free trial do not worry they're not going to charge you uh even if your three hundred dollar get exceeded they will ask you for your confirmation and then only they are going to charge you if you do not want to continue you can go ahead and delete your card details from there that's fine okay so let us say now you have created the cloud platform account okay and i want to create a virtual machine instance what i'll do is i'll go to this navigation menu three lines you see on the uh left hand side top i clicked on it and i will be going to compute engine okay so in compute engine i see a option called vm instances i clicked on vm instance and now i'll get an option to create a vm instance okay so i'm going to create a new vm instance now i clicked on create button and i just need to fill up some information let us say uh name of my instance is unix instance or unix only that's fine and what else okay so you can select your machine type since i'm not going to do any uh heavy processing on my this particular vm instance i'm going to select the macro service with 1cpu and 0.6 of gb of memory that's fine and you can see uh how much they are going to charge you okay so this this charge is uh going out of your three hundred dollar okay so you need not to worry okay so fine and here what os you want to install on your vm instance by default they offer debian but if you want to do any uh other os you can go ahead and change it okay i'm keeping as it is i do not want to change it that's fine now i'm accepting this firewall terms and i need to do some security uh give me a second and okay so let us say i want to connect to this particular vm instance via external uh tools like let us say your uh putty or vn scp then in those cases i need to provide this ssh key okay so for now in this video i'm not going to provide this ssh key because in this video i'm not going to show you how you are going to connect your uh putty uh with this particular vm instance that we'll be talking in next video so we'll we'll do this part in next video fine so for now i'm just going to click on create and this will create a new vm instance for you okay so uh that's in process you can see the instance creation is in process so as soon as the instance gets created it will assign some external ip for you okay so by using that external ip you're going to connect with external tools okay so let us wait till it gets connected it won't take much time so all over this course i'm going to use this particular vm instance as my unix terminal okay so uh okay it's still loading okay now you can see on the green tick that means my instance is running okay so the instance is created successfully with the name unix and it has some zones where my data is going to reside though it is your uh cloud but definitely it has some uh servers somewhere okay so they're situated in this us central one region uh add as some external ip so i'm going to use this particular external ip in order to interact as i said with other tools okay and you can see some option to connect over here okay so you can connect it in a browser window itself you can use another sss tool by using gcloud but for using this gcloud you need to have cloud sdk install so we'll not be talking about these things so we'll be uh in this video i'll show you how we can work it in browser window but we'll not prefer this we will use the ssh client which is my putti and venus ip okay so we'll be talking about this ssh client in next video for now let me click on open browser window and now it will open a unix terminal so it is just connecting now this time it will not ask me which host i want to connect what's the username what's password is there any ssh key which i need to use nothing it will not ask because we are directly connecting it from this particular instance so it is taking all those details and now you can see i'm connected to the vm instance okay so here you can see my username is aec underscore prakash and my machine name is unix okay so if i do any command over here it is going to work like i'm trying my what is my present working directory it is home slash aec dot prakash okay so this is how you can connect with the unix instance on cloud okay but the way which we will be using from our next session is by using another ssh client which is with the help of putti okay so we activated we saw how we can activate a trial account on gcp services and we created a vm instance on the compute engine and we are good to go for your practice okay so that's it let's submit in next video where i'm going to talk about how we can use putti and venus ip in order to interact with your vm instance that is your unix terminal thank you hello welcome back we'll come back to the course of unix protesters where i'm going to talk on manual and automated concepts uh regarding unix okay so uh in last video if you remember i talked about how we can create a unix instance for practice and purpose on google cloud in this video i'm going to talk on how you can connect to that particular unix instance unix server or vm instance via putti okay so basically putti uh is a ssh client is used to connect to unix server okay so uh how we can install putti okay so there are um many ways how you can connect to put uh unix server but this is the um generally used uh ssh client okay so i'm going to download and install putti from putti.org okay so if i click on putti.org it will ask me to download putti at the very first link i'll click on you can download putti from here and it will give me the option so i'm using my windows installer for 64 bit and it's going to download okay and it is downloaded i'm just clicked on it it will open it's going to install i just clicked on next uh the installation location fine with me clicked on next but in all you want to install install putti i don't want to create a desktop shortcut and whatever default they have that's fine with me clicked on install and it is going to install it won't take more than a minute view read me file i don't want click on finish so now i have installed my putti great next we have done with the installation now the next thing is uh to generate a public or private keys okay so uh okay so let me go to my unix instance okay so here i am this is my unix instance and once again let me connect to this particular instance via browser because i want to show you something regarding the keys okay so uh basically the uh public private keys okay so there are two kind of key public keys and private keys public keys are specific to my particular user accounts of key public key and private key so my private key is personal to me which i'm going to use it to connect to a particular instance and i'm responsible for it okay whereas public key is made public by a particular unix instance where uh a number of uh users from that particular server can interact with it okay so if i go to my unix server so i again opened it from my uh browser window itself okay and if i go to uh okay if i try and list the number of files what i have okay so we'll be talking about details what and all come on we have so i'm just trying to get what and all file i have in my account so you can see i have one file called as dot ssh okay so it is dot ssh which is a hidden file okay so if i try and open okay or let me find so let me open this dot ssh file okay it's a directory file let me go to that particular directory okay and let me check what and all i have in this directory again and here you can see i have something called as authorized key okay so do not worry about this command uh commands i'm going to talk uh and details okay so now i want to open this file so to open the files i can use cat command and the file name and here you can see some keys okay you can see some keys you can see two keys over here okay public key and my private key and you can see my details over here my username when it is going to expire and all those things okay so these keys if you remember these keys are present in my my personal account so this aec dot prokash is my personal account okay so if i check uh who am i it will give my username okay so i'm in this directory so these keys belongs to me so these are my private keys okay now where the public keys of particular unique server resides okay so let me go back and let me go to the folder called as etc ssh let me list out what and all i have okay okay so here in etc ssh folder you can see there are uh public and private keys are present okay so these are the basically the public keys for this particular uh made public by this particular unix environment okay so i'm not going to use these keys okay so what i'm going to use is i'm going to generate my own public and private keys which i'm going to interact uh i'm i'm going to use it while interacting with unix server okay and uh i i just install putty right so input along with putty installation there is something comes called as putty gen okay so if i open this putty gen so basically this is putty key generator and it will help me to generate my keys okay my uh basically my private keys okay and i'll just click on this generate and i will hover my mouse in this free space it will generate a key for me okay so this is the key generated for me okay so i'll just copy this particular key okay and okay i'll add uh key command as my name so basically that's my user name okay and i'm going to save it as my private key and i'm going to save it uh in some folder that's fine and i'm going to save it with name key fine so now my key is saved fine now i just copied this particular key okay now what i want to do is i want to use this specific key in order to interact with particular this particular unix server okay this particular unix server i want to interact with and for that purpose i'm going to use this key okay so how i can use it let me close this particular uh terminal now and let me go to this particular instance okay i'm going to that particular instance and because i need to update these key into that particular instance okay so i'm going to click on edit this particular instance and i should see some option to add the ssh keys okay so you can see some option as ssh key and it says you have zero ssh key i didn't added any ssh key yet okay so i just clicked on add and here i'm simply going to paste my key okay so fine now my key is there okay so that's fine i just clicked on save now my particular uh okay so my key is updated now so now what i'm going to do is let me open putty now okay so to open the putty i'm going to use this putty which i just installed okay so this putty is basically the interface uh which i'm going to use it to connect to this particular uh unix instance okay now it asks me a few things like what is my host name okay so basically the host name is your external ip address so i'm just going to copy this external ip address and i'll put it in host name here fine and what else port 22 is by default port which they will use and one more thing which i should give it over here is ssh key okay so if i go to this ssh over here and if i go to authorization it will ask me for some key file okay so i'm just going to browse and i'll give the location of the file which i just saved if they remember a couple of minutes back fine and i want to allow this and i just click on open okay now it will ask me to login as okay i'll enter my name whatever i used over there okay so fine so give me a second give me once more because i think the name was something different okay so what has happened is when we copied the key over here let me show you when we copied the key uh let me click on edit okay so when we copied the key over here it has taken the username as iris's key something okay but in actual i used the name as rakash okay uh this happened because i used i copied this key first and then i changed the name so the specific key didn't got copied i'm going to copy it again and i'm going to remove this one and i'm going to add new one now let me click on save because if you see whatever key file i is stored if i click on edit and you should see some name over here this is my user name and this is my key okay so this is my public key and this is my private key okay so uh now let us try okay let us go to the vm instance let us open putty again okay uh let me copy the post name which is my external ip and let me give the ssh key again let me allow agent forwarding and let me browse the key okay now what i'll do is i'll just go to the session and i'm going to save it with let us say uh unix okay because every time i did not to put this host name this port and this key okay so i'm going to save this fine i'm going to click on open and now it will ask me for the login name my login name is rakash fine so now i'm authenticated okay and here if you read it it is saying authenticated with uh authenticating with public key rakash because that's what my user name is in my particular uh ssh key okay so that's how now i'm connected to unix instance via putty okay so now if you want i can close this particular uh my cloud okay i can close everything and now i can uh work on this particular unix server okay like let us say i i i do ls-l to find out all the files which are present in my particular directory i do not have any file if i try ls-a which will give my hidden file as well so you can see now i'm able to communicate basically with my unix server okay so that's what i wanted to discuss in this particular session where uh i talked about how we can connect with unix server via putty okay so what we did is we installed putty then we created uh we generated basically a public private key by using uh putty gen okay so what i did is i just click on generate okay i just clicked on generate i hovered my mouse over here so that it will generate some random key for me and it has generated some key okay so the mistake what we did first time is we uh basically we copied this key first and we copied it first and then we changed this particular name okay let us say i changed it to prakash okay if you change it this particular key is going to modify and we didn't copy this modified key and that's the reason we got that issue while connecting with your unix server okay and you can just save it and you can refer it from your putty okay so that's all i have for this video in next video i'll talk about how we can connect to the same unix server via vinnacity which is again another platform which is basically a GUI platform uh to interact with the files on your unix server okay thank you welcome back friends in this video i'll be talking on uh how to connect to unix server via vinnacity okay so in my previous videos i talked on how to create this unix instance on cloud for practice purpose and in the last video i have shown you how we can connect to that particular instance via putty okay which is the ssh client used to interact with uh a unix server securely okay so that's the putty basically it's an ssh client okay uh the another thing what we have is vinnacity okay so in this video i'll be talking on what is vinnacity and how we can download install and connect to the unix server via vinnacity okay so what is vinnacity so vinnacity uh is basically a free file transfer tool for windows that supports ftp sftp and scp okay all these are the transfer types which we will be talking in uh next few videos okay and the the basic beauty of this vinnacity is it provides the windows explorer type interface that lets you do a drag and drop of files or folders in between your local and remote machines okay uh unlike your putty which is just just like a command prompt it's not that user friendly the vinnacity is bit user friendly and it is windows style and to to transfer the file from unix to local local machine to unix or to perform edit operations or to create files and to perform many operations we will be using this vinnacity which is windows style okay so to to work with unix sorry to work with unix via putty if you are a bit experienced you will enjoy working via putty but if you are a beginner then you will find this vinnacity uh little useful for you uh you will find it more comfortable as compared to putty okay so i have to download vinnacity so to download vinnacity this is their official url vinnacity dot net i just clicked on it and it will take me to the download url okay so here i'm on the url vinnacity dot net okay here you can see it's a pre-sceptp scp s3 and ftp client for windows basically it is for windows so i'm going to download vinnacity here and yeah the download has started and fine so meanwhile it downloads we'll be running the vinnacity installer as like how our normal program we install okay so the download is completed i'm just opening install on great accept the terms you just go through the terms and click on accept and typical installation i want i'm going to use it as explorer okay because we wanted windows style i clicked on next i clicked on install and it is going to install vinnacity problem okay now it is asking me you have stored session sites and putty sss client do you want to import them into vinnacity so my particular vinnacity has already detected that you are using putty sss client and it has some sessions stored okay so if you remember i stored some sessions to it okay so if i open putty okay so you can see here i have stored some session over here this is what okay so it is asking me do you want to use that i'll click on yes go ahead and use it unix this is the one which i stored go ahead and use it so that uh great i clicked on launch now it will open okay so this is the one which i stored okay so i'm just going to click on login so the username is prakash fine and save it going to click on login fine so now you can see i am already logged in okay so okay so uh this is basically the vinnacity explorer okay and if you see if you go to the root folder you can find these mini files okay so let me go to putty and let us compare okay so now currently i am into the directory prakash okay and where is this prakash directory if i give command leg pwd that is my present working directory it is giving me the location it is present under home slash prakash so if i go to home okay and if i go to prakash that is giving me uh okay so it is showing me under prakash i have these four files one two three four okay so now i'll check the same thing over here so to check the list of file we will using will be using ls that is list but here it does not give me any list because all these four files you can see they are starting with dot that is they are hidden okay and to see the hidden files we need to use hyphen a as a parameter and if i use hyphen a as a parameter you can see now i am able to see dot sss dot profile bh bash rc and bash log out you can see again a single dot and double dot so the single dot is nothing but my current directory double dot is nothing but previous directory that's what it refers to okay now see uh this makes very simple now let us say by any chance i want to go to this ssh folder okay now you can see the difference okay so ssh is uh highlighted with different color okay and here you can see sss as a folder right so that means the files and folders are uh colored in different way okay so the folders are with blue color and your files are with white okay that that is again something you can configure later on but that's the basic thing that uh but with the color itself you can differentiate them now let us say i want to go to the ssh folder so i'll do cd we'll use cd command to change directory so i am going to sh command and again i am doing ls hyphen a to find out all the files i have so i have some file called that authorized key okay here authorized key now let us say i want to uh edit this file authorized key okay ideally we should not edit these files keys files and all but just for an example i want to edit any of the file okay so how i will do it in uh from putty i'll be doing it like cat and my file name and basically here it is the file okay so so if if you are a beginner and if you see something like that's the very first time you will get very disappointed okay but if you go to this vnscp explorer and if you go to dot ssh here you see something called authorized key and if you open this you can see you have opened it in a uh notepad and you are pretty good with this you can edit it very easily right so that's that's what it gives you the windows like structure okay and here you see only windows file okay and what is said vnscp is used to transfer the file from your local machine to uh unix server right uh now let us take an example on your unix server you want to create new file so here you can find one direct option as create new file let us give file name as file one okay and i'll give some text as text and i'm going to save it and now your file is created in the directory kakash okay so it is seeing uh it is connecting and it is uploaded hundred percent completed and you can see file is present over here right you should see the same file from putty as well let me uh so uh now i should go to my home folder okay so to go to the home directory we have one command called cd till okay i'll be talking again on that later on now if i find out the list over here list of files now we can see i have file one present over here that is what i just created okay so that's how we can use either of the way basically the vnscp is good ui and you can you can work with that very easily uh okay and one more thing okay now here on this prompt you can see only uh the unix files now if you want to see a windows file and you just want to do a drag and drop of the files you can change the mode from this setting you can go to setting you can go to interface and you can change the mode to commander okay so if i click on okay and i need to restart my vnscp let me do that now this time can you see something different did it connect okay and this time you see something different on the left side you see a files from your windows from your c draw users my name and on the right hand side you can see the files from your unix server right so now let us take an example you want to upload some files okay so let me go to my uh so some directory let me go to my g drive and let us see i want to upload this some file or i can db data okay so i'll be just doing a drag and drop over here and it is going to copy the file now you can see the file is uploaded to my unix server thing you can verify the same thing from here right can you see now that has the file oracle db dot data right on the similar line if you want to download any file you can just do a drag and drop let us say i want to download this file file one from unix server to my local i'm just doing drag and drop into my local and i should see the file as file one downloaded to my local so that's it basically it's the uh it provides you the very good ui to work with files just to transfer your files okay along with transfer it gives you the way to change the properties to edit the files to create new files to create new directories it gives you the most of the functionality with ui rather than using it on 50 okay so going forward we will be talking about both the things okay whenever we need okay so fine so that's what i wanted to show you in this video how we can connect to your unique server via vnsc okay so fine thank you hello welcome back welcome to the course of unix foretester manual unix concepts and we can automate all those manual unix concepts so that we can incorporate them into the system framework in this video i'm going to talk about how much unix is basically needed uh for being your software tester right because uh if you look out for job description for any software tester uh profile could be manual or could be automation almost all the time they do ask for uh whether you have a unix knowledge whether you have a database knowledge so these two things are almost mandatory in each and every organization if there is a at least a medium scale organization okay so it is pretty much needed okay so what and all things now see unix is very vast concept right and it's a complete operating system so now let us see what and all uh unix is needed for a software tester okay so this could be a little bit varying depending on organization to organization or project to project but most of the things which are needed for common uh manual automation tester that's what i'm going to tell you now so the very first thing is basic unix architecture uh even though this is not uh very mandatory to know uh but ideally we should know this because we should know the architecture of whatever we are going to work on if i'm going to work on unix i should know what is shell what is kernel what is uh different like uh utilities and all those top right so i should know basic architecture of unix basic unix command okay so this is the very first thing uh software testers should know what and all basic unix command we have the very first starting from ls command then we have various uh utility programs so commands are basically utility programs so we have different commands for utility programs for file comparing then we have uh some for file operations and many other stuff we have executing the shell script and many other we have right so we should know all those basic stuff uh as a basic uh windows command okay then um uh how we will be executing those commands so we will be interacting with the unit server via various tools like your putty uh to do uh any kind of these operations or we will be using vncp or any other open source tools in order to interact with the unix server for any sptp operation for file transport operations from your one server to another server or for your local machine to unix server okay so we should know this couple of tools like putty and vncp and we should know all about processes and file system basically how the file system um is designed in unix like what and all different folders we have what folder is meant for what then what are the different processes we have how to deal with processes how to trigger the processes how to stop the processes so these things we should know okay and okay and apart from that um I think everything everything will come under unix commands so like what and all daily tasks we will be doing like we will be creating a file so to create files we should know some editor like mostly people use vi editor then we will be doing some search operation into the file or we will be doing fine operation uh for the file or uh could be uh executing the shell script or changing the file permissions right so all these things comes under your file permission so that's so these are the basic things which any uh software tester should know okay so all this was the things which we do manually basically okay we go to the unix server via putty and win and then we do all these things or if I do if I want to do file transfer then I go to vncp and do a drag and roll for file transfer so that will get a work done for me now if you have a situation where you have a unix operations or unix shell script involved in your applications let us take a very simple example where you are creating a data on your web application and then you need to run you need to execute some batch job or you need to execute some shell script so that the data will get picked and it will get processed and you have something next will happen post that okay so you have something like this or you have a very simple system like uh it gets files from some some server it processes the file then it puts back the file to another server or do whatever uh the system is meant for to do okay so if you have any such a kind of situation where you want to create uh the files or you want to process the file using shell script or you want to upload the file basically to the unix server or download the files from unix server for verification or if you have any such activities uh in your test execution and if you want to automate that specific part right so that uh it will be then your complete engine automation like you will have uh automation of your ui with any tool like your selen mqtp autoscout is complete whatever tool you do is and then your remaining part of unix processes unix operation can also be automated with the help of some uh we have some external apis like jsh for java then we have another api for c sharp we have many apis in fact okay i don't recollect the name now but i'm going to tell you as a part of this course and even you can do it by creating the patch file uh using some putty tools that is what again i'm going to show you so these things uh every automation testers should know like if you're trying to automate we should know these things like how we can automate all these processes and how we can incorporate these processes into your test automation framework okay so that is what uh i think uh every software tester should know um based on like what you want to do whether you want to do a manual testing or you want to do all those you want to automate all those concepts and you want to achieve end-to-end test automation okay so that's what i wanted to talk to you like how much unix is needed for software tester again as i said there might be little changes from organization to organization or i must say from project to project but all most of the things are common um whichever the software tester should know okay so i'm going to cover all these things as a part of this course right so stay tuned keep watching this unix for tester course from start to end uh where i have covered all this manual conception how we can automate as i said uh we using various methods all this concept so that you can we can incorporate them into our test automation framework okay so stay tuned thank you back welcome to the course of unix for testers which covers all unix concepts required for testing system which continue unix operations and uh i'm going to cover in this video like how we can automate all those processes unix processes in your test automation so that we can have complete test end-to-end test automation okay so now what are the manuals and automated process in unix okay so if you're if you're working on unix you might have some systems like they just need to execute the shell script okay and based on the shell script something else is getting triggered and you want to verify again outputs of that another system or another screens let us say or you want to verify the same screen after your shell scripts has has been executed something like that or you may have something like some file processing system where you are sending files to unix server unix server is processing and then you want to verify again the file which is processed by your shell script something like that okay so whatever operations what are all operations you do in your manual process okay so you can have like you you might need to execute various unix commands manually like changing the directory go to this particular directory then load the file into that specific directory or download from that specific directory or even execute the shell scripts manually okay so so to do all these operations what we do is we basically use some SSH clients like putty or um any any other SSH clients are to do ftp operations file transfer operations we use venuscp okay so for manual process we use these couple of tools okay so these are so these are some manual processes basically which we used whenever we have some unix operation in our end-to-end testing process now let us say i want to automate the complete process let us say i have some web application where i'm i'm i'm putting up some data and based on that data as soon as i hit enter or something like or i fit the data then i want to trigger that particular script then it will generate some file for me let us say text file for me and i want to verify the text file or as soon as the script gets triggered it it is going to update some uh screens and i want to verify those screens something like that it can be anything okay so basically you have some SSH operations which we perform SSH operations and some ftp operations if you have anything in your manual process then we can automate them okay so we all know we can use selenium for performing test automation of your web applications and even if you have some operations like you if you want to deal with excel if you want to deal with text files or even if you want to deal with uh sub PDF files or maybe some uh what i can say anything okay so basically what i wanted to say is basically Java is compatible with most of the things and you can find libraries for most of the things like so we cannot say like okay i cannot uh i cannot integrate the automation of putty or let us say um phoenix server whatever i'm doing on unix server i cannot automate those things and uh combine them with my selenium test automation framework that's not the case we can definitely do that and it will work very much perfectly okay so uh whatever manual processes i just talked over here or there can be any other manual processes your project specific might be great so all those unix processes can be automated with the help of uh any ssh client library okay so basically we there are many ssh client libraries uh which are specific to your languages like for java there is some set of libraries for if you're in c shop there is some set of libraries which uh which helps you to interact with your unix server via ssh okay so by using these libraries okay so in this uh for this course i'm going to use java and in java there is some library called as jsh in java basically there are four to five libraries but but this jsh is one of the best library and the famous one so i have picked it so i can use that library in order to automate all these processes okay so uh yeah so that's what so in this video that's what i wanted to tell you like we have some manual processes and how we can automate those manual processes using uh some um like by by writing some automation code with the help of ssh client libraries okay so hello welcome back welcome to the course of unix for testers manual and automated concepts which can be incorporated in your test automation framework in this video i'm going to show you how we can use vi editor basically uh in your unix or linux environment to edit uh text files okay so uh now uh let us say if i'm into my unix box and if i do ls i can see i have many files okay now let us see if i want to view the data from one of my file let us say from input file dot txt how we can get the data so if i just want to view the data i can simply display it okay like by using cat command cap input file dot txt and it will display the content of my file okay so these are the data of my file but now what if i want to uh edit the data or i want to make some uh changes or add some data or delete some data how i can do that so this is something basically i can do with vi editor okay so vi there are many ways in fact how i can edit the file in unix or linux but the best way is uh uh using a screen oriented text editor which is my vi editor there is another advanced form of vi editor which is vi m which is vi uh in fact a improved version of vi editor uh but we prefer generally vi okay and white is uh like preferred more because uh it is uh you know available across all versions all flavors of unique systems and their simply implementation is uh a bit simpler and it requires very uh few resources to conserve it is pretty faster compared to other uh editors okay now uh okay let's see how we can use vi editors now okay now let us say i want to edit the data from this input file okay so how i will use it i will use vi space my file name so my file name is input file dot txt okay so if i simply hit enter you can see uh my data is getting displayed okay and you at the end of the file you can see killed icon and at the bottom you can see something my file name and at some it shows you some information your OS and all and it has six lines and 176 characters and my current position and all those things okay so in this video i'll be showing you how we can basically create the file how we can edit the file and how we can do any or any kind of operations with the data into the file okay uh so this is how basically you can uh open the file uh in order to work on it now let me close the file how we can close it simply you can uh hit escape okay basically uh you need you can hit escape and it will get converted into command mode whenever it is covered so now what is this insert mode and command mode okay so now whenever by default you open any file it will get opened into command mode that is you cannot write anything in it because it is not in insert mode and now how to make your file into insert mode you need to simply hit um i button or i key from your keyboard and you will see the at the bottom you can see the mode has been changed into insert okay so you need to press i okay i as an insert now my uh file is an insert mode so i can insert any data now i'm good to write some data in it let us say this is modified data something like i can write anything i can write new line inserted whatever it is okay and now what i want what i want to save the data basically okay so how i can do that so now my file is currently in insert mode and now i want to make it to command mode in order to execute my command by using which i can save my file okay so to change the mode basically i'll be using escape key okay so i need to hit escape key couple of times and now i'm good to save my uh file so to save the file what command i need to use i need to use colon and w which will save my file okay so there are basically uh let me go to my text pad and let me show you okay so basically whenever you want to write any command it will start with colon okay and after colon if i write w that means you want to write the file that means save file okay save the content save the file content okay if i use colon q okay this means quit the file without saving the file content or if i use something like this this means save and quit okay so now what i want to do is i want to basically save and quit so what i'll be using is w for write and q for quit so w and q okay so you can see uh the whatever i'm typing it is getting typed at the bottom okay so that is basically a command line okay so now if i see the data so if i see the data using cat command now you should see the data which i have inserted this is modified data and the new line is inserted something like that right so this is how basically you can open the file so you can open the file using vi space your file name okay now i'll show you how we can open the file in to read only mode so if you use hyphen r as one of the option hyphen uppercase r followed by your file name this will basically opens the file in read only mode and how i'll get to know if my file is in read only mode this okay now okay how i will get to know i'll just hit i for insert mode and you can see you are changing a read only file that means the file is in read only mode right so it is not basically allowing me to uh do the insertions okay so let me quit okay so by using again by using command um colon q i use colon q to quit my file which was in read only mode okay there is another way how you can view your file so by using one of the command called us view and followed by your file name okay this will again open your file in uh read only mode okay by using new command so we three ways vi space your file name vi space hyphen r for to to open your file in read only mode followed by file name vi space of your file name to open your file now as i told we have basically two modes the first one is command mode and the second one is basically insert mode okay so basically your command mode enables you to perform your administrative tasks such as saving the files or executing commands or moving the cursor cursor here and they're cutting or bring copy paste into the file and all those kind of stuff okay so that that is something which you can do in your command mode now your insert mode is used to write the data okay this modes basically enables you to insert text into the file okay so that's what i'm going to show you now okay so okay so let me open one of the file now so how will open the file i'll open the file by using vi and this time i'm going to open the file called as sample data dot txt okay so this is my file and it's a little bit okay now okay so this is my file now in this file if i want to move then i can use basically the key my keyboard key up and down left and right key i can use to move my cursor but the standard keys provided by the vi editor to move up down and left right r k j h and l okay so basically we'll see how we can use those keys okay so this k key is basically used to move one line up okay j key is used to one line down something like this l key is used to move right h key is used to move to left like how we use the same keys in our gaming okay so in the similar line these are the standard keys which are suggested by this vi guys okay so we can use h to move left l to move right and k to move up and j to move down okay so these are the standard keys but anyways you can use your keyboard up and down keys which which i which i prefer them for you okay now you need to note couple of things like vi editor is a case sensitive okay so you need to pay special attention to capitalization whenever you're using your command okay fine as well you know as i said we will be using let us say l to move my key to right hand side but now what if i want to move like i want to move nine by two left or five by two left then i can use something like for you l i will get moved to five times into l i'll again use two l i'll get moved to two positions right or if i use something like eight h okay i'll get moved to eight by left so right so that means most of the vi command can be prefaced with the number of time that you want to take that particular action to occur okay now let's see a few more things few more commands basically okay so let us say if you want to move to beginning of the line okay now let us say i'm over here and you want to move to beginning of the file so as i said you can use number of times into h to move to left left hand side but in that case i need to count how many positions i'm here on but if you want to move to start of the line then you can just hit e zero you will be getting to start of the line right so you can use e zero okay then now what if you want to move to end of the file you can use symbol dollar you will get to end of the file okay dollar is to move to end of the line okay and likewise we have something like let me go here okay now let us say if you want to go one word forward like from this exclamation if you want to go to mark then you can use the blue key you will get one word forward okay so you can use basically the blue key and to move backward again you can use d key okay you will get one word back you can go back word by word so you can hit d key now you need to remember that i'm hitting all these keys whatever keys i am saying so these keys will work when you are in command mode only right because you don't see insert symbol over here that means you are in command mode and then only the commands are working so you need to make sure that you are in command mode okay okay so these are the keys which we generally use and okay now what if you want to move to uh last line of the file okay so to move to last line of the file we have some command called as g which is in uppercase okay so if i hit uppercase g i you can see i got navigated to my end of the file okay and on the similar line if i hit capital h i should get into uh so this edge uh yeah so this edge key is basically used to move to top of the screen okay and again this can be uh suffix sorry prefaced with number of count basically how many number of times you want to move this particular command up and down okay and if you want to go to middle of screen you can use key m in uppercase okay and yeah so there are many many commands like that maybe you can toss the manual but these are some generally used key to move to start to move to bottom to move one word forward one word and there are some keys like if you want to move to next paragraph they can then you can use open interlip raise close interlip raise something like that okay they work okay uh now you can see uh my file is a little bigger right my file has uh i need to scroll down and up to see the data okay so here i'm i'm just using my mouse cursor to move up and down okay it works but what if you want to uh go screen by screen okay so to go screen by screen there are some option i think i have noted over here to go screen by screen yeah so if you use control d you will be moved forward one and half screen okay so i'll just use control d you can see i am moving to down with half screen okay so control d is is basically used to move uh forward direction one and half screen okay and if you want to move full screen forward then you can use control to move backward by half screen you can use control use so i'm just doing control u you can see i'm getting back with half screen. okay if you want to move forward you can use control F, basically okay you will move to forward with full screen if you want to move back with full screen you can use control B. you can see i'm navigating basically up and down using these so you can use this ctrl d and ctrl f to move forward and ctrl u and ctrl b to move backward okay so this upscrin u and fullscreen b okay and if you want to move single line then you can use this ctrl e and ctrl i normally these are the commands basically but since this mouse scrolling works i do not use this basically but these are the keys which works with your unit's terminal okay fine what else now editing i have already told you okay let me show you how we can edit the file now my file is in view mode okay sorry command mode okay now what if i need to change the mode i want to edit the file then i can hit down e i right now you can see it is into insert mode i okay now there are some again there are some commands which can be used let let us say if you want to insert text before some line or after some line or if you want to insert some line so let us say i want to enter new line at this position okay let me click here and let us say i want to insert new line at this position then i can use give me a second okay so basically i can use a to insert a text after my current cursor location or i can use capital a to insert a text at the end of current line okay but for this i need to be in my command mode and now you can see i am into insert mode now how to switch mode i need to hit a skip key couple of times and my mode will be shifted okay now let us say if you want to insert a text after the your current line then i'll use capital a and you can see i got at the end of the line and my mode got changed into insert right so that i can hit enter and i can write some data over here right so what it is i used key which is capital a uppercase a which was used to insert at the current line now what if you want to insert at the current cursor location you can use a right so what i mean current cursor location now currently my file is in command mode because you don't see insert over here now let us say i clicked on this queue now let us say if you want to insert at this queue at after this queue okay where my where i currently clicked on we can hit lowercase a and you can see now my mode has been changed into insert and my cursor is just after queue and i can type some data to it so what i use i use lowercase a okay uh likewise we have uppercase o okay so it used to create a new line uh let us see how it works let me change my mode okay and if i hit my uppercase o now you can see i got internet if i use lowercase o okay you can see uh sorry for uppercase o you can see it has just created a new line form here right so what i use uppercase o okay and i can use lowercase o to create a new line for a text entry below cursor location right so this uh oe is used to create a line above cursor position and lowercase is used to create a line below cursor position okay now if i uh let us say if i want to create a new line after just below this division sign i can use a small o it will sorry i should be in insert mode sorry command mode i will just hit o now and you can see a new line has been created just below division sign because i entered lowercase o which is used to uh create a new line below okay uh what else okay so this basically this vi editor is quite a bigger concept there are many commands which we can use uh now let me okay and uh let us see uh how you can delete the complete line so again to use command you should not be in insert mode currently i'm in insert mode let me get out of it and to delete any uh line you will be using double d okay so let us say i want to delete this blank line how are we doing that just hit double d it will delete the file i want to delete this double d but it is blank line delete double d let us say i want to delete this 73rd record hit double d your 73rd record will get deleted can you see yes okay so you can use basically double d in lowercase to delete the line where your cursor is on okay now okay now let us see if you want to do copy paste of some lines let us say i want to copy this line number 72 and i want to paste it uh after last line okay so how i can do that so you need to click on the line which you want to copy and then you need to use command double y in lowercase so that it will copy the content now i just click double y so that it will copy my content right now what i need to do is i need to use p okay i need to use p uh where you want to uh paste my content so let us say i want to paste my content after this tilled so or let us say after this uh after whatever it is so i'll hit p over here and you can see my line has been paste over here so this is basically how you can do copy paste so double sorry double d is to delete double y is to copy and p is to paste okay and what else what else i am remembering with uh okay uh now uh let us see how we can perform a search okay so let us say if you want to perform something into the file okay so to to search basically we have two commands first one is hash and next one is your colon so your question mark okay so we use this slash if you want to search in forward direction okay so this slash is basically used to start in forward direction and question mark is basically used to search in backward direction okay so let us see how we can use this uh forward direction and backward direction so now let us say in this file okay I want to search something like okay let us say I want to search three okay how I can do that so now I'm into the command command mode again because I don't see any insert over here so I'll just hit my slash okay you can see slash is at the bottom and I'll type what I want to search I want to search for three okay and you can see three is getting highlighted okay but I could have many number of words which contain these three or I could have many number of matching to this particular pattern so how I can use them okay so to use that I need to use sorry to use that I need to use something called as n or capital N okay now how how to use this n so now if you want to find our next matching the next fields matching to this particular pattern you need to hit escape okay and you need to hit now lowercase n so that it will search in forward direction okay now can you see it has highlighted three it has highlighted three it has highlighted three I'm just pressing lowercase n so that it is pointing me to all three and here you can see search hit bottom continue at the top so that it has searched from all top to bottom okay and this lowercase n is to do the backward search okay so if I use uppercase n you can see I should be getting it is doing search from bottom to top okay likewise if I use question mark okay and if I search again okay so again it is doing a search okay and I can use an uppercase and a lowercase n so the difference is by using slash you will do forward search by using question mark you will do backward search and if you want to match in patterns you can use small n to find out to go basically in forward direction and uppercase to go in basically in backward direction okay what else okay and one last thing I want to show you is okay so this search or even in fact Unix itself is case sensitive right so what if you want to ignore case when searching okay so to ignore search case when searching what you need to do is you need to set some command okay so what you need to do is you need to set an IC sorry IC right so what it will do is it will ignore case IC stands for ignore case so you are basically setting ignore case for particular file open instance okay so if I use something set IC okay and if I use now three can you see I have typed three in lowercase but it is giving match main uppercase right so this is basically how it works to set something okay now let us see if I want to unset it so how I can use it I can use colon set and I can use no IC and now if I type it three in lowercase it is not giving me any match because I didn't set to ignore the case so basically what I can you use is to unset basically I can use set no IC that is no ignore case okay to set set IC and to ignore to reset basically no IC right no okay and okay so there are like multiple commands like this let us say if you want to see the line numbers on the left then what you can do is basically you can use command like you can use command like set and you or NUMER basically it will create a line number to your left okay so you can see this is the line number has been created okay if you want to answer can use set and oh and you that is set no number okay so this is how basically you can use the set command okay so that's pretty much what I wanted to talk you now let us see whatever I wanted to talk whether I have covered it or not we have used fine replace save fit in modes basically insert and edit and we talk various commands and search and fine so I think I have covered most of the things whatever I wanted to talk about this via editor okay so again you can use basically all the commands let me quit okay now here you can see I just use a quit command like this okay to quit my file but it is saying no right since last chain would you also it is giving me some warning basically and if I overwrite this warning I need to use this exclamatory okay so how I will do that colon Q exclamatory it will quit without any warning and I should see my main terminal now we did all these things by using VA now I said VIM is improved via editor so you you are good to use all the commands all the things which I just talk by using VIM so if I use something like VIM sample data okay you can see again the same things okay so basically you can use all these things all the command whatever we just saw in VIM editor as well in fact in most almost all the data set support okay so that's it I have about this via editor in Unix okay so thank you hello welcome back let us talk about Unix directories okay so basically we are talking about file types okay so we all know that file is collection of some information and is stored at some physical location basically into your hard disk and it is identified with some Unix Unix name okay so Unix operating system basically understand three different types of files okay so the very first one is your ordinary files or your regular file okay so basically these are your ASCII files okay so these are the most common type of files found in most of the system in your Windows in Linux in Mac in any kind of operating system we have these ordinary files so these you may treat it as your plain text file or your document file or PDF file okay or it can be your any executables or source code files right so basically it is a sequence of characters and bytes okay so to the to the Unix system there is no difference in between the text file and a binary files both are the streams of bytes divided into blocks right so that's what your ordinary or regular files are okay and if you go to your directories structure okay if I go to the root folder okay and at most of the places in my earlier video I talked about this direct list of what is most of the directories content okay so if I want to store the files my project specific files I go and store it in my home okay and if there are any executables or compiles or code then those are presented to this bin folder right so all my files all my basically all my ASCII files which I can read or even the binary files or any executables all comes under ordinary and regular file so basically we should understand that Unix system is all about files and processes okay so processes is nothing but different kind of past which operating system performs okay so as a user you can create your own shell script and execute or your Unix operating system or Unix or Linux whatever you say they have given their inbuilt program like whenever I do LS to get the list of files that's a basically one process one command right so when I hit that command some process get triggers in whatever background or foreground right so that is about process we'll be talking about processes in detail and the second one is about files right so Unix is all about processes and files so there are three types of files the first one is your ordinary and regular file which we just talked right and the second one is directories okay so directory is nothing but your in terminology it is your folder okay which contains number of files okay so basically a directory is a special type of file in fact it is a file of files okay so this type of file does not contain any text or executable program but it contains a list of file names because my directory will contain some files right so directory is nothing but it is special type of file which contain list of files because as I said in Unix terminology everything is about file and processes so directories again a type of file special type of file which store your list of the files which are in that particular directory okay and it also store the information like location on the storage device then what is size of that file who is owner of that particular file so all this information is stored in this particular special file type called as directory in short it is your folder and the very third type is your spatial file internal representation of physical devices a keyboard printer and terminal okay so there could be a number of input and output devices to my operating system right so the operating system provides you the standard interface between the hardware like your could be any your i o devices like this printer and your operating system okay so this device or a special files which basically contains the information about all these mapping information about your external devices and all this information is stored in some kind of file which is called a special file okay and if you go to your directory structure and if you go to the dev I mean to the root folder root location and if you go to the dev so basically it contains all your device files okay so that can be your any i o devices which are connected to which are connected to your particular units oh yes okay so that's what your three different types of files are ordinary files or regular files or your ASCII files which are my plain text files or could be my binary executables or could be my source codes could be anything which I can directories is nothing but list of files it is a special type of file which contains a list of files in short it is a folder and special files used to store all your device information i o device information so that's what these are the three types of files in units okay so yeah that's it thank you hello there welcome back let us try and understand unix directories now okay so let us talk about Unix file system okay so if you go to your putty okay and if you go to my whole directory let us check where I'm currently okay let me go to my root directory okay so I need to go to three steps back okay and now you can see I am present I am currently in my root directory okay so if I hit now ls command over here it will give me the list of all the files whatever what and all I have okay if I do ls-1a okay it will give me the all my hidden files as well hidden files and folders as well okay now what and all these files and folders are okay so that's what I'm going to talk in this video that is the word all about your Unix file system okay so the very first thing is your root directory okay so this slash is nothing but your root directory right so if I do pwt and if I see a slash that means I'm into the root directory so whatever whatever all directories whatever I have all my application all my data all like all the software components everything is present in my root directory right so everything is under my root directory okay or better what I can do is I can go to my vncp and here I can show you a file structure you can see it in a better way right so I just clicked on root okay and in the root you can see I have these many number of files okay sorry folders okay and in this folders each folder is specifically mean for some purpose okay that's what we are going to talk now we are not going to talk in much details okay because it's a huge right that's the those are the complete operating system concept that is something which we don't want okay we just want the folders which we will be dealing with and some important folders okay so let us talk about that the root directory everything is presented under your root directory the next one is your binary directories okay so binary directories are the directories which contains your executables like you see you have some pin directory or yes pin so if you go here you see you see some pin directory so if I open this pin directory you can see all the executables under this pin directory okay so let us take an example what and all we used okay so let us say we use this pwd command right so for us it is a command but for unix it is a executable right it is a application right so this pwd if I try and open I may not be able to read its content let us check if I can open it yes I can open but I am not able to read it because it is a executable file right so basically it is a bin file a bin folder basically contains all your executables okay and we have another one called sbin okay it is again it contains your executables only but the difference in between your bin folder and yes bin folder is bin folder contains the executable for your account as well as for your system whereas this executables for sorry there has been folder contents executables for your systems which can be used for with root privileges okay that's what this binary directories basically contains all your executable directories okay executable directories is nothing but your compile source code next next one is configuration directories okay so this configuration directories contains your all configuration files which are required for your system for example etc or root okay so if you remember we navigated to this etc folder let me go to root and okay let me go to etc as I said it contains the configuration files okay so if you remember in etc folder I went to the ssh and then here I saw I have shown you that we have some keys okay we have some public keys we have some private keys all the keys are present in this specific directories which are used to establish the ssh connection okay so that's what is present under your etc directory not only that but we have all the system configurations fine and the similar thing we have it in a boot directory as well okay so if I go to root give me a second here okay so this boot directory again contains some file but I should not touch the files from this directory because it contains the bootloader files what it means from the name it suggests used for booting my system okay so in other words it's like the only content of the file which are needed for basically in a system or basically in a system to get up and keep it going right I should not touch them so basically it contains all my files which are required to start up and to run my system right so that's what about my bin and etc folder which are my configuration directories okay what next I have I have the data directories right so data directories is something where I should put my data okay so normally when do we put our data so we go to home directory and we go to our specific user account and here we create all our data that could be your shell script that could be your files or could be anything any kind of data okay so in the home directory we use to store our data again there is something called as root folder as well remember this root and this root folder both are different okay so we can even use this root folder but it can be used only with root privileges that is your system admin privileges I'm not able to use it so I'm getting access fine what next I have a memory directories okay so so basically your memory directory contains the files of your whole system right so it contains basically all the information is contained in this dev folder proc folder system folder so here this dev folder stores the all the device information this proc folder store all the processing information and this sys all the files which are related to systems okay again this is something which are which we are not supposed to touch okay these are again some system related file device related processing related system related we are not supposed to test them next we have is user so this from the name it sounds like this could be user data but this user stands for unix system resources okay and the data is present in user slash bin and user slash lib if you go to the path variable in path variable you will see this unix system resources and it contains the read only data okay which is used by linux system it contains basically all the libraries which are used by unix systems again we are not supposed to touch them next we have is a variable directory so from the name we can see a var directory okay so whatever files i'm talking about all files are present over here like you can see proc you can see system you can see user you can see how that is your variable directory okay so in variable directory you can put basically the files from the name it's just like all the variable length file or variable size files okay so it's like the files where for which we are not sure about its size okay so that could be let us say your logs file or small file or your cache files we're not sure about their length right or size right it keeps increasing or we may delete it in our process somewhere right so all those unexpected size files are stored into this variable directory that is in var log and var caching okay so you can see caching and log code so while designing our system we should design in a such a way fine so these are your variable directory so that's what these are all the important directories which we deal with most of the time root directory binary directories where all our executables are then we deal with the data directory where we keep all our data is and all our configuration directories configuration files are present in this etc file then memory directories we are not supposed to pass them then we have a unique system resources again we are not supposed to pass them and variable directory is something which we should use for variable size file okay so that's what basically the important directories which we will be dealing with in unix file system okay so in unix file system you have this again some media law stand found so all these are what i can say uh non-standard directories okay so uh we are not dealing with them fine so that's all i have for this video where we talked about this important directories in unix file thank you hello there welcome back welcome to the course of unix foretester which covers all unix concepts required for testing a system with 10 unix operation and how can we automate them in order to use them into our test automation framework so uh in this video i'm going to talk on various unix commands which are required for software test okay so uh very firstly i'll be talking on unix directive command the commands which we will be using whenever we deal with direct trees okay direct trees there's nothing but kind of folders okay so in our uh let us see windows where's uh if if i group some files and put in some location we call it as a folder whereas in unix terminology uh they treat it as directive okay so before i begin let me connect to my unix instance so i would be so my unix instance is uh here located at this host ip and i'm going to connect it and i'm going to log in it as my username okay the authentication is based on some public key which i have already supplied to my unix server as well and to my sss client that is putty okay so now i'm connected to my putty and let us see um which which is the first command which we will be talking so the very first thing is pwd okay so this pwd stands for print working directory on the terminal okay so mostly people uh term it as present working directory but it is print working directory okay now let us say i have logged into my unix terminal and now i want to see what is my current location where i am in which directory i am currently okay so that's what this command will do print working directory print working directory where i'm currently in okay so if i hit enter it gives me some location that is home slash raka okay so this is the directory where i am in currently so whenever you log in with some uh username by default you will get logged into your folder okay under home and your account name so this is my present working directory what next next one is ls okay which is used to list the content of your directory okay so let us see if i hit enter if i hit ls so it gives me some list of okay so you can see i have multiple files file one hello file input file or ldb output file and script.sh so i have many files into my uh this particular location where i am currently in so this ls is basically to list out all the uh directory contents okay but it does not uh list all the contents in fact so it does not include the hidden files okay so if i want to use hidden files then i need to give something like ls-a so that it will include my hidden files as well so here you can see now it has included some files some files and folders which are starting with dot okay so the very first thing you see dot then dot bas directory dot bas rc then you can see dot profile dot ssh and some command some uh files or some folders which are starting with dot basically they are the hidden ones okay so this iphone a parameter we will be using along with ls in order to get them fine now i got the files and folders whatever i have but if i want to get uh a little more details about them then we have some command uh in fact some parameter uh along with this ls so if i use ls-l okay so basically it will give me all the list of all the files with little details like it gives me some here you see some rwdx and also we'll be talking about these things uh in our coming few videos then you see some uh group id and user id then you see some add date size and finally the file and folder name okay so fine so here i can see a little details about my all the directory content when i use option hyphen l okay now if i want to check the contents of the details of my hidden files then i will be i'll be combining two parameters actually so in order to get uh my hidden files i'll be using hyphen a and in in order to get them fit details i'll be using l so if i type ls hyphen al i should get the details of all the files which includes my hidden files as well so that's basically uh uh what we can do by using command ls okay and what else uh fine fine uh we'll be talking uh again if we get any more command whenever we work on it that's fine but this is fine for as of now now let's see uh what is td okay so this td stands for change directory okay now as i have shown you if i do my pwd that is my print working directory i am currently into this directory okay but now let us say if i want to uh go to this hello file directory okay so this hello file is my directory and all these are my files okay and how i got to know this because if i see the details over here so the very first starting point you see over here is d so this d stands for directory okay and from that i can say okay this hello file is my directory that is you can treat it as a folder and all others are my files okay now let us say i want to navigate to this particular folder which is hello file okay in that case i will be using command cd that is change directory okay so if i do cd and then i need to do the directory where i want to go in so i'll type hello file okay and now you can see and now if i check what is my print working directory now you can say it is home slash precast slash hello file okay and if i want to check what are the contents of this hello file you see uh it has not listed anything that means this hello file folder is empty that's fine now what i want to do is i want to return back to my home folder okay so a couple of ways what i can do is i can use cd and then i can use dot dot so this double dot uh cd paste double dot and this double dot uh specifies that you want to go to previous directory okay so if i do cd dot dot and if i take my print working directory now you can see i'm navigated back to my home folder okay uh let me tell you one more thing now let us say i want to switch to this hello folder again so i'll do cd and if i do type he okay and if i type tab okay you can see it is typing it is completing the name whatever it is file or folder whatever it is it is uh the autocomplete right so that's basically do we do it with that okay so let us say if i just type h and if i do tab now you can see it is giving me the file name but because why because uh in this particular directory i have all these files and the files which are starting with h there is only single file right so even if i type h it will give me and if i hit tab it will give me that particular autocomplete but if i use uh o okay let us say if i want to go to this output file anyway this is not a directory these are both of the files but let us say uh if i want to go to this output file okay and if i use o and tab right it will take me to the okay uh since it is case sensitive it will not work let us let us do that uh sometime later fine so now i'll go to this hello file directory okay now again if i do my print working directory i'm navigated to hello file directory now if i want to come back to my home directory i can do cd dot dot else i can use field sign okay so if i use pd tilled it will take me back to my home directory if i do my print working directory and you can see and i will get it back to my home directory right what i use i use tilled it is used to navigate to your home directory okay again you can use pd dot dot to go to uh one step back okay so uh you need to remember in your next dot refers to the present working directory and double dot refers to previous directory one step back okay so okay so that's what basically cd is about change working directory okay let us say if you want to change your directory let us say i want to go to the root directory okay so what is the root directory basically so uh let me do cd dot dot again now if i do my print working directory i'm into the home folder let me do again cd dot dot and now if i do my print working directory and you can see only flash okay so this is basically your root directory that is the starting point of your system okay that that is your root directory okay now let us say from this root directory you want to go to your home okay you want to go to your home and in home you want to go to uh directory called this prakash then you can type your command that like directly like this pd home slash prakash okay and you will be get to your home folder right you can type like this let us say if you want to go to two steps back okay so how you can do that you can type cd dot dot like it will take you one step back and if i type again uh followed by double dot it's two steps back right if i type pwd now you can see it is my root directory okay so you can see i use cd till it has taken me to my home directory so that was pretty much about cd now let us talk a little bit about mkdir so the name suggests it is make directory okay so let us say in my home directory i want to make some folder i want to create some folders okay so i can use command mkdir okay followed by directory name okay or even you can give directory path okay so let us say i want to create a folder or i'll call it as a directory one okay and if i check list of my list of content for this particular directory my home location you can see dir1 got created okay now let us say i'll switch to this newly created location that is dir1 and i'll list the content obviously it is empty because i do not have anything over there great fine uh okay so that's how we can create a new directory or let us say i want to make another directory over here mkdir and let us say i want to or let us go one step back okay now let us say i want to create a new directory within this dir one okay so i'll use mkdir and in mkdir i want to first list to dir1 and in dir1 i want to create a sub directory sub dir okay so okay so it has created okay so now if i list this to dir1 or in fact i can go directly to dir1 slash sub dir okay give me a second cd slash dir1 slash sub dir okay what has happened let us go and check so what is my present working directory my present working directory is my home directory now in my home directory i need i want to change my directory to cd dot dir1 and if i check the content of my dir1 you can see you have sqp dir1 so that is your directory is created within this dir one okay i can again uh go to my sub directory one fine i am there and if i want to switch back to my home directory again cd it will take me back to my directory next what i have i have rmdir that is directory okay so mkdir is to make the directory to create the directory to create a folder rm directory is to remove the directory to delete your directory to delete your folder okay so i'll use rmdir okay followed by uh my folder which i want to delete so let us say i want to delete dir1 okay and it is saying directory is not empty okay because in that particular directory i have another directory fine let us switch to uh that particular directory and in that directory i have another directory sub dir let us try and delete that okay so how i'm going to delete it rmdir and followed by sub dir and if i hit enter i should see i don't see any error message that means it is got deleted and if i see list of files now you see nothing is there fine that means particular directory has been deleted with the command rmdir but this rmdir is used to remove the directory to delete the directory if it is empty that's the constraint okay if it is not empty then we need to delete it recursively okay and to delete that okay before i delete that let me create one directory because currently i am in dir1 and i'm trying to delete i'll try to delete this dir1 recursively so uh so in order to use recursively my directory should have some content in it okay either directory or file whatever it is so i'll make one directory here uh called sub fine so now if i go back okay or let me check my content now if i do ls you can see my dir1 has some directory in it fine let me go back okay now uh if i type rmdir and if i try and delete dir1 you can see it is giving me the error because the directory is not empty that's fine that we saw earlier as well so i need to delete it recursively okay so i'll type command as rm to remove type one r is to delete the directory or to file recursively and then followed by my directory name uh what is my directory name it is dir1 fine now if i hit enter now i should see i do not see an error method that means my directory got deleted if i now i do not see any directory called as dir1 so that means my directory got removed but to remove the directory we cannot use this rmdir command directly if directory is not empty so we need to delete the directory recursively by using uh hyphen or option with rm which is used to remove your file so this rm command basically used to remove your files okay uh but if we use it with hyphen r and then folder name it will work to remove your directory even if it has some content in it uh okay so this was basically uh all about unix directory commands okay so we talked about pwd which is print working directory which gives me the location where i'm currently in then we talked about ls to give the list of all the files and folders then couple of options along with ls that is hyphen a to get my hidden folders hyphen l to get uh little details again you can use hyphen ltr to get it more details you can use hyphen f as well hyphen p as well we'll talk about those things whenever it comes in our picture then we talked about cd that is change directory if you want to navigate from one directory into another directory again there is some concept called as absolute path and relative path we will be talking about those things later on okay uh then mkdi is to create the directory rmdi is to remove the directory okay so that's it for this video in my next video i'll talk about uh some special characters and how we can use those special characters along with the commands which we just talked on thank you hello welcome back welcome to the course of unix for test manual and automated for selenium in this video i'm going to talk on unix file commands okay so uh as i said unix is all about files and processes so file commands are pretty much important in unix okay so let us see what and all important file commands we have in unix okay so the very first unix command is for file is touch okay so this touch uh unix command is basically used to create the file create new file okay so if you go to your winsep okay in winsep you can find the option to create new file here itself okay so here we do have some option we never did yeah here it is create new file or create new directory or create new link so if i click on file it will create new file for me but that's not the way how we do it okay so i'll go to my putty okay and inputty as i said we'll be using touch command to uch touch followed by file name let us i want to create some file uh with name file one dot txt so this is my file which i want to create okay so uh touch space file names okay so if i do ls now i should see file one dot txt should be created okay so here it is file one dot txt so this particular file is created okay now by using this touch command you can create again multiple files so we just need to use some multiple file name followed by space uh let us say i want to create two files file two dot text and file three dot txt okay so if i hit enter it should have created two files for me now can you see file one dot txt was my previous one and file two dot txt and file three dot txt created by using this another touch command come by only okay so that's what basically your touch command is about that's that is used to create your files next is cat command okay so this cat command is basically used uh to display the file content onto your screen okay so now uh just file one dot txt or file two or any file whatever i just created are my empty file are a blank file okay so if i do cat to display the content of file one dot txt it will not uh give me anything because it is blank okay now how can i add content to that specific file okay so i can use option vi that is for vi editor okay so i'll be talking about vi editor in sometime later uh we have a couple of videos for vi editor as well so talk about vi editor in detail so for now you can say like if i want to add uh edit or add content to any file i'll be using vi editor there are again multiple editors nano editors and some defaults editor i prefer a vi editor okay so i'll give vi space file one dot txt so that it will open file one uh to enter me some data okay uh let me enter some data i'll enter some data give me a second it is an insert mode record one give me a second i'm just trying to add some records okay now let us say i have added sufficient data okay so these are some records in my file which i want to process let us say okay now i have added sufficient data now i want to now you can see uh something insert over here okay anyway we will be talking about all this thing in our vi editor videos uh so you can see that it is an insert mode so in order to save this file i should insert mode so you can hit escape key so that uh it will move into your command mode okay now i need to give some command okay so i'll give command to save and quit okay right and quit so that my file is saved now now my file one will have some data so now if i do cat dot file one okay cat file one dot txt this time i should see all the data whatever my file add okay so that's what basically cat command is used to display the file content onto the screen okay now next one is rm is used to remove your files okay uh you can again have like remove multiple files or single files so let us say if i do ls now i have some file one file two file three so my file one has data i'm not going to remove my file one but i can remove file two dot txt so if i hit uh enter and if i do ls now i do not see my file two over here right so basically this rm command is used to remove your files okay and there are some options like you can use hyphen uh add option in order to delete your files recursively or you can even use hyphen i uh rm hyphen i so that it will be for user confirmation like let us say i have file three to delete okay so it will ask it will ask me for my confirmation okay now can you see remove regular empty file file two dot txt i'll give yes now my file should have been removed okay now my file is removed now i have only file one dot txt that's fine so rm is basically used to remove your files and as i said there are two options which i can use with hyphen r to do the operations recursively uh that is remove operations and i to query user for confirmation next i have a cp cp command is basically used to copy the files okay i can copy the files from one directory to another directory that is my source file path to my destination file path okay now let us say uh okay so if we check ls hyphen l okay so here my dir one is my directory okay so you can see dir one is my directory now what i want to do is i want to copy this file one from my home location to dir one directory okay so that's i can do with cp okay so i'll do something like cp and i want to copy file one dot txt two where i want to move it to or copy to dir one slash file one dot txt okay so it's asking me cannot create a regular file dir one okay now it should have been copied okay now what i'll do is i'll switch to dir one and i'll just distort the content and if i check this content of file one now i believe this file one was there earlier as well but if i check the content i can get the file one is the latest one or the older one okay now can you see the content or whatever i had added so that means the my file is copied from one directory into another uh so in copy as well you can have hyphen or option to copy the file recursively uh mv okay so the next command is mv uh is to move or even we can do rename as well so let us say let me go back to my directory and if i do ls now you can see i have file one okay so let us say i want to move this file one so earlier we did a copy right copy from one directory into another directory but now in case let us say i want to move this file from one directory so i want to move file one dot txt to dir one i'll move it to dir one slash file nine dot txt let us say this time i'll give file nine dot txt and if i switch to or let us say the content over here now here i do not see in my current directory i do not see anything called as file one because i use mv command which is to move okay and i move dir one directory let me switch to dir one and if i do ls now i should see something called as file nine dot txt which is uh moved from my home directory right so that's how we use mv command again with this mv command you can use user confirmation with hyphen i option uh what next okay and and actually knew how we can rename as well right so whenever you move the file it will you can you can keep the same name or you can rename it right so you you can see like earlier the name was where it is file one dot txt and i changed the name to file nine dot txt while i move the file so that's what we can move and rename or rename whatever then we have more command okay so this we have basically two commands more and less okay so this more and less command again basically we have four different commands more less head and tail okay so now if i want to check the content of basically all these four commands are used to view the file content okay so let us say let us talk about head first okay so head command is to display uh first 10 records from your file okay first 10 records starting from header so that's what head is about it displays the first 10 record of any file whichever you view with head command then on the similar line we have something called as tail okay so you must have guessed tail command is used to view last 10 lines so these are my last 10 lines of my particular file so head is to view first 10 lines tail is to view last 10 lines okay so uh we might have some cases like i just want to verify my uh let us say i have some data uh test data into my file or whatever production data whatever i have and my file have let us say some lacks of record and i just want to verify a couple of things like i just want to verify if my header record is correct and my trailer record is correct so my header record is first one trailer record is last one so if i want to verify those things then i can use this specific command so header uh i will use head command to verify my header because i i just want to view first record so i can i can get first 10 and to view last one i'll not open the complete file i just get last 10 records so that the operation will be faster right so what's what what are the advantages of commands more or less head and tail are uh the operation will get faster right because it will not load the complete file into memory okay uh now uh let us talk about more if i use more and what's my file name file 9 dot txt okay and you can see it is uh it is giving me the option to scroll right so it is it is it is showing me more over here and if i hit enter it is scrolling for me right so that i can view my data one by one so that's what we can use more is for now i'm done with that if i use less uh less and my file 9 dot txt okay so yeah so it will again give me um okay so the advantage of uh list is let me quit so i can use let us say uh hyphen 5 hyphen 5 with file 9 dot txt it will just give me uh give us again what is giving me complete records okay let us do less uh we can use basically some options over here like if i do uh less hyphen 5 and my file 9 dot txt it will show me last uh five lines basically okay so if i hit like scroll by hitting enter you can see it is showing me w2 w3 five and p and re that's basically showing me the last two lines based on my parameters or options what i specify okay so if i want to come out okay so basically uh this option um as i said uh head and tail are used to see the first 10 and last 10 and option cat is to display the content whereas this option more and option less are some different purpose which is it to view the file contents in the section determined by the size of your terminal so it takes care of your size of your terminal and it gives you the option to check the contents by um like page by page okay so that's the basic difference in between your head like more or less and cat and other two head and tail uh there is one more option like with more command let us say you just want to see uh the content from fifth line so if i give more five and file 9 dot txt it will show me the content from my record number five right so that's what this particular option does so this was about the option again we can perform search operations in this more and less command like let us see if i want to perform something i can to perform any search operation i can use slash followed by the string which i want to search hit enter it will do search for merit that's the basic thing um okay so that's what i had for this video basically all the different tunings file commands which are majorly used so that's it thank you hello welcome back welcome to the course of next protesters in this video i'm going to show you a few uh more commands uh which can be used and your next okay so the very first one which i want to show you on the terminal so like in order to create a terminal we use clear but one shortcut i need i want to tell you instead of clear what you can do is you can use control l it will create it will clear basically a terminal for you okay so fine now let us just do a video where i'm going to talk on some unix commands like who am i who su exit add user su and solo okay so let us start with the first one so my first command is who so who basically gives you the information about your username your date timestamp and few other things okay so so the similar thing is if i use who basically it will yeah and if i use w basically it will give me time from when my this okay so basically it gives me the more details like from where i'm connected the cpu timing idle time logging in my user it gives you details like that okay it also gives you from when your unit server is up okay how many users is there it is connected with and other things uh the important one is su so su is basically used to switch to root user okay so the current user which i am logged in is you can see here that is rapash okay so if you want to see what is your users you can just click on users so this particular users command will give you the it is used to basically show the user names of the user which are currently logged into current post so currently i'm logged in with my username rapash okay now let us say i want to switch from rapash to my root user so i can use basically commands cd sorry it will ask me for password let me enter my password and now you can see now i'm logged in with root okay so now i'm with root user okay so that's it that is basically su is used to uh switch to basically your root user okay and if you want to uh go back to your normal user exit from root user then you can use the command called as exit you will be directed to your user the previous one value logged in right so that is basically your exit command okay and if you want to add the user so basically uh you can use command like add user and then you can give username some username basically okay so it is saying add user command not found because add user is something which your admin should perform that is your root you root user should perform so the very first thing i'll switch to my root user using command su i'm typing my password okay now i'm at my root user and now i'll use add user and i'll give user one this time it is asking me to adding new user enter a new unix password for that particular user i'm entering the unix password and it is asking me to confirm few things if you want to enter otherwise just hit enter it will consider the default one information is correct yes and my now new user is created great so this is how you can use this command add user su i already talked okay now let us say now i'm into root user okay now let us say i want to change to my user which is newly created which is my su user one so there's basically su command if you are passing the particular username then i'll get into that particular user yeah so now you can see i'm with logged in with user user one right so this is you can use su followed by your username okay and if you want to switch to your again you to your normal user then you will be using exit it will take you to root user and if you want to exit again then you will get back to your the user where you log in okay so this exit is basically used to go one level up okay so this is how you can use this su command to switch to your root user as well and if you enter the username folder base you then it will take you to that particular account and the final one is sudo okay so sudo is basically used to perform or execute any command with root privileges okay if you are not able to execute any command with your account privileges then basically you can type any command like sudo and then the command which you are trying to enter so in my case let us say i'm just trying to execute ls command but it is with sudo that is with admin privileges like in our windows like we do start with something like start with admin or another administrative rate so it's something like that it start with root privileges fine now okay and if i want to see all the users okay so basically this user's command as i said it will it will give you the list of users which are currently logged into your unix server so my unix server with some host and i am the currently i am currently only one user who is logged in that is what this users come and use but if you want to get a list of all users which are not even logged in currently but they are users of of your system then what you can do is basically you can get it from okay it is an etc slash give me a second so this cat command basically is used to display the information and i'm going to directory cat sorry etc and in etc we have some file password okay so if i use cat etc password it will give basically all the information along with all the users like aec underscore prakash is my user rsa k is my user prakash is my user automation tux is my user user one is the newly created user right it will give all the information but it will give you some other information as well which i don't want okay so in that case what you can use is basically you can use the piping concept okay so let us say i want the very first step i want to get this information and from this information output of this particular first command will act as a input to my second command and in my second command what i'm going to do is i'm going to cut up a specific portion okay and i just i just want to get this the first one right and in this command sorry in this file you can see everything is separated by colon okay so what i can do is i can use hyphen d which is basically used to define a separator so my separator here is a colon okay so hyphen d and then i'll use a parameter where i want to select my field so i will use hyphen f so this hyphen f is basically used to select your fields which column you want which field you want basically so i want my first field okay so i hope it is clear so cat etc password it will give me the output which you which which you are just seeing on the screen but out of this output i just want to extract cut only the first column where it is separated with colon and now you can see the only first column and you can refer the last four or five rows where it is giving me all the users right so this is how basically you can get all the users for which you have the user account created on this particular post right so this is all about the unit's command which i wanted to talk in this video thank you hello welcome back in this video i'm going to talk on special characters which we can use along with various commands on your command prompt okay whatever you're going to interact with in xover we can use some special characters along with the commands which we use okay so let us start without delay so the first one is till okay so till we saw in my last video as well it is used to go to your current directory okay so let us say okay so let us say i'm in some directory okay so if i do pwd and if i want to i'm in some directory that is the ir1 but it is not my home location so if i want to switch to my home location i can go simply back because home slash prakash is my home directory this is my home directory so i can just go one step back click i can use cd dot dot or instead of using that you can use till symbol okay cd till okay so i am i'm there in my home directory okay so this is easy in this case we can simply use cd dot dot as well because you are just one step ahead but let us say if you are some four to five steps ahead then you need two types cd dot dot four to five times and instead of that you can use this till which is used to which refers basically your user home directory okay so fine okay now i said here is if you use dollar home okay so let us say if i use something like dollar home over here what i get i get is not a is a directory fine that is because this dollar that means it is an environment variable but if i do something like this echo and now if i use home what should i get now can you see i get my present working not present working directory it is my home directory basically right so this environment variable specific to my account which is set to home slash prakash okay and if you want to display anything on your prompt okay your this put in this case you can use option echo so let us say i want to type something like echo hello right so it will type hello for you okay and in this case what we use we used echo dollar home so it has displayed me a value whatever value we have there in the home directory right so this was one of the command which we can use and let us say now i want to clear the content whatever i have in this prompt okay so i will use another command called that clear so that it will clear all the content for me okay and now i will start from fresh okay now let us say which directory i am in currently i am in my home directory that's great what i know i have in my home directory i have some directory called as dir one i want to switch to that directory because in that directory i have some files which i'm going to use now okay so if i go to dir one you can see i have multiple files called as file one one dot text file one text file two text file three dot csp and some another file fine the next one we saw how we can use a dollar is used to access the variables okay not specifically environment variable only but table can be accessed with the help of this dollar okay let us take another example of path okay so if i do echo and dollar path it should give me the path value whatever is there okay so like in our windows we do environment variable and we set a path variable from where your particular program should be picked up on the similar line there is another path variable in your unix as well okay and this dollar symbol is used to retrieve its value fine what next ampersand is used to put your commands in background okay so there are basically two kinds of processes foreground process like whatever currently you see over here it is a foreground process and there is another concept called as background process okay and if you want to execute any command in the background process you can use this particular ampersand okay so i'll be talking about this foreground process and background process in next few videos so i'll skip this as of now what next we have is star that is a wild card okay so wild card basically returns a matching zeroes or more characters okay so if i do echo or okay or let us say now if i do list here now you can see i get number of files but now let us say i don't know like or i i need some file which are starting with file okay and the files which are starting with file i have many files like file one file one file two file three i have many friends right so i i want all the files which are starting with file okay so i will type file and then star there can be anything after file because i just want the file without starting with file dot txt if i hit enter you can see i got in fact all the files because all of my files are starting with a file now let us modify it i want all the files okay but we we we noticed one difference over here i have one file three dot csp over here and here i have all the text file because i use dot txt over here just the difference was this star over here any file starting with star with extension txt fine and now let us say i want any file which is starting with star and which can have any extension so i'll use star again after dot so i should see your csp file as well for here right so that's what so this particular wildcard star is used whenever you're not sure what particular and how many particulars places now some character or some numeric value will be there in your file name okay in fact it will be used in your cell scripts as well so this is basically a wildcard it it gives you the all the matching zero or more characters what next we have we have another wildcard which is your question mark but the differences in star it will return zero or more characters okay that could be any number of but okay you you must have noticed over here i used where it is i used file star okay so my file was file 11 so here it has picked two places one place two one place one place and here it has taken some eight to ten places right so star can take more characters from zero to n characters fine but this question mark is a wildcard which takes exactly one character okay so let us say if i do something like if i want to list all which has only one character after a file okay so i'll use something like file question mark dot txt okay it will return me only two files file one dot txt and file two dot txt because remaining files are like file 11 which is not matching file three but it is with tsv extension and this is again not matching i can do something like this as well file question mark and ending with any extension right so it will include now file three dot csp as well because file followed the exactly one number of character that's what this question mark a wildcard does okay so that's what this this can be used again in in combination with any of the command okay this slash is basically used as a continuation so if you have a command which is which you want to split in multiple lines we can use this basically next i have is okay so next i have is a single quote okay so the single quote what it says is the shell will not evaluate most special characters contained within this quote okay so let us say if i use something like okay so if i do something like eco okay and if i do something like eco home with dollar it is it is replacing the value of this home in my terminal fine now if i don't want to get that value replaced let us say in my shell script okay i want to use dollar home as it is then in that case i will be using it in single quote okay like this and this time it should print the actual thing what i had included in single quote not its value right so it's just like a string most it's saying is most of the special characters will not work over here like so this dollar does not have any meaning over here any special meaning because this dollar has a special meaning which is used to access the variables or environment variables that's what this single quote is used to another one is double quote okay double quote is again okay so this double quote is used to evaluate your variables contained within your double quotes okay so in this in the previous example if i use eco dollar home it was not replacing the value of dollar home right because this single quote is used to impact to to skip the meaning of the special character dollar okay but if you want to print it somehow then you can like let us say you have some statement okay let us say you have some statement some string so you will be putting that string in a double quote so let us say my home folder location is okay and now you want to insert your home variable environment variable okay and i'll close it with a double quote okay now can you see it has printed a string for me along with the replaced value of your environment variable four right so that's the difference in your single quote and double quote so this double quote mainly we use it whenever we deal with string and along with string if you have any environment variable and if you want to translate that environment variable into the actual value then we will be using like this and finally we have back tick okay so this is your back tick okay so both are different single quote and back tick both are different okay so this back tick is basically used to execute the command contained within this quote okay so this double in double quote we can add translate the value of your environment variables in fact the variables starting with dollar excuse me in back tick by using back tick you can translate any command okay so let us say if i use some string like this list of files is okay something like this okay and and now within this i want to execute some command so to put that command i should and enclose that command with back tick okay so not till it should be back tick and i want to execute command ls okay i'll i'll complete the back tick and then complete my double quote okay now can you see okay i should in fact use eco i forgot to write eco over there give me a second okay now can you see it has printed list of file is whatever i printed over here list of file is where it is here list of file is it has printed and then it has translated this ls as a command okay and it has printed the result of that particular command okay so that's what basically this back tick is used for okay so these are some special characters which we can incorporate with many of your commands whatever we use in our free today operations okay so that's it for this video in next video i'll talk about some unix file commands thank you okay let's start talking about the next information let us let us stand understand why do we need uh to work with file permission or why do we need to understand uh unix file permission okay so if i go to my unix terminal 50 okay so let me just increase this size again where is this okay sounds good now now fine if i do ls minus ltr it will give me some list of files okay and as i mentioned in my previous video where i forgot to talk a couple of things so i thought of continuing this video you can see i just changed the permission for this f1 as hyphen everywhere that means no one has the permission to rewrite and execute the particular file okay now uh let us take an example if i try and edit the particular file what happens like if i try and edit vif1.txt so it gives me the error like permission is denied okay so i'm not able to edit this particular file okay why because uh because even as a owner even as a owner the first three byte qc hyphen that means even the user or the owner of this particular file do not have the permission to edit ideally this is not the ideal scenario the ideal scenario could be like because the owner will be having all the accesses but if i am other than user or other than user group then i should restrict some permissions to them like uh other than user group should not be able to edit the things or something like that right so i should impose the permission restrictions on them and you saw uh you already saw it um if they do not have permission they will not be able to uh write the particular file okay let us check what happens if i try and delete this f1.txt okay so what it is saying is remove write protected regular file f1.txt so it is not allowing me to do right so i'll uh fine now what else i wanted to show you is let us say i have some shell script okay so this .sh is my shell script okay we'll be talking about shell script in detail you need not to worry so you can see for shell script actually so this is a script it is a program which i need to execute right so to execute the shell script i need to have the execute permissions right but here you can see even as a user as a particular owner of this particular file i have only read and write accesses not execute access right so if i try and execute the shell script okay script.sh okay we have two ways to execute it actually we'll talk on that detail so i just gave dot which refers my current directory slash script.sh now it is asking me uh it is stating the permission denied i do not have access to do that okay if i do something like chmod i'm changing the permissions using chmod and i'm setting it to seven four four let us say okay because seven means i am giving all three permissions read write and execute to user for my file script.sh okay and if i try this command now script.sh now this time i am able to execute my shell script you can see exact started and it is doing some execution that's fine i'm going to terminate that execution using control c my execution is terminated and if i see ls-l you can see my script.sh but now execute permissions for user or owner of that particular file fine so that's how if you do not have access you need to get the access to work with particular file particular directory particular script and then only you can work for this is how unit maintenance security for your files directly and processes basically fine so that's it i have thank you in this video i'm going to talk on unix file permission the video belongs to unix for testers course series so unix file permission okay so whenever we hear the word file permission what comes in our mind so we think of security related aspects okay so as i said in unix everything is about files and processes so files are used to store the data then the data is processed with the help of processes right so that's it unix is all about files and processes so if i want my system or my data to be very much secure now in unix case there are only two things files and processes so if i want security then i need to apply the security related things on my processes okay so on files what and all i can do on files i can restrict like if i can create create if i can give some user access of creating or deleting the directories or copying or moving or deleting the files right so i can give some access based on their roles right so that that is about the files about processes in unix there is like everyone will not have the access to start the processes right you need to give the access explicitly to specific user right to trigger the processes to execute the processes right so that's how the security related concern gets handled in unix right so it restricts the users by default not to perform some operations like okay so let us go into little details so types of permissions for files and directories okay so let me open my excel spreadsheet uh i can explain it better there give me a second okay so let us say we have two things we have files and we have directories we have two things files and directories where my data is stored okay and uh there are two kind of uh sorry three kind of operations which i can do i can do read operation i can do write operation and i can do execute operation so those so these are the three operations can be done let us see uh if i have what happened if i have read operations on the file okay so if i have read operations on the file then you can look at the file content because you have the read access if you have a write access you can modify file content and if you have execute permissions for that particular file okay then you can run the program so why i didn't took uh uh processes over here because in unix processes will get triggered via files itself like if i if i want to execute an shell script basically that shell script is my file only when i execute that shell script from that particular file it will get uh converted into a process right so if i have execute permission on specific file then i can then only i can run the program if i have more write then i can modify read these are the basic things so fine now let us talk about directories if i have read access to the directories then uh okay if i have read access then i can uh to to read the directories what basically we do we do the command ls right so if i go to my particular directory and let us say if i have read access to this particular directory then i can do ls i can get the list of commands list of uh contents in this specific folder basically that's what i can just read the folder contents that's what my read access is okay and if i have write access to the directory that means i can create new files rename existing files and delete the files right so i can create modify rename and delete files basically right because uh those files belongs to the folders and i have uh directories nothing but your folder only so if i have write access to the directory i can perform all these operations right and what else if i have execute permission then i can do basically uh cd on that particular directory right so see let us say if i have uh okay let me go to uh my vncp now okay so in vncp if i go to the root folder okay and in root my particular my particular home is present in this home location and prakash okay so what i'm going what i'm doing is i'm going in two folders detail like first i'm going into home and then i'm going to prakash so if i do not have the execute permission on this particular home then i will not be able to open this home folder okay so let us say for this rsa key or ac underscore prakash i think i okay i do have access because i might have logged in via root fine but if you do not have the write access or sorry execute access then you will not be able to see the uh content right or sorry not able to see the content but not able to move to that particular directory that's what i said you will not be able to cd you will not be able to change the directory right so basically uh there are three kinds of uh permissions basically read write and execute which we will be talking now so and in order to change the permission there is some command called as see it and mode which is change mode okay and one more thing is uh okay now let me go to my uh unix now if i do ls i get the list of uh files fine now if i want uh a little details then what i do is i do ls-l to get the details of the processes okay so here you can see um few columns okay now what are these columns so let me start for say i can take any file basically okay so let me take this file basically the second one okay so you can see these details okay so these are number of columns so this is the very first uh character basically the very first position denotes or defines whether what is your basically a file type whether it is a folder or it is a file or a folder is nothing but your directory so if you see anything starting with d over here that means it is a directory it is a folder and if you see hyphen over here that means it is your file fine so this is your first column now in second column you see something like r w x r hyphen hyphen something like that okay so i'll talk about this in a moment fine then next we have the third column which represent uh memory blocks basically i mean it represents a memory blocks how many memory blocks are utilized by this specific uh files or folder whatever it is then this is my user this is my user group and this is basically the size of particular file in byte okay so if you see in directory they have the default size 4096 these two are the directory or this is the default size but if you see the files they have the size in bytes based on the content what they have in it okay and then you have some data and all and believe we have the your actual file or directory name fine now let us talk about these things okay so let me just copy and let me paste it in not bad somewhere fine so i just copied this so as i said there was one first character uh which was indicating what is your file type now the second uh you can see there are total three uh total nine bytes okay so three bytes and then you have another three bytes and then you have another three bytes okay so this first three bytes first three bytes corresponds to user second three bytes corresponds to uh user group okay and the third three bytes corresponds to anyone else anyone else apart from user and user group fine now what they mean so r is stands for read permission w stands for write permission hyphen means they do not have any permission right so what this mean is uh if i talk about this specific file okay so to this specific file uh the first three bytes are for user so for this specific file the user have read and write access and the third one is for execute so the user has read write access but no execute access and the second one i said user group so r hyphen hyphen r hyphen hyphen what this mean is the user group and even from the user group has only read access no write and execute access and last three bytes states that anyone other than your user and user group have only read access no write and execute access similarly if you talk about the directory in directory if you are a user then you have all three accesses read write and x means execute fine if you are a user group if you are a part of user group then you have read and execute access and anyone else also have read and execute access now this execute is nothing but simply you are able to browse or navigate to that particular folder because in in terms of directory access nothing but you are able to uh navigate to that particular directory so i hope you are clear now the first three bytes are for user it states permission basically is like next three bytes are for user group and next three bytes are for anyone else now okay as i said three things owner group and other okay now let us take an example okay so let us take an example of this file f1.txt okay now what i want to do is i want to change the file permission for this file f1 okay and as i said we have command called as ch and modi which is change mode and to to change the the syntax basically for this ch mode is for owner there is some number for group there is some number and for other there is some number basically followed by for which file or directory you want to change the permission okay so fine uh let me go to my notepad now fine okay so let us say if you do not want any permission like you do not want read permission do not want write permission do not want any kind of permission or execute permission then basically your number will be zero that it it is basically a octal representation right you know octal code three by three three bytes basically that's the octal then if you do not want let us say read permission write permission and if you just want execute permission then your number will be one something like that uh if you if you do not want read permission you just want write permission and do not want execute permission your number will be two okay so basically your numbering will start like this and let us say if you want all three permissions okay if you want read permission write permission and execute permission your number will come to seven okay so so edit is like if you want only execute permission number will be one if you want right sorry read permission your number will be four and for write permission your number will be two so based on this for execute number is one for write number is two and for read number is four and for write number is two okay so now what I wrote over here like yeah that's what I wrote over here like your number is calculated like for read there is four multiplied by four write corresponds to two execute corresponds to one now I'll a little bit simplify this let us say let us say my this particular file okay I have some file f1.txt okay and my this f1.txt file wants all three permission read write and execute okay so what what number I have for read for read I have a number four number I have two for execute what number I have one that is four plus two six plus one seven so for for RWX I need to give seven okay and we have three things we have something for user something for user group something for anyone else right so let us say for user I want to give all three permissions so I will give seven okay and let us say for user group I just want to give the write access so for here I'll give only two and let us say anyone else I do not want to give any access so I'll give zero so basically my number is turned into seven to zero okay so how this CH mode commands works basically it is CH mod followed by your number now what is my number my number is seven to zero what this seven to zero defines seven to zero defines okay for this specific file for this specific file f1 you are trying to set a permission seven to zero which corresponds seven for user seven is starting first first first number in fact so it first stands for user second stands for group third stands for anyone else seven stands for you want to give all three permission read write and execute user group you want to just you want to give the right permission for anyone else you do not want to give any permission that's what it states now if I execute this command okay so for this f1 you can see currently it is RWRR okay now if I execute the command what I wrote now CH mode 720 f1.pxt and if I do ls-l I should see something different can you see it is RWX and earlier it was RW right and for other it was R but in other in this case it is that means no permission for other right so that's how you can give the permission okay now there are some different ways as well okay how you can give the permissions okay so okay let us take another example let us say you want to read write and just you want to do read and write but the whole world you don't want to do that then in that case you will use let us let us find it out you will use what you want to just read and write you want to read and write so in your case it will be six and the whole world don't want to do anything so you will do CH mode 6 0 0 followed by your file name now let us take an example you want to read write and execute and the world the rest of the other world don't want to do anything so in that case you will use CH mode 700 because 7 means all three permission for users 0 means no permission for user group 0 means no permission for the whole world okay so basically these these things are see this 7 means you can execute so this 700 is this kind of permission is great if you are giving it to some script because script is something which only I want to execute right so 700 is the best security permissions for scripts right fine let me tell you another way how you can give the permissions okay so as I said we have three things user user group and anyone else right so in short these are termed as you for user okay and then G for group okay and then we treat as a for anyone else okay so by using these short names now you for user G for group and a for anyone else we will try to give the permission now let us say CH mode okay now for this file one what I want to do is I want to now this file one has right and read write and execute permission basically for sorry for user right so what I want to do is for user so I want to perform action on users so I typed you and from user I want to remove the permission so for removing I will use minus and what permission I want to remove I want to remove W and X permission from user okay this use stands for user minus or hyphen stands for removing the permission and which permission you want to remove W and X okay and for which file it is F1.txt okay it is executed successfully let us do LS hyphen and this time you should see for file F1 you have only like right and execute permission got removed right so this is how we can use let us take another example this time let us say you want to add okay now this time you want to add what all three permission to anyone else okay so for anyone else what we have we have a okay so for anyone else let us say you want to add all three right and execute okay so a plus read write execute for F1.txt okay if I hit enter and if I do LS hyphen LTR or L whatever then for file F1 you should see anyone has all three permission RWX so I did it only for like anyone a okay so that means anyone anyone else or if you just want to do it for other okay so so there are two two different thing O and A so this O means only last three bytes and A means anyone okay so this is the so let us say now from this file F1 you have all three permissions for everything so let us say now you want to remove some permission from other that is the last three bytes you want to remove RWX all the accesses you want to remove from other so from F1.txt I'm done and if I do LS hyphen L and for F1 I should see all three accesses got removed from other so basically this is how you can you can use this short terms to give the permission so you can do it in both ways you can give it by numbers or you can give it with this short abbreviations by using plus and minus again you can combine the two things like if you want to let us say ch mode if you want a per group if you want let us say in to the group if you want to give read and execute access and for other you want to only execute access so if you want to do many things for the same file then you can separate it separate them by comma you can execute and you should see the things should get reflected as they want okay so this is basically how you can manage the Unix file permission okay so that's what this is what all we saw so let us take an example if we have ch mode 754 so this seven is stands for user five you stands for group and four stands for others okay so this seven means all three permission read write execute four plus two plus one five you means four plus one that means read plus execute so read plus execute for group and this four means only read permission only read permission for others right so this is how the Unix file permission get handled in basically Unix yeah okay so that's it I have in this Unix file permission video where we mostly talked about this ch mode command and why file security is important and how this file security is handled with the help of this file permissions okay thank you hello welcome back welcome to the course of Unix for testers Unix manual concepts and how we can automate all those Unix processes which we used in our day-to-day task as a part of testing which can be integrated with any test automation framework let us see selling them in this case because mostly I'm using Java in this case fine so let us talk about Unix processes okay so first let us try and understand what is process okay so process you know it's a general term okay and in Unix terminology a process is called as it is an instance of running a program whenever we execute any program the that particular instance of that program is called as a process or we we may call it as a program a process is a program in execution okay whenever we start execution of particular program that that that triggers a process or that is let us see that gets converted into a process let's take an example if let us say three people are running the same program simultaneously and then it will create a three different processes because the same program is triggered by three different people let us see three different users so three different processes will get created not just one right in fact we might have more number of processes running even when only one person is executing a program because one person may call another sorry one program may call another program which may call another sub program something like that it's like splitting the programs okay so like one process can get into a multiple processes so basically process whenever we run the program it will get converted into a process so that's what my process is okay so okay so what processes can be like how the processes will get triggered okay so whenever I run any shell script my processes will get triggered whenever I execute any command in fact programs okay so because commands are nothing but programs right programs in for unix programs are called as commands right or it might be any demon or any scripts okay so whenever we triggered any of these things your process will start okay so let us take an example if I go to my Unix box and give me a second okay so if I do something like this PWD okay so if I do kind of PWD that is my print working directory it is giving me some output okay so I'm hitting one command so internally what is happening is this command is nothing but a program for Unix so this command will trigger a program that program will trigger a process right so ultimately my command will trigger a process so likewise whenever I execute any shell script it will trigger a process okay so that's what your process can be triggered with shell scripts or commands okay so next is what is the parent of all processes okay so basically when we boot up my Unix machine what happens is it initialize all the things like what hardware I'm using what software I'm using like it initializes all the things right and all so for initializing all those things we need a script okay so basically there is one process called as init okay so if I go to my let us say vncp this time I'll go to vncp I'm browsing the same Unix server basically so if I go to my root folder and if I go to etc and in etc folder if I go to apt so here I find some scripts okay some scripts so basically all these scripts get triggered automatically whenever my Unix system boots up okay and basically that's the function of init process okay in it process initialization process okay fine and so basically in it is the parent process for all it is a parent for parent of all processes in it process and there is something another something similar another process which is again mostly used during boot up time itself which is jetty command ZETTY okay which takes care of your logins of different users or different sessions it takes care of all those things so basically init is your what against apparent of all the processes fine what next okay so okay before I move to the types of processes let us understand little more about commands okay so whenever any command is issued to Linux or any Unix OS basically it creates it creates or starts a new process for example as I have shown you whenever we issued a command PWD it creates a process for you okay and whenever the process it or a process is started each process in Unix or Linux have a five you digit ID called as process ID or PID okay and that five you digit ID will be unique in your Unix operating system okay and it ranges around 12 30,000 or 0 to 30,000 in fact okay okay and since it is a unique as I said it is a unique process ID it will not be same for multiple processes each process will be having the unique process ID okay so if I go to okay I'll talk about commands later on little bit okay but to get the list of processes we have a command called PS and here you see something called as PID which is my process ID so you can see I have two processes running over here it has and two processes have different process ID so basically these are your process IDs okay and it ranges from 0 to 30,000 okay and it is unique for all the processes now let us start talking about your types of processes so as I mentioned here we have two types of processes foreground process and a background process so from the name itself we can understand foreground process every process when it is started run it by default it starts it's running in foreground okay so it's like whenever I hit any command like as I've done over here PWD my command is starting in foreground that is I can in fact it is a user interact like I can enter the input or I can see the output so basically it is foreground which I can see okay so the basic disadvantage of foreground process is when a command or a process is running in foreground and this taking a lot of time no other processes can be run or started because the prompt would not be available until the program finishes processing and comes out because see this I typed PWD it has given me instant result but there might be some program when I start those particular program it might take some minutes to execute some hours to execute okay and while those programs are executing I may not be able to do any other things okay let us take an example okay in my this particular directory I have some shell script okay yeah I have this shell script and I'll tell you later on in detail like how we can execute shell script and all that we need not to worry just I'm running it over here with command sh.sh script.sh I'll demonstrate about creating script executing script in our later videos that's perfectly fine so as I said when process will get triggered whenever we fire any command any program or any script my process will get triggered okay so before I run this shell script you can see we have only two processes that's right now I'm going to trigger this particular process fine and here you can see my but it has printed something that is a part of my shell script and I do not see anything to enter input over here or I do not see any output because my shell script is running it is running okay and in fact I have just entered some sleep time over there but it is running let us say right so in this particular time I'm not able to use this particular terminal right so that's what the basic disadvantage of running your process in foreground that I am not able to utilize this particular terminal until and unless this particular process is terminated that is your foreground process fine now I'm going to terminate this process with control see I have terminated my process and if I check the list of processes again I have two processes because this particular process is turn off fine now there is something called as a background process okay so as the name suggests background so the process is running in background so it runs in the background without keyboard input and yet still the keyboard input is required thus other processes can be done in parallel with the process running in background since they do not have to wait for the previous processes to be completed like I said okay so what I'll do is I'll enter the same shell script okay let me clear this command terminal okay now what I'll do is I'll run the same script okay sh dot script dot sh I'll run this shell script but this time I'll run it in background process and how we run any command or any script in background just we need to give ampersand after your command or script that's how your next terminal you understand that whether he needs to run that particular command or script in foreground or background if you if you see anything ampersand Unix will run it in background I'll hit enter and you can see it gives you the process ID 24399 so my process is running now give me a second what does happen we give ampersand find my process is running great now if I check for PS that is processes you can see like earlier there were only two processes bash and TS right but this time I see these two processes got added and these two processes are running okay even though these processes are running I'm able to run my further processes right because because this particular script I have triggered is in backend right background it is running it in background so you can see the processes are still running okay so this is basically the difference in between foreground process and background process okay so what is okay so what next we have okay so moving the process from background to foreground and vice versa so we have two commands like BG for background on FG for foreground so we can use this command to switch your background command to foreground and foreground to background basically I was talking about processes okay so you need to give BG followed by process ID which you can see over here this is my process IDs PIDs it will convert your process from one one BG to ABG or ABG to BG whatever you want to do okay so we can do that okay what next I have okay some important commands related to processes okay so I have shown you how we can use ps to see the processes status so I have shown you we can use ps to get the processes status so you can see here I have four different processes running fine okay and if you want little more detail you can use ps-f okay so you can get little more details like UID what is the user so Prakash is my user PID what is your process ID so these are the process IDs for different processes then you can see something called as P PID which is parent process ID okay so parent process ID and here CPU utilization start time terminal type come time and command okay so here you can notice something this is my PID process ID and this is my PID that is parent process ID now observe middle two things okay these two things here process ID 24399 of this script.sh is the parent process ID for your slip process right so what this means initially I triggered this particular script it has it has triggered basically a process and then this process has triggered a child process so that's the reason this is a parent process ID for this particular process so by using this process ID this particular process has got triggered okay so that's the basically the concept of your parent process and a child process so parent process let us say it is the base process and let us in your form your parent process if there are some chances like there is something like multiple processes may get triggered so those multiple processes which got triggered from your one base process are called as your child process and your base process is your parent process so you can see them by using this particular ID is parent ID and process ID process ID and parent process ID okay and even if I show you the script okay the script is nothing it is just one one line give me second let me show you that script what I'm doing so in that particular script what I'm trying to do is I'm basically calling I am basically so you can see here this is my script.sh I have triggered this script.sh how can from that script.sh it has triggered this slip process right so this script.sh is my parent process whereas this slip and this whatever time duration is my child processes okay so this is what your parent processes and child processes are okay now what else we have so there are couple of more have option we use with option ps process status like we saw ps to get the list of detail list of your processes then we can use ps-f to get them in detail then we have something called as ps- e to get all the processes list of all the processes which in fact I have not triggered my OSS triggered and we have if let us say if you want to get the processes which are triggered by your user so I have type ps-u and my uid which is Prakash so it will give me the list of all the processes which are triggered by my id yeah so from here so from here these are the processes which are triggered by my uid what else okay and one more is there for hierarchical view okay if you want to see the tree like structure so we have some command like ps-upercase here so if if if there are some scripts or programs which are calling some sub-programs or sub-processes like in this case you can observe this middle two rows okay so in this you can see one some tree like structure though it is very small the SH SH is triggering slip that is the slip process it triggered by SH so this is the kind of tree like structure if you have again a little sub-processes you can find it in a tree format so that's what basically this ph ps-he's it gives the tree like structure so from here till now you must have clear this PA sorry 2439 process ID that is command SH is my parent process ID and the next one is my child process ID okay what else okay so this parent and child processes we already talked okay and okay and if you have any processes let us say SH and this time I'll run the script in foreground okay so my script is SH and my script execution is started now so I'm not able to do anything but for some reason if I want to terminate my to stop my process then we have some interrupt character which is control C so if I hit control C now my process will get stopped okay so that's how we can stop the process basically it is running in foreground but what if my process is running in background even if I do control C over here my process is not getting stopped see if I if I do ps my one of my process couple of my processes are running right but since they are running in background even if I use control C I'm not able to stop them I'm not able to terminate them so to do that we have some command called as kill followed by process ID so I'll give the process ID as 24349 24349 okay so what this means I want to kill this particular process ID which is my SH script okay I'll hit enter and if I do ps hyphen f now you can see that particular process is not still in my list so now I have only one process in my list which was my child process now let us try and understand what has happened the process which is this particular SH process initially I triggered this SH process and from this process this child process has got triggered okay so in the program flow you must be understanding okay if my base program is calling some sub program a child program basically my base program is waiting for some response some signal from the child program right now in this case since my base program or base process itself is killed where my child program or where my child process will send response to my child process will not be able to send response to anyone because its parent has died right so this kind of processes are called as orphan processes okay orphan processes so okay and there is something called as zombie processes so what are zombie processes so let us take an example I have I have already killed the process but still that process is getting reflected in my when I do ps okay when I when I when I do this ps command if my process ID is still showing but I have already killed it but it is not getting reflected so such a kind of processes are called as zombie processes they are dead and they are of no use but still my processes can I can see them in my processes so that was pretty much about the UNIX processes so we talked about what is processes whenever we start execution of any process any program or any shell script basically it turns into a process so we have two types of process in fact parent of all processes my unit then we saw something called a jetty which is responsible for login mechanism then we have organ process and background process so when whenever we hit any command on your terminal by default it will start in foreground process in background process we need to use ampersand we can move the command move the process is basically from background to foreground and vice versa then we saw some different commands in fact ps only with the various options and we talked about what are the parent process I tried the processes and basically this is on the process and our fun process so that's it about this UNIX processes stay tuned thank you welcome back welcome to the course of UNIX foretester very short video where I'm going to show you what on and filter commands available in UNIX and what what is the use of filter commands basically okay so this is what I'm going to talk various filter commands in UNIX okay now if I go to Wikipedia so as per the Wikipedia the definition of filter is a filter is a program that get most of its data from standard input and write its main result to its standard output yeah so let me elaborate what it is saying now let us say okay let me change the font size okay great now if I list out my files I have some files over here and if I let us say if I want to display data from one of the file let us say my file is cat new data so it has a huge number of data right but what I want to do is I want to filter some of the data out of this or I want to see only some amount of data as of now okay so basically those things can be achieved with the help of what we call this as a filter okay so under filter we have a huge list of commands in fact the filter programs okay and we have many like AWK cat itself is a filter program then we have cut then we have more less head grab we already talked about this then we have sort as well we already talked we have tell we have WC we have unique like like with whatever we out of this we have talked about most of this commands and those are called as your filter commands okay let us take very simple example okay now you saw whenever I want to get the content from this file it has a big list right now I want to restrict the data which I want to display onto my screen right so what I can do is I can use cat new data okay and out of this what I want to do is I want to display only the data which I can see on my screen right so for that purpose I am using more as my filter right now can you see I am seeing only the data right the data is starting from here starting from the following this much right the data is starting from this right so it has displayed the data which my screen can display which is visible on my screen and at the bottom it is showing the option as more okay and as soon as the hit enter it is scrolling me down line by line right so it is restricting my data which I can display on my screen okay likewise let us take a another example where I just want to do a word count okay or another example what I can check maybe want to display tell okay so it is it is like you can display only if you if you just want to display only last some number of lines on your screen let us see how it works okay so I just did control X and I'm using the last command instead of more let us say I'm using head okay so can you see when I used head it has restricted the data to only first whatever by by default command number of lines that consider okay if you want to specify the parameters like let us see if you just want to give display in 10 lines you can give the parameter option as basically hyphen 10 or hyphen 20 if you want to see 20 lines something like that okay so in between two commands whatever we see this symbol is called as pipes okay so about this pipes I'm going to talk in one of the video but in this video I just wanted to show you how we can like in fact what is a filter and I just wanted to aware that okay we are already talking about filter commands and directly those commands are called as your filter commands okay so fine thank you hello welcome back welcome to the course of Linux for tester in this video I'm going to talk on fine command in Unix so this fine command is very much useful like how we use a search for files in our Windows operating system so likewise we can use fine command in Unix to search the files so basically okay so file commands is one of the most versatile command used in Unix or Unix like operating systems whatever Linux or any other we have and I believe having a good knowledge of fine command in Unix or Linux whatever and understanding of its different options and usage will increase your productivity if you are a person or a support and your work involves a lot of searching a text onto the Linux or Unix machine then definitely this fine command is something which you will be dealing with daily okay so let us talk about this fine command and what are the various options various usages of fine command let us start so let me switch to my Unix terminal and here I am now the very first thing before I start with any syntax or any Unix command let me tell you how you can find the documentation so if you want to find manual of any command then you can use man followed by the command for which you want the documentation so if I use man space fine so I'm getting the documentation for fine command okay and okay so here you can read all the documentation so find is basically used to serve the files in the directory of hierarchy okay and you can just scroll down and you can see all the things like what are the various options are available and like you can read all the detailed documentation for this fine okay so it's a huge document I'm not going through that but I just wanted to show you okay if you want you can go through that it so if any you can just do man space your basic command which is fine and you will get that manual okay so fine now let us start with their fine command now what is the syntax for your fine command so your command start with fine keyword fine okay and then it is followed by your directory okay in which directory you want to search for or I can call it as a path name okay it is your direct your path name in which you want to search for some file okay and then next followed by some condition okay based on some condition you want to look for some file or it can be your matching criteria and actions okay so this is the basic syntax how we can use a fine command fine keyword followed by the directory in which you want to look for the files and the conditions are the search criteria or the matching criteria okay so your directory or path name if you want to find out it for in the current directory then you can simply use fine dot followed by again your conditions okay because this dot refers to current directory okay so this is the basic syntax we have okay so as I said we can use dot command dot to refer the current directory so what will happen if I just use fine dot then it should list me let us check what it does fine dot basically it gives me a list of all the files all the directories and subdirectories which are referring my current directory okay so it is still searching for all the files in particular directory I'm just doing quit okay let us finish fine so it has basically all the files and there are a huge number of files for the software so great so if I do find dot it will search for the current directory okay and now let us say you are already doing find operation you have type one let us say big find command and if you don't want to repeat it yes by doing like upper arrow you can repeat it okay you can get that command but let us say if after using this find let us say I we have executed some other commands like LS or any other command whatever it is okay now if I bring like up pressing up up key then I'm not getting my last command okay that that could be far far away but what if you you want to execute your last fine command okay so if you want to execute last fine command you can just use exclamatory and fine so this will execute your last fine command which you have executed okay so if I use enter it is again executing the same one same command which was find dot which was which is basically to list out all the files in my current directory okay so that is happening okay so let it okay so you let me quit it okay fine now okay now let us say okay let me go to my current directory and I have this many files over here let me go to my print working directory okay let me go to my directory in fact CD and let me go to home and let me check out for the files for I have what also these many files I have over here right now let us say I want to check for the file you call let us say run dot txt okay in my current directory okay how I can do that I can you simply use find okay and now which directory I want to look it in I want to look it in my current directory and then what I want to look for I want to look for file whose name is what is it run dot txt okay and you can see I got the file run dot txt rate so this hyphen name parameter is basically used to specify the name of the file okay now in this case you can specify regular expressions as well let us say if you want to list out all the files which are ending with dot txt extension then you can use star dot txt so basically it will list out all it will do you basically all the points which are ending with this dot txt extension whose name is basically ending with dot txt extension okay so and okay now let me go back and let me find out the file called as file 3 dot csv okay but the file is located in directory 3 okay now what I'll do is I'll just try and look out I'll try to look out for that file into my current directory itself okay so what I'll use find dot hyphen name and my file name is file 3 dot csv okay now can you see it is giving me the path starting from my current directory that is it is present in directory 3 file 3 dot csv again I have file 3 dot csv in my current directory again I have file 3 dot csv in my directory 1 as well okay now let us try one more thing so let us say if I want to ignore make it as a case insensitive then I can use hyphen I as in one of the parameter okay so I can use like find dot okay hyphen I followed by my another parameter is name and file 3 dot csv now in this time this in this case you can see file 3 which is in uppercase as well got listed over here so this I miss case insensitive okay so fine so basically okay and let us say if you want to look out for the files only in specific directories let us say if you want to look out for the file 3 dot csv only in directory 3 how you can do that either you can change the directory either you can change the directory and then you can use dot to refer the current directory and do that or you can give the directory here as well like instead of dot what I'll give is I'll give slash 3 3 followed by hyphen name and what file I want I want file 3 dot csv okay so can you see I'm getting the file which is only located in directory 3 so this whatever what I wanted to show is you can specify the file location here as well or else you can go to the directory 3 and then you can give the dot so that it refers to the current directory okay so that's how okay and okay and we have one more parameter called as hyphen not okay so from the name itself we can judge that okay hyphen not must be used to negate the things okay so if I use something like fine dot okay and let us say I want to find out the file you want to find out the file whose name is not whose name is not what I can say run dot txt let us say or which is not my shell script let us say right so my shell script must be ending with dot is it extension okay so it should be this not should be first okay so can you see it has listed all the files excluding the files which are having dot is it extension right those are my shell script okay so okay and okay you don't see any file with dot is it extension now if I simply remove this particular not from here you should see the file one of the file with dot is it extension can you see script dot sh rate so that's what if you if you don't want to include that file and if you want to list down all the files excluding that file then you can use this basically hyphen not parameter okay now okay now when I do find dot hyphen name and file three something like that file three dot CSV okay so basically it searches all the directories like it searches for directory three and it searches directly one or it might be searching subdirectories as well but since I do not have any and I'm not waiting any reason but if you want to restrict the result okay if you want to restrict the search result that is how many sub directive it should look for how many level it should go down to look out for your result you can give one of the parameter called as hyphen max depth hyphen max depth and you can specify its value that is I want to look out for this file three dot CSV only two two directories down from a current level so I can use something like max depth to right so it can it will go like it might go from a current directory to it will go in first directory then it will go to second directory it will search only these two directors but if you have any again subdirectories within those directors it will not go and search there because we have this with max depth is equal to two that is to restrict your search okay what else we have okay so this kind is basically very versatile command which we use most of the time okay now let us take an example you want to find the empty file in your directory okay so I how I can use I can use find okay and let us say I want to use it in current directory so I'm using dot if you want to look at it in some directory you can go ahead and like enter the directory and you can simply enter the option as type an empty okay so basically all these are my empty files you can see over here this hello hello file is empty this indirect three three file three dot CSVs empty all three CSV files are basically empty head so if I use something like if I want to find out the empty fields I can use something like hyphen empty as one of the parameter argument basically okay find dot refers to my current directory so whatever empty file I have in my current directory I'll get a list over here right so that is something find hyphen okay now let us say if you want to find out the file based on its file type okay so like we have some file types like we have some socket files or we have some directories or we have some hidden directory something like that okay so to work with that we have one of the parameters called as type or we can say one of the options called as type okay so let us say I want to find out I want to list basically all the directories which are present in my current directory okay so how again is find dot then I'll use optional hyphen type okay and what is type so type is the format directory let us say I want to find out all the directories so basically it will use me the list of all the directories which are present in the current directory only directory okay now let us say if you want to find out the hidden files then basically hidden files start with sorry hidden directory then hidden directory start basically with dot extension right so what you can use you can use something like find dot in your current directory let us say and host type what type you want to search it for I want to search it for directory okay now I'll pass my second parameter called as type and name and basically that's it with okay so can you see I have only one file which is starting with space I mean which is only with dot SSH file so this is basically dot files are your hidden file so this is how you can find out your hidden files okay so I'm trying to find out the files in my current directory so I'm trying to find type D means directories and I can name I'm just giving I'm just looking out for the file feature starting with dot so this is how we can find out the hidden files okay and if I want to find out the regular files okay so regular files are denoted with type F option so I can use like find in my current directory if I want to look for so I'll give option as type type and F so that it will give me the list of my regular files okay so basically we have three to four types of file like we have socket files so if you want to look out for socket files you can use option S if you want to list out the directories basically you can use hyphen type and then option as D then if you want to look out for hidden directories hidden directory start with dot and then some extension and if you want to find out for the regular files you can use hyphen type as F it will give you the list of all your regular files okay so this was let me clear my console now okay so this was pretty much okay and what let us say if you want to find out the file based on the file size okay so let us say I want to find all the files in my current directory for size so in order to use size you need to use option as hyphen size okay so you need to remember these options basically when I work with type I use hyphen as type if I want to find out the file based on some type whether it is a regular file hidden file or something like that when I when I wanted to specify the name then I used parameter as I can then I want to search for the files which are let us say less than 10 md then I will use something like minus or less than 5 md I'll use something like minus 5 u m so what it is giving me let me repeat it that the list must be huge okay or let me try this time plus 5 u m okay it will not give me any file because I do not have any file both size is exiting 5 md okay so this is how you can use like if you want to search the files which are exiting some size you can use plus if you want to look out for the smaller files which are smaller than let us say 10 md you can use as hyphen size minus m something like that you can use like that okay let us okay I do not have actually any data into the file so I will not be able to show you this but you can use something like plus and minus or if you want to look out for the file with exact size then you can use like find dot hyphen size and then specify the exact size let us say I want to look out for the files which is of size then and we but I since I do not have anything I'm not getting anything into the result okay what else okay and we have something more like you can find out the file based on the permissions okay so let us say let me do ls so I have let me do ls minus LTR okay so here the very first this nine this nine bytes or ten bytes we can see this indicates basically the permission to the user owner group and others right so if you want to find out the files based on permissions okay then you can do that with the help of again find comment let us say if you want to find your current directory with permissions okay and let us say if you want to search the files which is having all the permissions so all the permissions mean triple seven okay so basically it will give me two files okay let us check for those two files okay so can you see the first file having all the permission which is f dot txt and second file having all the permission is my script dot s h so this is the list so this is how basically you can find out the file based on permission okay and okay and there are there are a couple of more options like if you want to find out the file by its time like if you want to find out the file which is accessed a few days ago or modified few days ago then we have some options like there is something like time option so it is type on a time option okay and you can specify the time limit basically so if I use something like type on a time 90 then it will give me the file which was accessed 90 days ago or if you want to find out the file which was modified 90 days ago modified okay a means accessed and means modified then you can use parameter less the re-option as type and time okay size and type I already told you okay and there is one more option called as hyphen user okay if you want to look out for the files form specific user only then you can use hyphen user and let me show you this I can use something like find nmikr and direct3 and all the files with user as percussion okay so basically it will list me all the files because all files are by me only right so that's how you can use if you want to use from any user then you can use it similarly it would be for group as well okay if you want to find out the files which belongs to specific groups group owner then you can use this group as well and do the group name okay and what else okay so I think that's pretty much I have in this find command for this find command is basically used to search for the files into the direct trees okay and it has many options which I can use like hyphen name hyphen type hyphen type hyphen user and many others okay so I think this this is what I have for this video where I talked about the find commands okay and it should be very useful as a testers when we use when we deal with mix or printing system basically so that's it thank you to the data set within the files we have some grip command okay so this grip command is used for the pattern of characters into the file or multiple files okay so let us see if I have some files and in my file if I want to verify my file contains some specific word or specific pattern specific string could be a specific string for if it is a string that means if the pattern is containing white spaces then it must be quoted it must be included in single code whatever okay so fine so what happens is when we execute the grip command it sends its output to the screen and it does not do any changes into your file it just sends the output of your surface on to the screen okay so let us try and let us try with basically various command various options basically which we can use with grip command okay so first let us check the syntax of your grip command okay so before I go ahead with grip command in my last video if you remember I talked about find and I wanted to show you one more command sorry one more possibility how we can search for multiple files multiple file types basically using this file command okay so here it is so I am looking I am looking for I am basically finding out find I am giving my directory in this directory I want to find out something what I want to find out is I want to find out for file type F I want to find out regular file types and file host name is ending with .png or so this hyphen o is r okay so it is used basically for r r so hyphen name again .txt or .csv or .pdf so what this basically will do this will look out for the file with your png file or text file or csv or pdf let me simply do copy test and let me execute this command and let us see if I get yes I am getting all the files which are ending with the extension which I have mentioned over here like png or txt or csv or pdf so you can see here I have only csv and txt I do not have any pdf or png but I have only text and csv okay in fact you can see I had some shell script file .ssh file and many other files those files are not listed because by using this command I am getting only these four I am trying to get out only these four files right so this is how you can use this file find command basically to work with multiple files to get multiple files let me clear the content okay so in this video we are going to talk about grep okay so this grep and this grep this re stands for basically your regular expressions okay so this with this grep is basically used for globally searching your regular expression patterns into your files okay so what is syntax for using this grep so any thing start with the keyword so it is starting with grep keyword okay so this grep as I said used to find out some text within the file okay now grep followed by what text do you want to look for let us say I want to look for the word record okay you can like write like record and where you want to search for I want to search for my search it in my file 1 dot txt okay pretty simple okay so what will happen is this command grep will search for this particular text record into this file 1 dot txt but let us see if you want to search something like record 1 is present something like that something like that then this should be enclosed in course right because it includes white spaces now what this command will do it will search for this specific string into this file okay let us let us do and let us go and execute this in my file okay so what an old file I have okay so let me check my one of the file okay so this specific file file to send to host has some content like file to send to host record 1 record 2 record 3 and couple of more lines okay so let us see how I can use grep on this file okay now let us say I want to search for this specific string called record 1 okay how we can search I can type grep okay what I want to search for I want to search for record 1 okay and where I want to search it in I want to search it in okay I want to search it in my file okay what is my file name my file name is file to send to host okay that's it can you see it is giving me the matching record my matching record is record 1 okay or let us say if you want to find out in fact you can use what I can say as to the career like how we use it in regular expression let us see if you want to look out for any record starting or it could be record 1 to record n like that that you're getting two things record 1 and record 2 okay yeah you can see I have record 3 here as well I have record should be something like that but here it is starting with uppercase r so that's why it is not giving that particular source because it is case sensitive right unix is quite case sensitive so it is not giving you the result now if you want to ignore the case sensitivity then you need to use option hyphen i to ignore the case sensitivity okay so what I'll do is now I'll use the same command grep record star okay followed by my file name but after grep what I'll do is I'll use one option as hyphen i so that it will ignore the case sensitivity now can you see this time it is giving me all the matching records whether it is uppercase or lowercase so this hyphen i is basically used to ignore the case sensitivity okay okay so now since this file is present in my current directory so I'm not giving the complete file path but if you are executing this particular command or or let us say what I'll do is I'll go back and let us say then I'll try with this command okay now it is it is not working because I need to specify the complete directory for this specific file okay let me do that okay so I'll be going to home slash prakash slash and my directory name is file to send to host and can you see it is working now so that means you can specify the complete file name as well complete file path in short okay you should specify the complete file path as well if your file is not present in your current directory so this hyphen i option is basically to ignore the case sensitivity now let us check another option which is hyphen n okay we have one other option called as hyphen n is basically to print the line number okay let me use the same command now instead of i what I'll use is I'll use hyphen n let us check what happens okay can you see it is giving me the line number okay in this particular file on line number two you have record one line number three you have record two line number six you have some string containing some line containing particular matching pattern which you are looking for okay and you should be able to combine two okay you can combine two options as well like hyphen i option is to ignore the sensitivity and hyphen n option is to print the line number can you see both are working simultaneously I'm getting the real line numbers as well and getting the matching record by ignoring the case sensitivity both so hyphen i is to ignore the case sensitivity hyphen n to print your line number now along with that we have couple of more options like we have one option called as hyphen v so this hyphen v option is basically to search all characters or line which do not contain some word okay so let us say let us use the same line okay and instead of this i n now let me use hyphen v command so what will happen is it will print basically it will print all the lines which do not contain this specific pattern okay record okay now can you see it is it does not print this and record to it is printing on other lines which do not contain this pattern the record start okay so it is printing rest of the things okay again you can combine two or more options okay and let us say if you just want to look out for the files okay if you just want to get the file names only okay so let us say let us take the same example okay let us say if you want to find out the file names which contain this specific text okay so what i want to do is now i want to look for all the files so when i say all the files then from this specific location i should look all text files so i will use something like asterisk dot okay so that it will look for files which are ending with dot extension basically all the files okay now what i want to do is i want to print all the file names basically okay so i should use option hyphen l okay so if i use option hyphen l this will list out the file names okay complete file names including your file path which contain this specific pattern in it okay so that's how the record is present in record the specific string pattern is present in file to send to host file and my output file dot txt so this is how we can use hyphen l option to get the file names which contain specific pattern okay and there are couple of more options like if you want to what okay if you want to use count print the count like how many number of times specific pattern has occurred okay let us try this let us say if i want to check how many number of times this record pattern this particular string pattern record star has appeared then i can get the list over here right something like okay so here so in f1 the count is zero in so in this file f1 dot txt this particular matching pattern is not found in file to send to host the particular matching pattern is found three times so likewise so it works that gives you basically the count okay and okay and we have another option called a hyphen w which is basically used to print the search result only if the word is matching okay so you can go try with this option w it gives the result basically if if specific word is matching okay okay and one more thing is like you can use this grep command with like you can combine it with other command with pipe piping okay so you can refer my video where i talked about piping like how we can combine multiple commands so let us say okay so let us take an example if i use ps okay let me get all the processes okay so if i use command ps hyphen ef basically it will list out me all the processes okay so yes okay now let us say i want to list out all the processes which are with my username prakash okay so what i want to do is i want to find out basically all the process and i want to out of all these processes what i want to do is i want to get the processes i want to search basically okay i want to search the processes which contain the word prakash can you see now i got only these many processes okay so the first line it contain prakash here the second line contain here and here so likewise the processes contain prakash so that's the reason i'm getting this particular result over here so that means we can combine this grep command in fact any command using this piping okay so in this piping what happened is the output of this first command that is this complete list of the processes acts as a input to my second command which is grep over here so this ps dot hyphen ef is giving me the complete list out of that complete list that complete list is going as a input to the grep command then from that complete list this grep command is sorting basically expecting the records which contain prakash okay so that's who i'm getting the result okay so that means i can use the command with pipe okay what else okay so this is basically what i have about grep command so in grep we have multiple options like we have hyphen i option we have hyphen l option we have hyphen v option we have hyphen c hyphen w okay so these are the various options which we just demonstrated and okay so the basic basic things basic purpose in fact of this grep command is your re which is your regular expressions okay and i have shown you already one of the regular expression which is by using asterisk okay so if you remember i have even like something like record star that means any word which is starting with record okay so likewise so like how we use star okay so we use star so the star means matches zero or more character okay so its purpose is like it matches the line with zero or more spaces then we have something like we have what else i have okay i have something called as dollar okay so this dollar is nothing but it matches all the lines which are ending with something okay so let us say if i am if i am searching something like record okay so if i give in my source pattern something like record dollar then what will happen is it will search for all the lines and it will list out only the lines which ends with record okay because i am searching for the record with the the line which is ending with record that's what this dollar sign indicate okay and okay and we have what is where we have dot okay we can use dot basically okay so this dot matches one character basically so let us say if i use something like r e dot dot r d okay so this basically it will find out all the words basically which starts with r e and it it can have any two characters in between that and it ends with r d something like that okay so dot indicates only two positions basically okay and then we have something like upper triangle okay so this upper triangle basically indicates beginning of record okay so let us say if i want to find out all the records which starts with record okay i want to find out all the lines which start with record then i can use pattern like this okay upper triangle followed by a record okay so there are many other things in the regular expression so you can remember a browse for regular expression so regular expression concept is common in all the technologies okay so what i wanted to say is like if i use something like this instead of record one if i use something like this here okay so if i use something like this then what will happen is this command will search for all the lines in this file one dot txt which starts with record okay because this upper triangle indicates it is beginning of the line okay so that's what basically you can use any kind of regular expression after this command so that it will give you the matching pattern in your result okay so that's it i have for this okay and there is one more thing called as e-grap okay so what is e-grap e-grap is your extended grep okay so like how i used a grep command okay there is another command called as e-grap okay so the e-grap is basically extended grep so the advantage so the basic advantage of using e-grap is it has some regular additional um as compared to our regular um the regular expressions it has some additional regular expression meta characters which might be helpful okay so if you want to find out the manual you can just go to man e-grap you will get the complete manual okay so the so the basic basic things are same like you will give the options and you will give the pattern and you will give your file name that's the basic syntax we have okay so that's it i have for this grep so i have talked about grep command which is basically used to search um in your file for a specific file pattern matching file pattern which you can use your any kind of regular expression to find out the matching pattern okay so that's it i have thank you hello welcome back welcome to the course of unix versus manual unix concepts and how we can automate the unix concepts unix processes basically so that we can incorporate them into a test automation frameworks uh in this video i'm going to talk about pipes in unix a very important concept so let's start without further delay so what is pipe okay so pipe is basically a method of inter process communication okay so inter process communication is basically it enables the processes to communicate with each other to share the information let us say if i want to give the input or give the output of one process as input to another process so this is basically where my inter process communication is going to help me okay and install a pipe symbol is used okay so you can see a vertical bar that is called as a pipe symbol okay and that is what we are going to use as a pipe symbol okay so what it means is uh that output of one program or one side of pipe so as the uh input for the program on the another end okay what this means i'm going to show you with example okay so basically as i said pipe is a uh is used to basically uh to achieve inter process communication to talk in between the processes and pipe is a half duplex process uh half duplex basically why because the data flows only in one direction that is input uh sorry output of one program goes as an input to another program but it is not vice versa like output of my second program is not coming back to the first program it is not happening what is happening is output of first program is going to input as my second program okay that's what i said is as a half duplex okay so pipe basically allows to chain together your commands in very elegant way passing output of one program to input of another program and to get our desired end result okay basically in short we can call it as used to connect to or more command okay so uh let's take one very simple example uh okay and what i'm saying is the set of pipe command is also called as pipeline and why it is basically useful because combining a simple os utility is one can easily solve more complex tasks okay very simple example i'm going to show you now okay so if i go to my unix box okay and if i do something like ls okay uh in my present working directory if i do something like ls-l or ls whatever i can see in this top all the files and directories what i have here now if i wish to count uh number of directory in my particular location okay if i want to count then uh how i can do i can either use like ls-l l i'll get a list and then i can do one i'll count one by one one two three four five six seven eight nine eight eight up to 20 i can count it manually or the another way what i can do is i can do like ls-l and then i can write the data in some text file and then i can count the number of lines into that specific file that's the another approach but it's tedious if i have number of like less number of uh files in my directory that's fine but if i have hundreds of file that is not going to serve me so right so in that case you may write uh let us say a c program by using read directory to and for counting it in the loop but a very simple approach what we can use is here piping right so if i use simple uh ls okay i'm getting the list right now what i want to do is output of ls i want to give it as input to one of the filter command okay so i'm going to talk about one of the very important filter command which is wc which is word count okay so this word count command uh sorry it is a filter command basically and we are going to use this uh wc command now okay so and since i want to use pipe over here so what i want to do is i want to use ls first then i want to give output of this ls as the input to wc right so how i will use it ls pipe wc okay so this is simple i can use like ls pipe wc and you can see i'm getting something like 19 21 and 226 okay so what it means is i'm going to show you now okay so this wc as i said it is used to word count okay so if you use simple wc without any option okay then it gives you three things the very first thing is uh number of lines okay and second thing is gives you number of words okay and the third thing is gives you count of number of bytes in uh file or whatever you're going to do right so here you can see i i got 19 so what is my 19 my 19 is number of lines so number of lines is nothing but number of files okay so 19 is my number of files okay and 21 21 is number of words okay now why there is a difference because if you see maximum of the uh uh what i can say directories names or file names are without space but i have only one file over here which has two spaces so it has considered this file as three words first word oracle second word db and third as data.txt so that's the reason it is 21 and 226 is basically uh count of number of bytes into uh the specific uh uh list let us say okay we cannot call it as a file because all these are files so if i create a list of files from this particular file then that is number of bytes from that particular file okay so this is a very simple example how i can use pipe okay and if i need something more specific like uh if i just want to display this minus nine sorry this 19 then how i can use i can use something like ls uh pipe okay i'm passing the output of ls to wc and to wc i can pass number of arguments like if i use wc-l into display my 19 that is number of lines okay if i use another parameter called as w okay it is going to display me number of words that is 21 and finally if i pass it as a c then it is going to provide me the count of number of bytes right so this is basically uh we can use this three different option hyphen l to get the number of lines hyphen w uh number of words and hyphen c number of count of basically number of bytes okay so this is a simple approach how you can count number of files into uh your present directory okay and to achieve this i use this piping concept right so i am simply piping the output of my one program to input uh to another program as a input okay uh let me show you another example okay so if i use the file i might have shown you i don't remember uh i want to show that with cut command okay so one second so what i want to do is now i want to show you the demonstration of cut command okay now what i want to do is i have this file okay so this is my complete file okay now from this file i just want to get the first column right so so if you if you see the file the file is space separated right uh name is separated by space with age separated by space organization and it is common for all records so my space is the separated okay now what i want to do is i want to use the cut command but before i use cut command what i want to do is i want to sort the file and then use cut command okay this is what my aim is right so how i can sort i can do a simple sort with uh sort and my file name is input file dot txt it will give me the sorted result starting from amin andrew carolina james to jen okay now i got the sorted list now what i want to do is i want to give this sorted list as a input to my another program called as cut okay so how i can do that so this this particular command sort file name will do the sorting and output of this sort i want to give as input to my cut command okay and to cut what i can do is i can specify uh like you want to cut the file based on so that's the reason i am using hyphen f and which field you want to do it for a first field okay and what is your delimiter your delimiter so to specify the delimiter i'm using hyphen d and my delimiter is space so input and game space um space right so now can you see i'm getting the list of uh only uh first names right and that is with cut command so can you see now how i use pipe to give the output of one program uh as a input to another program uh so so as to uh in uh basically it is used to inter process communication in between multiple process communication in between multiple process okay so that's what i wanted to show uh and pipe so pipe is basically used to communicate uh to achieve the communication in between two processes that that is to give the output of one command as input to another command okay so fine that's it i hope these two examples should help you the wc example again this wc and cut are my filter commands so if i have not covered this filter command separately here i wanted to uh just demonstrate them okay so these are again a few filter commands so fine thank you hello welcome back welcome to the course of unique fortress uh manual and automated for selenium uh in this video i'm going to show you how we can read and write the files and your next okay so let us see what i'm in details what and on now i'm going to talk i'm going to talk about how to read files on terminal using cat command okay so uh okay and what and all else writes the file that is redirecting and append the data to the text file that is again redirecting okay but uh let me start with uh cat command which is used to read the text file to the terminal okay let me switch to my unit box and here i am now as i said i'm going to use cat command okay so uh in my earlier videos as well i must have used this cat command so this cat command is used to read the uh data so if i use cat followed by my file name it is going to read file for me okay it is going to display the content information of the file okay now this is not the only way we can use uh like read the file we can use view uh space your file this is going to read your file but it will open the file into uh vi editor okay you can refer my video where i talked about vi editor in detail so i'm just going to fit from here okay and so the it's like we have other editors like vi vi m or nano which are used to read the contents uh as well but the difference is cat command is used to read the content from multiple files at a time or we have few more uh possibilities as well with the cat command that that's what we are going to see now okay uh okay so i was talking about cat command so along with cat command like we can use couple of options like we can use one of the optional hyphen p which is used to add line numbers okay and another option we can use hyphen n which is again used to add line numbers but this hyphen n is used to add the line numbers to blank lines as well with option hyphen b you cannot uh number with a blank line but with option hyphen n we can give the numbering to blank lines as well now if i simply want to number this line sorry the content from this file how i can do is i can use cat followed by one of the option called as hyphen b followed by a file name and you can see my file uh contents are getting named record number one is i mean record number two is zen right so i can use one of the option called as hyphen b right now since my uh this particular file do not have any blank line even if i use one of the optional hyphen n i will not see any difference over here right i'm getting the same result okay so to to see the difference what i'll do is i will just modify the file and i'll insert couple of blank lines okay give me a second uh okay i have inserted one line over here let me insert another line here okay sorry okay i have inserted another line let me write and quit sorry i should bring command mode okay now it has a blank lines okay now i'll execute both the commands okay first i will execute cat hyphen b which is used to add the line numbers uh okay and if i use hyphen n over here okay give me a second something is fishy here this looks a little fishy to me because if i use a hyphen n as an option it should not give me line number to my blank lines but sorry hyphen b it should not give but i'm saying there might be some issue with my file anyway i can demonstrate this with uh another file that's fine i'll demonstrate in one of the video again uh i need to create another file in fact uh that's fine now let us take another example where uh what i can do is i can do a copy of file using cat command okay so let us see how we can do that okay so let us say i have one file my file is input file okay and i want to copy that input file do another file uh input file one letter say okay so how we can do that so i can use cat command input file dot txt so this will read my content okay uh and if i want to write this content to another file then we use this redirection operator okay this is something which i'm going to talk in couple of minutes okay and i'll give another file name let us say i1 i1 i1 dot txt okay so what should happen is the data from input file dot txt should get copied uh into a file called as i1 dot txt okay and if i do now cat i1 dot txt i should see the similar data that means the copy operation is successful now next what you can do is uh the main purpose of cat is concatenate concatenate operation okay so how you can perform this concatenate operation okay now let us take uh example what you want to do is you want to concatenate two files it is input file and you want to concatenate that with the second file called as i1 dot txt and you want to write the result in third file okay so how you can do that you can use cat input file input file dot txt okay so this is my first file and my second file is i1 i1 dot txt so these two files i want to concatenate and i want to write the result in i will name the file as concat file dot txt so what should happen is data from both file should get concatenate and get copied into the third file called as concat file okay now if i use cat dot concat and seeing the data from both the files both the data is same but it is getting copied right that means concatenation is successful okay and what else okay and you can basically append the data from one file to another file okay so i'll talk about appending the data okay so to appending the data we use this double directional arrow so i'll talk in a few minutes okay so this is these are a few examples how i can use a cat command basically concatenate command to read the data onto the terminal i can say i can use the options to give the line number then i can use this cat command to make a copy of the file or to concatenate basically the file which is the main purpose of cat what next how to write the file by using redirecting okay so so basically two things read and write okay so read that is something we already saw we can read it by using the cat command okay now what if you want to write the data okay so in my one of the example i have shown you how we can write basically so what we used we use this arrow to write the data to transfer the data from one command to another file okay so let us see how we can do this in more detail okay so the operators like your single arrow or this double arrow triangle are called as redirect command okay so these redirect commands are used to perform this writing operation okay now let us take an example very simple example let me do control l let me clear okay so let us say if you want to write the console data to file okay what like how you can do okay so let us say my present working director or let us say i want to copy the data of my present working directory into another file or i want to copy the data from my ls into another director let us take an example pwd in this case so let us say i want to copy the data result of pwd into a file called as let us say p1 dot txt okay so what will happen is the outcome of this pwd it is and it will be form slash precast will get copied into p1 dot if i see the content of p1 dot txt i should see the same thing form slash precast that means this particular operator is used to write the data into my text file okay and again this will work with variables as well okay so let us say if you define your variable first let us say i define my variable uh my url as equal to www in a second and there shouldn't be space i'm just trying to declare a variable let us say automation.com i have created a variable now what i want to do is i want to write the value of this variable into a file okay so how i can do it how i can access the value of variable basically by using a dollar symbol okay so my dollar symbol followed by my variable name is my url and where i want to write it i want to write it into a file called as uh let me create another file let me say it as url file dot txt right uh come on not found give me a second this should work in fact okay it has created now let us do cat operation or it is blank uh okay i use m2 that should be my let us equal or just printing correctly let us do this again okay why it is not printing because i should equal in fact right because when i equal then only it will print it right so i should use uh something like this equal my url and then i should navigate it to uh url file dot txt okay and now if i do cat on url file dot txt sorry url file dot txt now this should show me the variable which i did set that is automation.com right so we can use this redirect command basically to write the data from variables as well okay now what if you want to append the data right now what is the difference in between writing the data and appending the data is uh now let us say i have some data in my this url file okay and now if i try and uh append the data of this ls-ltr to my url file okay my data some data is getting copied and what the data is let us see okay so it does it has write it some data but i see my earlier record which is uh this www.automation.com is not present in this file that is it has overwritten the data okay so what i should do is i should append the data right so to append the data what we can do is we can use uh this okay so what i'll do is now i know i already have some data in this url file now i will append it with my variable data so to append i should use this double triangle okay and now it is done now let me go let me cat this particular file and at the bottom can you see the data is appended now so to append the data we will be using this double triangle okay so that's basically how we can read the data is in cat command write the day write the data into the text file and append the data to the text file again with redirect okay see two different things writing the data to the text file right with the with the way how we saw using redirect command or by creating the file using vi and then writing it by using vi editor that is another thing right so if you're interested if you're looking at how we can write in by using vi editor you can refer my one of the videos where i talked about vi editor okay so for this video that's it thank you hello welcome back welcome to the course of phoenix potesta in this video i'm going to talk about short command and unix so sort is one of the filter command again which is used to filter the data okay so this we use basically the sort in most of the technologies starting from my excel spreadsheet okay so basically sort command here is used to sort the file that is to arrange the records in particular order could be ascending order or descending order could be alpha particular order starting from A to Z numerical sort as well okay by default this the sort command sorts the file assuming that the contents are in ASCII format okay the standard formats for data okay and there are some options available for this sort command as well which i'm going to talk in a minute okay so let us see how this sort work okay so the syntax of sort it's very simple sort followed by some options okay you can specify some options i'm going to show you what and all options we have though they are not mandatory and followed by your file name which you want to sort okay so this is a pretty simple syntax sort followed by some options if you want to specify any followed by file name now what and all options there are okay so there are many options like like you have minus d option to ignore the leading spaces in each line then you have minus d then you have minus the f if you want to use case insensitivity by default unix is highly case sensitive but if you want to insensitivity then you can use hyphen f as one of the option then there are many but i'm just going to talk about a couple of options in this video which we use more okay so hyphen n is one of the option which we use generally okay and it is used for numeric sorting okay and if you want to have reverse order sorting then you can use hyphen r as one of the option hyphen r is used to to perform reverse order sorting and if you want to perform the sort based on specific field position okay so let us say this is your file okay this is your file and in this file this is my first field which is separated by space followed by second field separated by space followed by third field something like that or let me take another example let me go here and what and all files i have give me a second okay if i check the data from input file dot txt okay i have some data like this okay you can see i have some name followed by age followed by organization followed by some date of birth let us say okay and all the data is separated by spaces okay i mean is separated by space with age separated by space with organization separated by space with date of birth and likewise i have all the records okay and if you want to sort the data based on position like if i want to sort the data based on second field by default the data will get sorted if you do not specify any option the data will get sorted based on first field but let us say if you want to sort the data based on second position then you can use this as one of the option minus hyphen k right sort the file based on the data at specific field position and if you want to suppress the duplicate lines you can use hyphen you as one of the parameter okay now let us talk about a few important options which we can use with sort okay so first let us see how sort work basically okay so let me clear my console and so as i said how is the syntax sort followed by some options followed by file name so i don't want to give any options as of now i just want to sort my input file dot txt okay before that let me display the data from input file okay so this is how the data looks in my input file okay now what i'm going to do is i'm going to sort the data from input file and you will notice the difference okay now can you see the amin second was zen in my original file but in my sorted file you can see the data is getting sorted based on field number one that is amin and t u carolina zams finally zen starting from a to z alphabetical order so my file is getting sorted based on first position okay but see i am sorting the file but it is only for the purpose of displaying onto the screen my actual file is not getting sorted right so now see i have used sort for my file so you must be understanding to okay the file would have sorted okay now what i'll do i'll use again cat to see the data but data what i see over here is again same amin zen gems which is not sorted right so this sort command is used basically to sort the data to display on your console to display on your terminal on your screen right not to modify the file if you want to modify the file then you can do something like this sort this then you can write the data by using triangles and you can write it in the file okay you can do that okay then the data in that file will get overridden and sort in the sorted order basically okay now let's take another option where you want to sort the data based on the fields okay let me okay so here you can see if i see the content you can see the first field is named second field is let us say age now let us say if you want to filter the data based on the age now age is at second position and what i said is if you want to sort it with age then you need to use hyphen k as one of the option okay so if i want to sort the data based on my position of the field i can use sort hyphen k as one of the parameter as i said and which position i want to sort based on second position followed by my file name which is input file dot txt and this time you should the file is getting sorted based on second field that is 18 18 18 20 23 38 46 and 55 that is in increasing order right based on the second and if you see the first field it is catarina rina jams android ads the last gen is in bitcoin so it is not based on the first position but it is on the second position because we used option as hyphen k 2 k is to sort based on the field and on which field i want to sort it based on second field okay now on the similar line if you want to specify the data based on multiple fields then you can use comma separated value like hyphen k 2 comma 3 or 2 comma 4 based on how many number of fields you want to perform the sort okay now let us see quick demonstration of how we can do the numeric sorting okay so for numeric sorting let me take another file so my file is cat new data is new data yeah so here i have a i have a large number of data and here you can see the first column itself i have something like 20 21 starting and ending with 7 e okay let us say i want to sort this file okay so if i sort this my file name is new data okay and if i sort this and you see how it got sorted it got sorted like 20 starting from 20 okay starting from 20 21 20 to 23 likewise okay and ending with 7 a b c d e and finally my alphabets okay now let us say if you want to sort the data based on numerics right so this data isn't got sorted on the basis of numeric if it would have then it would have taken this as my first record 2 a would have been my first record because 2 is the lowest number right so if i use something like this sort hyphen n and new data okay now in this case let us see what it has taken okay so in this case and you see it has taken the data like 2 a 2 a 2 79 okay so it is considering the numeric value only right so that's how we can use hyphen n as one of the argument to sort in a numeric order okay now you can use the sorting in reverse order as well so here you can see i have one of the option as hyphen r so let us take an example where i was doing this sort hyphen k2 okay so this is doing the sorting in ascending order basically increasing order 18 18 20 to 23 but if if i wish to have this order as my reverse order then i can use one of the argument as let us say r okay and this time i should see give me a second okay it works with in fact numeric orders sorry this k give me a second there is a small misplace because this 2 is with k right so it should be an r k2 something like this yes and can you see it is in descending order 55 to 46 38 and last it is 80 it's in reverse order right so that's how basically we can perform the sort okay and you can have this sort in uh you can you can use it in fact with pipes as well okay so let us say let me do control l okay so pipe is something to combine the two commands okay so if i use sort and new data okay you can see i have used number of data but out of that if i wish to restrict the data which i can display on my screen only then i can use something let us say i just want to see few let us say 10 rows uh from my file so what i can use sort the file uh pipe and to get only 10 records i will use head okay so i can see only uh on where my command starts give me a second okay so my command starts from here and it has sorted and it has displayed only let us say 10 records right so that's how we can use this uh pipes as well with my sort command okay and in fact we can use this with cut command as well okay so uh okay so i'll talk about this cut command in my one of the video or let me show you one of the demonstration about this cut command uh okay so this cut command is basically used to let me open the file give me a second okay so let us say out of this new data file let us say i just want to extract the first word i just want to cut the first word all right so how i can do that okay so let us say i want to sort my file with my file name is input file dot txt okay i i just want to sort this file and out of the sorted file i want to cut my first field okay so what i can use i can use hop option as hyphen f1 okay and then i can use option as hyphen b followed by space okay i'll explain what it is first let me check if it works yes that is working perfectly first it is sorting the file okay can you see first it is coming with amin and true finally it is coming with xan so it has sorted the file and out of the sorted file on the cut of first field only right and it has displayed and now if you want to write this data into another file then what you can do is you can use uh uh write some output redirection symbol and cut data cut data dot txt okay and if i use the command cat for cut data now sorry okay now you can see in the file i have only first uh like the first field which is my names in this case right so this is how basically you can use the cut command to get the records to get the data for specific field only and if you want to write the data into some separate file then you can use output redirection followed by the file name which you want to create okay now in this case what is this f and d okay so basically this cut command select the field specified by hyphen f option and distinguish the field by the delimiter again delimiter character specified by hyphen d option okay so this f specify my field one one is my number one field and hyphen f is for field so hyphen f field i want to select the field which field i want to select the first field and hyphen d what is your delimiter and if you see in quotes i have given space that means my delimiter is spaces over here right so here you can see it is separated by spaces so that's the reason i have used spaces okay so this is basically how we can use a sort command and which we can combine with many other commands with piping okay so that's it i wanted to talk about the sort command over here so it is basically used to sort the data in some order which we want could be ascending descending reverse and we have many options as well which we can use it with so i just talked about some important options over here one of the important is if you want to suppress duplicates line let us say in your file if you have many duplicate lines and if you want to suppress them then you can use hyphen u as one of the option note that we can use many option together like i have shown you in one of the case like i use an rk2 we can combine many options okay so that's it about the sort command in my next video i will talk about a few more filter commands so stay tuned thank you welcome back let's come to the course of unix foretester in this video i'm going to talk about unique command which can be used in your Linux operating system so from the name itself we can understand it should be something to display which is unique and in which like in unix we are mostly dealing with files and processes so in unix unique command is basically used to display the or we can say filter out it is basically one of the filter command okay so it is basically used to filter out the repeated lines into the file okay in simple word unix sorry unique as a tool basically that helps to detect the adjacent duplicate lines and also delete the duplicate lines okay so you need to concentrate on the word adjacent over here because it works it detects the duplicated lines only which are adjacent to each other okay let's see one practical demo of that okay and the syntax of unique command is pretty simple unique followed by some options to it i followed by input file okay which is my input file okay so let's see the practical demo let me create one file quickly let me create one file called as data okay and let me add let me edit this file to add some data okay so i'll add some data to it report one okay let me uh repeat this line okay i have repeated this line some five times fine and now i'll insert few more records record two excuse me repeat the first records again give me a second let me edit the last one because i need one something in uppercase so that i can demonstrate few things fine so this is what i wanted let me save and close the file great now my file has some data i can use the data using cat command yes and this is what the data is okay so you can refer the data like it has some duplicated lines which are record one five times which are adjacent to each other then i have two record two which are again adjacent to each other record three and then i have couple of record one as well in which i have one in uppercase so let's see how it works so pretty simple command unique okay and my file name for now i don't want to use an option so my file name is data so uh let's observe the output okay can you observe the output the earlier i had five duplicated lines which were adjacent to each other and i now i have only one record one then i had two record two which were adjacent to each other and i have only one now then record three was single record three and then i have record one again they are duplicated into the file but they are not adjacent right so that they are present in my filtered data again and then i can see record one again which is having some data in uppercase right due to case sensitivity that particular record is not neglected neglected now let us see one of the option to uh neglect this case sensitivity is hyphen i which is most common option in almost all the commands to turn off case sensitivity okay so if i use unique hyphen i data then i should not see the last record one which is because of case sensitivity right now can you see record one and record two record three and record one the last one is neglected now it's filtered now basically right that is because of this option hyphen i okay and there are again a couple of options which we used in which we use basically in our day to day life let us take an example of one option called as hyphen c okay so what this particular option does is it basically gives you the count okay so if i use unique hyphen c data this will basically gives me the count how many times particular line particular record has appeared like so like record one has appeared five times record two has appeared twice and three one one is appeared once right again this record one and record one are adjacent to each other but due to case sensitivity they are not picked up as a duplicate it now i have an option as hyphen i to ignore case sensitivity and i have option hyphen c to account can i combine both let us try can i combine like hyphen ci yes i can let's see the output now can you see the output earlier there were two record one with one one count now i have record one with count of two because i used option hyphen i to ignore the case sensitivity okay so that's how we can use option hyphen c to count an option hyphen i to ignore the case okay and okay there is another option called as option hyphen u okay let us see what it does so from the name we can judge this u is used to print the unique data only the data which is unique right so you can file in the file i have duplicated data for record one and record two but record three and record one and record one they were unique right so that's the reason it has printed only unique data and that's what this particular command hyphen d does okay um then what does we have which we use hyphen i we already used okay i'm just trying to recollect if i use any other option with this hyphen s we use but that is not much important we use option hyphen d okay we have one more option called as hyphen d option okay what this option does is we can just again it displays only the record which are duplicated okay can you see here when i used option unique hyphen d it is giving me record one and record two only right so that's how we can use the various options again there are many options to this particular command but these are the repetitively used in our day-to-day task that's what i wanted to explain to to get more details you can refer the manual by using command man space unique you'll get the complete manual with all the options which which can be used along with this unique command but i i just explained this four to five options which we use day-to-day basis like option i to ignore case sensitivity options c to c the count option u to get the unique data hyphen d to get the duplicated data okay so that's what i wanted to talk about this unique command in units which is basically one of the filter command okay and you know you can use this any filter command basically in piping okay so you can basically coordinate two commands to get the data and just for example let us say if i want to use something like this cat so if i use cat data this will basically display the data on my console okay so if i want to let us say display the data and then i want to find out the unique data then i can use cat data let me use pipe unique okay can you see you can use unique command this way as well like i'm giving the file name to cat command so that cat command will read the data and the data which is read by cat command is given to unique command which will process by unique command then okay so that's what about unique command in unix or linux in fact thank you hello welcome back welcome to the course of unix for tester in this video i'm going to talk about how you can compare two files using command biwf diff command okay so in my last video i have shown you how we can use cmp command for comparison and which was basically doing byte by byte comparison okay now in this case if i use diff command the comparison will happen line by line if i was using diff command it was showing me the open the difference was found in line 1 and byte 16th okay but in diff command the comparison will happen line by line and which is something which i find most useful as a testing point of okay so let's see how it works okay so uh okay let me show you the syntax basically let me okay so the syntax is something like diff which is my command itself and then i have some options which i can specify okay again there are a huge number of options for this particular command which i'm not going to talk about all but just couple of options which we use more frequently and which we need basically okay those options i'm going to talk here and then followed by my file one and file two okay so this is the syntax which is very simple okay so let's see how diff works okay so let me use diff command now diff now my file one is new data in which i have some data and again the it's same copy with some minor changes and new data one okay i'll hit enter and you should see something like this okay now uh there are few things you should notice over here okay so give me a second so what you see over here is you see some some words like one c one and you see some less than symbol you see some greater than symbol you see something 18c 18 something like that okay so what are these things okay so what this basically diff command tells you the diff command tells you that what and all changes are required into the first file so that it will look exactly as same as your second file i have two files file new data and new data one so what this particular command will tell you what and all changes you need in new data which is my file one so that it will look exactly as same as uh my second file which is new data one and basically the comparison happens line by line okay so unlike its fellow member like we have different commands for comparison like cmp as i said earlier and we have one more called as form c o m m it tells uh basically they tells us uh bite by bite comparison but in this case we see the comparison line by line okay so it basically tells us which line uh in one file have to be changed to make the two files identical okay so what these things are now one c one less than symbol greater than symbol so uh basically this diff command give you the output and it uses some special symbols and instruction to uh give you the output okay so uh there are the two things the very very first one is the special symbols which are a c and d so as the name suggests it is a for add c for change and d for delete a for add c for change and d for delete okay now what it tells i'll tell you okay and we have two more things like we have one less than symbol which refers first file okay and we have some greater than symbol which second file okay now something should be clear to you okay now what the first uh this one c one tells me okay so this one c one tells me that okay this one is file one okay and this one is sorry this one is line one from file one and c is nothing but change and this one is again line one from file two okay so what this basically is telling me you need a change in line one of file one and line two of file two okay and where that's where that change is you can see the very first is less than symbol that is uh this particular line is from my first file okay so though you can see the file the following r and in r i have r in upper case in first file and in second file i have it in lower case that's the only change what i have in this particular uh line okay so because of which i can see this particular difference okay so i hope you're clear now this one refers line one from file one c means you need particular change in line one of file one so that it will look exactly same as line one from file two and this one refers to line one from file two less than symbol refers first file this is required this is line from my first file and this is the greater than symbol as refers line one from my second file okay on the similar line you see something next to that you see something seven c seven uh this means there is a difference ends line number seven of file one and in order to make uh the lines equal you need to do the change in line number seven c means change okay so you need to do the change okay so you can see the different difference lines like less than symbol means first file so the first file has something like optical description and the second file means greater than symbol has something like eggs description so you need to have change over here okay and again similar line i have something in line number 18 you where again you need change now why i see only ccc that is for change over here because i what i did it i simply went to the file i made a copy and i did some changes in that but if you have something extra into the file then you something like addition or something like deletion over there right but in my case since i have only changed it i'm not saying those things okay but maybe you can give a try by adding some content or deleting some content from another file uh you should get that okay so that's basically this is basically where uh very useful comparison for me if i want to compare two files okay and now let us take an example i want to ignore uh the case sensitivity if you see the first difference it is because of case sensitivity i have upper case r and i have lower case r and unix is quite case sensitive okay let us say i want to ignore case sensitivity okay so what i can do is i can use option hyphen i again which is option hyphen i is the common for most of the commands which is for to make case insensitive okay so i can use something like diff option hyphen i okay and followed by my file one new data and another file new data one okay now if you see when i didn't use option hyphen i i saw three differences the very first one was because of this r okay upper case and lower case but when i use option hyphen i i don't see the very first difference which was because of uh case sensitivity i just see other two differences okay so this hyphen i is to skip uh is to make your comparison case insensitive okay and we have another option which we use uh mostly which is to uh ignore uh white spaces okay if you have some white spaces in your file at the end of the file or something like that and if you want to ignore them you can use one of the option called as hyphen b in my file since i do not have it i cannot show and demo it to you but this will be used when you have some white spaces before or after your file and if you want to ignore them from comparison you can use this option basically hyphen so this is about how we can compare the file by using dip command okay and there are many number of commands which you can find in the manual okay so if i see man space dip that is i can get the dip manual and you can say you can find it has a huge number of commands okay so you can as per your requirement you can go here and you can try but the if i just want to compare the two files the two come the two options are useful to me which are my option hyphen i to ignore case sensitivity because i can see all the differences like this okay and what else okay there is one more option give me a second let me check there is one more option like hyphen why i guess let me check if it is di wf and if i use option as hyphen y and new data new data and new data one okay uh okay so this file i will not be able to see it correctly but i'll just tell you what this particular command does this particular command does the comparison column by column so it will put the file one in column one and file two in column two and it will show you the comparison results okay so you two files are like here you won't be able to see that much clearly because the files are big one but you can see something like some pipe symbol over here that means there is a difference over here and you can see the difference is in between r this the following r i have uppercase r over here and then i have this lowercase r over here in my second file this is the one okay again i see second pipe over here that means there is a difference over here you can see the first file has octal second file has hex okay and the third pipe is over here that means some differences over here that is in my first file i have z9 and in my second file i have a9 right so if you want to have column by column comparison if you want to put both files into two columns then you can use this option y uh hyphen y option as one of the option basically okay so this is how you can do line by line comparison using diff command which i personally feel more useful to me when i want to compare two files in unix okay as compared to byte by byte comparisons rather okay so that's it thank you hello welcome back welcome to unix for tester course this is a quick video in which i'm going to talk about how we can compare two files using cmp command okay so comparing file must be a repetitive task what we do most of the day when we deal with unix systems especially as a part of testing activities so for for doing file comparisons could be any any type of file so for doing file comparison there are three to four different commands out of that i'm going to talk about cmp command in this video okay so the cmp command is basically um as i said used to compare two files but the comparison happened byte by byte okay so if i go to my unix terminal and if i check the help document for cmp by using man cmp i should get some description like it is used to compare the two files byte by byte okay and the syntax for this particular compare command is like this cmp which is for compare followed by some options okay what and all options we have that i'm going to talk okay and followed by your file one and file two and if you want to skip any records then we can specify with options okay so uh we have some options like uh hyphen b hyphen i then we have hyphen uh l hyphen uh s to suppress the output we have four to five options okay so let's go to that quickly let me quit this okay now i have two files basically okay i have two files my first file is new data okay and in this file i have some data okay so in this file i have some data and i have made some changes into this file like i changed this lowercase r to uppercase r in this file and i changed a couple of things here and there okay uh so this is the my first change what i have in my file uh in one file i have small case r and in in one file i have uppercase r okay now let us see how this compare command work in this case okay so uh uh the syntax is basically cmp okay then option which are optional basically which i'm going to show you in some more time and followed by my file one name my file one is new data and my next file is new data one where i have made changes okay new data one these are the two to compare new data and new data one and i'll hit enter and you can see new data and new data one differs at byte 16 of line one so the comparison is happening basically byte by byte okay and wherever this particular uh program finds the uh difference it is going to terminate the program and giving me the output where is where my first mismatch found right so the first mismatch was on line one at byte 16 okay so this might not be that much useful in this way okay but uh uh if you want to use it in shell script then this particular utility could be useful i'll tell you how okay now let us see a few options what we have so we have uh option hyphen b okay so if i use cmp hyphen b okay uh it is basically used to print uh differing byte okay the the bytes which are differing it is used to print that so i'll use cmp hyphen b i can give file one as new data and file two as new data one and you can see there is something like new data and new data one differ byte 16 line one is 12 some control j and 160 r okay so there is some configuration issue with my unique system so that's the reason i'm getting this but in actual you should get like uh in this case you will get like upper case r and lower case r that's what the difference in between two bytes okay so this hyphen b option is used to print the bytes which are different okay so we have one option called as hyphen b for that now we have another option called as hyphen i okay uh if you skip uh some bytes from comparison let us say what i want to do is i want to skip uh let us say first uh since the mismatch is on 16 byte let me say i'm going to skip my first 20 bytes so for that i'm going to use option hyphen i followed by how many bytes i want to skip from both the files so let us say i want to skip 20 bytes uh from both the files the first 20 bytes should not be compared and comparisons should start from 21st byte okay what are my files my file is new data and new data one okay and now can you see the file is having another difference and it is on line 7 byte 267 that is the second change i made but now can you see clearly that it has skipped this particular comparison where i had the difference on line uh 1 on byte 16 so this particular comparison has been skipped and now there is a difference in line 7 byte number 267 okay so at work now uh you might have situation where uh you uh let me say again you might need to skip let us say first 10 byte from file one and 12 byte from file two might be you might have some few few junk special type of characters or few differences in the initial wording so if you want to skip let us say first 10 bytes from file one and 12 bytes from file then you can use syntax something like this okay so since i do not have that kind of file i'm not going to show you that but you can specify sorry there should be hyphen i as well here let me say again so it should be like hyphen i then byte to be skipped from first file let us i want to skip 10 byte from the first file colon byte to be skipped from second file let us i want to skip 12 byte from the second file and my both file file 1 and file 2 right so it will work in that way so yeah so again we can use hyphen i option for that okay let us take another example where you want to uh compare only first 10 byte okay so by using hyphen i option we skipped first 10 byte or first 12 byte whatever right but now if in case if you just want to compare only few bytes from some file then you can use hyphen n as one of the option and let us say you want to compare first 15 byte of both file and my both file are new data and new data one now in this case since my file had a difference on byte 16 of line one and i just said just compare first 15 byte so that's the reason i'm not getting any error message over here so if i'm not getting any uh message warning or anything that means the file comparison is successful so what we compared we just compared first 15 bytes using option hyphen n and okay and one last option i want to show you is hyphen s option okay so this hyphen s option is basically used to suppress the output okay so whatever output you see the comparison output in this case the output is something like this new data new data file differ add by 16 line one whatever this is okay so if you don't want to see this output you want to suppress it then you can use the option called as hyphen yes okay and you can give your file name new data and new data one so see i have the differences but the output is getting suppressed okay but in this case it will return some uh exit status so it will return exit status one and two one if it is success and two is there is some message something like that so now where it should be where it can be used it can be used uh in your uh shell script wherever you want to write a script and in that in particular script if you have some functionality where you want to compare the file and if you just want to check if both files are equal or not then you can use this uh hyphen s option from where you will get the exit status okay anyway we don't want it to use for our file comparison so uh as a tester i will not basically use this cmp option because it is not much useful to me um but this is one of the utility program what unix has provided okay so in next video i'm going to show you we have another two options to compare the files uh diff and one more we have so that is what i'm going to explain in next video okay so stay tuned thank you hello welcome back welcome to the course of unix for tester uh this would be a very short video where i'll talk about variables in unix or linux so though as a software tester it is not necessary for us to understand uh variables in detail i'm just going to show you uh at least how we can get the values for system variables okay so uh let us try and understand what is variable first okay so in any programming languages when we work with okay we assign some value to the variable in order to make it dynamic okay like i define some variable as name is equal to something like i define some variable and i assign some value to it right so that is what my variable is that is something used to store some value um which basically refers some memory location okay and in unix there are two kinds of variables first one is system defined variable and second one is user defined variable okay so system depends variables are something which are created and maintained by unix or linux itself okay so this type of variables are defined in capital letters okay so let us take a very simple example uh if i go to my shell unix shell okay so in my last video i shown you something like if i do something like eco uh dollar and uh shell okay if i do something like that then i will get what uh shell i am going to use right so here this shell is nothing but my system defined variable it is defined and maintained by system itself i can just access it if i want i can set its value and just by overriding that is something which i can do in the path variable uh okay in this in some folder under path variable that is i can do but i'm not supposed to do until and unless i'm very much sure if i want to make those changes for specific requirement again let us take some example like if i want to get my uh home location like okay so what i can do is i can use something like eco dollar home so this home is again another system defined environment variable okay and another example i can show you like let me check if does this eco sorry oh yes like walk over here it works in linux i'm not sure if it works here yeah it works over here and it is linux you know which is uh the unix flavor basically okay and we we all know right we have some environment variable in uh windows operating system like if you if we install let us any tool then let us see if i install Java then i need to configure environment variable so that it refers to particular environment a particular version of Java right on the similar line there are environment variables okay and uh everything is maintained under this path right so you can go to this location and do some changes if you want to do uh i suggest a lot to do okay and okay so this is how again there are many uh variable system defined variable a few of them i have listed over here like we have bash bash version then home which i have shown then log name our logging in name then we'll style then we have path ps1 pwd which will use me the present working directly like to get your present working directly i can directly use pwd like this or i can even do something like eco dollar pwd like this okay so the thing to remember here is if you see anything in uppercase uh any variable in uppercase that is your system defined variable okay now the second second variable type is your user defined variable okay so though as a software tester we do not need it let me show you how quickly we can define it and uh retrieve the environment okay so defining the variable uh mostly we will be using this thing in uh shell scripting right and as a tester i'm not going to do any shell scripting if that is then i'm not a software tester right i'm not complete data still developer but let us see how we can do that okay so what you can do is you can simply type your command let us say i want to create variable of name uh var and i want to assign some value to it which is 99 okay for example okay i have set it that's it my variable has been set and now if i want to access that value how i can access it eco dollar var and it should print 99 so this is my uh user defined variable which we should write it in lowercase right if it is some different that is an uppercase user defined should be in lowercase right so this was a very short video about variable type though it is not in detail because as a software tester i'm not going to deal with uh variables and all of them but i just wanted to show you some uh variables and how we can access them basically okay so and that's it i have uh for this video thank you hello welcome back welcome to the course of the next four tester uh in this video i'm going to talk about shell script okay so i'm going to talk about how we can create a shell script how we can execute a shell script in fact i'll start with what is shell script form okay so uh first let us talk about what is shell script okay so if you are aware in windows we have something called as batch file okay and i have one simple example where i have created a batch file okay so if you want to execute any script from goss okay uh then we use this basically windows batch file okay with dot bat extension okay if i open and if i show you something like this this is my batch file okay and these are the uh three different commands which i'm going to execute from my batch file okay so uh like if i don't use this batch file then what i need to do is i need to execute my command one first then i need to execute my second command then i need to execute third command in the sequence one by one manually but instead of that what i did is i wrote all three commands one by one in a line and i saved that particular file with dot bat extension that is batch file and simply i can double click on that batch file or even i can call it from my uh command prompt and the all the commands from that particular part it executed okay on the similar line if i wanted to do some same thing for linux then there is something called a shell script okay so basically shell script is a text file that contain a sequence of command for a unix based operating system so let us say in unix i want to do some processes like first i want to navigate to some directory then i want to read text file from the directory i want to process text file then i want to save the process data into some other text file and blah blah blah we have many operations which which can be achieved with uh unix right so if i want to do all those operations one by one manually it is very much time consuming i need to write a command uh each time uh for each uh command which i want to execute basically one by one manually right that is pretty tedious task so a unix shell script is a text file that contains sequence of all these commands which you which you want to execute one by one okay uh it's called a script because it combines two words script in a single file that is a sequence of commands that would otherwise have to be presented to the system in the form of keyboard one at a time right and the shell is the operating system systems command interpreter right because see what kind of operating system i'm using i'm using uh unix operating system and its interpreter is shell okay i'm going to show you where the shell interpreter is so based on these two combination like since i have a shell interpreter and i am writing uh all my command into a file which the script so that is why it is basically called as a shell script okay uh now i'm going to let us uh i'm not basically going to create a shell script but i'm going to existing shell script which i have created okay so if i do ls over here uh if you see any file uh here which is ending with dot ssh extension is called as your shell script okay so this is my shell script which is script dot ssh okay so as i said in windows batch file we have uh like we will be writing a text file with dot bat extension but in case of unix it will be uh file ending with dot ssh extension that will be termed as your shell script okay now let us view the content of this shell script what this particular shell script contains okay so let me do vi script dot ssh and this is basically my shell script okay so uh the very first line you see something like hash then exclamation symbol and then you see some path like slash bin slash ssh okay first let us go and check what this particular path is okay let me go to slash bin and let me check what and all i have here i have many things let me check if i have sh anything called as sh uh yes i do have okay so let me do ls iPhone LDR okay and let us check uh what is this sh is okay let me set in i saw i said somewhere it is there uh yeah so it is okay and this sh is basically uh special kind of directory okay so let me check if i can view its content okay actually i it is basically a file but i cannot view its content right because it is a interpreter for me right so i cannot open the interpreter and i cannot view the content right so let me quit fine so this is the basically location where uh my interpreter is slash bin slash sh okay that's what i wanted to show you now let me go to my shell script let me go to my home directory okay now i have my shell script over here okay and let me open it again so the very first line as i said uh contains the interpreter right so this is the very important line which tells unix operating system that okay execute the below commands with the help of this particular interpreter okay so this is called a shebang okay this complete line is called a shebang okay so i this is my basically a shell script and in shell script you can find i have uh i have some commands which i am going to execute one after another okay so this eco is my first command which i'm going to execute then after that i'm going to execute another eco then i'm doing some while look over the line which i'm going to read the data from my input file and then again finally i'm going to do eco so i'm going to execute the commands one by one so uh in order to execute all cringe right because i don't want to execute one after another go go there and execute manually i don't want to do that so what i did is i just combined all of them into one file called a shell script okay so this what this shell script is basically doing it is reading the data from input file dot txt okay so we know that this less than symbol and greater than symbol are the ioridirectional operators basically we can call them so this less than symbol is used to read the data and this right greater than symbol basically used to write the data into uh file right so this double uh greater than symbol is basically used to append the data to the output file okay so this shell script is basically reading the data from my input file and simply writing the data to output file by writing over all the lines okay that's the pretty simple example what i have okay now let me come out of this and let me tell you now how we can execute this shell script okay so basically there are two ways how we can execute the shell script so the very first way is you can refer the current directory that is with the help of dot and then give the name of your shell script which is script dot message okay so if i hit enter you can see my shell script execution is completed because i can see some messages are printed and if i see some file would have been generated but that's when i know that file is generated okay but since i see this message that means my shell script execution is completed okay but whenever you create a shell script by default it does not have a permission to execute that particular shell script okay and how can you see the permissions if you do ls-ltr you will see go to your shell script that is script.sh and here you will see some permissions right so the very first 10 bytes you will see starting from second byte rwx which are the permissions for user then second rwx permission for user group third rwx permission for others right so this is something which i set by myself okay but if you are doing it first time then you will have something like i'm just changing the permission back to the normal level ch mode i'm setting it to 640 and script.sh okay so this is how basically whenever you will create this first time you will see something like this and let me check what and all permission it has now so script.sh you can see it has only read rate permission for user and at the fourth place you can see it has a hyphen that means it does not have the execute permission okay and if i try to execute the script without execute permission i should see the error message called as permission denied okay so in order to execute any shell script we need to do the permission so you need to do the permission whether you want to execute this shell script by your user name or maybe all other users from particular group or maybe anyone else can execute this particular shell script so you can do permission accordingly right so you can refer my one of the video where i talked about file permission okay i have talked about all these things like how we can change the file permission using ch mode command okay so for now i'm setting the permission 777 that means i'm i'm giving all the accesses to all all the like users user group and others right and my script is script.sh okay and if i try to execute the same shell script now script.sh now this time i should see my script got executed right so this is the one way how we can execute the shell script navigate to the directory where your shell script is and then use dot slash your script name okay another way to execute your shell script is again navigate where your shell script is currently i'm in the same directory where my shell script is and then use sh which is basically a command or you can say utility program which basically runs your shell script and then give the name of your shell script which is script.sh and if i hit enter i should see my script execution is completed right so these are the two way basically how we execute the shell script okay so that's what i wanted to show you in this video basically what is shell script how we can create a shell script and how to execute okay so see as a task engineer whenever we deal with any system with unix operations and all we are not going to create any shell script right because that's the job of data stage developers or unix developer whoever it is what my job is my job is to execute the shell script verify the output file if the output file is getting generated if the contents are correct and all those things right my job is to execute the shell script and verify the results not to write the shell script or what are the contents they are in the shell script but i should have a little bit idea okay shell script is like this it looks like this it works like this and other things right so that i can get even more interest and i can i may get few different things into my execution okay so that's what i wanted to talk in this video okay so thank you hello welcome back welcome to the course of unix protesters manually learn how we can automate the unix processes which can be used with any test automation framework so in this video i'm going to talk on how to automate the unix processes so what are the different unix processes we have like we might need to execute the shell script we may need to send the file we might need to check if my file is existing on server if i might need to delete the file is existing or create file or might be receiving file from my unix server to my local machine for further processing for further validation it could be anything like so we can automate all those unix processes so that i can accommodate them into my test automation framework okay so let us take an example i have some application where i input some data on my web application which let us say which you have automated with selenium okay and then you have a part of unix shell script execution let us say after though after that shell scripts get executed then only your something happens okay and then you need to verify that particular something part into your ui again or into your database or so somewhere okay so you have automated the part web ui part very easily with selenium but how we can automate that unix integration part with so that i can have my complete intuint test automation or there might be some some application let us say like which is processing your text file and let us say your you are preparing some text file and then you are sending the text file to your unix server so that unix shell script will process it and then you will verify the text file right so you can automate even this process with the help of this uh putty or ssh library okay so we will be talking about in next three to four videos we will talk about how we can automate it with approach one and and then we'll say approach two that is by using third party libraries okay so there are two approaches i can suggest you like by using putty tool but this is something which i can refer very less okay there is second approach which is by using ssh library okay so when i say putty tool okay so if you go to your installation directory if you go to your c drive and where where your putty installation is so my put installation is in windows program files and putty so here you can see multiple applications okay like the very first thing is uc putty which is my this particular application which i used to interact with the unix server then we have couple of more we have putty gen to generate my public private key then we have couple of applications like pscp psct and plink okay so by using these tool plink and pscp or psct we can do the processes like we can run the shell script automatically or we can schedule sftq operation for file transfer from uh to and fro okay so we can perform those things by using these tool and in next three videos i'll be talking about this approach one how we can automate these processes by using this putty tool so when i say putty tool that means by using this plink and pscp or psct okay so by using these tool how we can automate the various processes okay so that's what we will be talking so what and all processes we can automate it as i said we can let us say if you want to execute any command or any shell script or you want to execute any ftp commands file transfer from your local machine to server server to local machine or anything else if you want to type a file existing or something like that if you want to delete file any any kind of operations okay or finally to interact with any server for any other purposes so i'll be talking about these things uh in my next three to four videos for approach one and then i'll start with my approach two which is by using ssh library so i will use one ssh library for java which is jsch and by using that ssh library we'll see how we can automate all those all those processes internally and how it is more effective than using your putty tool okay so fine so stay tuned for this next video where i'm going to talk about how we can automate the processes using putty tools thank you hello welcome back in this video i'm going to talk on how to automate your shell script execution using putty okay so in my last video i have shown you a couple of putty tools okay so let me go to it once again so if i go to my putty installation directory okay so we have some putty tools in that like filling psdp and psdp so by using these tools we can automate uh few uh unix processes okay like your shell script execution file transfer and few other things okay so in this video i'm going to show you how we can execute a shell script automatically okay and how you can include it in your program okay um in your letters in java programming in linux so the very first thing is what i'm going to do is i'm going to create a batch file okay so you know batch file is uh ending with dot bat extension that is my batch file okay and the advantage of creating batch file is as soon as i double click uh in fact batch file is executable file as soon as i double click it starts its execution into command prompt okay so that's where i'm going to use my batch file okay and then okay now uh from this putty installation tools i'm going to use plink in this case okay because this plink uh okay i'll not be able to open plink like this like how i can use a putty but i can call this plink to execute my shell script excuse me to execute my shell script okay so i'm going to show you how we can do that so the very first thing is since i'm using this plink i need to change my okay and as i said we will be using uh uh command prompt okay so let us say if i navigate to my command prompt okay and if i if i need to use this uh if i need to use this particular plink then i should navigate to this particular directory so the very first thing what i'll do is i'll change my directory to this so this will be my first step in my batch file okay so that's what my first step is cd to put installation directory okay and then i will be using some command like this plink.exe okay followed by my username at the rate my server followed by shell script path so this is the standard syntax how you can execute your shell script using this plink okay and we will be adding all these things into the batch file so that as soon as i double click on my batch file or you can call even that batch file is your executable file you can call that batch file from anywhere and like from any programs and it will execute it okay so and we can finally once your batch file is created we can execute it from your java code or in fact since it is executable it can be called from any uh programming language fine now let us start so i'll be creating batch files so how we can create a batch file so you can simply create a text file okay and you can save the text file like i'm going to click on save it on desktop okay and let us say i'm naming it as uh shell exact okay i'm going to name it as shell exact and extension should be dot bat dot that is batch and since i'm i'm specifying extension in file name itself you need to enclose it with double code right so that it will consider this dot bat as a extension not this txt right so if i click on save you can see now my batch file is created so if i go on desktop we can see something shell exact okay you can see it is as a windows batch file so if i click on this uh the app can't run fine fine we'll see why it is not running let us create it first so uh now my i have created a batch file now my next thing is i need to change my directory to put the installation directory which is this one okay so i'll be using this command cd and this okay let me copy this and let me paste it over here now i'll get navigated to this particular installation directory okay and from this particular installation directory what i'm going to call i'm going to call filling dot exe that is this particular tool filling dot exe so that's why i after i navigate it to this i'll be able to execute this filling dot exe now in order to use this filling dot exe what i said is i need to specify filling followed by my username at the red server and my script file path okay so the very first thing is we will see my username okay so my username if you go here you can see not here let me go to put t so if you go to put t you can see my username as prakash p-r-a-k-a-s-h yes so i will add prakash at the rate what is my server so if i need to check my server i need to start a new session and basically i can get my server name from here okay so i will add my username at the rate server okay and then okay so i have given filling username server followed by script file path okay so i need to give my script file now so now i want to tell uh filling that i want to execute a shell script so i am using parameter hyphen s s h okay so shell script i'm going to execute shell script and now how to execute a shell script okay so let me go to my put me here let me close this and so let me do ls okay so if i do ls you can see some shell script over here that is script dot s h okay and how to execute the shell script is by using s h followed by script what is your script name okay so now you can see exec has started social execution it started right so since there is nothing in the script it will not execute anything but you can see execute started that is part of my script fine i'm going to terminate this execution so my execution is stopped fine so what what i just wanted to show you in order to run the shell script you will be using s h followed by your script name script dot s h now since my shell script was residing into my home directory itself i need not to give any uh directory uh location like how i have mentioned over here like go to etc then go to backup and then i have s h file present over here so if in in such a case i need to specify location as well but in my case it is present in my home directory itself so that's the reason i need not to give any uh location so what i've done i'm calling feeling.exe from this particular location then i'm passing my username on this server uh followed by ssh and my script now you must be wondering uh how it how it is going to authenticate okay so there are two ways how we it can authenticate by using password okay or by using key so in my case uh i'm going to authenticate with key okay but if you have password already handy with you then what you can do is you can use one parameter called as pw as an option and specify your password like just before username you need to pass this parameter as a pw and your password here you can specify your password here then followed by your username and whatever we have next right so the extra thing is you need to pass your password over here by using type and pw uh in my case i do not have password okay so in my case i have ssh key so if i have ssh key then i need to use a parameter called as type and i and then i need to pass my public private key okay so where is my key uh my key should be in my f drive key and here is my key which i'm going to use it to achieve the connection that's what i'm passing it from my venus city from my book i'm passing the same key so let me get this path for this particular key okay so fine now after parameter i i need to pass my key path right so that's what i'm going to pass okay so this is what my complete command is let me zoom it out okay so first i cd over here then i'm calling feeling by using this particular key i'm going to authenticate i need i don't need this password here okay by using this particular key uh i'm going to authenticate on this particular server with this username and i'm going to execute this specific command okay and after this i need to exit fine as soon as the execution is completed i need to exit so this is my complete shell script sorry complete batch file uh from which i'm i'm going to execute the particular shell script okay let me uh execute it now how we can execute i can just double click and it will start the execution and you can see it has uh ccd uh to this particular directory and then it has typed this particular command and it says access granted trace return to begin section now if i hit enter uh it is saying exact started that means my shell script execution is started but here you can see a manual intervention because it is asking me to press the return key okay so if i do not want this manual intervention then we can add one more parameter which is called as no anti spoof okay so what i can do is i can add another parameter uh i can add here or even i can add after your uh server and the parameter is no no anti spoof okay so that it will not ask you to um press return key as a confirmation okay so now i just saved it and i'll hit enter on this uh exact and now you should see the execution should start yeah now you see the execution is started i it do not have any manual intervention now and your shell script execution will start great so my shell script execution is started and now what i can do is basically now my shell script uh shell script execution uh basically batch file for shell script execution is completed by using this particular syntax and now i'm good to execute this batch file from my java code impact as i said this is a executable file windows batch file you can execute it from any programming language okay so in next uh next three videos i'm going to show you after three videos in fact i'm going to show you how we can execute any batch file from your java code okay so uh what next i'm going to do is i i'm going to call this particular shell script for this particular batch file from my uh java code so that i can uh include this into my automation framework okay so this is a part of in fact my approach one which i said i prefer less rather than uh i prefer uh using sss libraries like jsth for java or sssnet for csharp okay so fine so we'll continue with uh next video where we i'm i'm going to show you how we can do a file transfer from your windows to server from server to windows and post that i'll show you how we can execute this particular batch file from your java code okay so stay tuned thank you hello welcome back welcome to the course of linux for testers manual linux concepts and uh help automate all those linux concepts and linux processes uh in order to accommodate uh the processes various automation processes of linux in your test automation framework so uh as a part of this series i'm going to talk on uh automation of sending file to linux server using putty okay so as i said i have two approaches using putty tools and using uh sss library called jsh so using putty tool uh currently i'm talking on so here um for like in my last video i talked about how we can execute a shell script using uh p-link by using putty and here i'm going to talk on how we can send the file impact how we can transfer the file to and fro uh from linux server to your windows machine or or your local machine or from your local machine to your linux server via pscp which is a part of putty installation okay so the process remains same i need to create a batch file then i need to see cv to the putty installation directory then i'm going to use at this time if i go to my putty installation directory you can see something called as pscp okay so this is uh putty secure uh sptp uh protocol which is uh used to transfer your file as that that is your file transfer protocol for performing ftp operations okay so this p-link in last video i have shown you how we can do this p-link to execute the shell scripts uh in fact we can execute any commands by using this p-link and here i'm going to show you how we can do this pscp okay so i'm going to use this pscp and we need to use it in below format okay so this pscp and here i need to provide some options okay what are those options like uh uh could be my password or could be my um sshp or could be any options okay then i need to specify the source okay and then username post and my target okay so in this case since i'm sending it from my local machine to the unix server so my source will be my file from my local machine okay and my target would be uh any target into my uh unix server okay so let us start so let me go to uh this okay so this was the script from my last uh video where i have shown you how we can install ssh how we can execute ssh script by using batch file now i'm going to create a new ssh sorry new batch file how i can create i can create just a text file and i can go and i can click on save as and i will name it as send to host okay and the extension should be bad because it is a batch file you can look for my previous video for detail the description and i'm going to click on save and i'm going to paste my command from my previous video because i need to cc a cd to this particular directory where my put is installed and from this i'm going to use in fact this exe is not required uh so at this time i'll not give exe or even if we give there is no harm i can give pscp because we are going to use this pscp okay so i have i have cd to this particular directory and from there i'm going to execute pscp okay and this time our format is options okay so in options i need to give my uh option which is my uh public private key so here again we need to use parameter hyphen i fine along with hyphen i my p okay and then i need to specify my source okay so now what is my source so let us say let me go so let us say i want to send this particular file to my unix server okay so i can get the path of this particular file uh let me copy copy as a path okay and i need to specify path over here okay so i'm just uh space followed by path okay which is my source file so let us say i want to send this specific source file to uh host okay and uh followed by what next we have we have user adverite host so what is my user user is prakash so i'm just removing this unwanted spaces now user is prakash uh adverite host okay and this time um this no anti-scope is not required i believe or let it be because i think this anti-scope is uh i i mean uh why we use this anti-scope it was to get the read of that particular message like access granted press the return key to continue so i think we will not get this for acceptivity operation we get it when we use building if we get then we will add it fine now i have uh username adverite for my particular host and in host then i need to use uh in my host where i need to transfer my file so let us say in host i need to transfer my file to my directory called home slash praka so if i go to putty and if i do my print working directory you can see it is home slash praka so let us say here i want to transfer my file okay and my file name is file uh to send to host okay so let me just uh clear and let us do ls okay so here i do not see any file called as files into host.txt and so i'm sending this file from my local directory to unit server into this specific location specific directory okay so i hope this is pretty clear nothing much uh to talk uh cd to this putty installation directory from putty installation directory use this particular pscp for secure uh your file transfer operations type an i to pass my public private key then my source file the file which i need to send followed by my username adverite host followed by my path where i need to send it to my unit server followed by exit okay so now your question might be if you're not aware your question might be in which cases we might have this kind of uh we might meet this kind of operation so as i said earlier let us say you have a system where um your upstream system is sending uh extracts of your data this could be your data this could be your uh main frame files or could be anything okay let us say your upstream system is sending the extract of or in fact let us say let us call in simple terminology or in upstream system sending the files to your unit server and in your unit server uh you want to execute the shell script so that that particular file will get fixed process and it will generate one output file in fact it will do let us say some operations it will result some data that we need anything it will process the output file and you need to verify that output file so in my system testing what is my process what what and all i need i need to send this particular file to host then uh i have host in the sense to my unit server okay i need to send it to because sending receiving it from upstream system that is part of sit or or ui or uat whatever right but in my system testing case let us say i want to send it to my unit server for my for testing my shell script if it is perfect okay so i'll i'll be sending it to my unit server then let us say i'll be sending it by using this particular uh match file then i'll be my shell script by using the another patch script which we saw last time and then once the shell script is triggered for shell execution uh it will process it will produce let us say one output text file which i need to verify and in order to verify that file i can even verify it on a unit server but in order to do some operations on it like read it line by line and then verify then compare it with my results and all those stuff what i'll do is better i'll get it on my local machines in those cases we will download the file from my unit server to my local machine so in there could be any uh such as an arloot where you might need this okay so now i'm done with this i have saved it okay now let us run this particular script send file to host so i'm just double clicking it and you can see the script is triggered in your command form and now you can see the file transfer is successful there was some pop-up and i couldn't grab it actually but if you go to your putty now and if you do ls now you should see some file new file which is file to send to host now this particular file has been sent from your local machine to putty installation sorry uh unit server okay and the script which we use this this one by using pscp okay so this is how basically we can send the file from your local machine to unit server using putty basically using pscp so this is when we have a single file but even you can play along with multiple files as well like simply by using this file card you can do that let us say from this particular directory i want to send all the files with with dot uh doc extension or maybe you can you can give like dot dot sorry aesthetic dot aesthetic so that it will send all the files with all extension from the specific folder to the required directory where you want to send it so likewise we can send multiple files as well or even if you want you can add this multiple command into the same batch plane and you can take it so now your main task is you need to make these things parameterized like from where your key will be picked up or from where this particular file name will come here in your test automation framework you need to update it dynamically so that is something you need to take care okay so fine so that's what i have for this video in my next video i'm going to talk on how we can receive the file from unit server to my local machine using again putty okay so that's it so in again as i said in my next couple of videos i'm going to show you once we are done with creation of all this batch file how we can execute this batch files from java port okay so fine that's it thank you hello welcome back welcome to the course of Unix 4 testers manual on automation uh by bison selenium okay so uh in this video i'm going to show you how we can receive the file from unit server uh to your local machine using uh one of the putty tool called as pscq okay so in my last couple of videos i talked about how we can execute the shell script using putty automatically by creating a batch file and we can involve basically remove the batch file from any of the port then uh how to send the file to unit server and this video i'll talk about uh through the survey file so basically the steps are the same create a batch file then steady to put the installation directory and this time as well we'll be using this pscp but only this this syntax will change okay so what i'll do is i will just go and create another batch file okay i have copied the content because most of the things will remain the same i'm going to save it as a batch file okay on my desktop itself and i'm going to name it as receive from post okay something like that and my extension should be dot bat so then double quotes because i need to uh over read this dot a extension with batch fine now the very first thing is uh cd to putty then pscp again i'm going to use edges the format will change because i'm receiving it from unit server so the first thing will come your unix thing and then your local thing in my earlier video where i talked sending the files from local machine to host in that case the first point was sending the file that is from your local and then your unit server so the sequence was basically reversed in a sending case your local file will be first in the receiving case local file will be last right so it would be your uh let me modify this so in this case your this particular parameter will be at the same position just this file name should be last right and let us say from uh this particular directory uh foam slash precar i want to receive one file called as let us say this output file dot psd let us say i want to get this file so i need to give basically the complete path even we can use wildcard here to receive it in multiple files so we can see that so what i'm going to do here is uh using this key on this for this specific username for this server and the file from my unit server that is uh per class it should be slash so this output file from this particular directory will get received at this particular location pretty simple okay now what i'll do is simply i'm going to execute this receive file from host and you can see the process quickly now you can see the output file and you see something right if you want to just uh keep you can do is you can add one more line called as pause so that it will wait for you okay but although i have added pause and i'm going to run it again so here you can see the file has been received output file has been received the size is 0 kb let us say if in actual it is 0 kb so what i'm doing is i'll do ls iphone lpr and i'll check where is my output file output file is this let me uh check the content of my output file and i do have some content okay so i should see these contents uh i should see all these contents in the present in my file what is downloaded okay so i'll go to the location where it is downloaded and here it is you can see output file actual size is one kb actually okay and if i open this you can see the file is downloaded okay so this is what the contents are so these are the content which are downloaded here you can see right so this is how we can get the file from your unique server to my local machine and now what i can do is in my test automation framework uh if i want to let us say i want to validate this file then i can have some separate logic where i am going to read this file line by line i'm going to verify it so that that's my separate logic based on what i need so the basic thing where i want to show you how we can download a single file and how you can again receive a multiple file by using a wild card okay so again the same uh if you're not sure with the file name or if you want to receive all the files basically you can give a wild card so in this particular example it will go to this source directory in source directory any file which is starting sorry which is ending with dot p extension will get downloaded to this particular location which is my seed drive and source folder okay so if you want to download all the files from this source uh on from your unique server then you can give wild card dot wild card so that it will receive any file ending with any extension okay so that's pretty simple so now we are done with creating the batch files okay so in my next video i'll show you how we can uh execute these batch files and how you can incorporate uh them in your test automation framework okay so like double click will work now these are the batch files that they got converted into your executable executable file so you can call this executable from any uh programming language no matter whether it is java whether it is t-staff whether it is anything you are in in case of tutic as well you can call this in case of java with selenium you can call this in case of uh any selenium binding language you can call it or even if you want to execute it with toskka you can do that though uh toskka have one uh you might be aware about toskka test automation tool which is a stripless automation tool so if you're using a toskka which is a stripless automation tool which is bit costly in fact so if but if your organization have you can definitely go ahead with that and it simplifies these processes very much like they have one simple uh standard model uh for executing all this command you can simply enter the value and they will get all the things done for you but again the drawback is it is bit costly and if your organization afford it if they have it better you can go with that right otherwise again these things are also very simple nothing complex in that fine so that's it i have this video in my next video i'll show you how we can add files from my java code by using couple of options like forces builder and again one of the new thing which i saw which is plexus it is okay so that's it for this video thank you uh hello welcome back welcome to the course of inxmore testers so uh in this video i'm going to uh explain how we can execute the batch file from java code okay so in my last video i talked on how we can create a batch files like if i want to perform some operation like if i want to execute any unix command or if i want to execute any shell script okay or if i want to uh send any files to unix server or the 7a file so we can do all those things automatically from our code itself with the help of putty tools basically okay so we use p-link for running uh shell scripts and we use p-s-c-p to do s-s-p-p operations okay so basically if you uh you must have referred my previous videos for that so uh now let us say you want to do uh though uh now i have automated uh that particular operations from batch file now what your aim is your aim is to incorporate that particular thing like let us say executing shell script into your test automation framework so what i've done is i have created one java project okay so basically it's a mevan project and in my mevan project i have created one package called comjcs demo okay so okay basically i should create another package or let it be so in this package i'm going to create a new class and i'll name that class as exec using uh process builder okay now i'll talk on what is this process builder and all uh fine so i'm using this main class great now we have created the batch files as i said and if i want to incorporate uh execution of this batch file in my test automation framework then i like in this case i'm using java code but as i said since this is a windows batch file uh it is executable file so you can call it basically from any programming language or even you can call it from any scriptless test automation tools as well right because this is just a plain executable file fine now what i what i'm going to show you today is how you can execute that windows batch file from uh java code which you can incorporate in your test automation framework and basically we have two ways to do that the first way is using process builder okay and we have another way which i'm going to explain in my next video where we are using one api which gives us a good way to deal with command lines okay so now i'm going to show you how we can do it with process builder so process builder is basically a class in your java okay so the edit is basically used to uh perform execute the uh or to initiate various processes so the very first thing is you need to create the object of process builder class okay so if i just repeat that you can see process builder it belongs to java.lang okay so i am using the builder and i'm creating the object called as pb is equal to new and it should be process new process builder string command fine so i'm using okay let's take a new process builder and here i need to give me basically the location of my batch file okay so in my case i have my uh okay so here it is let us say if i want to if i want to send particular files to host okay so i'm going to use this particular uh batch file okay and how you can get location for this batch file i can go to properties i can either get this full location okay or i can get this location only and then i can use uh system dot get properties right so let us say if i want to get the location of my current project and then i from my current project location i can navigate to this particular path okay that's what i'm going to do okay so if you want to get the current location of your project then you can use system dot get you should have something get property yes and the property to get your uh location is user dot dir it is to use get user directory now i am into this particular directory let us end and from this directory i need to navigate through this steps till this particular location wherever i want okay so i'm using class okay and now i want to navigate so i've just copied the location and i should use double slash right because it acts as a skip character fine now i have created the object for your process builder class okay now what next i should start the process so if i use pb dot and i should see one option as start okay and here you can read the basically description is to start the new process using the attribute of this process builder so i have created the process builder and i'm going to start my process by using this pb dot start okay so if i execute this simple line two lines of code it will work perfectly no issues okay but now what i want to do is i want to uh check if my execution is successful what is the written code what is the output that i'm expecting on my console uh or your terminal whatever it so in order to do that uh we need to uh get it basically in the process object so if i hover my mouse on start you can see it returns the process object okay so what i'll do i'll i'll uh use process object it is again from the same package and i will name it as process equal to pb dot start now i got this process object okay so by using this process object what i can do is i can get the input stream that is uh the data which gets on your terminal and basically i can get the exit code okay if my exit code is zero then the execution is successful if it is not then there is a mission fine now my process is started and i have uh send it to some process variable okay so what i can do is i can use process dot okay so if we do just process dot dot you can see some uh uh methods in it like get input stream and you can see the description for get input stream is it returns the input stream connected to normal output of your sub process okay so what basically this get input stream is whenever you run any process it will display some it will write some content on your console or on your terminal so in order to read that content we will be using this get input stream again we will be using this wait for okay so this wait for is used you can see it causes the current thread to wait it necessarily wait until the process is uh terminated okay so we will be using this process for as well and by sorry wait for as well and by using this wait for we will be waiting for my process to get completed and get the return code okay or exit code whatever okay so the very first thing is what i'll do is i will get this input stream okay and i'll just displayed on my uh this particular console over here right so i'm trying to get my input stream now uh okay what this get input stream return it returns input stream okay so i need to basically assign it to input stream okay so what i'll do is i'll use new input stream okay new input stream and okay so process dot input stream fine okay so basically we should use uh input stream reader yeah so we'll be using input stream reader to read the content and where we will be storing those content we will be storing those content into a buffer reader okay so i will create one object of buffer reader class buffered reader uh bf is equal to new buffered reader and i need to pass the reader okay and what is my reader my reader is basically this particular input stream excuse me so now what will happen is we we are using the process object to get set input stream this get input stream returns uh input stream reader okay and by using this input stream we are storing the content of that input stream into my buffer variable which is bf okay now or even i'll let me call it as reader okay so i'm going to store the content into the reader now what i'm going to check is i'm going to read the values from reader okay so to read the values from reader what we can do is we can use that object of reader and you can see the method called as read line okay so basically we can use this object read line okay and what i'm going to do is i'm assigning it to some string line is equal to let me define some string so what i will do is i will use while loop over here so that i can iterate over all the uh what i can say all the lines of text which is present into my buffer reader and i will check if my line is not equal to null if it is not equal to null then i want to display it okay okay now if it is not equal to null then i want to display it okay i can use okay or else what i'll do is uh okay i can basically one uh string builder okay so what i'll do is i'll create one string builder so string builder is basically a mutable string and what i will do is i will append uh the data to string builder okay my data is present in line okay and then uh i need to add a line separator okay so i'm going to do it so that my next line will get displayed onto the uh next line in my uh string buffer string builder sorry okay so now i'll have my all data into this specific string builder okay which is my sd now what next fine so what i can do is i can simply display system.out.println sd that is my content from string builder okay so oh god this command over here not required fine so now if i execute this code simply it will uh it should execute the code but before i execute the code let me connect to my putty and let me check what file i'm going to send it to my unit server okay so basically uh in my particular batch file i have i'm trying to send this file file to send to ghost and the file is already present over there let me delete that file okay now that file is deleted great now what i'll do is i'll simply execute the code and we'll see if it works okay so you can see uh my execution is successful and you can see the the things which uh which get compound on your terminal are already displaying over here that is because of this particular reader and this particular part otherwise if you just want to trigger the process these two lines are enough and if i do a list now i should see that particular file here but why don't i see okay let us let us what we'll do is we'll try and get the exit code if my exit code is zero that means my execution uh particular process is successful so what i'll do is i'll use process object dot we have some command called wait for that i have already explained okay and just wait for what it returns if you just hover your mouse on it uh in a second it returns an integer okay so i'll try and get int of a return code is equal to this okay and what we'll do is if we'll just check the code if my return code is equal to zero then this thing else i'll print something not successful now let us do it again okay so this particular part is getting executed that means my execution is successful because i'm printing that particular part then my return code is zero okay so now let me go to this particular file okay so basically uh my file what i'm executing i'm okay so actually i was using this receive file from host so i should use this send file to host okay so now it should work i was referring uh some different batch file okay so you can see uh i i didn't get any error messages like not successful or any other error message that means my execution is successful and if i do ls over here now you can see my file has been sent to host okay so this is my right okay so this is how you can execute any batch file from your uh java program uh let us let us let us try and run another batch file which is my run putty okay so okay so in my run putty okay let me show you the script what it has okay so in run putty basically uh the script is of three lines only so we are using pre-link to execute my script which is script.sh okay and i'll show you what is there in script.sh okay so if i do ls over here you can see one script called as script.sh okay so uh okay uh let let me show you the content of your script so my script content is something like this i'm just doing something and what i'm trying to do here is okay so i'm trying to read some data from input file and i'm going to write the data into file called as output file so i'm basically doing the read and write operation okay so that's fine i'll explain this uh shell script in another video uh so i'm going to terminate over here so this is my shell script basically okay so if i execute this shell script from over here like ss dot script then you can see uh shell script to read and output uh text file and the file process has been completed that means my shell script is executed successfully and it has generated your file called as output file by reading my input file file so this is how it will execute now i'm trying to execute the same script this script.sh from this specific batch file why am i java program so i'll just run my java program okay and you can see file process has been completed let me uh let me do okay so what i'll do is i'll just delete this output file so that you can see uh if my okay now my output file is not there now you don't see anything called as output file now this output file will get generated as soon as my shell script execution is completed now what i'll do is i'll execute the script okay my execution is completed and i should see the file called as output file so here it is so this is how basically we can use uh this process builder class to execute any batch file okay uh fine so you can incorporate basically this piece of code wherever you want to execute any batch file uh and in the batch file we have something we call up putty tools and execute our uh desired unix processes whatever we want to do fine now in my next video i'm going to show you how we can achieve the same thing by using uh another java api which is called as plexus utils okay so we are going to achieve the similar thing uh by using another api okay so thank you hello there welcome back welcome to the course of unix foretest source manual and automation in this video i'm going to show you how we can execute the batch file a batch script that is your windows batch file from java code with the help of a java api called as plexus utils in my last video i have shown you the same thing with the help of process builder which we used by default but this is something uh makes our life a little easier if i use this plexus utils but for this uh for using this plexus utils you need to uh add one dependency okay so i'll be showing you these things now so uh okay let me go to eclipse and let me create another class called as exact using plexus util and i want the main method uh fine let me remove these unwanted comments great now what i want i am i'm going to use plexus plexus utils okay so this is one dependency one java api in fact which we will be using so if i just go to google and plexus utils okay so you can see uh basically this plexus is from code house okay and if i go to this main one repository uh basically i'll be using this dependency from main one repository okay and it is from or the dot code house dot plexus okay so i'm getting this latest dependency 3.2.1 okay since i already have it let me check which version i had it uh so i'll go to my palm dot xml so if you do not have a main one project you need to download it and import it in your java build path but since i have a main one project what i'm going to do it i have used this dependency 3.0.24 but maybe you can use the latest one that should work so i what you can do is you can just go to the latest just copy this code and just paste it in your dependencies it will get a dependency for you and if i go to main one dependencies i should see plexus utils uh the respective respective version which i selected okay if you are not using a main one dependency you can just download it and then uh you can just download it from here jar and then you can import it in your java build path fine now i already have it so i'm not going to do that again great now let me start so uh to use uh okay so the plexus is basically to uh if you want to use with command line tools or i o tools then basically this plexus utils is going to help you okay and in this plexus we have some method called as command line okay so this is something which we will be using and it is from oarji.codas.plexus.util.cli okay and you can see the description here command line object command so i'm going to use this command line and cmd creating object for it new command line fine i've just created the object of command line class okay and then by using this cmd object what i can do is i can set the executable what i want to execute okay so if i just hit cmd. you can see some method like set executable create arguments set working directory if you want to just change your directory you can do with this why i simply want to set my executable because i already have a jar file okay and what is my executable my executable is let us say i want to execute this uh run put t okay so what i can do is i can okay i'm just going to my last code and i'm just copying it from here so we'll be using system.get properties and my irrespective batch file here let me copy this and i'm adding it as my executable great now i have set my executable okay so fine now if i use uh give me a second okay sorry yeah so we we just did a set executable okay this is something which i want to execute but we didn't started the actual execution now so to start your actual execution we have something called as another class which is my command line utils okay so i'm going to use this command line utils okay and if i do command line utils dot then you see something like execute command line okay so you see uh different overloaded method just let me expand this you see different overloaded methods so execute command lines have this five to six different methods sorry this class has different five to six method and you can see some uh like the very first argument is very very much common your command line cl and then next we have some input stream or we have your stream reader or something like that okay so let me check which i can use and you must notice all methods have written type as excuse me integer okay so basically i'm going to use the very first one and why i'll tell you okay so the very first one what is my command line i want to execute my command line as cmd okay and why i picked this because i wanted to get my system output whatever the output is going to print on the console or a terminal that is what i want to get in this system output and in system error in case of any error if my command is not found or if there is any issue then all those things i'll be passing in this system error but in order to pass this i should create object of them okay so to create the object of create object system out i should use uh a write stream consumer okay so let me second okay so we have one class called as write stream consumer i'm going to create object of it write stream consumer okay is equal to new write stream consumer and i need to give some writer okay so what is my writer i am going to create a new stream writer give me second i am looking for stream writer okay so basically that would be output stream writer okay so output stream writer and uh what i want to get output from so it would be from system dot out it will print my stream fine so now i got one object which is my uh system out with the help of class writer stream consumer so this will basically uh print it on my my console basically or i can get it in my uh what i can say i can get the text from it and i can use it in my program if i want next is my system error okay so what is system error in case of any error okay so how i can get it so again i'm going to use uh what i have uh okay so basically see two things system out and system error so if i execute any command on my terminal let us say so i'll get my output as well on this terminal itself and if any error then i'll get that error itself in the same terminal okay so basically i can use this system dot out itself for my system error as well okay so i'm just doing going to do a copy paste and assigning it to a object called as system error and that's done right now this will execute my command okay and uh what is written type so it's written type you can see its written type is integer okay so what i'll do is i will just get written type integer uh in my let us say written code okay so now i got the written code over here and if my written code is zero that means my execution is successful if not then there is an issue okay so i can use if written code is equal to zero then i'll print something successful with zero written code and in case of any issues i'll print them in else part okay so basically i'll just copy paste this and my execution will be unsuccessful and my written code would be non-zero okay so that's pretty simple what we did is we just created a reference of object reference for this command line which is the base class from where we are going to start and then to this cmd we are going to uh like i have just set my executable okay if you want to change the directory we have a method for that i just wanted to set my executable directly because i do have a batch file which is directly executable and then to read the content from my terminal i'm using like in case of normal system dot out in case of error i'm using system dot error those two things i need to pass to this uh execute command line methods uh under command line here okay so uh so and this particular execute command line method which is from command line utils returns uh an integer if that particular integer value is equal to zero that means your execution successful if not then you have some error let me execute this and okay you can see the execution is successful zero code and you can see whatever i had printed it in my command shell uh shell script it is getting printed so that means the execution is successful great so now uh you can just embed uh this this much lines of code anywhere in your test automation framework wherever you want to execute any batch file okay so this is how basically we can run the batch file and in my batch file i have the code i have some code which interact with my unix server right but now uh okay so now uh earlier as well i might have talked like uh i'm i'm going to tell you two approaches the first approach to do the automation of unix uh processes is with the help of putt and another one is with the help of and java api called jsch okay there are n number of apis for java for other other technologies as well for cshap we have for other as well we have uh but the drawback of using this particular uh batch file this batch file because in the batch file what we used in the batch file we have let me open the batch file in the batch file basically we have used something called as pscp.exe or pilling.exe okay uh so uh wherever you want to run this specific test automation framework if and if you are using this particular line of code then you should have this pscp with which is basically put you to install at this specific location whatever you will mention over here so if you are trying to execute this particular code in your test automation framework from uh let us say from jenkin server uh in your jenkin servers as well you should have putt installed and you should location of putt over here the same location what you have in your jenkin server okay on the machine where your jenkin server is installed so that is a prerequisite basically requisite uh for using this particular approach okay so and the second approach what i have is by using uh java api okay so since i'm using java in this case i'm going to use java api but if you are using c-sharp then you can use another api which are available in c-sharp which i'm going to show in my next video so if we're going to follow that approach this particular dependency gets removed because we do not interact with unique server via uh via any uh ssh client like putt okay we do the direct interaction okay and how do how we do that i'm going to talk in next four to five videos okay so it depends on uh your uh your your way where you you want to execute your test automation framework in some organization ssh uh java api for ssh client they do not permit they only permit using this putt so for them this is the way how they how they can do this otherwise if your organization permit you to use another uh third third party api like jsch which you are used to interact with uh unique server from your machine then that's the best approach we should go ahead with okay so that's it from this video so from next video i'll be talking about uh my second approach uh by using jsh okay so yeah that's it thank you come back welcome to the course of Unix for testers some manual and automated processes which can be clubbed along with any test work like selenium uh in this video i'm going to show you in fact talk about uh what are the various libraries available to automate unix testing so in my last four to five videos i talked about how we can create a batch file and how we can execute that batch file by using java code that is by using process builder and another java api okay so that is one way how we can automate the unix processes the various processes like sending the file to your unique server executing any unix command are receiving the file from your unix server to your local machine for some purpose and executing your shell script which is most important functionality within unix so that's the one way but in my last video i must have talked about excuse me drawback of why we may not use uh that that approach using sftp sorry uh or using putty tools because it need to have put installed on that particular machine where you want to run that run those specific test cases uh the another approach is to use a set of libraries various libraries which we have okay to automate all those processes and in this video i'm going to talk about two libraries uh basically uh for two languages so the first one is for java clients okay so the java you must be close to like maybe more than 80 person people for seven minute java so that's the reason i pick java library for automating this unix testing but in fact we can use uh like we have the ssh client for your c-sharp you can you have a ssh client for pipeline maybe you can have this particular ssh client and you can use them to achieve the similar things so what are the different java clients available uh for java what are the different libraries available for java to achieve these ssh things the very first one is your jsh and this is the one which we are going to use as a part of this particular course to automate all our uh unix processes and i'm going to show you how we can uh use it in your selenium test for promotion framework so the various other libraries are ssh j sshd common vfs then we have gandmaid ssh too but out of jsh is preferred more as compared to other tools moreover if you know uh how you can use one library the functionality of other libraries are a little bit same just they might have some different method name different classes different uh parameters and few other things so uh jsh is something which we are going to use which is a java client now if we talk about c-sharp clients for c-sharp as well we have ssh clients okay and the very first one is ssh net and we have another popular which is sharp ssh sort of that ssh net is bit popular as compared to this app sharp ssh so i should give a preference you should give in fact reference to this ssh net okay in fact if you talk about like we have one scriptless automation tool called uh toskata suit and they have given some standard models to interact with like they have already given standard models to automate all those things and in back end they have used uh this ssh net uh which is a c-sharp client because toskata is already built on c-sharp so they have they have used this ssh net okay now uh let us talk about this ssh net okay sorry ssh okay so if i google jsh so the very first uh url you see from jcrap who is the owner of this particular library okay and here you can see jsh which is a java secure channel okay to perform the areas operations and here you can see the applications which are using jsh like your eclipse itself is using jsh net bin is using jsh then your hp g-write itself is using your jsh and there might be many other who are using already using this j plant okay so now two things if you want to uh if you already have a mevan project then you can uh you you can go to mevan repository and get dependencies from there if you do not have you can download uh the jar from here you can directly click on here and it will get a jar downloaded to you but if you have a mevan project you can just go to uh or what i'll do is i'll jsh mevan dependency it will work for me jsh mevan dependency the very first url i got is com.jcraft jsh and the latest one is on dated November 2018 that means it is quite up to date not very much up to date but it is okay it is up to date okay so i'm going to prefer this latest version 1 0.1.55 and we will be using this dependency in our uh project which we will be talking from our next uh video okay so so this took up from all these processes like execute any unix command could be a very simple starting from your ls to get list of all the uh things in your particular directory could be your source functionality grape or any kind of command uh and that could be your sending file to your unix server receiving file executing your shell script checking a particular file exists onto your unique server at particular location could be uploading downloading multiple files to your unique server to alpha okay so all those things we are going to achieve with the help of this particular jsh library okay that's what we will be talking uh that's what i'll be continuing in my next five to six videos these things how we can automatically so that's it i have for this video stay tuned thank you hello welcome back welcome to the course of phoenix for the source manual and automated uh so in this video i'm going to show you how we can use basically uh jsh in your java project so the language binding which i uh chosen over here is shava okay so that's the reason i'm using jsh okay so i'm going to show you how we can basically we we must be knowing everyone how we can create a java new one project and then i'll show you how we can get this jsh mevan dependency so if you're using a mevan project then you can use basically the mevan dependency if you are if you are using non-mevan project then you can download the jsh jar and then you can add it in your build path okay so i have already created uh basically the mevan project so i'm not going to create a new one but i can just show you how we can do that click on file i'm basically using eclipse eclipse ide okay and the process must be common in uh almost all the idea whether it is eclipse idea whether it is net bin or it can be your ad so i'm going to file click on new then i'm seeing the very first option as mevan project if you don't see over here then go to other and search over here for mevan okay so you should see option called as mevan project if you don't see you might need to install the mevan add-in so you can get it from help and install software or eclipse marketplace you can send you can find both the options you can get it from there uh so i've selected mevan project okay and you can select the location basically so i can select my location as eclipse workspace great and i want to sing uh fine and i'm going to click on next so from here you can select the the archetype basically this archetype gives you the structure of your project and here you can just enter your group id and artifact id from where your project will get some name okay so yeah so basically i'll enter let us say group ideas come and then artifact id as let us say my project id basically which is let us say demo and dot if i want to enter anything that i can enter something something okay so like this okay and version could be a basic version or you can give like version one or version two it could so this version is basically used when you are packaging your jar but in our case packaging is not required so we can leave it as it is and you can just click on finish it will create a mevan project for you i'm not going to create i already have it so the basic thing of mevan project is your palm dot XML okay so in your palm dot XML we will be adding the dependencies for jsh okay so in order to use this jsh i need to download that particular jar in my project so that's that is something which i can get it from mevan dependency if i have a mevan project okay so i can just do something like jsh mevan dependency okay and the very first link i'll get it as mevan from mevan repository and the version i can select in fact we can select the latest version let me check which version i have selected the version i selected is 1.55 and yeah that's the latest one okay so you can just copy this dependency and test it in your palm dot XML under dependencies tag okay so this dependencies tag is your basic base tag under which you have dependency closing tag dependency so you can have multiple dependency under dependencies tag fine so now once you add your dependency you can just click on save it will download the dependencies for you and you will find something called as mevan repository over here and you will find the jar will get downloaded in your dependencies it is having various packages so if you do not have a mevan project what you can do is you can go to the same site you can just click on the jar file over here it will download the jar file for you and you can just go to your project and build path configure build path and you can add your jar files okay so you can go to libraries add external jars and you can select your jars and you can add it your project will pick them thanks so basically this is what we need as a dependency now next fine so we have created we have added a mevan dependency and we have downloaded the jar now what next I'm going to show you one example okay how we can use the jsh for interacting with basically your unix server okay and then we have like I'm going to talk about multiple examples like how to upload file to unix server download files how to check if file exists how to execute any unix or unix command onto the server or shell script onto the server will I'm going to show you many things okay so stay tuned for this thank you okay so let's get started with jsh and the very first thing when we are since we are talking about the communication between your local machine to your unix or linux server right so there should be some authentication method whenever I try to interact with my unix or linux server there should be some authentication there should be some key or there should be some password or any any other way right so that's what I'm going to show you how we can use it in when when we use jsh so now why authentication because as I said since we since we are interacting with the server there could be a linux server or linux server only a person should interact should be able to communicate with the specific server so that's the reason there is something called as authentication and we have various methods to use authentication the two which I'm going to talk is we have something called as private key and we have another one called as username and password okay so let me go to my eclipse and let us create a new class and let me call the class as execute any command on unix or could be your linux basically the processes are same unix server using jsh okay so this name is a bit long we should not refer the name as this much long but since I'm doing it for demo purpose the name isn't true so that's the reason I'm putting it great I have created a class and I have a main method in now what I'm going to use is I'm going to use jsh which is my ssh client java ssh client basically which I'm going to use to interact with my unix or linux server okay and if you see the main dependency jsh you can see some package called as jsh okay so basically it must be having some methods like okay so in this particular demo I'm going to talk about what is channel what is session then what is jsh basically okay so this jsh class is something which is my starting point okay so I am going to create an object of jsh class okay so you can see it is coming from the same package which I just opened and jsh and I'll call the name as jsh is equal to new jsh great now I have created the object reference for this jsh package uh sorry class great now this this is basically my starting point to enter into this process now if I use this jsh dot okay if I use this reference you can see some methods which I can use like get session the very first method and you can read the description it is used to instantiate the session object with a given username host and port note that the tcp connection must not be established until session dot connect fine so what it is saying is we can use this particular get session method so step to set the connection basically okay and we can pass username host and port okay but until and unless we do session dot connect actual session will not get started okay so we will be passing three parameters to it basically username host and port the other methods which we will be using is add identity the add identity method you can see the description it is used to set the private key okay and yes I believe you're watching my earlier videos and you must be knowing I'm using private key to establish my connection not a password okay so okay so let me use this get session okay and now what is my username okay so my username let me open my ssh putty sorry and in my putty let me get my server name as well my host name basically okay so let me connect okay so my host name I am putting my host name as my ip basically okay and port the default port which is double two and now I want my username so basically my username is prakash okay and you can see whenever I log in it says authenticating with public key as prakash okay so my username is basically prakash fine so now I have created a session so if I use this okay let me throw that exception js is exception fine now if I hover my mouse you can see this get session method written your object as object of session okay so let me create object of session then session session is equal to let me import this session from again from the same package fine now I have created a session so basically the flow goes like this so you have created the object of jsh class which is the entry point then by taking the reference of jsh I'm creating the session okay and from this session I am going to create a channel okay but before we go ahead with channel now we need to do something with setting my password or setting my key basically okay so how we can do that okay so if I do session dot let us see what an all method it has it has a method called as disconnect it has a method called connect so these two methods are self-explanatory connect and disconnect to connect and disconnect my session then we have something called as open channel okay so this method we will be using in order to establish the channels okay so the flow is first jsh object then create session using jsh object then by using the session object create the open the channel basically with various your object use it could be your sptp operation it could be your exec it could be anything other we will be seeing that then the next is set password okay so this basically the set password session dot set password we will be using it in order to if I have a connection method with username and password okay if my particular unique server or Linux server need password in order to authentication in order to do the authentication then I'll be using this session dot set password okay but in my case since I'm using the key basically I do not need this session dot set password okay so what I need basically is I'm basically using the key okay so you can see this is my key okay even if I edit you can see that there is some key okay I'm basically using this particular key okay so in order to use this key let me create an variable for this string private key path is equal to and let me get a path for this particular key because I'm going to use this particular key okay and fine now I should use sorry double slash now I have I'll be using basically this key with the help of this particular variable okay and we should pass this particular key to your jsh object so if you see jsh then you see something called as add identity and task to to set a private key so this is how we will be setting the key to my particular ssh object and which will be inherited by your session and channel you know while while while establishing the session this key particular key will be used great now we are done with creating the session not establishing just creating a session then by setting since setting password is not required because I'm not using password so that's the reason we added identity for your private key path okay and okay so there is okay so if you need to pass any properties okay if you need to pass any properties to your what I guess is session then basically we have some method called as session dot you should have something called as that okay yeah we have session dot set config okay so we have something called as session dot set config and you can pass the values with either you can pass a value of key and pair sorry key value pair or you can pass the properties file okay so I am going to pass a value for properties file and what value I'm going to pass is so for that let me create one instance of properties properties config is equal to new properties okay and in this property is what I'm going to put is config dot we should have some method called put yeah fine and then here I'm going to add a value here a key value pair basically okay so my key is strict host key checking I should give the value as no okay and why we need this I'll tell you okay so sometime what happens is even if you are setting the password from here or you are setting a private key from here it might ask you for a password in your command prompt whenever you whenever it's create a session before before in fact before it create a session okay so that's the reason we are asking to strict give me a second should this strict strict host key checking and I'm setting it to no and basically I should pass this config to set config here right so this is how we can configure the session here if that there there could be n number of properties which we can get and you can find the details on the website of jsh okay so you can refer this website it's their official website jcraft okay so you can see some examples over here some examples over here and wiki okay basically you can explore this particular their homepage you can see some examples as well over here okay so that's fine so now I have uh set this particular uh configuration file and now I should be good to establish my session session dot I should see some methods as connect great now I should be able to get connected with my Unix or Linux server okay I'm just trying to click on the run and so now I will not understand if my session is successful I can expect some exception if anything but I do not expect anything to be printed on this console okay so I'm assuming it is connected because we didn't use session dot disconnected okay because otherwise it will keep the session connected continuously session dot disconnect okay so let me put some thread dot sleep okay so you can see the execution is started let us say and it should get disconnected let us say after three seconds yeah it got disconnected now so I am able to basically authenticate by using my private key and my particular details my post name and my username okay so that's it I wanted to cover in this particular video in my next video I will explain the further processing how we execute how we can execute basically any command in jsh and which we can incorporate in your test automation okay so stay tuned thank you hello welcome back welcome to the course of Unix for testers Unix manual concepts and how we can automate all those Unix manual concepts which are required for basically testing purpose and we can incorporate them in your test automation framework so in this video I am going to talk on execute any Unix command via jsh yeah basically that's in your test that is something which you can incorporate in your test automation framework okay so what I'm going to talk is how to create authentication I have already talked in my previous video you can refer my last video we have created a session basically okay and we have connected a session in my last video so till that we covered now in this video I'm going to cover about how we can create a channel then how we can execute a command and how we can get the output of basically that executed command and I can verify it basically okay so let us switch to my eclipse now this is what we saw last time now let me remove this session dot disconnect and thread dot slip now once my session is connected okay and if I check what an all object I have sorry methods I have in my session so the very second one you can see open channel okay so at a session dot open channel so now I'm going to create a channel okay so now what kind of operation I'm going to perform over here right so let us say if I open this open channel method and fine so basically what I'm trying to perform the operation over here is I'm trying to execute the command okay so the type of channel for which I'm opening it is exact if if you want to do it for to do sftp operations file transfer operations then basically we'll be using sftp over there but in this case I want to perform exact operations right and if I hover my mouse you can see it returns a channel so let me create an object for channel and assign it to channel channel is equal to session dot open channel now I have created a channel now I'm good to execute my command okay so if I now if I use this channel channel object and what an all methods I have I can see something like disconnect basically connect and disconnect to so so we have two things sessions and channels okay so initially I'll set the sessions I'll connect to the sessions then I'll connect to the channel then I'll disconnect to the channel and then disconnect to the session so then we have something called as get input stream get output stream it's closed and we should see something okay we have another one called as get exit code to basically get the written code what is my output of my current operations which I'm which which I'm just doing basically we should have some set operation set okay so basically what we should do is we should cast this channel with channel exact because we are forcing it right so we should give me a second channel exact yeah so and let me import it let me import it I should get some option of the import give me a second okay so let me import it explicitly so let me copy this channel and I'm trying to import channel exec okay so if you see this jsh packet you should see something called as channel exec so here it is channel exec so this is the class which I'm going to use now okay so channel exact yeah so and whenever I'll be doing saptp operations file transfer operation I'll be casting it with channel saptp so in this case I'm going to use channel exec fine now I should not see that error okay let us check with if I can see yeah now I can see the method with set command okay and basically here I'm going to pass my command okay the command which I want to execute okay so let us say I want to simply execute my command as ls to get the list of files basically list of items in my present directory okay so fine now fine so now I'm done I'm I'm just I've just set the command now I am I'm good to disconnect my channel channel dot disconnect and I should be able to disconnect my session great now and if I run this okay so something has happened okay something has happened but I don't get my end okay so that's fine now okay let me show you something practically so if I go to ls-l okay so you can see something like okay so you can find my f1 file and the permission for f1 file is all are hyphen right so what I what I'm going to do is now I'm going to set a permission for this f1 and I'm going to set it all 777 permissions okay so the command which I'm going to execute over here is and the command to set the permission is you must have referred my earlier video is ch mode and I'm going to set up permission as 777 that is all the permission and my file name is f1 dot txt okay so if I execute this command now and if I do ls again I should see this permissions of this particular file f1 should have been changed to read write execute okay so now I can see the operation is completed and if I do ls hyphen l okay so you can see it is not done that means there is some issue okay let me check if the file name is correct it is f1 dot txt f1 dot txt is ch mode fine okay let us check uh okay so what we did is we just created a session and we are directly trying to disconnect a channel but we didn't create we didn't connect it to the channel yet so basically I should use channel dot connect okay and now if I see okay the operation is completed and if I do ls hyphen l again now this time can you see the the permissions for f1 it changed to rwx rwx and rwx right so that means whatever command I'm trying to execute it from here I'm able to execute it it is getting executed successfully in my Unix or Linux environment fantastic this is what I was looking for great now what next but in my terminal I'm not able to see any output right let us say like how will I get to know okay we have something like channel dot get exit status we have something like channel dot get exit status from this we can get to know if my execution is successful or not this is one way or what we can do is I can read the console basically okay I can read the console and I can check if my execution is successful or let us see if I'm trying to execute on a shell script then my shell script will print something right on my console basically so let us see if I want to verify that particular part of my console then what I can do is then in that case I need to read my basically the stream streaming messages okay so how I can do that let us let us do that okay so the similar thing which I did in my video where I talked about how you can execute a batch file so there should be something similar like that okay so the very first thing is I should get the input stream from my channel okay and where I'm creating my channel I'm creating my channel over here right so if I use channel dot get input stream it should return me some input stream okay and the written type for this is input stream okay so let me create it input stream in is equal to what's wrong okay yeah input stream in is equal to channel dot get input stream basically this will read my this will help me to get the messages from my channel whatever messages I'm getting into the channel I can get it now I need to use this particular I need to read this stream as well okay so once my channel is connected okay what I'm going to do is I'm going to read that particular messages by using input stream reader stream reader can I say somewhere input stream reader yeah and basically it needs your input stream my input stream variable is in okay so what what it returns input stream reader okay and what I can do is basically I can pass this input stream reader to my buffered reader where I am going to store my all the messages okay forward reader yeah buffered reader and my reader is basically my new input stream reader great fine and what this buffered reader return it returns my buffered reader where I can create its object buffered reader reader is equal to this now I should get all my messages which I'm reading it from input stream into this particular reader okay and how how I can read it from reader that I have already explained okay so what I can do is I can use reader dot read line this will basically give me give me the content line by line okay so what I'll do is first I'll create one string call line string line okay and what I can do is basically I can use a while loop okay while because I want to do it till my okay till it is not null okay so what I can do is while it is not null as not equal to null okay if it is not null what I want to do is let us say I want to print it I want to print my line okay and I can do that fine now this time what I'll do is I will execute to ls and I'll check if it works if it prints great it is printing it for me right if I want it in more sophisticated way what I can do is I can use ls add tia that will give me little more details excellent I'm able to read all the contents from my terminal okay now if you want to verify this particular content if let us see if you want to verify if a particular file is there or if what are particular operations sorry what are the different rights or permissions for a particular file has if you want to do some verification then what you need to do is you need to store basically it in some list store in some list okay so what you can do is you can store the content of this line into the list and then you can iterate over that list and you can verify it okay that is something how you can handle it again great now let us let me write some wrong command okay so I'm using ls0 which is not correct let me check if I can get a error message over here okay so what is happening is if I'm passing incorrect command okay so I'm expecting message like if I give something like ls0 I should see some message as bash ls0 command not found but here I'm not getting that particular message okay so what I can do is we can set the channel again with some error stream okay so here we used channel dot get input stream okay so the same channel what I can do is okay what I can do is I can set I can set channel error stream and what error I'm expecting the error form system dot error great now I should see the messages in fact this casting is not required this time because we already did once okay can you see the message now command not found great that is what I was looking for now so this is how basically you can execute any command so as I said if you want to verify anything what you can do is you can create a list I release and you can add all the message into the array list before you disconnect and then you can verify the content of list whatever you want basically okay so that's how you can execute any command basically on the Unix server using jsch which is a java ssh client okay so that's what objective of my particular video was okay so what you can do is you can basically uh incorporate it uh incorporate this particular code into your test automation framework to do whatever you want basically okay so most of the time it might not need to execute any command in automation but what we need is mostly we need how you can execute the shell script or how you can send the file to host or receive file from also those things mostly we work with we deal with okay so I'm going to talk about those things in my next video so stay tuned thank you hello welcome back welcome to the course of Unix 4 tester in this video I'm going to talk about how you can send or upload the file to Unix server from your local machine let us say okay so assume a situation in your a test automation project where you want to upload some file to the Unix server your shell script will run on the Unix server which picks up the file which you have just uploaded and yeah basically it will process and it will do some operation could be that could be db insert or could be producing another file or could be sending a lot somewhere could be anything right so basically what you want to do is you want to send the file so that let us say my shell script will pick could be an example okay so this is just what I said so how we can achieve this using jhsh api which I'm about talking from my last two sessions so the very first thing is creating authentication that is again same as how we did in my last two videos again creating channel that is again going to be same so let me jump to my eclipse quickly and let me create one class okay or rather what I'll do is I'll simply copy and paste this exact shell script class and I'll rename it as because I'm going to copy most of the content from that class so that's the reason I'm doing copy paste send file to Unix server great now let me open it if you are more if you are watching this video alone if you are not watched my previous video you need to go back to my previous video where I talked about how you can handle authentication and two other things you need to watch them then only you can understand this fine so let me start so the very first thing this private key I need this because I need to do that authentication so this is where I'm doing the authentication is in my private key that's what I need then I'm creating the session by using my username my host and my port yes I do not need password because I'm using a key then I'm setting a pass sorry properties basically with strict host post key checking to know in order not not the host ask me a password again and again then I need some changes from here so we were dealing with exact operation execute operation that could be your shell script execution that could be your any command execution that was exact but in this case the operation which I'm going to talk is about sending the file to Unix server so whether that is that could be sending file to your unique server or the same file to your unique server from your unique server my operation will be accept tp operation right so so in this case I should use my open channel in accept tp mode okay and so here since I was using exec operation over here I was using channel exec right but in this case I need to use channel accept tp okay so let me change it to channel SF tp okay and I think I need to import it let me import it explicitly so instead of channel exec I need to use channel SF channel SF tp yeah this is the one fine so now okay and can you see channel SF tp doesn't accept the command as set command right so that's the reason it is giving me error that's fine we'll look out what and all methods it has so what and all methods it has okay so let us go to methods I can see some versions that set file name I can see the operations like RM directory or RM or rename real path fit pwd put and get okay so basically sending file is nothing but it is my put operation I'm going to put my file onto the server right so this is my put operation basically okay so what what I need so I need to put my source let me go from start okay so I'm going to pass basically two parameters so first is my source and another one is my destination okay so here you can see this method particular particularly this method put string source and string destination so this is the method which I'm going to use okay so what is my source source is nothing but the file which I'm going to send okay so let me check if I have any okay so let me do the next four testers and let us say okay give me a second let me okay let me go to G drive and okay so here I have some file called as file to upload okay so let us say I'm going to upload this specific file let me copy it as a path and that could that should be my source in this case so it should be double slash five and what is my destination okay so my destination let us see my destination path and destination path is from your unique server so my destination path is let us say home and so that could be your any destination server where you want to send it fine so I don't want this okay let me use SFTP okay it doesn't accept that's when I don't need it anyway okay now let me try simply executing this okay and before that let me go to my server and let me do ls if if the file is existing okay so what file I'm going to send I'm trying to send file to upload and I don't see any file any such a file over here great let me execute I'm just saying there are some errors what are those errors well I don't see an error over here let me give me a second let me fix this okay so actually I had a problem with my JRE I recently upgraded my JRE and didn't set it in my current project so that was the issue fine so I okay and also I did couple of I did couple of messages okay I'll just show you so what I'm trying to do is I'm trying to connect a session from the session I have opened channel and as I said I'm going to use SFTP then I connected to the channel and then by using channel SFTP I just typecasted this channel to channel SFTP forcefully and by using that so that I can use one method on channel SFTP channel as a put method so I've shown you like we have some get method put method various overridden put method get methods okay so that's it simply I'm doing that okay so input method it is my source file so this is the file which I want to send to the host server and this is my host server location that is my unit server location where I should send this particular file okay and then what I'm trying to do is I'm trying to do if my SFTP is not equal to null okay then I'm trying to exit the SFTP session and finally I'm trying to disconnect the channel and disconnect the session fine so basically you can get this code on my github repository I'll share the link of my github repository so I have code for all the basically programs what I'm coding on my github repository fine now let me quickly execute this program and okay now you can see my execution is completed and SFTP so these are some error so messages so added by me so now we should see the file existing on the server which we're trying to send and yes it is file to upload.txt so this is the file which we were trying to send file to upload.txt okay so this is how we can send the file from my local machine to the Linux server so this is my source file name and this is my destination location where you want to send it so basically you need to parameterize these things based on your project requirements okay so what and all things you need to parameterize if you have your private key path then that is something which you need to parameterize if you have a password then again that is something you need to parameterize then your session sorry your username your post and your port these are the three things you need to parameterize and again your source file and destination path so these are the five six things you need to parameterize in order to make maintenance of your project easier in near life time okay so this is how basically you can send the file to the Linux server and that is what my objective of this current video was send or upload file to the Linux server so just the difference was as compared to my last video the difference was earlier I was using exact but this time since it is a file transfer operation so I'm using SFTP and I just forcefully typecasted this channel to channel SFTP so that this channel will act as a SFTP medium for doing the file transfer and then I have some methods put method by using a source file I am sending it to destination file so that's pretty simple okay so that's it I have for this video in my next video I'll talk the reverse thing that is how we can get the file from Unix server or how we can download the file from your Unix server to my local machine okay so stay still thank you hello welcome back welcome to the course of Unix for testers in this video I'm going to show you how we can upload or send multiple files to Unix or Linux server using a JSC which is a Java SSH library which can be used to interact with your Unix or Linux server from your Java code okay so okay so basically in my previous videos if you remember I talked about how you can send a single file by using put command okay so we can use some put command on SFTP object okay so we do something like SFTP.put followed by your source file name and destination name my destination name is my Unix directory okay so on the similar line we can perform the operation like sending multiple files or uploading multiple files from the directory to your Unix or Linux server so here I'm not going to write a complete code but I'll just tell you some logic how you can write it okay I already have written code I'm going to explain that so let us say I have some files into this particular folder called uh this g in my g tree I have some folder called as files and in that I have multiple files file 1 file 2 file 3 file 4 file 5 so let us say I have some situation where I want to send all this file or I want to upload all these files from my to my Unix or Linux server then how I can do that in one attempt okay so that's pretty simple so I know how to upload a single file so I can put put all the files in the loop and I can send it that's pretty simple right so basically I need to use a for loop so I will do it uh on the all the files but the thing over here is we need to get the list of the files okay so the very first thing I will do is I will try to find out list of all the files how many files I have in this specific folder and then from that specific collection from that specific list I'm going to uh get one one by file one by one basically and put it on Unix server by using my normal sbtp object dot put command okay so let us see how we can get this list of the files uh into a collection object or a list object let me switch to my clips okay and so here I have written a code already basically most of the chunk of the code is remain same that we saw in my last videos so creating the ssh object then uh this is my uh key basically a private key used to authenticate then I'm setting the private key I'm just setting the session by using my uh username and my basically server and port uh if you can if you have password you can set it uh you can set your preferred authentication methods and fine so now what we did is since it is again a kind of file transfer operation so I'm using a channel as a sbtp I'm just casting it to making it as a forceful as a sbtp channel right and now my uh the logic starts from here so the very first thing is I am creating the object of uh file so this files this files is my folder right so this is my folder but internally it is file only it is collection of files right so basically I'm creating an object of file where my files are located like in my g drive under files folder all my files are located so that's where I'm creating object of my file now I'm checking if particular folder is existing if it is exist then what we do is by using the file utils class okay so basically this file util class belongs to common IO uh package okay so if you do not have this particular dependency then you need to get this dependency which is basically o r g dot apache dot commons dot io dot file utils so whenever you perform operations related to file this file utils class make it very easy right so now for what and all this file utils class is used so here you can see a thick list for writing to a file reading from a file making directory copying the files and directories deleting files converting it to a url listing the files and directories by filter and extension so this is what I need now listing my files so this is this is only what I need listing my file okay so that's what this particular thing is doing I am going to list my all the files from this particular directory which is my local file directory into a collection or call it as a list let us say into a collection called as file list okay now in my file list list of all the files that's great now as soon as I get list of all the files what I'm trying to do is I'm trying to put all the files onto the server okay before that what I'm going to do is I'm going to create a new directory onto the unique server and my name of my directory is multiple files upload so this particular directory will get created on your unique server and I'm using command called sptp which is my sptp object of the channel dot mkdir to create the directory and this is my directory name so once this directory get created what I'm doing is I'm using forage loop okay so on the forage loop I'm iterating on the file okay onto the file list basically and from from the file list what I'm doing is I'm getting the absolute path of the files one by one so let us say initial let us say I have all file all five files into the file list called as collection called collection of files called as file list I have five objects then the very first thing is I'm getting the first object into this file and I'm getting file file that is my file one dot get absolute path so I'll get its absolute path the complete path and I will put them on multiple file uploads folder basically I'll upload them there okay so if you have if you want to specify the complete location from where it is located basically then you can give the complete location like how we how we gave it in a single file upload so this process will iterate till it basically process all the files into this file list object okay so once this is completed it will basically send all the files to my unique server and then finally the rest of the part remains same sptp exit channel disconnect and session disconnect once I'm done with everything I'm going to close my sptp channels then my channel and then my session okay so this is how basically we can send all the files to post or upload all the files to whether whether it is your unique server or Linux server we can do this okay now let me go to my unix okay and let me do ls over here so here you do not see so here you do not see any folder with name what is the name here is multiple files to upload so here you do not see any directory like that now what I'm going to execute this particular program let me run it as our application you can see the file uploaded is it has uploaded the first file second file third file fourth file and fifth file and my execution is completed except if you exited channel and session disconnected great that's when my program is worked all and all now let me go to my unix and let me check the list of file again now this time do you see some folder called as multiple file upload yes now let me go to that particular directory and let me get a list of all the files over here and do you see all five files are uploaded starting from file one to file five so this is how basically you can send all the files to your unix or Linux server so again there could be any kind of requirement whether you want to send single file multiple file but basically the logic logic remain same you are sending the file by using this put command and rest of the things is your basically a java logic right so here we use this file utility class which basically used to perform the operations general manipulation utilities for your files and for this basically okay it makes it makes our core our coding a little bit easier so fine so that's it i have basically so here i talked about how you can send our multiple files to unix or Linux server using a jsch which is a java client library for for setting up basically the assets its connection to your unix or Linux server okay so fine so that's it thank you hello welcome back i'm coming to the course of unix photo source uh there i'm going to i'm talking basically uh manual unix concepts and how we can uh automate those unix concepts uh in order to use them in my desktop to machine framework so in this video i'm going to show you how we can execute a shell script via jsch which is my sss library for using java bindings so uh basically i'm going to create one java class file okay and i'm going to show you how we can execute uh the initial script basically uh from my java project okay exact shell script okay and fine okay so basic most of the things will be common from my execute any command in unix via jsch which i covered in my last video okay so most of the things will be common over here okay so what i'm going to do is i'm going to copy let me copy all the course then i'll modify it there okay fine now what we need definitely we need to set the key exactly yes we need to create a session with my same username host and port yes we need the strict host checking key in in order to skip this key checking again and again that is it might ask me for password again and again and i'm opening a channel for exact that is to execute any command or it could be your shell script right even right if i if i want to execute any shell script then i'm doing it from my command itself right so that is again your command itself so i'll be using exact only here right now the difference will be here right so i'll be just passing my shell script over here right the way how i can execute my shell script in my set command part okay i have explained all these things briefly in my last video you can go through that i hope you must have gone through that if you have not please go through that first then you can refer this now if i check my directory so here you can see some shell script called as script.sh now i want to execute this script script.sh from my java program okay so what i can do is i can use . which will refer my current directory slash script.sh okay so if i use something like this it will execute my script with name script.sh right so of course you need to parameterize these things whenever you incorporate it incorporate these things in your test automation framework so this is something which i am hard coding as of now fine now if i execute this let us see what happens okay so what it is saying is permission denied because i do not have access so let me check if i have access if i do ls-ltr for this shell script script.sh you can see i do not have exact permission right so i need exact permission so let me change the permission i am going to set triple seven to my script.sh okay now i am done with first setting permission let me check if it is successful now this time for script.sh you can see rwx command for all the basically my user group and others so if i try and execute this particular code now i should be able to get it successful okay so you can see the shell script is reading our text file and the file process is completed that means my shell script execution is completed okay okay let me tell you one more thing so let us say i am changing my properties of this particular file back to what it was so it was 640 i believe where it is script.sh yeah so now i reset it back to the earlier one okay and now what i will do is i will change the properties of the particular file from here itself from a same command okay so basically i am going to execute two commands at the same time now and how i can do that i can use chmod and i want to set triple seven to my script.sh okay and basically in order to coordinate two commands i need to use double amp person right so this is my first command it so this first command will be executed first after that it will execute my second command okay so now even though it does not have a execute permission but since i am setting the execute permissions from here it will execute my code okay so let us check can you see it is executing okay and now if you check ls ls iphone ltr you should see the permission must have modified can you see script.sh all permissions are set to rw x that means the permissions are modified by executing these are the first script and then it has executed the second script okay now let us say okay now what i am doing what i am doing here is i am just starting my execution via this channel dot connect as soon as i do channel dot connect it will start my execution fine now let us say if i want to wait till my execution is finished since this file this whatever shell script i have it does not have much things to process but if my shell script has many things to process like let us say millions of record to process then my particular channel should wait for processing to get completed before it disconnect right so if i use something like channel dot i should see some method it's closed okay i'm i'm seeing method as it's closed okay and it's closed method it is a boolean method you can see it is a boolean method okay so basically what i can do is if it is not closed then i want to continue something like that so i can use something like while channel dot close is false something like that okay and if it is false then you can keep waiting right so i can add something thread dot slip off let us say 250 minutes again right so i can i can i can do something like this so that it will keep waiting until my channel is not closed right so this is the one way how you can achieve this okay and what else okay and as well you can get the exit status as well okay so like if i use channel dot get this okay so basically it print the exit status exit status is okay if i execute now it should print my exit status sorry i used err it should be system dot out dot print alone it's my mistake okay so you can see the exit status is zero that means my execution is successful right so this is how you can track the status code as well as you can wait till your execution is finished and then only maybe you can put this code as well in some condition like if your channel is closed then only you can disconnect or something like that right you can have that as well so that is how basically you can execute a new shell script from your java code okay so you just need to pass the location of your shell script right another way to execute your shell script is like this sh dot script dot sh right so there might be some situation in which you might need to cd change your directory to let us say home followed by your name followed by some project location project name right and then you might need to execute your shell script so you can combine your two scripts like this right so first you are changing the directory then you are executing this particular shell script right so you can combine the command before you execute them so this is how you can execute the shell script from your java code okay and you can combine it in your test automation framework so that's what i wanted to talk today about how you can execute a shell script using jsch which i can incorporate basically in my test automation framework if i am using java bindings okay so that's it for this video thank you hello there welcome back welcome to the course of phoenix for testers and this video i'm going to show you how you can verify if particular file exists on unix server or not that is with the help of jsch which is a java ssh library and yeah so we can basically use this particular code piece of code in my test automation framework if we have any such a requirement okay so let me log into my unix server okay so if i do ls on my home page you can see i have multiple files present over here so if you remember in my one of the video where i ran a shell script with automation it has created one file output file called as output file dot txt okay so let us say if i have some requirement like i'm running some shell script and my shell script is producing couple of files and i need to verify those files got all actually produced or not if the files are already created or not if the files are already present or not on particular location on my unix server then this particular piece of code is going to help you uh yeah basically in your test automation framework okay so let me go and go to my eclipse id basically okay so this is my uh code where i talked in my last video like how you can receive a file from unix server okay so basically last time what we did is we created a instance of sptp and we used the get method to get the file from unix server again we have one put method to send the file to your unix server right so basically i'm using this piece of code so what i will do is i will just copy this class and i'll paste it and i'll name it as check if file exists on unix so unix or linux fine so it's here great so now what and all i need now so let us start from scratch so the very first thing is my private key path so this is something which i need in all examples which i'm talking because in every example i'm i'm connect i'm getting connected with unix server and i'll be getting connected with the help of this key itself key and this few parameters like user name host name and port if your unix server accepts password instead of private key then you can set it using session dot set password and you can provide your password fine and if you have multiple things like and out of that if you want to send the preferred authentication then basically you can set this set configuration you can set this one of the parameter called preferred authentication and you can set the values by comma separated like i want to give pass reference to public key then i want to go give some pass preference to password and then finally let us say i need to give a preference to my keyboard interactive where it will ask password in my command prompt something like that okay so you can give that sequence over here great then i'm configuring the session fine so this is all about authentication fine so now i'm connected with the session and this time as well i need this open channel with a septic instance because that is again a kind of file transfer because i'm going to check if my particular file is present or not right so now i'll if i go here and get method let me check what and all i have so connect and disconnect the very basic method then i have one cd method where i can change my directory then i have another method called ls to get a list of files right so basically this is something which i'm going to use in this case ls then we have a few more like make directory then we have get put exit and we have many more it l password eof is closed disconnected so basically it has a large set of methods so you can look at them as per your requirement whatever requirement you have and basically this is something all the operations required which requires basically a set tp or ftp basically all those methods should be present in this particular class sptp class okay so i'm going to use sptp.ls okay and here i need to provide the path right so this path is nothing but let us say i want to check if this particular file output file.txt is present or not but at which location so i want to check it if it is present in this particular location or not which is my home slash prakash okay so let me give that particular location over here okay so this sptp.ls fine now what this ls written if i hover my mouse on this ls you can see it returns a vector okay so this vector is basically as similar to your collection where you can store a list of entries you can say it is just like as like your how your list work how your array list work system and similar concept it work but just the thing is it has some legacy method which are not used much nowadays because there are many advanced method in the collection but this particular method returns a vector so i need to store it into a vector basically okay so i'm going to create a vector instance and which is present in java utils vector and what is it type okay so my type over here is ls do i have something like ls entry yeah so ls entry is basically in list of entries present in directory okay and let me give the name as files let us see okay so what i did is i just stored the list of entries whatever list i'll get on this particular directory into a vector you can just say it as a list okay list of files so this basically files object will contain list of all the files which are present at this particular location okay and for example if i just do sys o system dot outward print ln and if i simply print files dot get okay so i need to check how many files are present in this particular directory but for just for example sec i'm just trying to get the very first file which is present in my particular location that is home slash prakash okay so let us check what output it prints okay so this is the very first entry which it has printed right file to send to post and i believe okay give me a second ls if an ldr okay looks like it doesn't maintain the sequence okay but it is giving me the complete things okay but this is something which i don't want i just want the file name okay so if i do something after get zero if i do something like get file name now this time i should get only the file name other than getting all these things which i don't want as of now great can you just got one file name which is file to send to host okay so this other things are the messages just printed for my understanding purpose but this is something which is printed by this particular files dot get zero now what my aim is to my aim is to verify if particular file is present so in order to do that what i need to do is i need to iterate over the complete list of files which is present in this particular files object okay so basically the very first thing is i need to get this file count okay so how can i get the file count int file count is equal to then files i'll use this files object dot then i have one method called as size method okay so this basically this size method will give me the list of all the objects sorry the number of all the objects which are present in this particular object which is my file which contain all the lists okay so now what i will do is basically i will it's rated in a for loop okay so for i will do something like for int i is equal to zero i is less than okay so i need to do it till my sorry till my file count and i plus plus great now what i need to do in this scope so basically by using this for loop i am going to iterate over all the files which are present in this files object okay and what i'm going to check over is if my file exists okay so fine so what i need to check is if uh what is my object name my object name is files dot get and i'm starting it from zero so that is starting from i right dot get file name sorry get file name okay and i want to check if it is equals or let me use equal signal case okay and the actual file name which i want to give okay so in this case i'll give the file name as let us say my output file dot txt okay so this is something which i'll give okay so if my uh file name is equal to this okay then what then that means the file is present okay so i'll print some message like file is present okay and if my file is present then that's it that's what i was looking for okay then what i can do is i can do channel disconnect okay and then i can do session disconnect okay and finally i can break out of the loop otherwise it will keep looking keep in the loop but since i got the file then i need to break out of the loop fine now uh how i'll get to know if the file is not present okay so what i'll do is i will add one more if condition if my i is equal to equal equal to okay so what did if my iteration is reaching to my last file so what is in my last file last file is nothing but my file count minus one okay so if this particular condition is getting satisfied what that means is my particular file is not present because i'm already iterating to the uh i'm already reaching my end of the list file is not present fine and then finally again the same three lines of code disconnect and break anyway it is going to break so that's it so this is something which is going to help me okay so this break and all disconnect and all i don't need because i'm already doing it session again i'm doing it i don't need this find this sft2p again i don't need this okay now uh let us try and execute this particular piece of code so since my output file dot txt is already present so i should get a message like file is present which i'm printing it from here so you can see file is present okay so let me remove this okay now let us say i'm just changing the file name i'm just looking out for file output file one dot txt which is not present so if i try and execute this so can you see i'm getting the message like file is not present so this is how basically you can keep checking so this is um i just printed the messages basically but in your real-time real-time scenarios what you might need to do is you might you might need to have one method which returns true or false uh you you may have one method like okay let me just drop something you may have some method like public boolean if file exists on server something like that you may have some method like this okay and what you can do is from this particular method you can return uh basically true or false okay so what you can do is like whenever wherever i am printing this message right so from instead of break instead of break what we can do is you can return from here return as true okay after you're returning break is not required and if file is not present right what that means you can return as false over here right so this is uh something how you can use it in your real-time uh scenarios right so that you can refer it in your other scripts right so this is uh what i wanted to show you basically how you can execute how you can check basically if particular file exists on your unix server or basically unix server or not okay so fine so that's it i have for this video where i have shown you how we can verify particular file exists on unix server or not so i have shown you like we have a large number of methods which are present under this SFTP okay so you can just you can just uh go through them one by one may yeah so as per your requirement you can pick your method and start working on it they have a huge set of methods whichever are required for you are performing your SFTP operations okay so that's it for this video thank you hello welcome back welcome to the course of unix for testers and in continuation of my jsh video series uh today i'm going to talk on how to receive or to get the file or how to download the file from unix server to uh my local machine via jsh which is my java ssh client okay so if you uh if i go to my unix server okay and if i do ls now i have some files which i can download let us say i want to download one of the file let us say i want to download this output file dot txt let me check the content of my file dot txt and it has some content okay it has some content which i want to download now so this this this is what content of my uh output file is it's it looks a little weird but that's what the content of my output file dot txt is now let us say i want to download this output file dot txt to my local machine okay and local machine let us say i want to download it uh here okay in my g drive okay and my file name is output file dot txt and i do not have any file called as output file dot txt open here right so let us see how we can uh achieve this with the help of uh jsh which is a java client library for achieving this ssh operations okay so basically the process remains same creating authentication, creating channel, creating sessions and uh with the help of channel we can get the file uh using get method so if you remember last time to send the file to the unix server from my local machine i used the put method okay this time i'm going to use the get method so without delay let me switch to my uh eclipse okay and here i'm simply going to copy paste my last video file which is send file to unix server and i'm going to paste it with name receive file from unix server right because most of the content of my file remains same in fact almost all the contents of the file remains same just the difference would be the type of operation which i'm going to perform again uh if you're watching this video directly it is not advisable go go little back and start watching the video at least from where i started talking about authentication in jsh and then the couple of more videos the very first thing is i'm doing private key path setup then with the help of username uh my port and my host i'm setting up the session and finally i'm creating the i'm basically i'm opening the channel to perform sptp operation so like sending the file to host or getting the file from unix server that is my host uh is kind of sptp operation so i'm opening the channel basically for sptp operation and then i'm i'm cast type casting this channel sptp which channel so that i can use this get and put methods because it is not available directly in channel so i need to cast it with a channel sptp so that i can create the object of sptp okay here i have created a channel sptp great now my channel sptp channel sptp channel has some methods like gateput and all which i have shown you last time so you can see i have some whole bunch of put methods okay and again it has some fields like uh offset and all how much time we should wait and all those things uh if if there are any issues uh it has again some method like uh if you want to get the list of all the files so instead of sending the command you may use this sptp operation or if you want to get your pwd or any other things so this time i'm going to use uh this gate operation where uh i need my source file and destination file okay so this is something which i'm going to use now so what is my source my source file is it is in home slash pakaj because my source file is uh basically what i'm trying to do is i'm trying to get the file from minix server download the file from minix server so my source in this case my source location would be uh this particular file okay so and this particular file is present if you check over here my present working directory that is home slash pakaj okay so that's what i have mentioned home slash pakaj followed by my file name which is output file dot txt and then i want to store it in my g drive which is my destination okay and my file name i want is output file dot txt and i just want to slash is great so that is what the change in this particular script should be okay so instead of put i'm using get method so that i'm trying to get the content get the file from my unix server to my local machine and rest other things remain same i'm doing the validation if my sptp channel is null or not and if it is then i'm trying to exit it then i'm trying to disconnect the channel and i'm disconnecting the session okay so these are the cleanup activities which i'm doing so the main part is this sptp dot get okay so that's it i think i have in the code let me try and execute this if i can get the file which i mentioned over here to my local machine okay so you can see sptp is executed execution is completed great now let me go to my g drive and see if any file called as what is the file name output file do i have any yes i do have output file and you can see it is just downloaded before us again and if i open this it should have the same content what i had in what i have shown you here right basically they are not in a line that is that is some other issue that's fine that has nothing to do with this particular operation okay so this is how basically you can receive the file from my unix server to my local machine so when you will get such a kind of scenario so as i said again assume a situation where you want to do the file processing your linux your linux linux or unix l script will let us say generate some kind of files could be any kind of files could be your text files or xml files or accent file or could be any kind of file data does them so it could be anything so if you want to download those files to your local machine so that you can do further validation on that file by using your let us say java code in this case then for such operations we need to receive the file from we need to get the file basically from the unix server on my local machine so that i can do the further operations and do my validations on it right so great so that's it i have for this video in my next video i'm going to talk about so let us say you have a situation like you are you have sent the file to the unix server unix or linux server then it has triggered a shell script then it has generated your output file okay or let us say your shell script generates couple of more files so you want to check if your shell script has generated or in simple terminology if you want to check if any file exists into the unix or linux server or not okay so i'm going to talk more about this concept in my next video so stay tuned thank you hello there welcome back welcome to the course of unix protesters and this video is in continuation where i'm talking about how we can use jsh which is a java ssh library which i can use basically to interact with my unix or linux server to perform various operations like executing any kind of command on your server or executing shell script or doing any acceptable operations so out of that this is the kind of last video where i'm going to show you how basically we can receive or download multiple files from your unix or linux server using our jsh so till now i talked on how we can send a single file multiple files so we can receive a single file how you can execute a shell script or basically any command okay so here i'm going to show you how we can receive basically multiple files from unix or linux server to your local machine and basically it could be for any operations okay so again i'm not going to write a code for this i'm going to show you basically a logic how you can write it okay so let me clear and let me do ls over here okay so if i do ls on my let us say this particular home directory you can see there are multiple files so now let us say what my aim is my aim is to download all these files from this specific folder or even if i if you remember in my last video i did send a files to this particular directory that is file one to file five or better let me get the files from my home directory itself because it has some shell script and some doc file as well we'll see how we can get them right so what i will do is i will try and get all the files from my home directory and in my home directory if i do ls-la then okay then basically i have these many files and i want to get these many files into on onto basically my local machine okay so how i can get we know that how we can get a single file by using a get command that is a set tp channel object dot get we have some method called as get if we know how we can do it for one definitely we can do it for multiple as well by using simple our for loop but the basic challenge over here is how you can get the list of all these files see when we did a reverse thing that is sending all the files from local machine to host so for that purpose what we did is we we have taken a list of all the files into an object of file utility if you remember we use file utility over there so in this case so let us say if i execute a command like ls so it will give me list of all the files basically right so okay and if you remember when i used okay in a second let me show you where i talked about verify if file is present okay so in this video what i have shown you shown you is if particular file is present at some location so there if you remember i use something called as s tp dot ls okay so we created a s tp channel and on that s tp channel we use dot ls so that it will give me the list of all the files in this particular directory and it will store it into a vector collection of this then what we did is we simply it related it over the list of all the files so in this case in my this getting all the files from Unix or Linux server case what i will do is instead of this part i am simply going to use s tp dot get all the files from this particular collection that's pretty simple let's see how we can do that so here it is so again all the basic stuff so if you are watching this video alone make sure that you have watched my video where i talked about how we can create a jsh like the how we can basically establish the session and do the authentication that's the one of the video in the series fine so i'm not going to talk about that so we have created a channel s tp channel and then by using the s tp channel so here i am doing s tp dot ls and i'm trying to get the list of all the files from my dot reference to the current directory so this basically command s tp dot ls what it will do is it the list of all the files from this particular directory and it will get stored into a vector object called as uh list okay that's the basically object of ls entry okay that we talked in where i talked about verified file is present now what i'm trying to do is i'm trying to iterate over this particular object of list so here you can see i'm trying to iterate over this list okay and i have created one reference variable of ls entry type okay and basically what i'm trying to do is if it is not a directory because i just want to get all the files not a directories so what i'm trying to do is i'm trying to get uh whatever i have into this particular list dot get attribute and if its attribute is directory and here you can see i have a not symbol that means it is a not directory if it is not a directory then i'm using s tp dot get then get the list get the first element from that file and store it into add this particular location into this files folder where i have it in my g drive okay so here it is if i go to my g drive i have one folder called as files and in this file i'm expecting all the files from this particular uh unique server and these are the files okay so and that's pretty simple just accept tp dot get and it will get all the files uh which are presented to this particular list basically and which we got it in the list by using this ls command and to the current location okay and after that if you want to let us say remove the files then you can use the s tp dot rm and give the file name basically whatever you want to do with that events the files are downloaded okay so that's it i wanted to show you now let me execute okay so what i'm expecting i'm expecting all the files from this current directory should get downloaded into my download uh into my files folder and now you can see the file you can see the downloaded file name is this downloaded file name is this again it is it is downloading all the dot files as well and it is downloading basically all the files from my home folder okay and you can see it is completed now if i go to my files folder can you see it has downloaded all the files basically from this particular location which was my current location basically right so this is how you can get all the files from your unix server to your local machine okay so fine so that's it i wanted to talk in this video i hope you have enjoyed this series of video where i talked about how you can use jsh to perform various operations or to interact with your unix or linux server to perform various operations okay again you can explode it as much as you want i have shown you like we have many methods which you can explore as per your requirement okay so fine that's it thank you