The cd command changes directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. Examples:
-
To navigate into the root directory, type:
cd /
-
To navigate to your home directory, type:
cd
or
cd ~
-
To navigate up one directory level, type:
cd ..
-
To navigate to the previous directory (or back), type:
cd -
-
To navigate through multiple levels of directory at once, specify the full directory path that you want to go to. For example, type:
cd /var/www
to go directly to the
/www
subdirectory of/var/
. As another example, type:cd ~/Desktop
to move you to the
Desktop
subdirectory inside your home directory.
pwd: The pwd command will show you which directory you're located in (pwd stands for “print working directory”). For example, typing
pwd
in the Desktop
directory, will show
~/Desktop
.
GNOME Terminal also displays this information in the title bar of it's window. |
The ls command shows you the files in your current directory. Used with certain options, you can see sizes of files, when files where made, and permissions of files. For example, typing
ls ~
will show you the files that are in your home directory.
The cp command makes a copy of a file for you. For example, type:
cp file foo
to make
a exact copy of file
and name it foo
, but the file
file
will still be there.
The mv command moves a file to a different location or will rename a file. Examples are as follows:
mv file foo
will rename the file file
to foo
.
mv foo ~/Desktop
will move the file foo
to your Desktop
directory but will not rename it. You must specify a new
file name to rename a file.
If you are using mv with sudo you will not be able to use the ~ shortcut, but will have to use the full pathnames to your files. This is because when you are working as root, ~ will refer to the root account's home directory, not your own. |
Use the rm command to remove or delete a file in your directory. It will not work on directories which have files in them.