Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Copying files and preserving ownership

If you're copying a file on a Unix / Linux / OS X operating system, use the cp command. Use cp -r to copy a directory and all its contents - the -r means "recursive". If you use the cp command to copy files that you have read access to, but do not own, then you'll be made the owner of the new copies; for the command to do otherwise would have security implications.

So what if you need to copy whole directory structure and retain the current user and group assignments? First, you'll need to log in as the system administrator (root). Use the su - command and be careful!

Once you're logged in as root, change to the directory that's above the one you wish to copy, and copy via the tar command. For example, to copy everything in /home to /second/home:

cd /
mkdir /second
tar cpf - home | (cd second; tar xpf -)


The tar utility is more often used to make an archive file containing all of the information in a directory or series of directorys.

• Specified with the c parameter, tar creates an archive and with the x parameter, it extracts from an archive

• With the f - option, tar is instructed to write to stdout or read from stdin.

• The p option preserves ownerships on extraction, to prevent all of the files being changed to the ownership of the person running the command ... and for reasons of inter-user security, this only works for root.
(written 2006-04-28 08:53:01)

 
Associated topics are indexed under
A162 - Web Application Deployment - Backups and File System Management
A101 - Web Application Deployment - Linux -An Introduction For Users

Back to
Iterators - expressions tha change each time you call them
Previous and next
or
Horse's mouth home
Forward to
Erin Brent - rest in peace
Some other Articles
A story of goldfish
May day away
Disc Partitioning
Erin Brent - rest in peace
Copying files and preserving ownership
Iterators - expressions tha change each time you call them
Minature Cyclists only - limited headroom
As I walked in to Oxford
Extremes costs of getting on line
Catch up weekend
1892 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho