0

I want to copy the contents of a folder colors from ~/Downloads/vim-colorschemes-master to /etc/vim/colors. I tried this as instructed:

cp colors/* ~/etc/.vim/colors

But I am getting the error:

cp: target ‘/home/advenio/etc/.vim/colors’ is not a directory

How do I do this correctly?

7
  • First, are you sure you have an etc folder in your Home (/home/advenio)? Normally there isn't one there. Second, if your destination is /etc, then are you sure the vim folder has a dot in front of it? – user68186 Mar 12 '14 at 15:45
  • Post the output of [-d /home/advenio/etc/.vim/colors ] && echo "dir" || echo "not dir" – Avinash Raj Mar 12 '14 at 15:46
  • You said, i want to copy from ~/Downloads/vim-colorschemes-master then why do you try cp colors/* ~/etc/.vim/colors? – Avinash Raj Mar 12 '14 at 15:49
  • @user68186 Ok you were correct abut it. – Robin Mar 12 '14 at 16:13
  • @AvinashRaj actually I wan to copy the contents of colors in the vim/color dir – Robin Mar 12 '14 at 16:13
6

~ refers to the home directory (in your case /home/advenio/). The place you want to copy it to is /etc/vim/colors

Try the command sudo cp ~/Downloads/path_to_colors/colors/* /etc/vim/colors

4
  • he will need sudo for copying into /etc ;) – Rinzwind Mar 12 '14 at 15:53
  • I tried so, but still getting this error: cp: target ‘/etc/.vim/colors’ is not a directory . – Robin Mar 12 '14 at 15:53
  • Ok I had to remove . from .vim but now getting this error: cp: cannot stat ‘colors/*’: No such file or directory . – Robin Mar 12 '14 at 15:55
  • colors needs to be in your working directory. I don't know the full path, but if you do something along the lines of cp ~/Downloads/vim-colorschemes-master/colors/* /etc/vim/colors it should work fine. Bear in mind that that's a guess since I don't know your file structure. – Hugo Buff Mar 12 '14 at 16:18
1

Try the following command:

sudo mkdir -p /etc/vim/colors && sudo cp ~/Downloads/vim-colorschemes*/colors/* /etc/vim/colors
2
  • I am getting an error: cp: cannot stat ‘colors/*’: No such file or directory – Robin Mar 12 '14 at 15:55
  • I fixed the command but make sure that you downloaded/cloned vim-colorschemes in ~/Download – Sylvain Pineau Mar 12 '14 at 16:27
0

First make sure the target directory (here ~/etc/.vim/colors) exists.

If it does not, create it with:

mkdir -p ~/etc/.vim/colors

To copy the contents of a source directory to some other location:

cp -rvt destination-directory source-directory/*

(this will copy all contents, both files and directories within source-directory to destination-directory.)

cp -vt destination-directory source-directory/*

(this will copy the files within source-directory to destination-directory.)

Example:

cp -rvt ~/etc/.vim/colors ~/Downloads/vim-colorschemes-master/colors/*

Here, the contents of ~/Downloads/vim-colorschemes-master/colors directory will be copied to ~/etc/.vim/colors.

If you want to copy the source-directory itself use:

cp -rvt destination-directory source-directory

(where v in -rvt is for verbose output, r for recursive used when copying directories, t to specify the destination.)

Example:

cp -rvt ~/etc/.vim/colors ~/Downloads/vim-colorschemes-master/colors

Here, the source ~/Downloads/vim-colorschemes-master/colors directory will be copied to ~/etc/.vim/colors.

1
  • it seems the correct location was /etc/vim/colors (the . was the whole problem I think) – Zanna Nov 8 '16 at 10:01
0

Here's how to copy a folder in Ubuntu terminal.

At the upper most part of your terminal window you will know what user or directory you are.

Note: you won't be able to run the cp command if you are in the wrong directory.

Terminal command:

cp -R /home/user/directory /destination

You'll get it to work soon, just continue thinking hard. Me, it took about 3 hours before I understand the command.

1
  • 1
    this isn't really what OP wanted, they actually wanted to copy the contents, not the directory, although it wasn't clear from the question – Zanna Nov 8 '16 at 10:00
0

When copying folders using the cp tool, use the recursive option. This copies the contents of the colors folder:

sudo cp  ~/Downloads/colors/* /etc/vim/

or copy the entire folder

sudo cp -r ~/Downloads/colors/ /etc/vim/

where the ~ sign represents the home directory.

By the way it's not .vim but vim.

0
0

The command for copying a directory including all of its contents is:

me@linuxbox:~$ cp -R location_of_source_directory location_of_destination_directory

This command will create the destination directory at the new location.

For example, here I copied a folder from one destination to another destination. I used cd and ls to make sure the files were copied and didn't exist before.

Copying a whole directory using terminal

By the way, as you are trying to copy the folder to /etc/... you need to use sudo like:

me@linuxbox:~$ sudo cp -R location_of_source_directory location_of_destination_directory

Because that location is owned by root and you don't have permission to add/remove files/folders in there.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.