Ubuntu – The program ‘sed’ is currently not installed. You can install it by typing [sed: not found]

bashbashrccommand line

I was trying to create my own program in the /usr/local/bin.

During the process I messed something up and now anytime I press enter or type anything in the command line, I get this stupid message….!

The program 'sed' is currently not installed. You can install it by typing

How can I get rid of "sed" or whatever it is.

enter image description here

What I have discovered thus far about 'sed', it is SED Stream Editor which manipulates text. I used to use it within my .bashrc for git parsing and coloring of text. I now disabled the git parsing function within my .bashrc.

How can I get 'sed' installed again?

I ran apt-get install sed … It tells me sed is already the newest version. SED is now causing me more issues. My git commands are breaking and even my apt-get remove and updates sometimes breaks as well.

This is another example of what SED is causing me since SED is not found

/etc/grub.d/00_header: 1: /etc/grub.d/00_header: sed: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-ex....

Which sed

When I run which sed … It comes out completely blank, it doesn't output something like this /usr/bin/sed.

Here is my current PATH=.., which I pulled from /ect/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Best Answer

Besides copying the binary from another machine and hoping it is the correct version, this can also be solved by using apt or apt-get to install the sed package and passing the --reinstall option so that the .deb file will be downloaded and installed even though Ubuntu's package manager thinks it is already present.

sudo apt install --reinstall sed

This works with apt-get instead of apt, too. It uninstalls and reinstalls the package in a single step. The situation in this problem is that the se package is already installed but the executable has been deleted, so reinstalling solves that. Without the --reinstall flag, the package manager assumes nothing has to be done, because the package is installed already.

You can run sudo apt update first if you want, though it will not typically be necessary in this case, unless you've modified your software sources without doing so. You can pass the --purge flag too if you want but it's unnecessary here, since that just causes conffiles for the package to be removed when it is uninstalled.

sed is a utility that programs are generally allowed to assume exists and to rely on themselves. As you noticed, the scripts that run when installing, removing, or upgrading software can use sed. That's the source of your specific error messages. In theory APT or dpkg could rely on it directly and be unable to reinstall it. In practice, this does not appear to happen, and I don't expect it to. I've tested this on Ubuntu 16.04 LTS.

I cannot think of any situation where replacing the binary fixes the problem but reinstalling neither works nor shows an error immediately (see comments on the post). Although I cannot be 100% sure that these instructions would work for you--because perhaps more was broken than documented in the question--they should generally work at least as reliably as manually replacing /bin/sed for others who experience this problem.

Related Question