7

I am trying to access calendar by "cal" command in terminal but there is error message.

hetz@hetz-Lappy:~$ cal
bash: cal: command not found
2
  • Are you using Ubuntu?
    – Pilot6
    Commented Jun 25, 2022 at 6:37
  • I have upgraded from 20.04 LTS to 22.04 LTS recently.
    – learner
    Commented Jun 29, 2022 at 18:01

3 Answers 3

13

I would recommend first installing command-not-found to help with errors like this:

sudo apt install command-not-found

Then open a new terminal to ensure its features will be available within it.

Now when you try to run cal, you will get an more useful error message which will tell you which package to install:

Command 'cal' not found, but can be installed with:
sudo apt install ncal
2
  • Running zsh, command-not-found does not appear to work -- still get the same command not found Commented Nov 30, 2022 at 4:01
  • 1
    @OskarAustegard For Zsh, you need to add the command_not_found_handle function to .zshrc (see my answer for an example). Commented Dec 8, 2022 at 13:31
2

Install the ncal package:

sudo apt install ncal

If you have command-not-found installed and enabled (which it is by default in Bash) you should get a suggestion to install the package. If you use Zsh, copy these lines from /etc/bash.bashrc to your .zshrc (or enable a relevant plugin for your Zsh framework):

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
    function command_not_found_handle {
        # check because c-n-f could've been removed in the meantime
        if [ -x /usr/lib/command-not-found ]; then
           /usr/lib/command-not-found -- "$1"
           return $?
        elif [ -x /usr/share/command-not-found/command-not-found ]; then
           /usr/share/command-not-found/command-not-found -- "$1"
           return $?
        else
           printf "%s: command not found\n" "$1" >&2
           return 127
        fi
    }
fi
0

I had the same problem, for some reason cal is no more present on the distribution installation, what I recommend is to install fcal as following:

snap install fcal - Must run it as a root user

After this you will have the command fcal avaible, it will act like cal (it's not but it's kind of work around).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .