Purpose: Locates files in a directory hierarchy based on specified criteria.
Syntax:
find path -options argumentsCommon Options:
- -type: Specifies the file type (e.g.,
ffor regular files,dfor directories). - -name: Matches files based on their name.
- -newer: Matches files modified after a given file.
Example:
find . -type f -name "*.txt" -newer file.txtThis finds all regular files named "*.txt" in the current directory or subdirectories that were modified after file.txt.
Purpose: Quickly finds files based on their name.
Syntax:
locate patternNote: locate uses a database of file names that is periodically updated using the updatedb command.
Example:
updatedb
locate myfile.txtPurpose: Measures the execution time of a command.
Syntax:
time commandExample:
time ls -lPurpose: Displays the current date and time.
Syntax:
datePurpose: Provides more detailed information about the system's date and time settings.
Syntax:
timedatectlPurpose: Pauses the execution of a script for a specified number of seconds.
Syntax:
sleep secondsPurpose: Creates and extracts tar archives.
Syntax:
tar -cvzf archive.tar.gz filesOptions:
-c, --create:Create a new archive.-x:To extract an archive.-v:Verbose output.-z:Use gzip compression.-f:Specify the archive file.-r, --apend:Append files to the end of an archive.-t, --list:list the contents of an archive
Example:
tar -cvzf backup.tar.gz important_filesPurpose: Creates ZIP archives.
Syntax:
zip archive.zip filesExample:
zip backup.zip important_filesPurpose: Compresses and decompresses files using gzip.
Syntax:
gzip -c file.txt > file.txt.gz
gzip -d file.txt.gzExample:
gzip -c myfile.txt > myfile.txt.gz
gzip -d myfile.txt.gzPurpose: Compresses and decompresses files using bzip2.
Syntax:
bzip2 -c file.txt > file.txt.bz2
bzip2 -d file.txt.bz2Example:
bzip2 -c myfile.txt > myfile.txt.bz2
bzip2 -d myfile.txt.bz2Note
zcatandbzcatare equivalent togzip -dcandbzip2 -dc, respectively.zmoreandbzmoreare similar tomorebut for compressed files.zlessandbzlessare similar tolessbut for compressed files.