Skip to content

Explanations for basic Linux commands related to date and time settings, file compression, extraction, and transfer.

Notifications You must be signed in to change notification settings

panwar100/linux-file-and-time-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Linux Date, Time, Compression, and File Transfer Commands Guide

This repository provides examples and explanations for basic Linux commands related to date and time settings, file compression, extraction, and transfer.

Table of Contents

1.Set Date and Time

2.File Compression and Extraction

3.Transfer Files Between Systems

4.Using Rsync for Synchronization

5.Hard Link and Soft Link

6.Disk Usage and Search Commands

1. Set Date and Time

View Current Date and Time

Screenshot from 2024-12-02 22-04-16

Explain:

  • timedatectl is a powerful command-line utility in Linux, particularly useful for managing and configuring the system's date, time, and timezone settings

  • System clock synchronized: yes – The system time is being kept accurate by an external time source (NTP).

  • NTP service: active – The service that keeps time in sync is currently running.

  • RTC in local TZ: no – The hardware clock is using UTC instead of your local timezone, which is typical for most systems to avoid confusion when daylight saving time changes or timezones shift.

List Available Timezones

Screenshot from 2024-12-02 22-05-08

OR

Screenshot from 2024-12-02 22-06-57

Set a Specific Timezone

Screenshot from 2024-12-02 22-08-35

Enable/Disable Automatic Time Sync

  • disable NTP

Screenshot from 2024-12-02 22-09-35

  • Enable NTP

Screenshot from 2024-12-02 22-11-24

2. File Compression and Extraction

Create and Extract .tar Archives

a) Create a .tar Archive

Screenshot from 2024-12-02 22-15-02

b) Extract a .tar Archive

Screenshot from 2024-12-02 22-18-43

c) Display Contents of a .tar Archive Without Extracting

Screenshot from 2024-12-02 22-19-17

Compress Files

a) Gzip Compression

tar -czf t2.tar.gz f1 f2 f3

b)Bzip Compression

tar -cjf t2.tar.bz2 f1 f2 f3

c) Xz Compression

tar -cJf t2.tar.xz f1 f2 f3

Screenshot from 2024-12-02 22-30-51

3. Transfer Files Between Systems

Using scp

The scp (secure copy) command in Linux is used to securely transfer files and directories between two systems over a network. It uses SSH (Secure Shell) for data transfer, ensuring that the communication is encrypted.

a) Send a File to Another System

Screenshot from 2024-12-02 22-37-20

Screenshot from 2024-12-02 22-38-02

b) Retrieve a File from Another System

Screenshot from 2024-12-02 22-40-01

Screenshot from 2024-12-02 22-41-37

Using sftp

The sftp (Secure File Transfer Protocol) command in Linux is used for transferring files securely over a network. It operates over SSH (Secure Shell), ensuring encrypted communication between the client and the remote server.

a) Connect to Another System

sftp 192.168.1.13

b) Send a File

Screenshot from 2024-12-02 22-49-03

c) Retrieve a File

Screenshot from 2024-12-02 22-56-27

4. Using Rsync for Synchronization

a) Create Directories and Files

Screenshot from 2024-12-02 23-09-58

b) Synchronize Directories

Screenshot from 2024-12-02 23-08-59

c)Copy Only New/Updated Files

Screenshot from 2024-12-02 23-12-07

5. Hard Link and Soft Link

Hard Link

a) Create and Verify Hard Link

Screenshot from 2024-12-02 23-16-03

cat x # View content

cat y # Should match x

b) Delete Original File

Screenshot from 2024-12-02 23-19-26

remove x

  • cat y # Content remains accessible

  • After permission, number is given is change 1 to 2

Soft Link

a) Create and Verify Soft Link

Screenshot from 2024-12-02 23-21-17

  • ls -l # Verify symlink with arrow symbol
  • Permission change

b) Delete Original File

Screenshot from 2024-12-02 23-22-35

remove x

cat u # Error: No such file or directory

6. Disk Usage and Search Commands

Disk Usage

Screenshot from 2024-12-02 23-26-32

Locate Files by Name

The locate command in Linux is a fast way to search for files by name on the system. It uses a pre-built database (usually updated periodically) to quickly find files, making it faster than commands like find because it doesn’t have to search the filesystem in real time.

locate in -> iT find 'in' present file

Screenshot from 2024-12-02 23-40-26

Search with find

The find command in Linux is used to search for files and directories in a directory hierarchy based on various criteria. It’s a powerful tool for searching and managing files, offering flexibility in searching based on file names, types, permissions, sizes, and more.

Screenshot from 2024-12-02 23-51-12

a) Find files:

find / -name ln

b) Find directories:

find / -type d

find / -tpye d -name "dirname"

c) Find files only:

find / -type f

d) Find symbolic links:

find / -type l

e)Find files by size:

find / -size 10M # Exactly 10MB

find / -size -10M # Less than 10MB

find / -size +10M # Greater than 10MB

About

Explanations for basic Linux commands related to date and time settings, file compression, extraction, and transfer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published