CheeseAndBiscuits
Posts: 5
Joined: Sun Jan 16, 2022 1:29 pm

Cal command not found

Sun Jan 16, 2022 1:32 pm

Hi folks,

I've been following a guide as part of my uni course that tells me to use the cal command in the terminal, however whenever I try to use cal I get the error message: -bash: cal: command not found.

I imagine there's maybe something obvious i'm missing but i'm brand new to this and no amount of googling helps.

Thanks!

DirkS
Posts: 10867
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Cal command not found

Sun Jan 16, 2022 2:42 pm

What does that command / program do?
Pls also tell us which OS + version you're using.
If possible also a link to your guide.

User avatar
kerry_s
Posts: 5419
Joined: Thu Jan 30, 2020 7:14 pm

Re: Cal command not found

Sun Jan 16, 2022 2:47 pm

Code: Select all

sudo apt install x11-apps
What does that command / program do?
it displays a calendar in the terminal.

drgeoff
Posts: 13594
Joined: Wed Jan 25, 2012 6:39 pm

Re: Cal command not found

Sun Jan 16, 2022 3:05 pm

You need to install the calendar package.
Quis custodiet ipsos custodes?

CheeseAndBiscuits
Posts: 5
Joined: Sun Jan 16, 2022 1:29 pm

Re: Cal command not found

Sun Jan 16, 2022 3:24 pm

drgeoff wrote:
Sun Jan 16, 2022 3:05 pm
You need to install the calendar package.
Would you know the command for this or where I can find it ?
kerry_s wrote:

Code: Select all

sudo apt install x11-apps
What does that command / program do?
it displays a calendar in the terminal.


Thanks for the suggestion but that command didn't work. And yes it is a command to display a calendar - I'm using the latest release - cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian

trejan
Posts: 5624
Joined: Tue Jul 02, 2019 2:28 pm

Re: Cal command not found

Sun Jan 16, 2022 3:45 pm

cal is part of the ncal package.

CheeseAndBiscuits
Posts: 5
Joined: Sun Jan 16, 2022 1:29 pm

Re: Cal command not found

Sun Jan 16, 2022 4:00 pm

trejan wrote:
Sun Jan 16, 2022 3:45 pm
cal is part of the ncal package.
Thanks!! Got it working now

User avatar
scruss
Posts: 5382
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: Cal command not found

Sun Jan 16, 2022 4:56 pm

It came as a surprise to me that ncal wasn't shipped as default, as there's so much historical software that calculates dates by calling cal in the background. The ncal manpage notes that:
HISTORY
A cal command appeared in Version 1 AT&T UNIX. The ncal command appeared in FreeBSD 2.2.6. The output of the cal command is supposed to be bit for bit compatible to the original Unix cal command, because its output is processed by other programs like CGI scripts, that should not be broken. Therefore it will always output 8 lines, even if only 7 contain data. This extra blank line also appears with the original cal command, at least on Solaris 8
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

GlowInTheDark
Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: Cal command not found

Sun Jan 16, 2022 6:36 pm

It came as a surprise to me that [n]cal wasn't shipped as default...
Yeah, it is stone cold basic Unix. Impossible for it not to be there (and have whatever distro is running call itself Unix).

Be nice to know what's really going on here...
Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?

bls
Posts: 2969
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Cal command not found

Sun Jan 16, 2022 6:48 pm

scruss wrote:
Sun Jan 16, 2022 4:56 pm
It came as a surprise to me that ncal wasn't shipped as default, as there's so much historical software that calculates dates by calling cal in the background. The ncal manpage notes that:
HISTORY
A cal command appeared in Version 1 AT&T UNIX. The ncal command appeared in FreeBSD 2.2.6. The output of the cal command is supposed to be bit for bit compatible to the original Unix cal command, because its output is processed by other programs like CGI scripts, that should not be broken. Therefore it will always output 8 lines, even if only 7 contain data. This extra blank line also appears with the original cal command, at least on Solaris 8
I didn't do an exhaustive check through all the images (32/64, with desktop and Lite), but looks like it was installed by default on Buster, but not on Bullseye.

There doesn't appear to be a 'cal' package, just 'ncal', and cal is a link to ncal.

