Bash это каталог ошибка

This is really confusing…

I currently have a Debian 8 computer, and I connect to it using PuTTY (SSH).
The default console used is Bash.

When I try to pass a path to an alias, it gives the following error:

 -bash: /: Is a directory

Here is an example:

putty

Also, there’s a bizarre behaviour: running '/' or "/" cause the same error, as if Bash were ignoring quotes.


If it matters, the alias explorer was defined like this:

alias explorer='pcmanfm 1>/dev/null 2>&1 &'

Is this the expected behaviour?
If not, what am I doing wrong?

TLDR: Create ~/.bash_completion.d directory instead and reference it wherever it’s relevant.

Following up as I stumbled upon the exact same scenario and wanted to figure out how to process this properly.

For information, I’m running Linux Mint (Debian based).

In .bash_profile, there is this line:

[ -f /etc/bash_completion ] && source /etc/bash_completion

The sourced file contains:

. /usr/share/bash-completion/bash_completion

So far, we got pretty much the same behavior. It’s just not handled the same way.

Now, since this is default, it’s better not to touch anything to avoid extra issues. Most Linux distributions assume that ~/.bash_completion is a file with user-defined completions, not a directory.

And there is this (kind of?) convention for creating directory suffixed with .d in their name to make things explicit and prevent conflicts (such as our).

The solution would then to be:

mkdir -p ~/.bash_completion.d
mv ~/.bash_completion/* ~/.bash_completion.d
rm ~/.bash_completion
vim ~/.bashrc

Once the editor is open, update the path from:

source ~/.bash_completion/alacritty

to:

source ~/.bash_completion.d/alacritty

Reload and you should be good to go no matter the distribution you’re working on :)

Apparently one of your modifications to .bashrc introduced an error that treats /bin like something other than a directory (for example, by trying to run it as an executable file, read data from or write data to it as a file, etc.). Because .bashrc runs when your interactive shell starts, the error message always appears.

You may be able to identify the error yourself by looking through your modifications to .bashrc.

(Otherwise, to identify the specific problem it will be necessary to see the contents of your .bashrc file. You can copy its entire contents to the clipboard and paste it into your question, select it in your question, and format it as code with Ctrl+K. If you’ve made this file, much, much longer than it usually is, it might be too long to put into your question in its entirety. In that case, you can post it at http://paste.ubuntu.com and edit your question to include a link to the posting.)

One possibility is that you may have introduced a space in a path starting with /bin. For example, near the beginning of the default .bashrc file is the code:

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

If you accidentally put a space after /bin (in SHELL=/bin/sh), this might produce such an error.

That is just one example, and not necessarily the most likely one.

When i logging with «oracle» user (su — oracle), «-bash: /home/oracle: is a directory» warning appears.
Is an error? This warning was not happening on my other virtual machine.

asked Aug 20, 2020 at 11:58

zayit's user avatar

Looks like something is trying to execute the string «/home/oracle» as a bash command.

If this happens at each login, it’s possible such a command has been added to .bashrc or .bash_profile, e.g.

# mkdir /home/oracle

# echo '/home/oracle' >> /home/myuser/.bashrc

# su - myuser
Last login: Thu Aug 20 20:44:19 CEST 2020 on pts/0
-bash: /home/oracle: Is a directory

answered Aug 20, 2020 at 18:48

Marco Baldelli's user avatar

Marco BaldelliMarco Baldelli

3,6031 gold badge22 silver badges29 bronze badges

3

Этот вопрос уже имеет ответ здесь: что такое каталог с двойной косой чертой (//)? 1 ответ

Иногда, когда я делаю опечатку в терминале и случайно говорю Bash интерпретировать /, я получаю вывод bash: /: Is a directory. Теперь я считаю, что этот вывод должен иметь дело с корневым каталогом или чем-то подобным.

Но я не понимаю, что, когда я ввожу увеличивающиеся количества спреев, он продолжает выводить одно и то же …

Примеры

//// -> bash: ////: Is a directory

//////// -> bash: ////////: Is a directory

задан
6 January 2018 в 09:28

поделиться

3 ответа

/ является разделителем каталогов. Любая строка, которая заканчивается на нем, по определению является именем каталога:

example #This could be a file or directory
example/ #This is a directory in the current directory
/example/ #This is a directory in the root directory

Таким образом, серия из / s будет интерпретирована как серия {null} каталогов. [ ! d2]

ответ дан ravery
22 May 2018 в 15:43

поделиться

/ является разделителем каталогов. Любая строка, которая заканчивается на нем, по определению является именем каталога:

example #This could be a file or directory
example/ #This is a directory in the current directory
/example/ #This is a directory in the root directory

Таким образом, серия из / s будет интерпретирована как серия {null} каталогов. [ ! d2]

ответ дан ravery
17 July 2018 в 23:45

поделиться

/ является разделителем каталогов. Любая строка, которая заканчивается на нем, по определению является именем каталога:

example #This could be a file or directory
example/ #This is a directory in the current directory
/example/ #This is a directory in the root directory

Таким образом, серия из / s будет интерпретирована как серия {null} каталогов. [ ! d2]

ответ дан ravery
24 July 2018 в 17:06

поделиться

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Bash убрать вывод ошибок
  • Bash синтаксическая ошибка ожидается операнд неверный маркер
  • Bash подавление вывода ошибок
  • Bash подавить вывод ошибок

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии