Part 1 - Unix/Linux for Testers | File Commands

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome you all this is pawan from today i'm going to start a new series on linux commands and which are very very important for testers and especially when working with real-time projects most of the times your databases will be installed on your remote machines and those machines are having unix or linux operating system and sometimes you should also deploy your applications on linux or unix servers and you should be able to connect to them and you have to conduct some testing on their environments and to do that you need to know some basic commands uh from linux or unix and uh for entry perspective also which are very very important so before discussing these commands first thing you need to have environment to execute all these commands and uh there are multiple ways you can execute these commands either you can have the dedicated environment like you can just download ubuntu uh vm and you can just run that vm by using virtual box or if you don't want to install anything then you can have multiple internals online terminals are available without installing any unix or linux in your local machine you can just google it there are so many open terminals are there and directly you can execute those commands okay through browser all right so as a first step uh here i have listed out some of the commands like file commands directory commands miscellaneous commands and filter commands file compare commands and chmod so i'm going to discuss these commands in multiple videos so as part of first video so today we are going to focus on file commands okay so first we will see how we can work with the cad command cp mv and rm so let us start with file command so for that i have already have ubuntu vm so let me start my vm so once you click on this i already and i already set up my vm so i'm just logging into my vm okay i'm providing my password and now i log into my login into my ubuntu vm okay this is basically one of the flavor of linux and there are multiple flavors are available you can just go with fedora line x and red hat line eggs or this is ubuntu flavor of linux okay and linus is a little advanced than unix and this is a on top of unix the linux is implemented so these commands whatever commands i'm going to show you these commands are the core commands and all flavors of linux are all flavors of unix or these commands you can use all right so now i have just opened my uh vm so this is basically ubuntu linux and if you want to execute these commands we want to work with the commands you need to open a terminal so if i just look at here a small terminal is available so when i click on this which will open it small terminal and you can work with all the commands here you can execute all the commands in this terminal and let me just increase the size of the terminal okay so let me increase a font also you can just zoom in here and once you zoom in your font also will be increased okay so now i have zoomed in okay so now this is my terminal so whatever commands we are going to discuss so all the commands we should execute only through this terminal okay all right so the first category of the commands are file commands so today i'm going to discuss these commands file commands so under file commands we have four types of commands a cad command cp mv and rm okay now each command we can use in multiple ways now i'm going to show you the purpose of these commands so as a first step so we are going to start with file command the first command is cat command so what we can do with the cat command so we can use this cad command multiple purposes like we can create a new file and we can also display the content from the file or we can concatenate multiple files or suppose i already have some file which contains some data now i can also add some more data that means i can also append some data to the existing file so there are multiple operations i can do by using this cat command okay now i'll show you practically how we can work with this cat command now let's go to terminal so here what i'm going to do is i'm going to create a new file so that's my first action so i'm going to create a new file if i just look at here when i type ls command ls needs nothing but a listing command list so when i type ls command by default it will show you what are the directories are available what are the files are available here okay so it is just like equivalent to dir command in ms dos so here i'm going to show you uh first command so clear is a command which will clear the screen so the first command is a cat how what we can do with the cad command is we can create a new file now how we can create a new file so to create a new file by using a cat command simply you can say cat greater than and specify the file name let me just give something called testing.txt you can give any extension to the file so i just create cat greater than testing.txt so when i press enter it is waiting for providing the data so we have to provide some data into the file so here i'm just providing some data i'll say manual testing i say automation testing so press enter after that i want to exit from this problem so i'll say control d from the keyboard i have to press ctrl d then the command prompt is exited so cat greater than name of the file so which will create a new file which contains this data now how we will know that when i say ls which will give you the name of the file so the file is a part of this list now i want to display the content of this particular file so i want to display the content of the file so simply you can use the same command i'll say cat and the name of the file is testing testing dot txt so this will display the content of the file so so far we have user cat command in two different purposes one is we created a new file by using cat greater than name of the file and after that we display the content of the file just we say cat name of the file along with the extension which will display the content in the particular file now we can also use cat command to concatenate more than one file so to concatenate more than one file so for example i'll also create one more file let's say cat and i'll say testing one two three dot or we can say one two three dot txt okay cat greater than testing123.ext and here i'm adding some data let's say i'm adding let's say selenium and also i'm adding something called cucumber and then control d now i have created one more file now you can just list here ls you can see two files testing123.ext testing.txt two files have created now i want to see the data from the both the files i want to see the data from the both the files so you can use cat command which will also concatenate more than one file now how we can do that let me just clear the screen ls now i have a two files testing123.ext testing.txt now i want to see the content from the both the files then what you can do is you can say cat i say simply cat and here you can simply say name of the file i'll say space cat space testing dot txt this is my first file and one space and the second file is testing123.txt so the cat command will display the content from the both the files press enter now you can see these two lines are created as part of testing.txt and these two lines are created as part of testing123.txt so we can also use cat command to concatenate more than one file if you have a multiple files you can just give one space and provide multiple files three four five or whatever files we have so that is a concatenation so we have seen three purposes one is we can create a new file then we can display the content of the file then we have concatenated the two files that means we have got the data from the two files display the content from the two files that is called concatenation now finally we can also do one more thing called appending the data to the existing file suppose i already have the testing.txt let me print the data i'll say cat [Music] testing.txt so currently this file contains the two lines manual testing and automation testing now i want to add a few more testing so a few more content in this particular file that is called appending so how we can append the data so to append the data we can use this command like this i'll say cat and uh to create a new file we have just given greater than right now this time you have to give two greater than so cat greater than greater than then we can specify the same file i'll say testing.txt and in the same file i already have two lines of content now i'm going to add another content manual testing automation testing both are there in the testing.ext now i'm going to add something more like say i say regression testing and i'll say sanity testing i say smoke testing okay i have added three more lines and then ctrl d so now it is exited so now if i just want to print the data as a cat testing dot txt now we can see three more lines have added so along with the two lines three more lines are added so this is basically called as a appending append in the content to the existing file okay so we have seen cat command in three different purposes let me also write the node so that i can put in the description so the first way the first purpose of cad command is we have to create a new file we can creating a new file and then we have displayed the content of the file then when concatenating the more than one file then we have append the data to the existing file so this is a usage of cat command all right so now let me show you one more command go to the document so the next command is a cp command so what is cp mean cp simply means copy so we can copy the content from one file to another file so copy consent content from the one file to another file so to destination this is called copy command now i'll show you how we can use this copy command let's go to the terminal and let me clear the screen when i say ls i have testing.txt file so i want to copy the content from this file to some other file i want to copy the content from this file to some other file okay so now i'll say how to copy i can say cp command i say cp and testing.txt so txt contains some data right so cp testing.txt and i want to copy the content from this file to another file so i'll say testing1.ext so not one to three testing one two three is already there now i'm just giving some other file or you can simply say testing underscore new file okay so testing.txt space testing underscore new dot txt now whatever content we have in the testing dot txt will be copied into testing iphone new dot txt now if i just say ls now we can see a new file called testing underscore new dot txt now let us display the data i'll say cat testing underscore new dot txt so this will print the content so previously this file was not there now whatever content we have in the testing.txt i just copied the same content into a new file okay this is a usage of copy command so copy is a command which can copy the contents from one file to another file source to destination so what is the syntax cat and uh here the cp sorry cp and source file and target file so the content from the source file will be copied into target file and once it is copied we can display the content of the file by using cad command so this is a usage of cp command and then we have mv command so what is the use of mba command s we can use mv command for multiple purposes so the first purpose is we can use this command to renaming a file suppose i want to rename the existing file i want to rename it so for that i can use mv command or you can also renaming the directory suppose there is a directory which contains multiple files i want to rename the directory still you can rename the directory and the other usage is we can also move the files from one directory to another directory we can also move the files from one directory to another directory so let me put the points so we can use uh mv command in multiple ways i'm just saving the file okay so mv command we can use three different purposes we can use mvcommand for renaming a file that means changing the name of the file we can also use mba command for renaming the directory so directory means which contains a multiple files and we can also move the files from one directory to another directory so this is called moving moving is different than copying okay so now we'll see practically how we can use this purposes like mv command now go back to terminal and i'm just clearing the screen so ls i have few files here okay now the first file first purpose of the mv command is renaming the file so how to rename the file suppose for example i already have testing.txt okay so i will just say command mv mb testing dot txt so i want to rename the file testing.txt2 okay i'll say automation.txt testing.txt and i want to rename the file with the automation.txt so press enter and after that just say ls now we can see testing.txt file is renamed with automation.txt so now i have renamed the existing file now testing.txt will not be there so the new file we have just renamed the file so automation.txt is created now if you want to see the content again i can say cat automation.txt and which will display the same content so this is a one purpose of mv command we can use mv command for renaming the file that means changing the name of the file now the next purpose is we can also use it for renaming the directory so we can also rename the directory so directory means which contains a multiple files or sometimes we can also create empty directories okay so how to rename it directly so to rename it directly also we can use mv command so for example uh here i have few directories available so let us say here blue color is representing these are all directories directories folders we can call it as a folders and windows or else we can create our own directory so by using uh command mkdir we can create our own directory i'll say mkdir so which will create a new directory mkdir make a directory so i'll say uh my dir okay so my dir so this is my directory which is created now we say ls you can just look at here my dir should be up here in this list somewhere you can see this is a my own directory which is created now i want to rename this directory so previously we have renamed the file now i am going to rename the directory so my dir is my own directory which is just now created now i want to rename the directory so to rename it we can still use method called mv mv my dir2 my directory to i'll give some other urdir your directory now it is renamed now we can just say ls now we can just look at this my dear is renamed with urda so you can just look at here so mv command we can use it for renaming a file and also renaming the directory and also we can use mv command to move the files mv is nothing but a moving so moving the file from one directory to another directory moving in the sense in the source location file will be deleted and the destination location file will be copied so there is a difference between copy and moving copy means there is a duplicate entry will be created duplicate file will be created but in case of moving there is no duplicate file okay so now mv is a command which we can also use it for moving the files from one directory to another directory now i'll show you how we can do this how we can move the file from one directory to another directory and if i just look at here i have one file here automation.txt and currently in which directory we have if i just say pwd present working directory which will show you the current directory so this is my current directory in this current location in the home pa1 is my director name and here my file is present automation.txt if i just say ls again you can find automation.txt now i want to move this file from here to your directory so currently automation.txt file is present in my directory now i want to move this file to urdir okay so then how we can move that file so we can use mv command to move the files from one directory to another directory so for that you can use mv command which well you want to move automation.txt mb automation.txt so where you want to move to your directory so you can specify the directory name i say you are dir okay so you are there i'll say enter now command is successfully executed now when i say ls now we can just see automation.htfl you cannot find anywhere because that file is already moved to urdir now i want to see that particular file whether it is move to urdir or not so what we can do is we can just say cat urdir inside the folder what is my file name automation.txt so when i enter this and it is saying your directory automation.takes no such file or directory saying so we have to give the properly command cat your dr slash forward slash automation.txt so now we can see the content so in linux or linux environments always we use forward slashes okay so your directory is your directory name inside this file is available so that i got the content okay so directly i can access the content of the file by specifying the location of the file like this or you can also enter into the directory suppose currently if i say present working directory currently i'm in power directory so i want to go to urdir so simply cancel cd command you can give cd and they say you are dir now you are entering into the urdir so if i just look at present working directory pwd you are there in the your directory now you can just ls here then you can see the file okay so this is how we can just check the file which is present in the proper directory or not and if you again go back to your previous directory you can say cd space dot dot cd space dot dot so changing the directory it will go to one level back now again if you just say pwd now currently we are in permanent directory so mv command we can also use to move the file or files from one directory to another directory so that is a use of mv command now the last command we have is rm so rm is a command which we can delete a file or a directory we can delete or remove a file or directory in both the purposes we can use rm but the rule is we can directly delete the file by using rm but when you're trying to delete the directory by using rm that directory should be empty then only can delete the directory but still if the directory is having some files still you can forcefully delete the directory okay i'll show you multiple options so rm is a basically command which will delete or remove a file or directory now let me show you how we can use it let me clear this i say ls now as a first step i'll show you how we can remove the file or delete the file so i have something called testing123.txt i want to delete the file or i want to remove the file so simply you can use rm and name of the file testing123.txt so after execution of this command just say ls now you can see testing123s got removed from this list okay testing one two three is remote so we can successfully remove the file now i want to remove the directory now so we already have one directory called urdir right which contains a file also earlier we moved the file into doordar automation.txt file which is available inside this urdir so if i just look at this again uh i'll go to this directory cd uh urdir if i say ls now my file is present here urdir inside this directory automation.txt exist now go back now what i'm going to do is i want to i'll try to remove the directory which contains some file i want to remove the directory which contains the file so currently your dir contains a file now let us see what will happen so i'll say remove remove name of the directory is your dir okay now when i say execute this command what is saying cannot remove your dr is a directory it cannot it is clearly saying you cannot remove the directory you cannot remove the directory because it is having some content that means it is having some files but still i want to remove the directory even though it is having some files then what i can do is you can just execute one command rm iphone r recursion rm iphone r and then specify the directory name and say you are dir and our iphone r is a command rm iphone r then urdr even though the file or directory contains the files still it will remove the directory now executed now when i say ls now you can see your dir is removed from this list okay so this is how we can also use rm so rm is used to delete or removing the specific file or we can also remove or delete the directory okay but if i directly use rm we cannot directly remove the delete the directory and you have to make it empty but still if the directory is having the files if you still want to delete the file or delete the directory then you can use iphone rm iphone r then your directory name okay so these are all four commands which are comes under file commands so cad command can be used to create a new file display content of the file copying the contents of the file sorry concatenating the files right and cp is a command by using this we can copy the file into another copy the content of one file to another file and mv is a command so by using mv we can rename the file and we can move the file from one place to another place means one directory another directory and we can also rename the directory names and by using rm we can delete or remove the files or we can also delete or remove the directories so this is a usage of file commands okay so in the next video we will discuss directory commands and that's all for this video thanks for watching
Info
Channel: SDET- QA Automation Techie
Views: 42,301
Rating: undefined out of 5
Keywords: Python, Selenium with Python, Selenium webdriver, Automation, Testing tools, Selenium tutorials, Python tutorials, Manual testing, SDET, Java, selenium with java, big data, hadoop, web services, postman, soapui, rest assured, big data testing, hadoop testing, ETL testing, SQL, Programming, Software Testing material, selenium videos, python videos, automation vidios, jira, jmeter, performance testing, functional testing, QA, QC, Agile testing, SDLC, Automation Step by Step, restapi
Id: LxrKRkCyRwU
Channel Id: undefined
Length: 25min 17sec (1517 seconds)
Published: Thu Dec 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.