0

I am having problem to find a file has basic commands like rm, ls, cd, etc. I need the file path in Ubuntu to edit them. I checked on web but just found UNIX file locations (/usr/bin).

So, here it is what I mean,

# cd /usr/bin
# ls -lh rm
-r-xr-xr-x   1 root   bin   14K May  1  2007 rm
# chmod 4555 rm
# ls -lh rm
-r-sr-xr-x   1 root   bin   14K May  1  2007 rm
# chmod 2555 rm
-r-xr-sr-x   1 root   bin   14K May  1  2007 rm

I want to change the privileges of rm. Inclusion of any suggestions or documentations are welcomed.

Kulfy
  • 18,154
Hexcake
  • 3
  • 2

2 Answers2

2

whereis command tells you where the binary and all documentations are located of a command. But not all commands have some binary that is invoked whenever they are executed. Some commands are shell built-in. Since Ubuntu uses bash as its default shell, these Bash Builtins are present.

The easiest way to determine whether a command is an alias or invokes some binary or is a command provided by the shell, is using type (which itself is also a shell built-in command) with -a option.

For example, if you use

whereis cd

You'll observe that there is no output which may convince you that cd is some magical thing which isn't present in /usr/bin. But cd is a shell built-in command. And if you run

type -a cd

You'll get

cd is a shell builtin

If you try it yourself, you'll find that rm does have a binary in /bin.

But there are some exceptions. echo is the example.

If you run

type -a echo

You'll get

echo is a shell builtin
echo is /bin/echo

That means there is both an echo shell built-in command and an external command in /bin/echo. The reason is described in Eliah Kagan's answer and muru's answer.

ls is another exception. By default ls is an alias to ls --color=auto as well. The output of type -a ls will look like:

ls is aliased to `ls --color=auto'
ls is /bin/ls

This alias is defined in ~/.bashrc. If this alias is "unaliased", ls would invoke the binary located in /bin.

terdon
  • 104,119
Kulfy
  • 18,154
0

If I wanted to know where the command ls is, I'd ask the system using

whereis ls

guiverc@d960-ubu2:/de2900/buster$   whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz

and it tells be where the binary is located (/bin/ls), plus manual (reference) too (/usr/share/man/man1/ls.1.gz)

fyi: use man ls to view the manual page, the .1.gz at the end of the man (manual) page just tells you it's a page 1 type (ie. an executable program or shell command).

guiverc
  • 33,561