You are not logged in.

#1 2009-04-11 06:13:25

astacha
Member
Registered: 2009-03-04
Posts: 27

What do these shorthand directories mean?

Hi all,

Very stupid question for you all.

I've been using linux for a while now but wanted to ask, what exactly do the shorthand directories mean:

for example, create the file ~/.xinitrc

I know this means create a hidden file called xinitrc, but which directory?

If there are any other shorthands for directories can people let me know please.


Alexie

Offline

#2 2009-04-11 06:15:40

SkonesMickLoud
Arch Linux f@h Team Member
From: The D of C
Registered: 2008-09-20
Posts: 178

Re: What do these shorthand directories mean?

~ is the shorthand for /home/user/

Offline

#3 2009-04-11 06:15:49

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: What do these shorthand directories mean?

"~" denotes user's home directory.

Offline

#4 2009-04-11 06:20:24

peart
Member
From: Kanuckistan
Registered: 2003-07-28
Posts: 510

Re: What do these shorthand directories mean?

You can also specify another user with ~someuser ("cd ~bob" will bring you to bob's home dir).

Offline

#5 2009-04-26 07:04:05

astacha
Member
Registered: 2009-03-04
Posts: 27

Re: What do these shorthand directories mean?

Thanks guys.

Offline

#6 2009-04-26 08:59:45

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: What do these shorthand directories mean?

Many directorys are stored in variables also

cd $HOME - takes you home
cd $OLDPWD - takes you to your previous directory
cd $PWD - takes you to your current directory (not sure what the point of that would be, more useful as `echo $PWD`)

There are probably more smile

Offline

#7 2009-04-26 09:36:20

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: What do these shorthand directories mean?

gazj wrote:

cd $PWD - takes you to your current directory (not sure what the point of that would be, more useful as `echo $PWD`)

This is from the times where there were only primitive shell prompts.
Otherwise it has proven useful in several scripts of mine.


To know or not to know ...
... the questions remain forever.

Offline

#8 2009-04-26 09:55:06

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: What do these shorthand directories mean?

bernarcher wrote:
gazj wrote:

cd $PWD - takes you to your current directory (not sure what the point of that would be, more useful as `echo $PWD`)

This is from the times where there were only primitive shell prompts.
Otherwise it has proven useful in several scripts of mine.

Of course it would be handy in shell scripts, had thought of that smile

Offline

#9 2009-04-26 10:49:51

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: What do these shorthand directories mean?

"-" is shorthand for $OLDPWD and "." for $PWD.

Last edited by lucke (2009-04-26 10:50:17)

Offline

#10 2009-04-26 19:23:46

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: What do these shorthand directories mean?

lucke, thanks! That's a real time saver.:D

A little OT, but running cd with no options will take you to your home directory as well.

Last edited by dmartins (2009-04-26 19:27:05)

Offline

#11 2009-04-27 02:43:46

froli
Member
From: Germany
Registered: 2008-06-17
Posts: 455

Re: What do these shorthand directories mean?

and cd .. brings you to the previous directory too. (very useful sometimes)


archlinux on Macbook Pro 10,1

Offline

#12 2009-04-27 03:03:02

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: What do these shorthand directories mean?

froli wrote:

and cd .. brings you to the previous directory too. (very useful sometimes)

Actually, cd .. brings you one directory up the hierarchy.

Offline

Board footer

Powered by FluxBB