Setting the time on Debian is important as different operations and tasks are completed concerning the time. The Debian system maintains the activity performed on it concerning the actual time.
Many installed applications such as weather forecast applications need to know the current time of the computer. Similarly, the cron daemon executes cron jobs, and the cron daemon’s operation depends on the system’s timezone.
However, during the installation of Debian, it configures its time and date automatically with the connected network. Still, sometimes there is a need to set the time on Debian. This post will explain the method of setting up the time on Debian with the following outline:
- What are the Methods to Set Up the Time on Debian 12
- Method 1: Set Up the Time on Debian Using the date Command
- Method 2: Set Up the Time on Debian Using the timedatectl Command
- Method 2: Set Up the Time on Debian Automatically
- How to Display the Current Time on Debian Linux
Let’s start the post by exploring different methods to set up time on Debian.
What are the Methods to Set Up the Time on Debian 12?
Two different methods including the manual approach and automatic approach can be used to set the time on Debian. Both methods are explained in detail with the demonstration of the commands for setting time.
Method 1: Set Up the Time on Debian Using the date Command
To set the time on Debian manually, run the date command with the “set” option and define the current time. For instance, run the command:
$ sudo date --set 21:08:00
The time has been set manually on Debian.
Method 2: Set Up the Time on Debian Using the timedatectl Command
One more command utility to set up the time on Debian 12 is by using the timedatectl command. For example, to set the time now, run the command:
$ timedatectl set-time 18:40
So first disable the automatic time synchronization by running the command:
$ timedatectl set-ntp 0
Again run the above command to set the time:
Method 3: Set Up the Time on Debian Automatically
Another method to set the time is automatically by making the changes in the NTP configuration file (Network Time Protocol) with the following steps.
Step 1: Open the Terminal
First, open the terminal as shown below to make changes in the NTP configuration file:
Step 2: Install the NTP on Debian
Now install the NTP by executing the command:
$ sudo apt install ntpsec -y
Step 3: Open the NTP Configuration File
Next is to open the configuration file of the text editor using the command:
$ sudo nano /etc/ntpsec/ntp.conf
Step 4: Set the Pool
As the pool is global, set the pool according to the desired from the mentioned page. Now replace the mentioned line with the actual pool:
For example, to set the pool according to the US, type the following line:
Save the file after the changes and the time has been set successfully.
How to Display the Current Time on Debian Linux?
To display the current time using the terminal of the Debian, run the command:
The time has been displayed on the screen.
To set the time on Debian 12, either use the date command or the timedatectl command in the terminal. Also, time can be set automatically by configuring the NTP.
All these methods for setting up the time on Debian 12 have been explained in this post.