Fundamentals

Moving files and folders

Easy
10 min

You can use the command line at the bottom of the page to practice commands. Finally, execute the given tasks on the same command line.

Renaming and moving files and folders can be done with the mv command, which comes from the word move.

mv old.txt new.txt

In the image below, we are renaming the file.

Using the same principle, you can move files or folders by first specifying the original location and then the destination.

# move the file to the folder
mv file.txt folder/

# move all files ending in .txt to a folder.
# The * character symbolizes the wildcard character.
mv *.txt folder/

# move the file from the folder to the current working directory.
The # dot symbolizes the current working directory.
mv folder/file.txt .

# move the folder "folder2" to the current working directory.
mv folder/folder2 .

In the image below, we first move the file named tiedosto2.txt to a folder, and then we move both txt files back to the current working directory using the wildcard (*) and dot.

Training

Move and rename the files and folders in a similar way. At the end of the task, there should be a folder called end -in the home folder, and inside it, files named file1.txt and file2.txt -.

Exercises

Task 1

Move and rename the file ~/start/a.txt to the folder ~/end/tied1.txt.

Task 2

Move and rename the file ~/start/b.txt to the folder ~/end/tied2.txt.

hakatemia pro

Ready to become an ethical hacker?
Start today.

As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.