Java Reference
In-Depth Information
But now you're down in
HelloWorld/src/helloworld
. How do you get back up to
HelloWorld
? To go up just one level, you'd type this:
$
cd ..
Or to go up two levels, type this:
$
cd ../..
That's two periods (or dots), which is pronounced “up one.” One dot by itself
means the current directory, which isn't very useful with
cd
, but we will use
“.” with other commands—especially when copying files.
But now suppose you need to visit a directory that isn't just in the current
directory or up one. How do you get there? Suppose I'm somewhere completely
different, like
/home/minecraft
, and I want to go to
/Users/andy/Desktop/code/HelloWorld
.
I'd do something like this:
$
cd /Users/andy/Desktop/code/HelloWorld
The leading slash makes the difference. Earlier, when you typed
cdsrc
, the
cd
command looked for
src
right under the current directory. But if instead you
typed
cd /src
it would look for a directory named
src
under a directory named
“
/
”—which we call the
root
.
Root is the topmost directory on your system. It's above your code, above
your Desktop, above everything. Somewhere under root are your home
directory and Desktop. In my case, that's
/Users/andy/Desktop
. I could get there
the slow way by typing this sequence of commands:
$
cd /
$
cd Users
$
cd andy
$
cd Desktop
But we'll see a much easier way in just a moment. And speaking of shortcuts,
you don't even need to spell out each directory name fully, like D-e-s-k-t-o-p.
On most systems, there's a nice keyboard shortcut to save you from typing
out long names—the
Tab
key. If you type in the first few letters of a long name
and then press the
Tab
key, it will autocomplete to the long name. Suppose
I'm in my
code
directory:
$
ls
Adventure
CreeperCow
LocationSnapshot SquidBomb
ArrayAddMoreBlocks EZPlugin
MySimple
SquidBombConfig
ArrayOfBlocks
FireBow
NameCow
Stuck
BackCmd
FlyingCreeper NamedSigns
install
BackCmdSave
HashPlay
PlayerStuff
mkplugin.sh