Amusingly, cal outputs the calendar in a reasonable format (for most people), while ncal rotates the whole calendar 90 degrees. What's with that? Oh, and 'ncal -C' outputs the calendar in 'cal format'.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

GlowInTheDark
Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: Cal command not found

Sun Jan 16, 2022 7:00 pm

it was installed by default on Buster, but not on Bullseye.
Then yet another reason to take a pass on "bullseye". Not having "cal" is just weird.

Incidentally, "cal" is just a symlink to "ncal", so it is probable that somehow, whoever put Bullseye together (either "upstream" or at RPF/RPT/whatever), just lost that symlink somewhere along the way.

So, all you need to do is:

Code: Select all

$ sudo bash
# cd /usr/bin
# ln -sv ncal cal
#
Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?

trejan
Posts: 5624
Joined: Tue Jul 02, 2019 2:28 pm

Re: Cal command not found

Sun Jan 16, 2022 8:04 pm

bls wrote:
Sun Jan 16, 2022 6:48 pm
I didn't do an exhaustive check through all the images (32/64, with desktop and Lite), but looks like it was installed by default on Buster, but not on Bullseye.
It is because Debian no longer includes it in the base image. cal/ncal used to be part of bsdmainutils but that was split into separate packages like ncal. bsdmainutils was marked as important in Buster and older but is now optional in Bullseye. ncal has inherited the same.

Somebody else can dig into the reason why it isn't included by default in Bullseye.
bls wrote:
Sun Jan 16, 2022 6:48 pm
Amusingly, cal outputs the calendar in a reasonable format (for most people), while ncal rotates the whole calendar 90 degrees. What's with that? Oh, and 'ncal -C' outputs the calendar in 'cal format'.
"The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of Easter. The new format is a little cramped but it makes a year fit on a 25x80 terminal."
bls wrote:
Sun Jan 16, 2022 6:48 pm
Oh, and 'ncal -C' outputs the calendar in 'cal format'.
cal is actually ncal. It check its own filename and automatically adds the -C option if it is ran as "cal".

bls
Posts: 2969
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: Cal command not found

Sun Jan 16, 2022 8:09 pm

GlowInTheDark wrote:
Sun Jan 16, 2022 7:00 pm
it was installed by default on Buster, but not on Bullseye.
Then yet another reason to take a pass on "bullseye". Not having "cal" is just weird.

Incidentally, "cal" is just a symlink to "ncal", so it is probable that somehow, whoever put Bullseye together (either "upstream" or at RPF/RPT/whatever), just lost that symlink somewhere along the way.

So, all you need to do is:

Code: Select all

$ sudo bash
# cd /usr/bin
# ln -sv ncal cal
#
Indeed, I mentioned immediately above that "cal is a link to ncal".

Unless you've found a rogue case to the contrary, there's no need to symlink cal to ncal because it's already there.
Pi tools:
Quickly and easily build customized exactly as-you-want SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure IPSEC/IKEV2 VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

W. H. Heydt
Posts: 16179
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Cal command not found

Sun Jan 16, 2022 10:55 pm

bls wrote:
Sun Jan 16, 2022 6:48 pm
I didn't do an exhaustive check through all the images (32/64, with desktop and Lite), but looks like it was installed by default on Buster, but not on Bullseye.
Son of a gun....you're right. I use cal from time to time and I'm used to it just being there. I just installed it on my one Bullseye system that is up and running. I'll have to add that to the list of What to Install on a new system.

I wonder why it wasn't included by default and what we can do to arrange that it is...

GlowInTheDark
Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: Cal command not found

Sun Jan 16, 2022 11:18 pm

WHH says:
I wonder why it wasn't included by default and what we can do to arrange that it is...
Trejan says:
It is because Debian no longer includes it in the base image. cal/ncal used to be part of bsdmainutils but that was split into separate packages like ncal. bsdmainutils was marked as important in Buster and older but is now optional in Bullseye. ncal has inherited the same.
I think that explains it.

Anyway, and FWIW, the reason I included instructions for (re-) making the symlink is that someone mentioned "ncal" working but "cal" not. That suggests breakage, and I was trying to give instructions on how to fix it.

Obviously, if you install the package, then everything should be setup correctly and should be good-to-go.

