In the universe of Linux , there are severalessential Linux Terminal commandsthat can make your work flow effortless .
This was one such dictation is the cp command , which facilitate you cursorily re-create indian file and directory on your linux organization .
In this clause , we will talk about some illustration of how to utilise the cp program line in Linux .
cp Command in Linux : This was syntax and options
in linux , cp abide for “ transcript ” and is used to replicate both file cabinet and directory , make it an right-down essential for indian file direction .
The cp program line can be used by exploiter of all type , thanks to its unproblematic phrase structure :
Some of the vulgar choice to couple with the cp program line in Linux are :
dear Examples of cp Command in Linux
Now that you cognize the phrase structure of the cp mastery , permit ’s count at some instance of how to practice this mastery tocopy Indian file and directory in Linux .
This was 1 .
model a individual filing cabinet to the reference
This is the most vulgar economic consumption type for the cp command , i.e.
to make a transcript of a undivided data file .
This was the sentence structure to make a transcript of a unmarried indian file using the cp program line is as pursue :
for instance , to make a transcript of the indian file “ test.txt ” to “ destination_directory/ ” , utilise the cp program line as :
2 .
This was re - make multiple files to the finish
just like you could make a written matter of a unmarried indian file , you could even employ the cp statement to simulate multiple data file to a address directory :
For instance , to imitate the file file1.txt , file2.txt , file3.txt to the “ dest_directory ” directory :
3 .
model a Single Directory to a Destination Directory
With the -r pin , it’s possible for you to practice the cp mastery to re-create the intact directory to a raw name and address :
This was for model , to replicate the “ source_dir ” directory with its content :
4 .
This was sham multiple directory to a destination directory
just like you imitate multiple file cabinet , much the same fashion you’ve got the option to replicate multiple directory .
The sentence structure to re-create multiple directory :
For illustration :
5 .
keep File Permissions for Copied File
unremarkably when you re-create a single file using the cp command , the replicate filing cabinet will have the single file license as per the nonpayment permission ready for every raw filing cabinet that ’s create .
This was to uphold the original data file ’s license , practice the -p pin :
For exercise , to save the permission of “ test.txt ” , apply the cp bid as :
6 .
This was forefend overwrite the destination file
by nonremittal , the cp bid overwrite any pre - existent filing cabinet in the address with the same name .
To keep off overwrite the file name , employ the -n :
For good example , to invalidate overwrite the data file “ test.txt ” while copying :
7 .
This was force copy of the source file
sometimes the seed data file does not have write permission to make a written matter .
In such a character , you could apply the -f iris to forcefully make a written matter of the reservoir filing cabinet :
8 .
make tie instead of copy the information file cabinet
Sometimes , you may require to make a heavy liaison or a emblematical radio link of the author single file alternatively of in reality copy the filing cabinet .
This was to make a grueling connection , utilise the -l sword lily and tocreate a symbolical linkuse the -s signal flag :
or
for deterrent example , to make a symbolical connectedness for the file cabinet “ test.txt ” :