SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
Prepared by
Engr. Md. Jamal Uddin(Rayhan)
01814840483
cp command in Linux
cp stands for copy. This command is used to copy files or group of files or directory.
It creates an exact image of a file on a disk with different file name. cp command
requires at least two filenames in its arguments.
Syntax:
cp [OPTION] Source Destination
cp [OPTION] Source Directory
cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory
First and second syntax is used to copy Source file to Destination
file or Directory.
Third syntax is used to copy multiple Sources(files) to Directory.
cp command works on three principal modes of operation and these
operations depend upon number and type of arguments passed in cp
command :
1. Two file names : If the command contains two file names, then it copy the
contents of 1st file to the 2nd file. If the 2nd file doesn’t exist, then first it
creates one and content is copied to it. But if it existed then it is simply
overwritten without any warning. So be careful when you choose
destination file name.
2. cp Src_file Dest_file
Suppose there is a directory named jamal having a text file a.txt.
Example:
$ ls
a.txt
$ cp a.txt b.txt
$ ls
a.txt b.txt
3. One or more arguments : If the command has one or more arguments,
specifying file names and following those arguments, an argument
specifying directory name then this command copies each source file to
the destination directory with the same name, created if not existed but if
already existed then it will be overwritten, so be careful !!.
4. cp Src_file1 Src_file2 Src_file3 Dest_directory
Suppose there is a directory named engrjamal having a text file a.txt,
b.txt and a directory name new in which we are going to copy all files.
Example:
Prepared by
Engr. Md. Jamal Uddin(Rayhan)
01814840483
$ ls
a.txt b.txt new
Initially new is empty
$ ls new
$ cp a.txt b.txt new
$ ls new
a.txt b.txt
Note: For this case last argument must be a directory name. For the above
command to work, Dest_directory must exist because cp command won’t
create it.
5. Two directory names : If the command contains two directory
names, cp copies all files of the source directory to the destination
directory, creating any files or directories needed. This mode of operation
requires an additional option, typically R, to indicate the recursive copying
of directories.
6. cp -R Src_directory Dest_directory
In the above command, cp behavior depend upon
whether Dest_directory is exist or not. If the Dest_directory doesn’t exist, cp
creates it and copies content of Src_directory recursively as it is. But if
Dest_directory exists then copy of Src_directory becomes sub-directory
under Dest_directory.
Options:
There are many options of cp command, here we will discuss some of the useful
options:
Suppose a directory named engrjamal contains two files having some content
named as a.txt and b.txt. This scenario is useful in understanding the following
options.
$ ls engrjamal
a.txt b.txt
$ cat a.txt
GFG
$ cat b.txt
EngrJamal
1. -i(interactive): i stands for Interactive copying. With this option system first
warns the user before overwriting the destination file. cp prompts for a response, if
you press y then it overwrites the file and with any other option leave it uncopied.
Prepared by
Engr. Md. Jamal Uddin(Rayhan)
01814840483
$ cp -i a.txt b.txt
cp: overwrite 'b.txt'? y
$ cat b.txt
GFG
2. -b(backup): With this option cp command creates the backup of the destination
file in the same folder with the different name and in different format.
$ ls
a.txt b.txt
$ cp -b a.txt b.txt
$ ls
a.txt b.txt b.txt~
3. -f(force): If the system is unable to open destination file for writing operation
because the user doesn’t have writing permission for this file then by using -f option
with cp command, destination file is deleted first and then copying of content is
done from source to destination file.
$ ls -l b.txt
-r-xr-xr-x+ 1 User User 3 Nov 24 08:45 b.txt
User, group and others doesn't have writing permission.
Without -f option, command not executed
$ cp a.txt b.txt
cp: cannot create regular file 'b.txt': Permission denied
With -f option, command executed successfully
$ cp -f a.txt b.txt
4. -r or -R: Copying directory structure. With this option cp command shows its
recursive behavior by copying the entire directory structure recursively.
Suppose we want to copy engrjamal directory containing many files, directories
into gfg directory(not exist).
$ ls engrjamal/
a.txt b.txt b.txt~ Folder1 Folder2
Without -r option, error
$ cp engrjamal gfg
cp: -r not specified; omitting directory 'engrjamal'
With -r, execute successfully
$ cp -r engrjamal gfg
$ ls gfg/
a.txt b.txt b.txt~ Folder1 Folder2
Prepared by
Engr. Md. Jamal Uddin(Rayhan)
01814840483
5. -p(preserve): With -p option cp preserves the following characteristics of each
source file in the corresponding destination file: the time of the last data
modification and the time of the last access, the ownership (only if it has
permissions to do this), and the file permission-bits.
Note: For the preservation of characteristics you must be the root user of the
system, otherwise characteristics changes.
$ ls -l a.txt
-rwxr-xr-x+ 1 User User 3 Nov 24 08:13 a.txt
$ cp -p a.txt c.txt
$ ls -l c.txt
-rwxr-xr-x+ 1 User User 3 Nov 24 08:13 c.txt
As we can see above both a.txt and c.txt(created by copying) have same
characteristics.
Examples:
Copying using * wildcard: The star wildcard represents anything i.e. all files and
directories. Suppose we have many text document in a directory and wants to copy
it another directory, it takes lots of time if we copy files 1 by 1 or command becomes
too long if specify all these file names as the argument, but by using * wildcard it
becomes simple.
Initially Folder1 is empty
$ ls
a.txt b.txt c.txt d.txt e.txt Folder1
$ cp *.txt Folder1
$ ls Folder1
a.txt b.txt c.txt d.txt e.txt

