|
IntroductiontolinuxBog'liq introductiontolinux| 17
Now we will move to the root directory / and then run a command to list all directories inside of it.
You can also move deeper into the file system using relative paths:
You will see a list of folders and files appear. This is the current contents of your home directory. We
are going to move into the directory ‘Desktop’ using a relative path.
cd ~
pwd
cd /
pwd
Changes Directory to your home
directory (donated by ~)
Print the current working directory -
You should be in /nas/ganymede/home/
msc/msai135 (where msai135 is your
own username)
The command ‘cd’ stands for ‘change
directory’. This is used to move to
different directories, and can be
used with absolute or relative paths.
/ tells the system to navigate to the
root directory of the filing system,
irrespective of your current working
directory.
Print the current Working Directory
cd ~
pwd
ls
First, return to your home directory
Print the current working directory
to check out location.
This will print (display on screen)
a list of files and folders stored in
the current working directory. In
this instance, we’re printing the
contents of your Home Directory.
cd Desktop
pwd
This changes the current working
directory to ‘Desktop’, which is
located in your current working
directory
IMPORTANT:
All Commands are Case
Sensitive!
Print the current working directory
to check out location.
18
|
Now we will return to your home directory and use commands to move around using relative and
absolute paths.
IMPORTANT:
In the following list of commands, replace
with
the path to your home directory that you wrote down on Page 16.
As you can see, you can chain different folders together to move between many levels in a single
command.
The command you ran was ‘cd /’ The ‘../’ part of this is the path that you are moving to. This is what
is known as a relative path, as you moved up one level (to /home) relative to your starting position
(from /home/msai135).
cd ~
pwd
cd
pwd
cd ~
pwd
cd ~/Desktop
pwd
cd ../
pwd
Changes Directory to your home
directory (donated by ~)
Print the current working directory -
You should be in /home/msai135 (where
msai135 is your own username)
Changes directory using an absolute
path. the ‘/’ denotes the root of the
filing system.
Print the current Working Directory
to confirm your current location
Return to your home directory
Print the current Working Directory
to confirm your current location
Change Directory to your Desktop
folder, which is absolute to the
root(/) of the system.
Print the current working directory
to confirm your current location
The ../ tells the system to navigate
up exactly one level, relative to
your current working directory.
Print the current working directory
to confirm your current location
|
| |