Here I go again...

Baddc053

Active Member
Joined
Nov 11, 2022
Messages
167
Reaction score
82
Credits
1,403
I'm about to show my ability for complete lack of understanding/comprehension on how to do something.
I got my new external hard drive today, and wanting to copy a directory from the drive that is failing, to the new one, and it's turning into a king sized headache.
I'm missing the boat somewhere. I attempted using the cp command, it told me the place I chose to send it wasn't a directory. The command I used was:

cp media/lardeb/My Passport* //CLONED STOR/The Night Sky/

The drive is named: /media/lardeb (/dev/sgd1) And the directory I want to copy is named: The Night Sky

I want to move all files in that dirctory to:

The drive is named: /media/lardeb/CLONED STOR (/dev/sgh1) And the directory I want to send it to would be: The Night Sky

I obviously messed up on the command string somewhere, But I've got no clue as to where. So...HELP PLEASE, what should the command string be?

I'd do it manually, but there are almost 4,000 files in the directory.

Thanks Again. And Happy Thanksgiving to all who observe it.
 


I can't brain right now, but you can try quotes or asterisks.

file name becomes "file name" or becomes "file*name".
 
I can't brain right now, but you can try quotes or asterisks.

file name becomes "file name" or becomes "file*name".
That's where I'm having a brain fart/senior moment, it just ain't clicking in my noggin.
Thanks though.
 
First you cannot have any spaces in your cp or mv commands you have "The Night Sky" it should be TheNightSky - one word or use underscores in between
And the directory I want to send it to would be: The Night Sky
The drive is named: /media/lardeb (/dev/sgd1) And the directory I want to copy is named: The Night Sky
You cannot sent it The Night Sky and copy the same drive and besides it has to be one word like: TheNightSky you cannot have any spaces in the directory name
Code:
cp -a /path/from /path/to
The -a flag turns on recursive behavior (which can also be done with the -R flag), and will also attempt to preserve metadata such as file ownership, permissions, timestamps, links, etc.
cp -a /media/lardeb/CLONED-STOR /media/TheNightSky

also notice the "-" in CLONED-STOR again no spaces yours is /media/lardeb/CLONED STOR

Another Option is
Code:
cp -ax / /new-disk
This is the simplest method, but will only work if your original Linux system is on a single disk partition.
 
Last edited by a moderator:
cd to the drive and the directory.

Code:
:cd /media/lardeb/dev/sgd1/ /The Night Sky/

Once your in The Night Sky directory type at the prompt:

CSS:
cp /The Night Sky/
When it's done copying that directory move it to the desired location.

Code:
mv /The Night Sky/ /media/lardeb/CLONED STOR /dev/sgh1/

The secret is to type out the full Path to the drive and the directory that you are starting from. Once the cmd-line interpreter see's the path and what's in the directory it can see/locate what you want to cp and move.
 
Last edited:
Thanks Lord Boltar:
I didn't know directory names couldn't have spaces.

So if OP changes the name of the directory from /The Night Sky/ to /TheNightSky/ Bash should mv it?
 
So if OP changes the name of the directory from /The Night Sky/ to /TheNightSky/ Bash should mv it?
and he has to change /media/lardeb/CLONED STOR to /media lardeb/CLONEDSTOR or CLONED-STOR
 
Thank, And Sorry but I'm still missing or doing something really wrong on this one.

Here's what I entered in terminal:

lardeb@lardeb-Latitude-E6420:~$ sudo cp///media lardeb/CLONED-STOR/TheNightSky/
[sudo] password for lardeb:
sudo: cp///media: command not found

I want to copy the directory named The Night Sky from the drive named /media/lardeb (/dev/sgd1)

To the brand new freshly formatted drive (Has nothing on it right now.. no folders or directories or partitions, this drive will only be for .html files, but is mounted) to :

/media/lardeb/CLONED STOR (/dev/sgh1)

I hope I'm presenting this correctly, if not...I'll try describing better.

Thank You everyone.

Problem is, I'm just to used to how Windows worked, once I pass that hurdle I'll be good.
 
You can also simply right click that directory and select copy and then right click and paste it where you want it to go on the other drive as long as both are mounted or you can also use cut to move it permanently - it may take some time depending on how big it is
 
Did you rename the directory The Night Sky to TheNightSky?

