date

file managementLinux/Unix
The date command is one of the most frequently used commands in Linux/Unix-like operating systems. date Sample fallback description for date

Quick Reference

Command Name:

date

Category:

file management

Platform:

Linux/Unix

Basic Usage:

date +"%Y-%m-%d %H:%M:%S"

Common Use Cases

  • 1

    Time synchronization

    Display or set the current system date and time

  • 2

    Formatting timestamps

    Convert between different date and time formats

  • 3

    Script timestamping

    Add timestamps to logs or output in shell scripts

  • 4

    Date calculations

    Perform date arithmetic for scheduling and planning

Syntax

date [OPTION]... [FILE]...

Options

Option Description
-l Use a long listing format
-a Show hidden entries starting with .
-h Human-readable sizes
-R List subdirectories recursively

Examples

How to Use These Examples

The examples below show common ways to use the date command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

ls
List files in the current directory.
ls -l
List files in long format with details.
ls -a
List all files including hidden ones.

Advanced Examples:

ls -lah Detailed list with human-readable sizes. ls -R List directories recursively.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

These are sample notes for the date command.

Tips & Tricks

1

Use the +format option to specify the output format

2

Use the -d string option to display the date for a specific string

3

Use the -s string option to set the system date and time

4

Use the -u option to display the Coordinated Universal Time (UTC)

5

Use the -R option to display the date in RFC 5322 format

Common Use Cases

Time synchronization

Display or set the current system date and time

Formatting timestamps

Convert between different date and time formats

Script timestamping

Add timestamps to logs or output in shell scripts

Date calculations

Perform date arithmetic for scheduling and planning

Time zone conversion

Display times adjusted for different time zones

Related Commands

These commands are frequently used alongside date or serve similar purposes:

Use Cases

1

Time synchronization

Display or set the current system date and time

2

Formatting timestamps

Convert between different date and time formats

3

Script timestamping

Add timestamps to logs or output in shell scripts

4

Date calculations

Perform date arithmetic for scheduling and planning

5

Time zone conversion

Display times adjusted for different time zones

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the date command works in different scenarios.

$ date
View All Commands