This repository provides examples and explanations for basic Linux commands related to date and time settings, file compression, extraction, and transfer.
2.File Compression and Extraction
3.Transfer Files Between Systems
4.Using Rsync for Synchronization
6.Disk Usage and Search Commands
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.
OR
- disable NTP
- Enable NTP
a) Create a .tar Archive
b) Extract a .tar Archive
c) Display Contents of a .tar Archive Without Extracting
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
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
b) Retrieve a File from Another System
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
c) Retrieve a File
a) Create Directories and Files
b) Synchronize Directories
c)Copy Only New/Updated Files
a) Create and Verify Hard Link
cat x # View content
cat y # Should match x
b) Delete Original File
remove x
-
cat y # Content remains accessible
-
After permission, number is given is change 1 to 2
a) Create and Verify Soft Link
- ls -l # Verify symlink with arrow symbol
- Permission change
b) Delete Original File
remove x
cat u # Error: No such file or directory
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
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.
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