cal -y

Have you ever wished there was an easy way to adjust time and date settings on your system without having to go through that little widget and hunt for the exact one you want all the time? Linux Bash makes it easy by providing a few commands to tweak time zones, time, date and anything related to keeping proper timing on your computer. If you're new to Command Line-like tools, this is a good place to start without wrecking your system too badly, though of course you should know how to undo any mistakes you make. If you're stumped, man yourcommand is a good way to get everything you ever wanted to know about whatever command you want to use. Trust me, proper date/time settings on your computer can't be overrated since many applications rely on staying synced with devices on the network it's attached to.


man cal

The cal command is a relatively simple one. It displays a calendar with the current date highlighted. Simply typing in cal will display the current month and year in a familiar calendar format. If you want to know what day of the week Independence Day falls on this year even though it's still June, cal -y will display the entire year or cal -A number will display both this month and the number of months you specify after it. Cal -B number will display the current month and the number of months you specify before it. Cal -m month displays the month you specify.



Without any arguments, the date command will display the current date, time, time zone and year. For easy-to-read formats, the syntax would look like, date +%D, which gives you today's date as 6/4/2013. More parameters include:

  • +%M – Minutes (00 to 59)

  • +%H – Hours, 24-hour clock

  • +%I – Hours, 12-hour clock

  • +%a – Weekday, short form (Sun – Sat)

  • +%A – Weekday, long form (Sunday – Saturday)

  • +%d – Day as 2-digit number

  • +%D – Four-digit date (mm/dd/yy)

  • +%b – Name of month, short form (Jan – Dec)

  • +%B – Name of month, long form (January – December)

  • +%m – Month as a 2-digit number (01 – 12)

  • +%y – Year as 2-digit number (YY)

  • +%Y – Year as 4-digit number (YYYY)

  • +%T – Time in 24-hour format (hh:mm:ss)

  • +%r – Time in 12-hour format (hh:mm:ss)

  • +%t – Tabulator.

  • +%n – Line Break

  • +%% – Displays a percent sign.

For some operations using the date command, you may have to precede it with sudo, for instance, sudo date -s 4 June 2013 3:34 will set the time/date stamp to 4 June 2013 at 3:35 AM. By default, the timestamp uses 24-hour time, so setting the time for afternoon and evening hours will require you to add 12 to the current time on an accurate 12-hour clock. 3:35 PM would be 15:35 if you use the time defaults.



The hwclock command is one to be careful with because this one manages the internal clock that keeps the hardware running smoothly. If the hardware time is being lousy, it may be time for a new CMOS battery and especially time to make sure all the data on your computer is backed up. In the meantime, you can use hwclock to make sure the hardware time doesn't drift too far in one direction or another. You can set the system time by the hardware clock (hwclock -s), the hardware clock by the system time (hwclock -w) and set the system time by the time zone (hwclock --systz). Because you're working with the internal clock, most of the hwclock options that actually make changes will have to be accompanied by sudo and your superuser password.

What's In It For You?

Cal, Date and hwclock provide easy ways to manage the time and date settings on your Linux box, including tasks that aren't handily accessed through the toolbar widget. They will take practice, but can be mastered so that you barely look at the widget while managing your settings through the Linux Terminal.