Exercise 3 LINUX
Exercise 3 LINUX
Steps:
1 mkdir my_directory
1 touch my_file.txt
• Use the ‘mv‘ command to move a file or directory to a new location or rename it:
1 mv my_file.txt my_directory/
2 mv oldname.txt newname.txt
1 cp my_file.txt my_directory/
1 rm my_file.txt
1 rm-r my_directory/
Steps:
Step 1: Create Directories and Subdirectories
• Use the ‘mkdir‘ command with the ‘-p‘ option to create directories and subdirectories:
1 mkdir-p parent_directory/child_directory/grandchild_directory
1 mv file1.txt parent_directory/
2 mv file2.txt parent_directory/child_directory/
• List the contents of the directories to ensure files are organized correctly:
1 ls-R parent_directory/
Objective: To find files and search for content within files using various commands.
Steps:
2 find .-type f-name "*.txt" # Search for all .txt files in the current directory and
subdirectories
1 locate filename.txt
• Use the ‘grep‘ command to search for specific content within files:
a director