Linux date command is a very powerful utility to get or set system time in various ways. Let us check, how to get Unix timestamp from a Linux /Ubuntu terminal.

Echo Unix timestamp using the date command


Code:
date +%s
Example:
Code:
$ date +%s
1262322642
By default, the Unix timestamp (epoch) is calculated in UTC, so there will be no difference in it regardless of the timezone.
Storing timestamp in a variable, and echo it
Code:
$ timestamp=$(date +%s)
$ echo $timestamp
1262322992

What is epoch time (Unix timestamp)?


The Unix epoch is the time 00:00:00 UTC on 1 January 1970. Current epoch time is the number of seconds counted from there.
Reference: https://en.wikipedia.org/wiki/Unix_time