LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-04-2006, 11:56 PM   #1
kalak
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Rep: Reputation: 0
question about ~directories


How do I make a directory on my system accessable from anywhere by the ~mydirectory convention?

I'm sure its easy but I had trouble finding an answer.

thanks
 
Old 10-05-2006, 12:09 AM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,748

Rep: Reputation: 159Reputation: 159
you mean symlinks?

ln -s
 
Old 10-05-2006, 12:27 AM   #3
kalak
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Original Poster
Rep: Reputation: 0
yes but how do I make the link accesable from anywhere?

for example my home directory can be accessed no matter what my current direcotory is by typing

cd ~

my mysql directory can be accessed from any directory by typing

cd ~mysql

I would like a universally accessable link like that but make it something like

cd ~mydir


-Kalak
 
Old 10-05-2006, 02:48 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
cd is a bash built-in cmd, where '~' means 'home dir of specified user', default 'current user' if none specified.
To emulate that I think you'll have to write a short script and ensure it's always in a dir in your $PATH env variable.
If you get it working, post it here, as i'm sure others would like to see it.
 
Old 10-05-2006, 03:35 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,459

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
You can achieve what you want without the "~" shell feature.

Just use the CDPATH variable, which allows cd to search for different places when a relative directory is passed.
 
Old 10-05-2006, 07:27 AM   #6
mickyg
Member
 
Registered: Oct 2004
Location: UK
Distribution: Ubuntu/Kubuntu
Posts: 245

Rep: Reputation: 30
Or you could set up alias'??

Type alias at the prompt to see which you already have set-up.
 
Old 10-05-2006, 02:14 PM   #7
kalak
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Original Poster
Rep: Reputation: 0
the CDPATH solution is the closest so far, but not quite right. My CDPATH is empty yet I can still cd to ~mysql or ~vpopmail from anywhere.

anybody know the answer?

-Kalak
 
Old 10-05-2006, 02:52 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,459

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Quote:
Originally Posted by kalak
My CDPATH is empty yet I can still cd to ~mysql or ~vpopmail from anywhere.
Sure, that's a shell feature.

Quote:
anybody know the answer?
I'm confused, the answer to what question ?
 
Old 10-06-2006, 02:44 PM   #9
kalak
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlliagre
Sure, that's a shell feature.


I'm confused, the answer to what question ?
If it's a shell feature, how do I add my own directory to it?

eg. before I installed vpopmail I could not say
> cd ~vpopmail
and get to vpopmail. So I know that it is possible to add a new "link" (I quote it because i'm not sure what call it).

how do I get a link to mydar so that it can be accessed from anywhere by
> cd ~mydir
without adding it to a system variable. ~mysql, ~vpopmail, ~games, etc. are not anywhere in the system variables.

-Kalak
 
Old 10-06-2006, 04:01 PM   #10
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,459

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Quote:
Originally Posted by kalak
If it's a shell feature, how do I add my own directory to it?
You can't, it's a shell builtin feature.
~someone means someone's homedir
Quote:

eg. before I installed vpopmail I could not say
> cd ~vpopmail
and get to vpopmail. So I know that it is possible to add a new "link" (I quote it because i'm not sure what call it).
If you want that, you still can create a user account whose name is vpopmail and whose home directory is the directory where you want to go with "cd ~vpopmail"
Quote:
how do I get a link to mydar so that it can be accessed from anywhere by
> cd ~mydir
without adding it to a system variable. ~mysql, ~vpopmail, ~games, etc. are not anywhere in the system variables.
These have nothing to do with system variables, variables start with $ not ~.
 
Old 10-07-2006, 02:20 AM   #11
kalak
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlliagre
You can't, it's a shell builtin feature.
~someone means someone's homedir
If you want that, you still can create a user account whose name is vpopmail and whose home directory is the directory where you want to go with "cd ~vpopmail"

These have nothing to do with system variables, variables start with $ not ~.
Ok, so basically the solution is to create a user that can't use a shell and has a home directory of whatever dir. I want to access?

I knew cd ~username works but I never thought about that. Thanks!

-Kalak
 
Old 10-07-2006, 02:49 AM   #12
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,459

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Yes, it's a hack but that's the only way to achieve what you want.
 
Old 10-09-2006, 03:52 AM   #13
mickyg
Member
 
Registered: Oct 2004
Location: UK
Distribution: Ubuntu/Kubuntu
Posts: 245

Rep: Reputation: 30
Again, why not use alias'???

At the terminal type
Code:
alias 'cd ~whatever'='cd /folder/whereever'
 
Old 10-09-2006, 10:39 AM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,459

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Quote:
Originally Posted by mickyg
Again, why not use alias'???
Probably because that doesn't work:
Code:
$ bash --version
GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.11)
Copyright (C) 2004 Free Software Foundation, Inc.
$ bash
$ alias 'cd ~whatever'='cd /folder/whereever'
bash: alias: `cd ~whatever': invalid alias name
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
General Question - Non-Standard Directories shevegen Linux From Scratch 1 03-18-2006 07:19 AM
How to delete non-empty directories? Also have a terminal question Nylex Linux - General 10 07-15-2005 11:51 PM
dumb newbie question about renaming directories Lleb_KCir Linux - General 2 10-26-2004 08:37 PM
Directories Question duddy11 Linux - Newbie 7 07-30-2003 08:04 AM
Question about accessing shared directories zikfreak Linux - Newbie 0 08-18-2001 04:19 PM


All times are GMT -5. The time now is 11:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration