20120131 the humble cp command - plembo/onemoretech GitHub Wiki

title: The humble cp command link: https://onemoretech.wordpress.com/2012/01/31/the-humble-cp-command/ author: lembobro description: post_id: 2033 created: 2012/01/31 11:26:18 created_gmt: 2012/01/31 15:26:18 comment_status: closed post_name: the-humble-cp-command status: publish post_type: post

The humble cp command

I am a great fan of the humble cp command in Unix. Some brief tips and tricks follow. On many (most? all?) Unix systems like Linux when you type 'cp' you are actually invoking the alias

alias cp='cp -i'

that means no matter what you do, the command always runs in interactive mode. This is usually a good thing, a desirable thing. Except when you're restoring your system from an old hard drive. In that case you'll be using this a lot

/bin/cp -r -f [source directory] [destination directory]

Like this:

/bin/cp -r -f /media/_home/myuser /home/myuser

Note that in order to capture hidden ("dot files") as well as non-hidden files you don't want to include a wildcard ("") character in your command string (you'd need to do a "/." for the visible, and then a "/.*", for the invisible ones). I used this in migrating to a new Scientific Linux 6.1 machine from an older CentOS 5.7 system. In the end I actually wound up having to be more surgical in what I copied, particularly when it came to dot (.) files. The main problem was with the Gnome desktop. Enough differences existed in its configuration on the source and target systems that it was easier to just rebuild the few customizations I really needed (like custom application launcher icons).

Copyright 2004-2019 Phil Lembo