LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-10-2021, 11:18 PM   #1
NightSky
Member
 
Registered: Sep 2001
Location: Texas :(
Distribution: Slackware64- 5.15.2
Posts: 909

Rep: Reputation: 55
Copy Directory to /mnt/backup missing operand


xxx@xxxxocuments$cp -r /mnt/backup/Documents/
I made a directory in /mnt/backup/ named Documents
but when I issue the above command I get: missing destination file operand after '/mnt/backup/Documents/'
What am I doing wrong?
FYI /mnt/backup is a seperate hdd. Thank you
 
Old 08-11-2021, 12:31 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
cp wants a source and a target.
You’ve not specified what you want to copy to /mnt/backup/Documents/ — and since you’ve not specified both, the error says you’re missing a destination. Pretty clear.
man cp is your friend.
 
1 members found this post helpful.
Old 09-07-2021, 05:57 PM   #3
NightSky
Member
 
Registered: Sep 2001
Location: Texas :(
Distribution: Slackware64- 5.15.2
Posts: 909

Original Poster
Rep: Reputation: 55
@scasey thank you. I thought because I opened xterm in the directory I wanted to copy, I didn't need its full origin path in the command. Anyway I got it. FYI while Linux in 10 Minutes warns: the copy to Target requires you $mkdir destination before cp -r <Target path> But because I didn't want to change the directory name I was copying, I wound up with /mnt/backup/Documents/Documents and just wanted
/mnt/backup/Documents
Have another questions since my /mnt/backup is the name of another HDD once I finish backing up wanted folders, can I just install the latest Slackware on sda without losing accesses to my /mnt/backup on /dev/sdc1
 
Old 09-07-2021, 06:58 PM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,342

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
As said you have to tell cp what to copy and where to put it.
cp -r is recursive so if you give it a directory as the source it copies that directory and all its content. if you give it a directory as the destination it puts what it is copying into that directory, thus your extra level of directories. You copied a directory into another directory of the same name.

You could have used 2 different ways to do that.
Code:
cd    # first to make certain where you are.
cp -ar Documents/* /mnt/backup/Documents/

or

cp -ar Documents /mnt/backup/
Either way would have done exactly what you expected.
Read the man page for cp to see what the -a option does. Probably what you want.


For your second question.
I would suggest you dismount that directory/drive before you start an install. It can always be mounted and accessed after the install is complete. Leaving it mounted will (usually) not be an issue since rebooting to start the install will dismount it, but better to do it manually than to rely on the system doing it for you.

Last edited by computersavvy; 09-07-2021 at 08:12 PM.
 
Old 09-07-2021, 07:28 PM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,780

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
You can use a . that refers to your current directory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MailScanner: chown: missing operand after `postfix' chengli Linux - Server 1 01-14-2012 11:04 AM
[SOLVED] acroread gives me dirname:missing operand slackingclement Slackware 2 07-03-2011 08:24 AM
"mkdir: missing operand" error when installing Linux gnuub Linux - Newbie 1 05-17-2011 02:28 PM
Error message "dirname: missing operand" when starting acroread thethinker Slackware 2 08-19-2010 09:49 AM
Error in building world: warning: operand 1 missing mode? henkelarsson12 *BSD 0 04-14-2006 02:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration