LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 01-18-2012, 01:08 AM   #1
abi
LQ Newbie
 
Registered: Jan 2012
Posts: 12

Rep: Reputation: Disabled
Can I give names to folder paths to navigate through them easily??


Can I give names to folder paths so that when ever i need to go to that path i need not have to give the whole folder path again and again ,instead give a simple name which would take me to that path ??

eg:/usr/local/bkp/folder1/old_files/graphics_project/

contains 3 folders graphic1,graphic2,graphic3.

so every time i need to access any of these(graphic1,graphic2,graphic3.) folders i need to go through all those folder paths ie: cd /usr/local/bkp/folder1/old_files/graphics_project/

instead can i give a name which will automatically take me to graphic1,graphic2,graphic3.
 
Old 01-18-2012, 01:31 AM   #2
xylos
LQ Newbie
 
Registered: Oct 2011
Location: USA
Distribution: Backtrack 5, Ubuntu 11.10, Linux Mint 12, Cyanogen Mod 7, FreeBSD 9.0
Posts: 17

Rep: Reputation: Disabled
Try this:

alias graphic1='cd /usr/local/bkp/folder1/old_files/graphics_project/graphic1'



Then you can switch to that directory by just typing:

$ graphic1

Or you could just create links, like this:
$ link -s /usr/local/bkp/folder1/old_files/graphics_project/graphic1 /tmp/graphic1
$ cd /tmp/graphic1

Last edited by xylos; 01-18-2012 at 01:33 AM. Reason: Amplifying information
 
1 members found this post helpful.
Old 01-18-2012, 01:39 AM   #3
kishore_ari
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Rep: Reputation: 5
Hi abi,
you can use alias command to create aliases for your self as shown in the below example.
-bash-4.2$ alias grahics1='cd /tmp'
-bash-4.2$ grahics1
-bash-4.2$ pwd
/tmp
-bash-4.2$ alias grahics1
alias grahics1='cd /tmp'

I hope this meets your requirement.
 
Old 01-18-2012, 03:42 AM   #4
abi
LQ Newbie
 
Registered: Jan 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Can I give names to folder paths to navigate through them easily??

I tried this way but found the following.

[kamath@samhrd-4150 usr]$ alias graphics1 = 'cd /usr/local/bkp/folder1/old_files/graphics_project/graphic1'
bash: alias: graphics1: not found
bash: alias: =: not found
bash: alias: 'cd /usr/local/bkp/folder1/old_files/graphics_project/graphic1': not found
[kamath@samhrd-4150 usr]$
 
Old 01-18-2012, 04:34 AM   #5
kishore_ari
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Rep: Reputation: 5
abi,

try this alias graphics1='cd /usr/local/bkp/folder1/old_files/graphics_project/graphic1' instead of alias graphics1 = 'cd /usr/local/bkp/folder1/old_files/graphics_project/graphic1'.

The difference between both is a simple space.
 
1 members found this post helpful.
Old 01-18-2012, 06:59 AM   #6
jithindevasia
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Rep: Reputation: Disabled
Thanks for the tips
 
Old 01-18-2012, 08:33 AM   #7
abi
LQ Newbie
 
Registered: Jan 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Can I give names to folder paths to navigate through them easily??

Thanks all, that has helped and i am able to give alias names.But when i open a new terminal and give the alias name i am not able to get to that path

eg: this i did after taking new terminal.

[kamath@samhrd-4150 usr]$ graphics1
bash: graphics1: command not found...


is there any way that i can permanently mark those alias so that it works in new terminals also??
ie when i give graphics1 command i should be able to go to /usr/local/bkp/folder1/old_files/graphics_project/graphic1
 
Old 01-18-2012, 08:41 AM   #8
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Debian
Posts: 201

Rep: Reputation: 36
Put the alias line inside your ~/.bashrc and it will be executed whenever you start a session.
 
1 members found this post helpful.
Old 01-18-2012, 08:51 AM   #9
abi
LQ Newbie
 
Registered: Jan 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
thanks all,it has worked.
 
Old 01-18-2012, 11:07 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
* Also see 'man bash' for CDPATH.
 
Old 01-18-2012, 11:25 AM   #11
lonesoac0
Member
 
Registered: Jan 2010
Distribution: Ubuntu
Posts: 94

Rep: Reputation: 4
Pretty sure that you can edit your .profile and have your own variables with full path names.

For example: music=/home/user_name/music/; export $music
videos="/home/user_name/folder with space must be in quotes/"; export $videos

Once you are done editing your .profile you can simply type
cd $music
This will change your directory to /home/user_name/music/

Last edited by lonesoac0; 01-18-2012 at 04:44 PM. Reason: more info
 
  


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
Unable to navigate to folder on server via browser SupremeUK Linux - Server 1 09-30-2011 06:29 AM
[SOLVED-BUT-STILL-THINKING] Is it possible to give ONE user MULTIPLE names ? essaion Linux - Server 4 04-20-2010 10:43 PM
Little bash script and file to give long (or any) directories short names WardXmodem Programming 1 11-23-2009 01:24 AM
Skype not working: How to easily give ALSA permission for users for a noob ? Xeratul Linux - General 1 11-27-2006 08:18 PM
copying files and give new unique names to each file by using xargs command gnim66 Programming 6 06-22-2005 09:29 PM


All times are GMT -5. The time now is 08:09 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