LinuxQuestions.org
Help answer threads with 0 replies.
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 05-15-2013, 08:47 PM   #1
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Rep: Reputation: 2
shortcut sought through directory thicket ....


Currently, due to my adding a non-root user for myself yesterday, I have a pathway in my directories such as:

(the pathway in question extending from command line prompt at highest level ie: michael@tex:/home$)

/home/michael/Documents/journals/aujour/diary.txt

Question: I read an entire article on directory hierarchies last night, hoping to find a short cut from root of pathway to *any* node in a given pathway, but the only "shortcut" I found was:

$ ./<directory name of child directory> which is no shortcut at all, since cd <directory name> would do the same...

Seems I must have misunderstood something, as I feel sure that there must be a way of going from anywhere "up-stream" to anywhere "down-stream" *in the absolute pathway*, by a shortcut nominating the target "down-stream", without having to type all the intervening directory elements.
 
Old 05-15-2013, 09:08 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,342

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
Sounds like you want symlinks
http://linux.byexamples.com/archives...reate-symlink/
http://stackoverflow.com/questions/1...-file-in-linux
 
1 members found this post helpful.
Old 05-15-2013, 09:49 PM   #3
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
That did it Chris.
Obligado!

Tex
 
Old 05-15-2013, 11:24 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,342

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
No worries
 
Old 05-15-2013, 11:56 PM   #5
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 910

Rep: Reputation: 174Reputation: 174
With a hierarchical filesystem, directory navigation at the command line can be a bit of a chore. But you can often avoid having to type the entire directory string by using an asterisk in each directory name at an unambiguous prefix.

For example, if I am in my home directory and I want to navigate to ~/docs/photography/Beseler/45A_head/Beseler 45A manual, I could type the full path on the change directory command or I could specify the smallest unambiguous prefix at each directory level, which in my case would be "cd do*/pho*/Be*/4*/B*".

This:

cd do*/pho*/Be*/4*/B*

is a lot faster to type than this:

cd docs/photography/Beseler/45A_head/Beseler\ 45A\ manual

Last edited by Z038; 05-15-2013 at 11:57 PM.
 
1 members found this post helpful.
Old 05-16-2013, 12:59 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,342

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
See also tab-completion
 
Old 05-16-2013, 08:26 AM   #7
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by Z038 View Post
With a hierarchical filesystem, directory navigation at the command line can be a bit of a chore. But you can often avoid having to type the entire directory string by using an asterisk in each directory name at an unambiguous prefix.

For example, if I am in my home directory and I want to navigate to ~/docs/photography/Beseler/45A_head/Beseler 45A manual, I could type the full path on the change directory command or I could specify the smallest unambiguous prefix at each directory level, which in my case would be "cd do*/pho*/Be*/4*/B*".

This:

cd do*/pho*/Be*/4*/B*

is a lot faster to type than this:

cd docs/photography/Beseler/45A_head/Beseler\ 45A\ manual
okay, but since making this post, I have discovered by trial and error that, when logged in as root, one can use:

~./ <target_directory_name>

in order to jump from root, skipping multiple steps, to a targetted directory in a path.

Is that strictly a feature of root's privileges, non-extendable to the non-root trees?

Last edited by textillis; 05-16-2013 at 08:29 AM.
 
Old 05-16-2013, 09:07 AM   #8
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 910

Rep: Reputation: 174Reputation: 174
Can you give a concrete example of what you are referring to?

Here are some useful shortcuts.

cd . (change to current directory, not especially useful)
cd .. (change to parent directory of the current directory)
cd (with no argument, change to your home directory)
cd / (change to the root directory)
cd - (change to the last directory you were in)

If you are at the /usr directory and you type cd ./src, it will go to /usr/src. But you could just as well type cd src. The ./ that you show in your example is implied in the cd command argument (i.e., current working directory), so you don't have to specify it.
 
Old 05-17-2013, 01:42 AM   #9
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by Z038 View Post
Can you give a concrete example of what you are referring to?

Here are some useful shortcuts.

cd . (change to current directory, not especially useful)
cd .. (change to parent directory of the current directory)
cd (with no argument, change to your home directory)
cd / (change to the root directory)
cd - (change to the last directory you were in)

If you are at the /usr directory and you type cd ./src, it will go to /usr/src. But you could just as well type cd src. The ./ that you show in your example is implied in the cd command argument (i.e., current working directory), so you don't have to specify it.
Thanks Z, this clarifies the matter: in other words: use threshold redundancy principle when navigating at CLI.

(I must have been sleep deprived when I wrote the above concerning use of cd ~./, since just then, I went and typed:

cd ~./<directory>

and it returned an error)
 
Old 05-17-2013, 02:42 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,342

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
In the context of bash (& other shells), '~' is a synonym for your home dir eg /home/you (as specc'ed in your entry in /etc/passd).
The shell var $HOME means the same thing.

https://en.wikipedia.org/wiki/There%...e_way_to_do_it
 
1 members found this post helpful.
Old 05-17-2013, 03:20 AM   #11
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by chrism01 View Post
In the context of bash (& other shells), '~' is a synonym for your home dir eg /home/you (as specc'ed in your entry in /etc/passd).
The shell var $HOME means the same thing.

https://en.wikipedia.org/wiki/There%...e_way_to_do_it
Tim Toady Bicarbonate,
indeed...

thanks heaps Chris,
got it.
Tex
 
Old 05-17-2013, 02:29 PM   #12
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Take a look at the CDPATH variable too. You can set it to a colon-separated list of directories that bash will look into when you use the cd command.

If your CDPATH contains "/home/michael/Documents/journals", for example, then "cd aujour" will take you directly to "/home/michael/Documents/journals/aujour".

There's also the cdable_vars shell option that, when enabled, will allow you to store directory paths in variables and cd into them using that variable name as the argument.

Next, you can always create an alias or shell function that you can call to jump directly to a set location.

Finally, I know I've seen several scripts/commands in the past that people have written for quick directory navigation, such as jumping up n levels at once. Try a web search or two.


PS: Just for accuracy, "." and ".." are not shell shortcuts of some kind, but actual directory names. *NIX filesystems automatically create them as hard links to the current and parent directories, respectively.

Last edited by David the H.; 05-17-2013 at 02:40 PM. Reason: Some additions.
 
1 members found this post helpful.
Old 05-17-2013, 09:30 PM   #13
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
David, thank you muchly for abundantly detailed and heat-seakingly targeted response.

Mucho gracias.
Texo
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
gnome-terminal:keyboard shortcut launches terminal with / directory default! deepclutch Linux - Desktop 1 06-21-2010 11:48 AM
Mounting a directory as a shortcut? x837cue Linux - Newbie 4 11-03-2008 07:06 AM
home directory shortcut raaste Linux - Software 2 08-10-2004 01:08 PM
My Home directory shortcut folder on my desktop doesn't work Bensoft Kill MS Linux - Software 2 11-28-2003 09:31 PM
how do i remove a 'shortcut' directory? omgkthxbye Linux - General 2 11-07-2002 07:26 AM

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

All times are GMT -5. The time now is 09:19 PM.

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