0% found this document useful (0 votes)
15 views

2.Practicing Basic Linux Commands

Uploaded by

Darshan.r Darshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

2.Practicing Basic Linux Commands

Uploaded by

Darshan.r Darshu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

3.

Student Activity
Student Activity: Practicing Basic Linux Commands

Objective: This activity is designed to help beginners practice and understand basic Linux
commands by applying them in a real Linux environment. By the end of this activity, students
should be comfortable navigating the Linux file system and performing basic file operations.

1. Navigating the File System

Example 1: Using pwd

1. Objective: Determine your current directory.


Command: pwd
Expected Output: Displays the path of the current directory, e.g., /home/student .
2. Example 2: Listing Files with ls
3. Objective: List all files and directories in the current directory.
Command: ls
Expected Output: Displays a list of files and directories, e.g., Documents Downloads
Pictures .
4. Example 3: Changing Directories with cd
5. Objective: Navigate to the Documents directory.
Command: cd Documents
Expected Output: Changes the current directory to Documents .

2. Managing Files and Directories

Example 1: Creating a File with touch

1. Objective: Create an empty file named example.txt .


Command: touch example.txt
Expected Output: A new file named example.txt is created in the current directory.
2. Example 2: Creating a Directory with mkdir
3. Objective: Create a new directory named project .
Command: mkdir project
Expected Output: A new directory named project is created in the current
directory.
4. Example 3: Copying Files with cp
5. Objective: Copy example.txt into the project directory.
Command: cp example.txt project/
Expected Output: example.txt is copied into the project directory.

3. Moving and Renaming Files

Example 1: Moving Files with mv

1. Objective: Move example.txt from the current directory to the project directory.
Command: mv example.txt project/
Expected Output: example.txt is moved to the project directory.
2. Example 2: Renaming Files with mv
3. Objective: Rename example.txt to sample.txt within the project directory.
Command: mv project/example.txt project/sample.txt
Expected Output: example.txt is renamed to sample.txt in the project
directory.
4. Example 3: Removing Files with rm
5. Objective: Delete sample.txt from the project directory.
Command: rm project/sample.txt
Expected Output: sample.txt is deleted from the project directory.

4. Viewing and Editing Files

Example 1: Viewing File Contents with cat

1. Objective: Display the contents of sample.txt .


Command: cat project/sample.txt
Expected Output: Displays the contents of sample.txt .
2. Example 2: Editing Files with nano
3. Objective: Open sample.txt in the nano text editor.
Command: nano project/sample.txt
Expected Output: Opens sample.txt in nano for editing.
4. Example 3: Saving and Exiting nano
5. Objective: Save changes and exit nano .
Steps: Press Ctrl + O to save, then Enter , and Ctrl + X to exit.
Expected Output: Changes are saved, and you exit the nano editor.

Conclusion
By completing these exercises, students will gain hands-on experience with basic Linux
commands, enhancing their understanding of the Linux file system and command-line
operations. Encourage students to explore further by creating more files and directories,
experimenting with different commands, and asking questions if they encounter any issues.
Happy practicing!

You might also like