cd
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.- To navigate into the root directory, type:
cd /
- To navigate to your home directory, type:
cd
or
cd ~
The ~ character represents the current user's home directory. As seen above, cd ~ is equivalent to cd /home/username/. However, when running a command as root (using sudo, for example), ~ points instead to /root
. When running a command with sudo, the full path to your home directory must be given.
- To navigate up one directory level, type:
cd ..
- To navigate to the previous directory (or back), type:
cd -
- To navigate through multiple levels of directories 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 theDesktop
subdirectory inside your home directory.
pwd
pwdin the
Desktop
directory, will show /home/username/Desktop
. ls
ls ~will show you the files that are in your home directory.
Used with the -l options, ls outputs various other information alongside the filename, such as the current permissions on the file, and the file's owner.
cp
cp foo barto make an exact copy of
foo
and name it bar
. foo
will be unchanged. mv
mv foo barwill rename the file
foo
to bar
. mv foo ~/Desktopwill move the file
foo
to your Desktop
directory but will not rename it. rm
rm foodeletes the file
foo
from the current directory. By default, rm will not remove directories. To remove a directory, you must use the -R option. For example,
rm -R foobarwill remove the directory foobar, and all of its contents!
mkdir
mkdir musicwill create a directory named
music
in the current directory.
No comments:
Post a Comment