LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-27-2013, 02:30 AM   #1
linishjacob88
LQ Newbie
 
Registered: Jan 2013
Posts: 8

Rep: Reputation: Disabled
Smile General enquery abt the path in linux server.


hi,

Is there any method to go to the path without entering the CD command in linux.

Eg:/]# bin :like this
/bin]#


without entering cd bin
 
Old 04-27-2013, 03:39 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Why? What's purpose of doing this? The cd command stands for change directory and is build for purpose of changing the directory.
 
Old 04-27-2013, 04:00 AM   #3
linishjacob88
LQ Newbie
 
Registered: Jan 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
hi,

my intention that, we can change the path very easily. no need to enter the whole path,
were the file is existin
i saw somewhere that, without enterin the cd/whole path they changed the path

is there any scriptin for that?

can we switch from one t other without usin cd/whole command..?

like====cd home/bin/crbt/cfg

can we go to cfg directly without using all these ??
 
Old 04-27-2013, 04:17 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
See 'man bash' about "CDPATH" ?
 
Old 04-27-2013, 04:26 AM   #5
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 521

Rep: Reputation: 141Reputation: 141
I use alias for quick directory change. following lines i have inserted in '/etc/profile' and '/etc/bashrc'
Code:
alias cdkvm="cd /var/lib/libvirt/images"
alias cdftp="cd /var/ftp/pub"
alias cdwww="cd /var/www/html"
alias cdrep="cd /etc/yum.repos.d"
alias cdnet="cd /etc/sysconfig/network-scripts"
At terminal, you can also use following command to toggle between the last two directories
Code:
$ cd -

Last edited by mddnix; 04-27-2013 at 04:57 AM.
 
Old 04-27-2013, 04:59 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
Quote:
Originally Posted by mddesai View Post
I use alias for quick directory change.
Doesn't beat using CDPATH IMHO. Try it.
 
1 members found this post helpful.
Old 04-27-2013, 05:29 AM   #7
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 521

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by unSpawn View Post
Doesn't beat using CDPATH IMHO. Try it.
Tutorial: How to set and use the Linux CDPATH variable with bash
Code:
[root@srv ~]# export CDPATH=$CDPATH:/etc:/var

[root@srv ~]# echo $CDPATH
:/etc:/var

[root@srv ~]# pwd
/root

[root@srv ~]# cd images
bash: cd: images: No such file or directory

[root@srv ~]# cd pub
bash: cd: pub: No such file or directory

[root@srv ~]# cd html
bash: cd: html: No such file or directory

[root@srv ~]# cd yum.repos.d
/etc/yum.repos.d

[root@srv yum.repos.d]# cd network-scripts
bash: cd: network-scripts: No such file or directory
Path for leaf directories are as stated in post #5. What i'm doing wrong...?

Thanks.
 
Old 04-27-2013, 06:27 AM   #8
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 521

Rep: Reputation: 141Reputation: 141
OK. I resolved the problem.

The problem was
Code:
[root@srv]# find /var /etc -type d -name images -print 2>/dev/null | wc -l
15
[root@srv]# find /var /etc -type d -name html -print 2>/dev/null | wc -l
2
so i changed path, its working fine now

Code:
export CDPATH=$CDPATH:/var/lib/libvirt:/var/ftp:/var/www:/etc/yum.repos.d:/etc/sysconfig
@unSpawn Thanks very much. Its really a cooool command.
 
Old 04-27-2013, 07:42 AM   #9
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
@linishjacob88:
In addition to setting CDPATH variable, you can also learn about types of paths i.e. absolute and relative paths (see here).
Code:
~$ pwd
/home/user
~$ cd ./some_directory    ## Use of relative path i.e. equivalent to /home/user/some_directory
Also you can:
Code:
~$ cd /home/user
~$ cd ~   ## Same as /home/user
 
Old 04-27-2013, 11:31 PM   #10
linishjacob88
LQ Newbie
 
Registered: Jan 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks all for your valued information.@unSpawn,@mddesai,@shivaa....Let me try..
 
  


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
Port Enquery _ AsiF Linux - Networking 2 11-20-2006 06:56 AM


All times are GMT -5. The time now is 10:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration