CentOS ls uses dpkg

I am logged in as a user on an CentOS version 6.9 HPC. When I try the ls command, I get:

/usr/local/bin/ls: line 96: dpkg: command not found Abort, this script
is only intended for Ubuntu-like distros

When I open the corresponding ls file, line 96 has the line:

# (internal) The architecture of the local system
arch=$(dpkg --print-architecture)

I understand that dpkg is a Debian thing which is why it wouldn’t work on CentOS. But why is the dpkg there in the first place. And how do I run a simple ls?

Asked By: R Walser

||

From the question text, it is evident that the ls command is picked up from the /usr/local/bin directory, which means that this directory is found earlier in the PATH variable’s value than e.g. /usr/bin and /bin.

Changing the ordering of the variable’s value in your shell’s startup files, possibly by prepend /bin and /usr/bin to it, should stop your shell from using ls from /usr/local/bin, assuming that there is an ls command in /bin or /usr/bin.

PATH=/bin:/usr/bin:$PATH

The reason why /usr/local/bin/ls is a shell script (possibly a copy of the Ubuntu-specific script found here, which, although not malware, is not at all related to the ls command in any way) is still a mystery, as is whether this anomality is limited to the ls executable or whether it extends to other files and directories under /usr/local.

Answered By: Kusalananda
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.