Now that we know a bit about directories, let’s go back to looking at files. Remember, Linux® treats everything as files, so being able to manipulate them is a useful skill. Let’s begin by creating a file in our home directory:
Alpha:~ computerlamp$ echo "Teenage Mutant Ninja Turtles" >Turrtles
Well, oops. I misspelled Turtles. I should fix that. The command mv will let me do that.
Alpha:~ computerlamp$ mv Turrtles Turtles
The mv command moves files. It can move from one place to another or, in our case from one name to another. We can make a directory and move the file Turtles into it.
Alpha:~ computerlamp$ mkdir Sewer Alpha:~ computerlamp$ mv Turtles Sewer
There, now the Turtles file resides in the Sewer just like they’re supposed to. We can either
Alpha:~ computerlamp$ cd Sewer Alpha:Sewer computerlamp$ ls
To see our Turtles or just:
Alpha:~ computerlamp$ ls Sewer Turtles
Now if we want our Turtles back out of the sewer, there’s two ways to do that. If we’re in the home directory, the command is:
Alpha:~ computerlamp$ mv Sewer/Turtles .
That’s a period after the file name Sewer/Turtles. That actually means a special directory, the one we’re currently in. We could also have said:
Alpha:~ computerlamp$ mv Sewer/Turtles ~
Which means move it to the home directory. On the other hand, if we cd into the Sewer directory, the command is:
Alpha:Sewer computerlamp$ mv Turtles ..
That’s two dots. That means the parent directory of the one we’re currently in. To summarize: mv Move files . Current directory .. Parent directory