Also, in response to: "Why it isn't default and if we can fix it so that it is", it sounds like the answer is "No" and "You'll just have to install it yourself". Like we all do with the many essential packages that aren't present in the base image.
Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?

W. H. Heydt
Posts: 16179
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Cal command not found

Mon Jan 17, 2022 12:27 am

GlowInTheDark wrote:
Sun Jan 16, 2022 11:18 pm
Also, in response to: "Why it isn't default and if we can fix it so that it is", it sounds like the answer is "No" and "You'll just have to install it yourself". Like we all do with the many essential packages that aren't present in the base image.
I would class cal as a rather more basic function than the packages I add to any new install, they being putty, units, mplayer, gparted, and fortune. If someone fairly young is likely to use the system, I add tuxpaint and tuxmath to the list. I really don't expect anything on that list to part of the default image. "cal" on the other hand...

User avatar
scruss
Posts: 5382
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: Cal command not found

Mon Jan 17, 2022 12:43 am

I missed it when writing a script to make this:
cyrb2022-smol.jpg
Curse You, Red Baron! - 2022 ASCII art poster calendar
cyrb2022-smol.jpg (53.07 KiB) Viewed 6744 times
(which, if you must, you can find here A new old calendar in a variety of formats)
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

User avatar
jojopi
Posts: 3737
Joined: Tue Oct 11, 2011 8:38 pm

Re: Cal command not found

Mon Jan 17, 2022 1:01 am

trejan wrote:
Sun Jan 16, 2022 8:04 pm
It is because Debian no longer includes it in the base image. cal/ncal used to be part of bsdmainutils but that was split into separate packages like ncal. bsdmainutils was marked as important in Buster and older but is now optional in Bullseye.
Even that is not the whole story.

In other distros "cal" is provided by util-linux. util-linux is marked as an essential package in Debian. However, perhaps because Debian is theoretically multi-kernel, they disdain util-linux and do not allow it to provide any binaries that they can live without.

So in Debian, you can have the "cal" from BSD, or the one from Plan9 (package 9base; binary installs into /usr/lib/plan9/bin/), but never the one from util-linux.

During buster, someone reported an issue that the "rename" command from util-linux could not be made the default, like it is in other distros. Debian was installing it as "rename.ul" so they could continue to provide a janky Perl script as rename. So in bullseye, even rename.ul is gone. Used that? Tough.

Perhaps weirdest of all, the version of "write" from util-linux, which is the standard version in other distros, Debian not only calls "write.ul" but also places in the package bsdextrautils.

Because of the "rename" issue, I compile util-linux from source into /usr/local/bin/ on Debian systems.

GlowInTheDark
Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: Cal command not found

Mon Jan 17, 2022 9:15 am

I would class cal as a rather more basic function than the packages I add to any new install, they being putty, units, mplayer, gparted, and fortune. If someone fairly young is likely to use the system, I add tuxpaint and tuxmath to the list. I really don't expect anything on that list to part of the default image. "cal" on the other hand...
Just to be clear, we are in total agreement here about cal being obligatory. As I mentioned upthread, cal is (IMHO) stone cold basic Unix. To remove it is insanity.

This just seems to be yet another instance in which "Bullseye" has missed the target (with pun intended).
Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?

User avatar
scruss
Posts: 5382
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: Cal command not found

Mon Jan 17, 2022 4:35 pm

jojopi wrote:
Mon Jan 17, 2022 1:01 am
... so they could continue to provide a janky Perl script as rename.
excuse me, but that script you decry as 'janky' has been in constant development and careful maintenance since 1992. It's pretty much perfect, and is a must-have
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

GlowInTheDark
Posts: 2331
Joined: Sat Nov 09, 2019 12:14 pm

Re: Cal command not found

Mon Jan 17, 2022 4:43 pm

In the category of "One man's meat is another main's poison"...
... so they could continue to provide a janky Perl script as rename.
excuse me, but that script you decry as 'janky' has been in constant development and careful maintenance since 1992. It's pretty much perfect, and is a must-have
One man's "must have" is another man's "Oh, god, not this!!!"
Poster of inconvenient truths.

Back from a short, unplanned vacation. Did you miss me?

Return to “Troubleshooting”