Weitere Àhnliche Inhalte

Was ist angesagt?

Code obfuscation, php shells & more
Code obfuscation, php shells & moreCode obfuscation, php shells & more
Code obfuscation, php shells & moreMattias Geniar
 
DPDK KNI interface
DPDK KNI interfaceDPDK KNI interface
DPDK KNI interfaceDenys Haryachyy
 
499198466-LTE-Fundamentals-FinalMerged-PB5.pdf
499198466-LTE-Fundamentals-FinalMerged-PB5.pdf499198466-LTE-Fundamentals-FinalMerged-PB5.pdf
499198466-LTE-Fundamentals-FinalMerged-PB5.pdfMohamedShabana37
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocolManusha Dilan
 
How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.Naoto MATSUMOTO
 
IP-600 IP Network Audio System Design Templates
IP-600 IP Network Audio System Design TemplatesIP-600 IP Network Audio System Design Templates
IP-600 IP Network Audio System Design TemplatesEric Zhang-CMX Audio
 
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)k33a
 
Civil Engineering Degree
Civil Engineering DegreeCivil Engineering Degree
Civil Engineering DegreeMumtaz Hasan
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsHisaki Ohara
 
Quality of Service
Quality of ServiceQuality of Service
Quality of ServiceAbhishek Wadhwa
 
active-grammar-2
 active-grammar-2 active-grammar-2
active-grammar-2Anca Ionescu
 
Cisco Packet Tracer Overview 20 Jul09
Cisco Packet Tracer Overview 20 Jul09Cisco Packet Tracer Overview 20 Jul09
Cisco Packet Tracer Overview 20 Jul09Tumennast Erdenebold
 

Was ist angesagt? (20)

Code obfuscation, php shells & more
Code obfuscation, php shells & moreCode obfuscation, php shells & more
Code obfuscation, php shells & more
 
DPDK KNI interface
DPDK KNI interfaceDPDK KNI interface
DPDK KNI interface
 
499198466-LTE-Fundamentals-FinalMerged-PB5.pdf
499198466-LTE-Fundamentals-FinalMerged-PB5.pdf499198466-LTE-Fundamentals-FinalMerged-PB5.pdf
499198466-LTE-Fundamentals-FinalMerged-PB5.pdf
 
TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
 
Unit 4
Unit 4Unit 4
Unit 4
 
How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.
 
IP-600 IP Network Audio System Design Templates
IP-600 IP Network Audio System Design TemplatesIP-600 IP Network Audio System Design Templates
IP-600 IP Network Audio System Design Templates
 
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP)
 
Civil Engineering Degree
Civil Engineering DegreeCivil Engineering Degree
Civil Engineering Degree
 
Ch06
Ch06Ch06
Ch06
 
Tcp
TcpTcp
Tcp
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructions
 
Quality of Service
Quality of ServiceQuality of Service
Quality of Service
 
TWAMP NOKIA.pdf
TWAMP NOKIA.pdfTWAMP NOKIA.pdf
TWAMP NOKIA.pdf
 
Introduction to VoIP
Introduction to VoIPIntroduction to VoIP
Introduction to VoIP
 
active-grammar-2
 active-grammar-2 active-grammar-2
active-grammar-2
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
 
Cisco Packet Tracer Overview 20 Jul09
Cisco Packet Tracer Overview 20 Jul09Cisco Packet Tracer Overview 20 Jul09
Cisco Packet Tracer Overview 20 Jul09
 
Transportlayer tanenbaum
Transportlayer tanenbaumTransportlayer tanenbaum
Transportlayer tanenbaum
 

Ähnlich wie Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Preparation

Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsShankar Mahure
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdfMarsMox
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11duquoi
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualKuntal Bhowmick
 
Examples -partII
Examples -partIIExamples -partII
Examples -partIIKedar Bhandari
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examplesabclearnn
 
Linux commands part -2
Linux commands part -2Linux commands part -2
Linux commands part -2bhatvijetha
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3Gourav Varma
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptxSaileshB5
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variablesGautam Raja
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testersnitin lakhanpal
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands Raghav Arora
 

Ähnlich wie Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Preparation (20)

Cp command in Linux
Cp command in LinuxCp command in Linux
Cp command in Linux
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
 
intro unix/linux 11
intro unix/linux 11intro unix/linux 11
intro unix/linux 11
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
 
Linux commands part -2
Linux commands part -2Linux commands part -2
Linux commands part -2
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables5_File_Handling_Commands__vi_editor_and_environment_variables
5_File_Handling_Commands__vi_editor_and_environment_variables
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Lnx
LnxLnx
Lnx
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 

Mehr von Engr. Md. Jamal Uddin Rayhan

Bangladesh Bank Data entry control operator Question Solution.
Bangladesh Bank Data entry control operator Question Solution.Bangladesh Bank Data entry control operator Question Solution.
Bangladesh Bank Data entry control operator Question Solution.Engr. Md. Jamal Uddin Rayhan
 
Bangladesh Bank Assistant Maintenance Engineer Question Solution.
Bangladesh Bank Assistant Maintenance Engineer Question Solution.Bangladesh Bank Assistant Maintenance Engineer Question Solution.
Bangladesh Bank Assistant Maintenance Engineer Question Solution.Engr. Md. Jamal Uddin Rayhan
 
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021 Taker: AUST
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021  Taker: AUSTCombined 2 Bank Compiled Post: ADA Date: 25.09.2021  Taker: AUST
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021 Taker: AUSTEngr. Md. Jamal Uddin Rayhan
 
Combined 2 Bank Compiled Post: SO(IT) Date: 25.09.2021 Taker: AUST
Combined 2 Bank Compiled Post: SO(IT)  Date: 25.09.2021  Taker: AUSTCombined 2 Bank Compiled Post: SO(IT)  Date: 25.09.2021  Taker: AUST
Combined 2 Bank Compiled Post: SO(IT) Date: 25.09.2021 Taker: AUSTEngr. Md. Jamal Uddin Rayhan
 
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AE
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AEBank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AE
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AEEngr. Md. Jamal Uddin Rayhan
 
BPSC Previous Year Question for AP, ANE, AME, ADA, AE
BPSC Previous Year Question for AP, ANE, AME, ADA, AE BPSC Previous Year Question for AP, ANE, AME, ADA, AE
BPSC Previous Year Question for AP, ANE, AME, ADA, AE Engr. Md. Jamal Uddin Rayhan
 
Titas gas sub-assistant engineer question pattern
Titas gas sub-assistant engineer question patternTitas gas sub-assistant engineer question pattern
Titas gas sub-assistant engineer question patternEngr. Md. Jamal Uddin Rayhan
 

Mehr von Engr. Md. Jamal Uddin Rayhan (11)

DESCO AE CSE Question Solution
DESCO AE CSE Question SolutionDESCO AE CSE Question Solution
DESCO AE CSE Question Solution
 
OSI Model Cheat Sheet
OSI Model Cheat SheetOSI Model Cheat Sheet
OSI Model Cheat Sheet
 
Bangladesh Bank Data entry control operator Question Solution.
Bangladesh Bank Data entry control operator Question Solution.Bangladesh Bank Data entry control operator Question Solution.
Bangladesh Bank Data entry control operator Question Solution.
 
Assistant Programmer, Bangladesh Bank
Assistant Programmer, Bangladesh BankAssistant Programmer, Bangladesh Bank
Assistant Programmer, Bangladesh Bank
 
Bangladesh Bank Assistant Maintenance Engineer Question Solution.
Bangladesh Bank Assistant Maintenance Engineer Question Solution.Bangladesh Bank Assistant Maintenance Engineer Question Solution.
Bangladesh Bank Assistant Maintenance Engineer Question Solution.
 
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021 Taker: AUST
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021  Taker: AUSTCombined 2 Bank Compiled Post: ADA Date: 25.09.2021  Taker: AUST
Combined 2 Bank Compiled Post: ADA Date: 25.09.2021 Taker: AUST
 
Combined 2 Bank Compiled Post: SO(IT) Date: 25.09.2021 Taker: AUST
Combined 2 Bank Compiled Post: SO(IT)  Date: 25.09.2021  Taker: AUSTCombined 2 Bank Compiled Post: SO(IT)  Date: 25.09.2021  Taker: AUST
Combined 2 Bank Compiled Post: SO(IT) Date: 25.09.2021 Taker: AUST
 
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AE
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AEBank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AE
Bank Question Solution-ADBA Previous Year Question for AP, ANE, AME, ADA, AE
 
BPSC Previous Year Question for AP, ANE, AME, ADA, AE
BPSC Previous Year Question for AP, ANE, AME, ADA, AE BPSC Previous Year Question for AP, ANE, AME, ADA, AE
BPSC Previous Year Question for AP, ANE, AME, ADA, AE
 
Titas gas sub-assistant engineer question pattern
Titas gas sub-assistant engineer question patternTitas gas sub-assistant engineer question pattern
Titas gas sub-assistant engineer question pattern
 
information security and backup system
information security and backup systeminformation security and backup system
information security and backup system
 

KĂŒrzlich hochgeladen

Résumé (2 pager - 12 ft standard syntax)
Résumé (2 pager -  12 ft standard syntax)Résumé (2 pager -  12 ft standard syntax)
Résumé (2 pager - 12 ft standard syntax)Soham Mondal
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...amitlee9823
 
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men 🔝bhavnagar🔝 Esc...
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men  🔝bhavnagar🔝   Esc...âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men  🔝bhavnagar🔝   Esc...
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men 🔝bhavnagar🔝 Esc...amitlee9823
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfGabrielaMiletti
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...poojakaurpk09
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)amitlee9823
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.GabrielaMiletti
 
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)Delhi Call girls
 
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...amitlee9823
 
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...ssifa0344
 
Joshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxJoshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxsportsworldproductio
 
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...amitlee9823
 
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...Pooja Nehwal
 
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...amitlee9823
 
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...rightmanforbloodline
 
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...sonalitrivedi431
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jonesjonesyde302
 
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Standamitlee9823
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negronnegronf24
 

KĂŒrzlich hochgeladen (20)

Résumé (2 pager - 12 ft standard syntax)
Résumé (2 pager -  12 ft standard syntax)Résumé (2 pager -  12 ft standard syntax)
Résumé (2 pager - 12 ft standard syntax)
 
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
Nagavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore Es...
 
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men 🔝bhavnagar🔝 Esc...
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men  🔝bhavnagar🔝   Esc...âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men  🔝bhavnagar🔝   Esc...
âž„đŸ” 7737669865 đŸ”â–» bhavnagar Call-girls in Women Seeking Men 🔝bhavnagar🔝 Esc...
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
 
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
Virgin Call Girls Delhi Service-oriented sexy call girls ☞ 9899900591 ☜ Rita ...
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Call Girls Bidadi ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.
 
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
 
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
âž„đŸ” 7737669865 đŸ”â–» Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
 
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
 
Joshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxJoshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptx
 
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Chikkabanavara Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
 
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men  🔝Pallavaram🔝   E...
âž„đŸ” 7737669865 đŸ”â–» Pallavaram Call-girls in Women Seeking Men 🔝Pallavaram🔝 E...
 
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
 
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad đŸ’«âœ…đŸ’ƒ 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
 
Personal Brand Exploration ppt.- Ronnie Jones
Personal Brand  Exploration ppt.- Ronnie JonesPersonal Brand  Exploration ppt.- Ronnie Jones
Personal Brand Exploration ppt.- Ronnie Jones
 
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night StandCall Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Stand
Call Girls In Sarjapur Road ☎ 7737669865 đŸ„” Book Your One night Stand
 
Personal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando NegronPersonal Brand Exploration - Fernando Negron
Personal Brand Exploration - Fernando Negron
 

Linux Command For Beginners 6 - copy commands for linux | BUET Pattern Job Preparation

  • 1. Prepared by Engr. Md. Jamal Uddin(Rayhan) 01814840483 cp command in Linux cp stands for copy. This command is used to copy files or group of files or directory. It creates an exact image of a file on a disk with different file name. cp command requires at least two filenames in its arguments. Syntax: cp [OPTION] Source Destination cp [OPTION] Source Directory cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory First and second syntax is used to copy Source file to Destination file or Directory. Third syntax is used to copy multiple Sources(files) to Directory. cp command works on three principal modes of operation and these operations depend upon number and type of arguments passed in cp command : 1. Two file names : If the command contains two file names, then it copy the contents of 1st file to the 2nd file. If the 2nd file doesn’t exist, then first it creates one and content is copied to it. But if it existed then it is simply overwritten without any warning. So be careful when you choose destination file name. 2. cp Src_file Dest_file Suppose there is a directory named jamal having a text file a.txt. Example: $ ls a.txt $ cp a.txt b.txt $ ls a.txt b.txt 3. One or more arguments : If the command has one or more arguments, specifying file names and following those arguments, an argument specifying directory name then this command copies each source file to the destination directory with the same name, created if not existed but if already existed then it will be overwritten, so be careful !!. 4. cp Src_file1 Src_file2 Src_file3 Dest_directory Suppose there is a directory named engrjamal having a text file a.txt, b.txt and a directory name new in which we are going to copy all files. Example:
  • 2. Prepared by Engr. Md. Jamal Uddin(Rayhan) 01814840483 $ ls a.txt b.txt new Initially new is empty $ ls new $ cp a.txt b.txt new $ ls new a.txt b.txt Note: For this case last argument must be a directory name. For the above command to work, Dest_directory must exist because cp command won’t create it. 5. Two directory names : If the command contains two directory names, cp copies all files of the source directory to the destination directory, creating any files or directories needed. This mode of operation requires an additional option, typically R, to indicate the recursive copying of directories. 6. cp -R Src_directory Dest_directory In the above command, cp behavior depend upon whether Dest_directory is exist or not. If the Dest_directory doesn’t exist, cp creates it and copies content of Src_directory recursively as it is. But if Dest_directory exists then copy of Src_directory becomes sub-directory under Dest_directory. Options: There are many options of cp command, here we will discuss some of the useful options: Suppose a directory named engrjamal contains two files having some content named as a.txt and b.txt. This scenario is useful in understanding the following options. $ ls engrjamal a.txt b.txt $ cat a.txt GFG $ cat b.txt EngrJamal 1. -i(interactive): i stands for Interactive copying. With this option system first warns the user before overwriting the destination file. cp prompts for a response, if you press y then it overwrites the file and with any other option leave it uncopied.
  • 3. Prepared by Engr. Md. Jamal Uddin(Rayhan) 01814840483 $ cp -i a.txt b.txt cp: overwrite 'b.txt'? y $ cat b.txt GFG 2. -b(backup): With this option cp command creates the backup of the destination file in the same folder with the different name and in different format. $ ls a.txt b.txt $ cp -b a.txt b.txt $ ls a.txt b.txt b.txt~ 3. -f(force): If the system is unable to open destination file for writing operation because the user doesn’t have writing permission for this file then by using -f option with cp command, destination file is deleted first and then copying of content is done from source to destination file. $ ls -l b.txt -r-xr-xr-x+ 1 User User 3 Nov 24 08:45 b.txt User, group and others doesn't have writing permission. Without -f option, command not executed $ cp a.txt b.txt cp: cannot create regular file 'b.txt': Permission denied With -f option, command executed successfully $ cp -f a.txt b.txt 4. -r or -R: Copying directory structure. With this option cp command shows its recursive behavior by copying the entire directory structure recursively. Suppose we want to copy engrjamal directory containing many files, directories into gfg directory(not exist). $ ls engrjamal/ a.txt b.txt b.txt~ Folder1 Folder2 Without -r option, error $ cp engrjamal gfg cp: -r not specified; omitting directory 'engrjamal' With -r, execute successfully $ cp -r engrjamal gfg $ ls gfg/ a.txt b.txt b.txt~ Folder1 Folder2
  • 4. Prepared by Engr. Md. Jamal Uddin(Rayhan) 01814840483 5. -p(preserve): With -p option cp preserves the following characteristics of each source file in the corresponding destination file: the time of the last data modification and the time of the last access, the ownership (only if it has permissions to do this), and the file permission-bits. Note: For the preservation of characteristics you must be the root user of the system, otherwise characteristics changes. $ ls -l a.txt -rwxr-xr-x+ 1 User User 3 Nov 24 08:13 a.txt $ cp -p a.txt c.txt $ ls -l c.txt -rwxr-xr-x+ 1 User User 3 Nov 24 08:13 c.txt As we can see above both a.txt and c.txt(created by copying) have same characteristics. Examples: Copying using * wildcard: The star wildcard represents anything i.e. all files and directories. Suppose we have many text document in a directory and wants to copy it another directory, it takes lots of time if we copy files 1 by 1 or command becomes too long if specify all these file names as the argument, but by using * wildcard it becomes simple. Initially Folder1 is empty $ ls a.txt b.txt c.txt d.txt e.txt Folder1 $ cp *.txt Folder1 $ ls Folder1 a.txt b.txt c.txt d.txt e.txt