0% found this document useful (0 votes)
3 views2 pages

Unix Assignment With Examples 1

The document provides instructions on creating hard and symbolic links using the 'ln' command, along with examples for each. It also covers file search and retrieval methods using 'find' and 'locate', as well as file and directory management commands for creating, copying, moving, renaming, and deleting files and directories. Key commands include 'touch', 'mkdir', 'ls', 'mv', and 'rm' for various file operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Unix Assignment With Examples 1

The document provides instructions on creating hard and symbolic links using the 'ln' command, along with examples for each. It also covers file search and retrieval methods using 'find' and 'locate', as well as file and directory management commands for creating, copying, moving, renaming, and deleting files and directories. Key commands include 'touch', 'mkdir', 'ls', 'mv', and 'rm' for various file operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like