a.
Hard and Symbolic Links:
Create Symbolic Links (Symlinks):
Use ln -s to create shortcuts to files.
Example:
ln -s /home/user/file1.txt link1.txt
Create Hard Links:
Use ln to create an actual duplicate reference to the same file data.
Example:
ln /home/user/file1.txt hardlink1.txt
b. File Search and Retrieval:
Search Files by Name/Type (using find):
Example 1: Find a file by name
find /home/user -name "notes.txt"
Example 2: Find all `.sh` scripts in a folder
find /home/user/scripts -type f -name "*.sh"
Locate Files (using locate):
Faster search using a database.
Example:
locate report.pdf
c. File and Directory Management:
Create Files and Directories:
Create a file:
touch file1.txt
Create a directory:
mkdir myfolder
Copy a file:
cp file1.txt myfolder/
List Directory Contents:
Basic listing:
ls
Long format (details):
ls -l
List hidden files:
ls -a
Human-readable sizes:
ls -lh
Move, Copy, and Rename Files:
Move a file:
mv file1.txt Documents/
Copy a file:
cp file1.txt file2.txt
Rename a file:
mv oldname.txt newname.txt
Delete Files and Directories:
Delete a file:
rm file1.txt
Delete a folder and its contents:
rm -r myfolder
Delete an empty folder:
rmdir emptyfolder