LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  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: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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: 249

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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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: 249

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: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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



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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:15 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration