8

I think there must be simple answer to this, but I can't figure out why this isn't working!

I have a folder in my home directory (well, a few levels down) called installed-plugins. I want to transfer all the contents of that folder (about 15 .jar files) to a different folders, also called installed-plugins.

This is what I am trying:

$ sudo mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/                                                                                                                             
mv: cannot stat `/home/jira-plugins/installed-plugins/*': No such file or directory

What is my error?

The folder is definitely not empty. Here is the ls output:

$ sudo ls /home/jira-plugins/installed-plugins
analytics-client-3.15.jar                                  plugin.2223138796603023855.jira-importers-plugin-6.0.30.jar
atlassian-chaperone-2.0.3.jar                              plugin.330169947367430109.jira-fisheye-plugin-6.2.8.jar
atlassian-client-resource-1.0.jar                          plugin.4363048306537053933.jeditor-2.1.7.2.jar
atlassian-pocketknife-api-commons-plugin-0.19.jar          plugin.4438307615842123002.jira-ical-feed-1.0.4.jar
atlassian-pretty-urls-plugin-1.8.jar                       plugin.461510159947098121.jira-issue-collector-plugin-1.2.5.jar
base-hipchat-integration-plugin-7.8.24.jar                 plugin.5630909028354276764.atlassian-universal-plugin-manager-plugin-2.7.8.jar
base-hipchat-integration-plugin-api-7.8.24.jar             plugin.6920509095052318016.atlassian-bonfire-plugin-2.9.13.jar
hipchat-core-plugin-0.8.3.jar                              plugin.6952408596192442765.atlassian-bonfire-plugin-2.8.2.jar
hipchat-for-jira-plugin-1.2.11.jar                         plugin.7079751365359230322.jira-importers-bitbucket-plugin-1.0.8.jar
jira-email-processor-plugin-1.0.29.jar                     plugin.7451827330686083284.atlassian-universal-plugin-manager-plugin-2.21.4.jar
jira-fisheye-plugin-7.1.1.jar                              plugin.7498175247667964103.jira-importers-redmine-plugin-2.0.7.jar
jira-ical-feed-1.1.jar                                     plugin.7803627457720701011.jira-importers-plugin-3.5.3.jar
jira-issue-nav-components-6.2.23.jar                       plugin.7977988994984147602.jira-bamboo-plugin-5.1.6.jar
jira-servicedesk-2.3.6.jar                                 plugin.8372419067824134899.jira-importers-plugin-5.0.2.jar
jira-workinghours-plugin-1.5.5.jar                         plugin.9081077311844509190.jira-fisheye-plugin-5.0.13.jar
plugin.1260160651631713368.stp-3.0.11.jar                  plugin.9128973321151732551.jira-fisheye-plugin-6.3.10.jar
plugin.2076016305412409108.jira-fisheye-plugin-3.4.10.jar  plugin-license-storage-plugin-2.8.jar
plugin.218965759549051904.jira-importers-plugin-6.1.5.jar  querydsl-4.0.7-provider-plugin-1.1.jar
plugin.2211202876682184330.jira-ical-feed-1.0.12.jar       stp-3.5.10.jar
  • 2
    Is the jira-plugins folder in /home/, or is it in: /home/USER/? – clk Sep 11 '16 at 19:38
  • Are there actually files there? Did you turn off globbing? – Jeff Schaller Sep 11 '16 at 19:48
  • the files are definitely there – esther h Sep 11 '16 at 20:11
  • 2
    Please edit your question and post the output of ls /home/jira-plugins/installed-plugins/. – terdon Sep 11 '16 at 20:25
  • 1
    You still haven't responded to terdon's request for information. Please do so. – Michael Hampton Sep 12 '16 at 1:51
16

It's almost certainly due to the fact that your ordinary user account cannot access the directory, so the shell cannot enumerate the files that would match the wildcard.

You can confirm this easily enough with a command like this

ls /home/jira-plugins/installed-plugins

If you get a permission denied then there is no way the shell is going to be able to expand a * wildcard in that directory.

Why? Consider your command

sudo mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/

The order of processing is (1) expand the wildcards, (2) execute the command, which in this case is sudo with some arguments that happen to correspond to a mv statement.

You can solve the problem in one of two ways

  1. Become root and then move the files

    sudo -s
    mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/                    
    
  2. Expand the wildcard after running sudo

    sudo bash -c "mv /home/jira-plugins/installed-plugins/* /var/atlassian/application-data/jira/plugins/installed-plugins/"
    
  • Perfect, +1 for explaining the order of processing for the command. – Theyna Mar 10 '17 at 3:09
10

As you do sudo ls to list the folder, I assume one or more directories in the path are unreadable by regular users. That would explain the behaviour. The key misunderstanding here is when glob expansion of the * is done. It is done by the shell, before invoking any command. If the shell does not have permissions enough, it can not expand it.

What happens in this case in more detail is:

  1. Your shell tries to expand the command line. Since you do not have the right to read /home/jira-plugins/installed-plugins as yourself, it will not be able to expand the glob pattern /home/jira-plugins/installed-plugins/*. It will leave it unmodified. After this stage, * is no longer special.
  2. Your shell invokes the command sudo with the arguments mv /home/jira-plugins/installed-plugins/*, and /var/atlassian/application-data/jira/plugins/installed-plugins/
  3. sudo invokes mv with the arguments /home/jira-plugins/installed-plugins/*, and /var/atlassian/application-data/jira/plugins/installed-plugins/
  4. mv tries to move a file actually named /home/jira-plugins/installed-plugins/*, but it doesn't exist and thus the error message.
  • thanks, makes perfect sense. I accepted the other answer because it came first, and also told me exactly what to do about it. – esther h Sep 12 '16 at 7:35

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.