Score:0

I want to copy my document directory, complete with sub-directories plus contents, from an old drive across to a new drive

gf flag

I tried creating symlinks to the source and target drives using:

sudo ln -s /media/phil/4A05-B4F6 /olddisc

sudo ln -s /media/phil/3117e488-bf89-426e-a606-55e8397cf1ee /pcdisc

I changed the directory to /olddisc This worked. However using an ls command it just said 'System Volume Information" which was not helpful.

I am new to UBUNTU.

I want to be able to use the cp command to copy the documents tree structure plus contents from olddisc to pcdisc.

ar flag
I don't understand the question What is stopping you from using the `cp` command? Please be precise and copy and paste any errors you get along with the exact command you tried. Edit your question.
PhilR avatar
gf flag
My system crashed but the disc still worked so I put it into a HDD USB docking Station on my PC. I loaded UBUNTU onto a spare HDD and put it into the PC. I now want to copy my documents across onto the new HDD in the PC.
PhilR avatar
gf flag
The old HDD has its Documents folder under /home/phil/Documents
PhilR avatar
gf flag
The Documents folder has many sub folders.
Score:1
cn flag

You are mixing up separate, rather independent aspects:

1. Symbolic links

Symbolic links (symlinks) in Linux allow to create access to a certain folder from within another folder. For example:

sudo ln -s /media/phil/4A05-B4F6 /olddisc

will make sure the contents of /media/phil/4A05-B4F6 can also be seen in /olddisc.

For practical purposes, a symbolic link feels and behaves just like a real directory. You can thus copy contents to and from it.

2. Copying an entire directory tree

There are a number of ways to do that. The standard cp (copy) command can do that when executed with the appropriate option, -R. rsync is a more specialized tool for that job, and has the powerfull feature where it can only copy new or updated files from a source directory to a target directory, making it rather perfect for synchronizing two directories or maintaining backups.

Thus, you could copy an entire directory tree with the command:

cp -R /media/phil/4A05-B4F6/* /media/phil/3117e488-bf89-426e-a606-55e8397cf1ee

Because you created symbolic links, the same effect can be achieved with

cp -R /olddisc /pcdisc

rsync can be used with the -a (archive) flag to "mirror" directories:

rsync -av /olddisc/ /pcdisc/

(pcdisk should already exist, and the trailing / are important: keeping them in or leaving them out has a different meaning and can have a different outcome depending on whether the target does exist or not).

Remark on using sudo

*Avoid the use of sudo as much as possible. Only use it for system tasks, and when you know what you are doing. *For copying user data, you should not have to use sudo.

On Linux, a user can copy/move/delete in directories where permission has been granted. You automatically have permissions for files in your home directory, and for files in removable hard drives that you connect while you are logged in.

In any other case, for example an internal partition, use sudo to grant yourself permissions. Then proceed manipulating your user data as a user. Only use sudo to copy, move or delete system files.

Score:0
cn flag

You can use the cp command to achieve what you want: cp -a source-dir/ dest-dir/

The -a option enables "archive mode", which will copy everything recursively while preserving permissions, timestamps and SELinux context if any.

Note that symbolic links does not copy anything from source to destination, it is similar to the idea of shortcuts on Windows.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.