Linux Activity Sheet -1
- Navigating the File System:
- Task: Navigate to the root directory (
/
), then to your home directory (~
), and finally to the /etc
directory.
- Task: Navigate to a directory called “Documents” within your home directory.
- Creating and Removing Files and Directories:
- Task: Create a directory called “Projects” within your home directory.
- Task: Inside “Projects”, create subdirectories named “Project1” and “Project2”.
- Task: Remove the “Project2” directory.
- Copying, Moving, and Renaming Files:
- Task: Create a text file named “file1.txt” in the “Project1” directory.
- Task: Copy “file1.txt” to the “Project2” directory.
- Task: Move “file1.txt” from “Project2” to the parent directory of “Projects”.
- Task: Rename “file1.txt” to “newfile.txt”.
- Viewing File Contents:
- Task: Create a text file named “example.txt” and add some text to it.
- Task: View the contents of “example.txt” using
cat
.
- Task: View the contents of “example.txt” using
less
or more
.
- Searching for Files and Text Within Files:
- Task: Search for all files with the “.txt” extension in the “Projects” directory.
- Task: Search for the word “Linux” within all text files in the “Projects” directory.
- File Permissions:
- Task: Create a file named “secret.txt” with read, write, and execute permissions only for the owner.
- Task: Change the permissions of “secret.txt” to allow read access for all users.
- Task: Remove write permissions for the owner of “secret.txt”.
- Piping and Redirection:
- Task: Create a file named “numbers.txt” containing numbers from 1 to 10.
- Task: Use
grep
to find lines containing the number “5” in “numbers.txt”.
- Task: Redirect the output of
ls
to a file named “directory_contents.txt”.
- Archiving and Compressing Files:
- Task: Archive the “Projects” directory into a file named “projects.tar”.
- Task: Compress “projects.tar” using
gzip
to create “projects.tar.gz”.
- Task: Extract “projects.tar.gz” into a directory named “restored_projects”.
- Using Wildcards:
- Task: Create three text files named “file1.txt”, “file2.txt”, and “file3.txt”.
- Task: Rename all files with the “.txt” extension to have a “.bak” extension.
- Scripting:
- Task: Write a bash script that creates a directory structure for a project, including subdirectories for “source”, “documentation”, and “tests”.
- Task: Write a bash script that takes a filename as an argument and displays whether it exists and if it’s a file or directory.