0% found this document useful (0 votes)
9 views7 pages

DTL Lab 4

This lab manual outlines basic file operations in Linux using command line tools, including creating, editing, moving, and deleting files and directories. Key commands such as touch, mkdir, mv, and rm are introduced, along with a step-by-step procedure for performing these operations. The exercise aims to provide hands-on experience and essential skills for managing files in a Linux environment.

Uploaded by

shubhamuchougule
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)
9 views7 pages

DTL Lab 4

This lab manual outlines basic file operations in Linux using command line tools, including creating, editing, moving, and deleting files and directories. Key commands such as touch, mkdir, mv, and rm are introduced, along with a step-by-step procedure for performing these operations. The exercise aims to provide hands-on experience and essential skills for managing files in a Linux environment.

Uploaded by

shubhamuchougule
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/ 7

Lab Manual 4: Basic File Operations in Linux Command Line

Aim:

To perform basic file operations using Linux command line tools such as creating, editing, moving, and deleting
files and directories.

Theory:

Linux is a powerful operating system widely used in servers, development environments, and embedded
systems. One of its key strengths is the command-line interface (CLI), which allows users to perform tasks
efficiently. File operations are fundamental to working with any operating system, and Linux provides a variety
of commands to manage files and directories.

Key Commands:

1. touch: Creates an empty file or updates the timestamp of an existing file.

2. mkdir: Creates a new directory.

3. nano/vi: Text editors used to create or modify file content.

4. mv: Moves or renames files and directories.

5. cp: Copies files and directories.

6. rm: Deletes files.

7. rmdir: Deletes empty directories.

8. ls: Lists the contents of a directory.

9. cat: Displays the contents of a file.

10. cd: Changes the current working directory.

Procedure:

Open the Terminal:

Launch the terminal on your Linux system. You can do this by searching for "Terminal" in
the applications menu or using a keyboard shortcut (e.g., Ctrl + Alt + T).

1. Creating a Directory: o

Command: mkdir my_directory


2. Creating a File: o Command:

touch my_file.txt

3. Editing a File:

o Command: nano my_file.txt

4. Displaying File Contents: o

Command: cat my_file.txt

5. Copying a File:

o Command: cp my_file.txt my_file_copy.txt

6. Moving/Renaming a File: o

Command: mv my_file_copy.txt

renamed_file.txt

7. Creating a Subdirectory: o

Command: mkdir sub_directory

8. Moving a File to a
Subdirectory:

o Command: mv renamed_file.txt sub_directory/

9. Deleting a File: o Command:

rm

sub_directory/renamed_file.txt

10. Deleting a Directory: o

Command: rmdir sub_directory

11. Listing Directory

Contents: o Command: ls

12. Deleting the Original

Directory: o Command: rm -r

my_directory
––
Steps to Follow:

1. Open the terminal.

2. Create a directory using mkdir.

3. Navigate into the directory using cd.

4. Create a file using touch.

5. Edit the file using nano or vi.

6. Display the file contents using cat.

7. Copy the file using cp.

8. Rename or move the file using mv.

9. Create a subdirectory using mkdir.

10. Move the file into the subdirectory using mv.

11. Delete the file using rm.

12. Delete the subdirectory using rmdir.

13. List the contents of the directory using ls.

14. Delete the original directory using rm -r.

Output:

• Successfully created, edited, moved, and deleted files and directories using Linux
commandline tools.

• Gained hands-on experience with basic file operations in a Linux environment.

• Learned to use commands like touch, mkdir, nano, mv, cp, rm, rmdir, ls, and cat.

Conclusion:

This lab exercise provided a comprehensive understanding of basic file operations in


Linux using command-line tools. By performing tasks such as creating, editing, moving,
and deleting files and directories, you have developed essential skills for managing files
in a Linux environment. These skills are critical for system administration, software
development, and working in Linux-based systems.

Web/Virtual link: https://www.kali.org/

You might also like