And did you rename /media/lardeb/CLONED STOR (/dev/sgh1) to CLONEDSTOR?

Before you can cp or move you'll need to do that.

Code:
lardeb@lardeb-Latitude-E6420:~$ sudo cp///media lardeb/CLONED-STOR/TheNightSky/
[sudo] password for lardeb:
sudo: cp///media: command not found
You need a space after cp and only one forward slash-
And the destination you wish to cp it to.
 
Did you rename the directory The Night Sky to TheNightSky?

And did you rename /media/lardeb/CLONED STOR (/dev/sgh1) to CLONEDSTOR?

Before you can cp or move you'll need to do that.

Code:
lardeb@lardeb-Latitude-E6420:~$ sudo cp///media lardeb/CLONED-STOR/TheNightSky/
[sudo] password for lardeb:
sudo: cp///media: command not found
You need a space after cp and only one forward slash-
And the destination you wish to cp it to.
Yep that syntax is way off - be easier just to use the right click copy and right click paste that way he won't have to change things to get the cp or mv commands to work
 
For example I have a file in my Downloads directory named Commands.odt.
Let's say I want to move Commands.odt to my Documents directory.
This is what I would run via the cmd-line:
Code:
cp /home/Alex/Downloads/Commands.odt /home/Alex/Documents/
 
Yep that syntax is way off - be easier just to use the right click copy and right click paste that way he won't have to change things to get the cp or mv commands to work
Agreed-

I'm just wondering if (/dev/sgd1) or if (/dev/sgh1) (the new formatted HDD) is/are mounted?

I'm assuming that /dev/sgd1 is OP's os that's up and running on an external drive-
 
Last edited:
I'm about to show my ability for complete lack of understanding/comprehension on how to do something.
I got my new external hard drive today, and wanting to copy a directory from the drive that is failing, to the new one, and it's turning into a king sized headache.
I'm missing the boat somewhere. I attempted using the cp command, it told me the place I chose to send it wasn't a directory. The command I used was:

cp media/lardeb/My Passport* //CLONED STOR/The Night Sky/

The drive is named: /media/lardeb (/dev/sgd1) And the directory I want to copy is named: The Night Sky

I want to move all files in that dirctory to:

The drive is named: /media/lardeb/CLONED STOR (/dev/sgh1) And the directory I want to send it to would be: The Night Sky

I obviously messed up on the command string somewhere, But I've got no clue as to where. So...HELP PLEASE, what should the command string be?

I'd do it manually, but there are almost 4,000 files in the directory.

Thanks Again. And Happy Thanksgiving to all who observe it.
I think i know the solution to your problem, because i fumbled with this a little bit after a fresh format on my desktop...

in order to see all your drives, use this command:

Code:
df -h

once you do this, you will get a list of file systems, figure out which will look like this...i'm posting part of what it looks like when i use the command on my computer:

Code:
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.5G  3.3M  1.5G   1% /run
/dev/nvme0n1p2  769G  413G  317G  57% /
/dev/sda1       239G  131G  109G  55% /media/xarathustra/MusicAndBac

there are several more file systems than that, but this is enough for your purposes. Look at the categories at the top: filesystem, size, used, avail, use%, and mounted on. You want to copy/paste the path under "mounted on" when you have a identified which drive is what with your cp command. If you copy the device path under "Filesystem", you will get the "not a directory" error because it's a device and not a directory (confusing i know...). The last item on my list is an external flashdrive that i use to back things up, so if i wanted to copy the contents from that to either another external device, i would copy/paste /media/xarathustra/MusicAndBac with my mouse, and ad it to the cp command before pressing enter...you can type it if you want, but no need to with today's linux distros:

Code:
cp /media/xarathustra/MusicAndBac <destination-path>

that is fast, but you can also just use select and right click like you do with windows in the graphical file manager...if you are going for specific folders within the drive instead of copying the whole thing, then learn to navigate with the "ls" and "cd" commands.
 
Last edited by a moderator:
See also:


You can deal with spaces in the terminal. There's a few ways, from quotes to slashes to asterisks.
 
I know it seems a bit silly for me to mention it at this point, but if the terminal is causing issues due to your lack of knowledge, then why not use a visual interface instead?
Maybe even boot a live distro of something simple... like Lubuntu?

I know you want to learn, but if your drive is failing, you have to act fast before it conks completely!
 

Staff online


Top