LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-02-2014, 10:43 AM   #1
rupeshforu3
Member
 
Registered: Jun 2013
Location: India
Distribution: any Linux, BSD, Solaris, sco unixware, Windows 8
Posts: 59

Rep: Reputation: 0
How to create alias to change to sub directory in Debian wheezy


Hi recently I have installed Debian wheezy on my laptop.

I have created a local account practice and after that I have login to the above account.

After that I have created a directory programs under that a directory called c.

In order to create alias to change the working directory I have added the following the alias to .bashrc file

Code:
alias c="cd  /practice/programs/c"
I have logout and login.

Now when I issue the command c at terminal it is displaying message as /home/practice/programs/c is a directory and nothing else.

I have even delted the above alias from .bashrc file and added the same to .bash_aliases file even no use I am getting the same message.

Kindly suggest the solution.

Regards,
Rupesh.
 
Old 09-02-2014, 11:04 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
alias c="cd ~/practice/programs/c"
c
pwd
/home/jj/practice/programs/c
you can 'practice" without logout|in using the c-line as shown.
You're missing the ~ unless you meant to cd to /practice and not /home/practice.

Code:
alias c="cd $HOME/practice/programs/c"
is just as good.
 
Old 09-02-2014, 12:05 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rupeshforu3 View Post
Hi recently I have installed Debian wheezy on my laptop. I have created a local account practice and after that I have login to the above account. After that I have created a directory programs under that a directory called c. In order to create alias to change the working directory I have added the following the alias to .bashrc file
Code:
alias c="cd  /practice/programs/c"
I have logout and login. Now when I issue the command c at terminal it is displaying message as /home/practice/programs/c is a directory and nothing else. I have even delted the above alias from .bashrc file and added the same to .bash_aliases file even no use I am getting the same message.
A very brief Google search for "how to set up a bash alias in linux" tells you lots:
http://www.hypexr.org/bash_tutorial.php#alias
http://www.stchman.com/alias.html

You need to have the command in single-quotes, not double, and have it in .bashrc. Did you try to look for any examples on how to do what you're after? And Habitual pointed out that unless the /practice/programs/c directory is from the root level, it won't find it, since you created it under your home directory.
 
Old 09-02-2014, 12:07 PM   #4
rupeshforu3
Member
 
Registered: Jun 2013
Location: India
Distribution: any Linux, BSD, Solaris, sco unixware, Windows 8
Posts: 59

Original Poster
Rep: Reputation: 0
Thanks the issue is solved.
 
Old 09-02-2014, 01:02 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by rupeshforu3 View Post
Thanks the issue is solved.
Great...so how about posting what you did, so that others can benefit??? What was the solution? What worked for you???
 
Old 09-02-2014, 08:56 PM   #6
rupeshforu3
Member
 
Registered: Jun 2013
Location: India
Distribution: any Linux, BSD, Solaris, sco unixware, Windows 8
Posts: 59

Original Poster
Rep: Reputation: 0
I have made a mistake ie., I forgotten to place cd in alias statement and after placing cd in alias statement it is working.
 
  


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
[SOLVED] Mapping a Network Drive (LS421DE) to a Debian Wheezy Directory bruceam Linux - Networking 1 08-03-2014 05:20 AM
[SOLVED] Lightdm - cannot figure out how to change default xsession - Debian Wheezy ratman1 Linux - Newbie 9 05-23-2013 05:00 AM
Creating user accounts from a csv file, force to change password and create alias rojasm Linux - Newbie 13 04-02-2013 10:19 PM
[SOLVED] I would like to create an alias that tells me the current directory I am in... BMan8577 Linux - Newbie 5 12-12-2011 11:28 PM
LXer: How To Create A Debian Wheezy (Testing) OpenVZ Template LXer Syndicated Linux News 0 09-15-2011 02:30 PM

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

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