First of all is the cd command. This is short for "change directory". The default location for you to start is in your home directory, and entering the following:
cd
will take you to your home directory. You can also use the ~ character (known as a tilde) as shorthand for your home directory, which is useful if referring to your home directory from elsewhere. So, entering the following:
cd ~
will give the same results as the previous command.
You can also navigate up one directory as follows:
cd ..
And can go back to the previous directory using this command:
cd -
These commands can be used as part of longer paths. For instance, say you are currently in /var/www but want to go to a folder called Music in your home folder. You can go there with this command:
cd /home/username/Music
Or you can use this:
cd ~/Music
Now, say you want to go from there to another folder in your home directory called Pictures. You can enter this:
cd ../Pictures
Then, to head back to the Music folder, you can enter the following:
cd -
And to head to the root of the filesystem, just enter the following:
cd /
Now, how can you see where you are? Easy, just enter the pwd command (short for Print Working Directory). Here I'm in the Desktop directory:
/home/matthew/Desktop
Got that? I recommend you spend a little time getting comfortable with these commands as they are the first building blocks in becoming proficient at the command line. Next time I'll go into creating and deleting files and folders.
2 comments:
looks like there's a typo. dir on windows is not the equivalent of cd on linux... dir on windows = ls on linux.
Oops! Thanks for pointing that out, Keith. I'll change that right now.
Post a Comment