Announcement

Collapse
No announcement yet.

Question about the cp (copy) command

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question about the cp (copy) command

    If I have two files on my desktop, named "test" and "SaveFile" and I type:

    mv test SaveFile in Konsole, it works fine. But when I type:

    cp test SaveFile, I just get "cp: omitting directory `test'", and it doesn't copy. What am I doing wrong here?

    Also, what would I type if I wanted to mv/copy my "test" file to the /etc or /usr/ directory?

    #2
    Re: Question about the cp (copy) command

    In a console, type:
    Code:
    man cp
    man mv
    For help on using either command.
    Windows no longer obstructs my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      Re: Question about the cp (copy) command

      Tried man. An example would be more helpful.

      Comment


        #4
        Re: Question about the cp (copy) command

        cp - Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY

        cp file1 filenew (create a copy of file1 and call it filenew)
        cp file1 file2 file3 myfiles (create a copy of file1 file2 and file3 in the directory called myfiles)

        mv - Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY
        Windows no longer obstructs my view.
        Using Kubuntu Linux since March 23, 2007.
        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

        Comment


          #5
          Re: Question about the cp (copy) command

          When you ran
          mv test TestFile
          you renamed test, so it is not available for the command
          cp test TestFile

          Also, make sure you are in the correct directory when you issue the commands.
          If the files are on the Desktop, you need to change into the Desktop:
          cd Desktop
          (this assumes you are already in your /home/your_name when you issue the cd command).



          EDIT
          Go here:
          Tuxfiles: http://www.tuxfiles.org/
          She covers every possible combination for cp (files, directories).
          An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

          Comment


            #6
            Re: Question about the cp (copy) command

            Originally posted by jacatone
            cp test SaveFile, I just get "cp: omitting directory `test'", and it doesn't copy. What am I doing wrong here?
            Is test a directory or a file? From the message it looks like a directory. If you want to copy directories over, a cp -r will help. It will copy files along with their directories.
            Originally posted by jacatone
            Also, what would I type if I wanted to mv/copy my "test" file to the /etc or /usr/ directory?
            If you do an ls -l /, you will see something like:
            Code:
            drwxr-xr-x 121 root root 12288 2008-04-22 21:49 etc
            The first character 'd' tells you that it is a directory. The next three characters tell you whether the owner has read (r), write (w), execute (x) privileges. The next three are for the group and the three after that are for other. The root root portion tells you that root is the owner of the directory (the first root) and that the directory is also part of the root group (the second root).

            So in this example, the owner root is able to read, write, or execute things in the directory. The root group can only read or execute things in this directory. For the sake of the example, let's say that your username is jacatone and your group is jacatone. Since you are not the owner of the group and your group is not a part of the directory, you fall in the other category. The other category says that you can only read or execute things in this directory (provided that the file/directory in the directory allows you). What this means that you will not be able to copy/move files into the directory. You however can copy things out of the directory (since you can read), but cannot move them out (you cannot delete a file since that requires write privileges). If you want to copy/move something into the directory, you will need to ask root to do it or if you have sudo privileges, you can use sudo to copy/move the files over.

            Sorry for the long reply. The man pages are a great source of information, but I was not able to find this tidbit there so I figured that I could try to explain it a little to help you and possibly others that might have the same question.

            Comment


              #7
              Re: Question about the cp (copy) command

              jacatone--btw, Tuxfiles will go into permissions as jayhawk has done as excellent job of here, also.
              An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

              Comment


                #8
                Re: Question about the cp (copy) command

                Actually, I figured it out. the cp command must be "cp -r 'file1' 'file2'" whereas the mv command doesn't require the -r. At least that's the way it works on my machine. Thanks for the responses.

                Comment


                  #9
                  Re: Question about the cp (copy) command

                  Makes no sense, unless file1 and file2 are directories.
                  I thought we were dealing with files, as you said.
                  An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                  Comment

                  Working...
                  X