Remove a terminal command [closed]
Is it possible to remove a terminal command? For example, if there was a command call lookup (not an alias), how would I go about removing it?
A better way would be to redirect the output of the command to /dev/null
. That way, the command will 'be there' but will show no results.
Example: the ls
command.
-
Make an alias
alias ls = "ls > /dev/null"
- Running
ls
now will not show any results.
EDIT: Thanks to @scai
In the answer above, the command will still show errors because we have redirected stdout
but not stderr
plus a more serious issue, it will still run the command.
Quoting @scai:
If the command in question does things you don't like, for example creating or deleting files, changing settings, painting your nose blue, then this alias won't stop it from doing these things.
For the workaround, we will just alias the command to an empty string, then just redirect the resulting error to /dev/null
.
alias ls = "" > /dev/null 2>&1
That's much better now.
EDIT 2: Thanks to @scai again :-)
This is a temporary solution.
To revert back to the original function of the command (in our case ls
), just run unalias ls
.
You can do that but you shouldn't.
Anyway there are four main places for commands.
/bin & /usr/bin & /sbin & /usr/sbin
To know the command you want where is
whereis COMMAND
Then as a root you can delete or just rename or move to other directory
sudo rm /path/command
Or
sudo mv /path/commad /newPath
Be sure that the newPath is not in your $PATH environment