16

I had this script:

spd-say "Hello, don't forget the trash bin."

So it reminded me of what I supposed to do, and I moved it to /usr/local/bin/ and the command trash pronounced the argument,then I set a crontab job, to make it remind me everyday what I wanted to do. But the crontab didn't work and I couldn't understand why(It does other jobs flawlessly).

Once I saw this message in my terminal:

You have new mail in /var/mail/root

at the end of which this line made me do a bad mistake:

/bin/sh: 1: trash: not found

I know that it was a silly thing to do but I did:

mv /usr/local/bin/trash /bin/sh

thinking that sh is a directory and I should move the script there in order to be executed.

Now, when I want to see a man page the system says:

"Hello, don't forget the trash bin."

And the output of cat sh is:

#!/bin/bash
spd-say "Hello, don't forget the trash bin. "

Anyway, can I do anything or I have to reinstall my operating system?

  • 2
    I'm speculating, but cron jobs run with a very limited environment, including a $PATH with just a few directories. That might be why it works from the terminal, but not through cron. (In fact, when something works from a normal terminal but not through cron, that's the first thing I check.) – a CVn Jul 14 '19 at 10:43
  • 1
    @ a CVn; I don't know what the problem is but when I replace spd-say by echo and set the crontab job: trash > ~/Desktop/trash.txt**, it works & a file is created on my Desktop. I think I should ask about it in another question. – Codito ergo sum Jul 14 '19 at 18:17
  • Yes, if you want to ask about that, please do ask it as a separate question. – a CVn Jul 14 '19 at 18:19
  • 'Now, when I want to see a man page the system says: "Hello, don't forget the trash bin."' To be fair, most man docs are rubbish (or difficult to understand) – LogicalBranch Jul 14 '19 at 18:46
  • 8
    @LogicalBranch I disagree; I love them;they're powerful, off-line guides. – Codito ergo sum Jul 14 '19 at 18:47
30

In Ubuntu systems, /bin/sh is a symbolic link to the dash shell by default:

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Jul  7  2018 /bin/sh -> dash

So (assuming your terminal emulator uses the bash shell, and didn't get broken by your mistake) all you need to do is re-create the link:

sudo ln -sf dash /bin/sh
| improve this answer | |
  • 14
    OP: mv /usr/local/bin/trash /bin/sh, sh: You could not live with your own failure, where did that bring you? Back to me. – LogicalBranch Jul 14 '19 at 18:51
  • 2
    @LogicalBranch how do you only have 1 upvote for that masterpiece? – vikarjramun Jul 15 '19 at 2:36
  • 4
    @vikarjramun it sounds like a masterpiece but i just dont quite get it... – Nacht Jul 15 '19 at 6:23
  • @Nacht it's from Avengers: Endgame; a line from the villain, Thanos. – Cullub Jul 15 '19 at 14:57
  • @Cullub Oooooh..... thanks... I'm pretty sure I get it now... – Nacht Jul 16 '19 at 1:03
7

No, you don't have to reinstall your system. /bin/sh is only a softlink to your shell. readlink -f /bin/sh /bin/bash In my case bash. Move your script and make a softlink to your favorite shell.

| improve this answer | |
  • 10
    /bin/sh should actually point to /bin/dash. If you want to change the system shell, use sudo dpkg-reconfigure dash, per How Can I Make /bin/sh point to /bin/bash?. Also note the system shell is not the default interactive shell. – wjandrea Jul 14 '19 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.