This is the 9th post of a series for teaching cyber-security in a coding-club. Read [part 8]
Create directories and move files
We have a lot of files and folders on our home directory, so we are going to do some tidying.
mkdircommand creates a new folder (or directory). so,
mkdir myfolderwill create a new folder called
myfolderat the level we are at.
We are going to create a new folder were we will move all the clutter. Create a directory called
mystuff by typing:
ls -l to confirm that it has been created.
Let's move all the clutter away.
mv file directory
mv, or move command takes two arguments: The name of the file we want to move and the directory where we want to move it. It will only work in that order.
Let's try it out. Assume there is a file called
mv index.html mystuff/
Remember that you can do
mv i and then hit tab to autocomplete and then type
m and again tab ).
index.html should now have disappeared from the home directory. Let's make sure it ended up where we wanted it to be:
Is it there? Can you move any other files to your new folder? Check that it worked:
ls -a mystuff/
It turns out that the move (
mv) command can also move entire directories. To use it you write:
mv <source directory> <destination directory>
Let's try it out. let's move
mv test-website/ mystuff/
In the example above, we are passing the
test-website/ directory) as the first argument and the second argument, (the
<destination>) as the
mystuff/. You can now find the test website at
Let's move on to more advanced commands in [Part 10]