"/dev/fd/63 No such file or directory"

24,869

Solution 1

TL;DR: copy the /root folder outside chroot into the chroot directory

The <(...) operator is known as process substitution and is a way to run command, output of which goes into anonymous pipe. That's what /dev/fd/63 is. The idea is to allow external command ( here it's bash ) to treat another commands output as if it was a file. Generally the form would be to use < to redirect that pseudo-file object into bash's input stream.

bash < <(wget -q0 https://raw.githubusercontent.com/ubports/unity8-desktop-install-tools/master/install.sh)

This is generally no different from wget https://stuff.com/blah | bash. In both cases, it's generally not recommended to use such commands unless you're hundred percent sure the script you're downloading isn't from sketchy source and isn't malware.

However, since you've mentioned running command in chroot and the script outputs No such file or directory root, and because bash allows running scripts as bash script.sh here your script is being executed, but there's no directory named root in your chroot. You could just fix it via sudo cp -R /root chrootdir. For better results I'd suggest just reading the script first, see what it needs, and copy that to the chroot folder, and only then run the script locally within the folder. No need to run wget multiple times

So the script works. Errors in shell scripting generally in form <shell>: <command user typed>: error message so the script being temporarily stored as /dev/fd/63 and runs, it just doesn't find what it needs.

See also,

Solution 2

Error message

/dev/fd/63 No such file or directory

Problem source

Indeed the directory /dev/fd/ did not exist on that machine.

Solution

The solution was to create a symbolic link from /proc/self/fd to /dev/fd like so:

ln -s /proc/self/fd /dev/fd

Process substitution <(..) wouldn't work on QNAP without this.

Share:
24,869
Radu
Author by

Radu

Updated on September 18, 2022

Comments

  • Radu
    Radu over 1 year

    I've been trying to run a command in chroot (pretty new to this), and I get the following output.

    root@hostname:~ # bash <(wget -q0 https://raw.githubusercontent.com/ubports/unity8-desktop-install-tools/master/install.sh) 
    bash: /dev/fd/63: No such file or directory root
    
  • Radu
    Radu over 5 years
    Seems to have worked. Thanks. Also, the script is legitimate, and is just to try some stuff in a VM, anyhow, so no security risk.
  • jmary
    jmary almost 4 years
    Please provide answers in the context ... Why do you mention "if you are coming from search engine" ?
  • fredericrous
    fredericrous almost 4 years
    I updated my answer. why did you minus 1 my answer? I think this addition will help people in the future
  • jmary
    jmary almost 4 years
    Because "the mention if you are coming from search engine" doesn't make sense in context. Also you provide a "magic" command which is writting into a system directory without explaining why it is safe to do this. Sorry I don't mean to be rude. Please edit your reply so that newbies can use what you explain with confidence.
  • fredericrous
    fredericrous almost 4 years
    You are being rude but at least your second message was constructive. Is my answer better now? I believe a newbie doesn't mess with process substitution.
  • fredericrous
    fredericrous almost 4 years
    to add more on my previous comment, I believe the mention "if you are coming from a search engine" does put things in context. My message applies in a different context than the original question. no chroot here