0% found this document useful (0 votes)
13 views5 pages

Linux Lab

This lab provides instructions for managing files and directories using Command Line Interface (CLI) commands in Linux. It covers creating, changing, and verifying directories, creating text files, moving and deleting files, and copying directories. The lab emphasizes practical exercises to familiarize users with essential Linux file system commands.

Uploaded by

kurunau
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)
13 views5 pages

Linux Lab

This lab provides instructions for managing files and directories using Command Line Interface (CLI) commands in Linux. It covers creating, changing, and verifying directories, creating text files, moving and deleting files, and copying directories. The lab emphasizes practical exercises to familiarize users with essential Linux file system commands.

Uploaded by

kurunau
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/ 5

Lab – File System Commands (Linux Version)

Introduction

In this lab, you will use Command Line Interface (CLI) commands to manage
files and directories in Linux.

Recommended Equipment

 A computer running Linux (Ubuntu or any other Linux distribution)


 Access to the terminal

Instructions

Step 1: Access the Linux Terminal

1. Log into your Linux machine.


2. Open a terminal by searching for "Terminal" in your application menu
or pressing Ctrl+Alt+T.

Step 2: Create and Change Directories

1. Type pwd in the terminal.

Question:

a. What is the current directory?


b. Answer: Type your answers here.
2. Use the ls command to list the files and directories in the current
directory.

ls
3. Create three new directories: ITEfolder1, ITEfolder2, and ITEfolder3
using the mkdir command:

mkdir ITEfolder1 ITEfolder2 ITEfolder3

4. Verify the directories have been created:

ls

5. Change into the ITEfolder3 directory:

cd ITEfolder3

Question:

a. Which directory are you in now?


b. Answer: Type your answers here.

Step 3: Create Nested Directories


1. Create a nested folder structure: ITEfolder4/ITEfolder5 inside
ITEfolder3.
mkdir -p ITEfolder4/ITEfolder5

2. Verify the nested folders have been created:


ls -R

Question:
a. What command did you use to create the nested folders?
b. Answer: Type your answers here.
3. Navigate to ITEfolder5 using:
cd ITEfolder4/ITEfolder5

4. Move back to the parent directory using:


cd ..

Question:
a. After issuing the cd .. command, what is your current directory?
b. Answer: Type your answers here.
Step 4: Create Text Files
1. Navigate to the ITEfolder1 directory:
cd ~/ITEfolder1

2. Create text files doc1.txt, doc2.txt, file1.txt, and file2.txt using the
echo command:
echo "This is doc1.txt" > doc1.txt
echo "This is doc2.txt" > doc2.txt
echo "This is file1.txt" > file1.txt
echo "This is file2.txt" > file2.txt

3. Verify the files have been created:


ls

4. View the contents of the files using the cat command:


cat doc1.txt
cat doc2.txt

Step 5: Copy, Delete, and Move Files


1. Move doc2.txt to ITEfolder2:
mv doc2.txt ~/ITEfolder2/

2. Navigate to ITEfolder2 and verify the file has been moved:


cd ~/ITEfolder2
ls

3. Create a copy of doc2.txt named doc2_copy.txt:


cp doc2.txt doc2_copy.txt

4. Move doc2_copy.txt back to ITEfolder1:


mv doc2_copy.txt ~/ITEfolder1/

5. Rename doc2_copy.txt to doc2_renamed.txt:


mv ~/ITEfolder1/doc2_copy.txt ~/ITEfolder1/doc2_renamed.txt

6. Delete doc2_renamed.txt:
rm ~/ITEfolder1/doc2_renamed.txt

Question:
a. What single command would you use to delete all files with
"doc2" in the filename?
b. Answer: Type your answers here.
7. Use a wildcard (*) to move file1.txt and file2.txt into ITEfolder3:
mv ~/ITEfolder1/file* ~/ITEfolder3/

Step 6: Use the cp Command to Copy Directories


1. Copy all contents of ITEfolder3 to ITEfolder1:
cp -r ~/ITEfolder3/* ~/ITEfolder1/

2. Verify the contents were copied:


ls ~/ITEfolder1

3. Use the cp --help or man cp command to determine how to copy


directories, including empty ones.

Step 7: Use the rm Command to Delete Files and Directories


1. Delete the empty ITEfolder2 directory:
rmdir ~/ITEfolder2

2. Attempt to delete ITEfolder1:


rmdir ~/ITEfolder1

Question:
a. Were you able to delete the directory? Why or why not?
b. Answer: Type your answers here.
3. Delete ITEfolder1 and all its contents using:
rm -r ~/ITEfolder1

Reflection Question
 What are the advantages of using CLI vs. GUI?
o Type your answers here.
End of Lab.

You might also like