LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-11-2016, 08:17 AM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 452

Rep: Reputation: Disabled
In which file are aliases stored?


Hello,

please kindly help me to find the file where are alias stored.

I DO NOT wish to update the alias file using command:
alias something="command"
because when i do it and exit that VPS back to node server, it no longer works next day.

but i want to know which file need to be updated.

I will be adding this line:
alias whoowns '/scripts/whoowns '

Currently whoowns command do not works and i already added that line into files:

.bashrc
.cshrc
.tcshrc

At the end of "man alias" i see: "GNU Bash-4.0"

The OS is: CentOS release 6.7 (Final)

Last edited by postcd; 04-11-2016 at 08:20 AM.
 
Old 04-11-2016, 08:36 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
Aliases typically go into a file in your home directory that is executed once when you log in to your account.

They look like this:
Code:
alias lc='/usr/bin/clear; /bin/ls ${LS_OPTIONS} -aCF'
alias ll='/bin/ls ${LS_OPTIONS} -al'
alias cls='clear'
alias hi='history -${LINES}'
alias rs='eval `resize`'
(those are mine, yours will vary).

They can go into ./.profile if you want to cover all the bases (it is the first thing executed when you log in). You mention .cshrc in your post -- note that shell-compatible aliases (sh, BASH, KornShell) will not be compatible with C-Shell syntax (and vice-versa).

Hope this helps some.
 
Old 04-11-2016, 09:04 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,115

Rep: Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915
Quote:
Originally Posted by postcd View Post
Hello,
please kindly help me to find the file where are alias stored.

I DO NOT wish to update the alias file using command:
alias something="command"
because when i do it and exit that VPS back to node server, it no longer works next day.

but i want to know which file need to be updated.

I will be adding this line:
alias whoowns '/scripts/whoowns '

Currently whoowns command do not works and i already added that line into files:

.bashrc
.cshrc
.tcshrc

At the end of "man alias" i see: "GNU Bash-4.0" The OS is: CentOS release 6.7 (Final)
Here's something that should help:
http://lmgtfy.com/?q=how+to+add+alia...entos+6.7+bash

The very first link...of over 111,000.
 
Old 04-11-2016, 09:53 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Put your aliases on the VPS in /home/user/.myaliases
Put in /home/user/.bashrc
Code:
source /home/user/.myaliases
type
Code:
source /home/user/.bashrc
and your aliases from /home/user/.myaliases will show up and be present on re-connect to the VPS.

Do I have to explain that the "user" in /home/user is the ssh user?

3 Years... sad.

Last edited by Habitual; 04-11-2016 at 09:57 AM.
 
1 members found this post helpful.
Old 04-11-2016, 10:19 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,115

Rep: Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915Reputation: 5915
Quote:
Originally Posted by Habitual View Post
Put your aliases on the VPS in /home/user/.myaliases
Put in /home/user/.bashrc
Code:
source /home/user/.myaliases
type
Code:
source /home/user/.bashrc
and your aliases from /home/user/.myaliases will show up and be present on re-connect to the VPS.

Do I have to explain that the "user" in /home/user is the ssh user?
3 Years... sad.
Agreed.

However, your use of sourcing the .myaliases file isn't something I'd have thought of doing, and it makes sense. I'd just shovel things directly into my .bashrc file.
 
Old 04-11-2016, 10:44 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Agreed.

However, your use of sourcing the .myaliases file isn't something I'd have thought of doing, and it makes sense. I'd just shovel things directly into my .bashrc file.
My use of ".myaliases" is merely for the seemingly under-experienced.
The correct answer to "In which file are aliases stored?" is any where you choose.

I use to have a need to reconcile moving targets, and in my case, my alias file actually contain the
"ssh -i key user@dom.com" parameters for a few clients. Plus I'm very type A, and after years of a single .bashrc,
it just got to be too monolithic. So now I stick everything work-related in ".all.c9aliases" instead of listing them
all in .bashrc
Code:
# source /home/jj/.ssh/c9/hosts/c9.hosts
# source /home/jj/.ssh/c9/hosts/client1.hosts
# source /home/jj/.ssh/c9/hosts/client2.hosts
# source /home/jj/.ssh/c9/hosts/client3.hosts
# source /home/jj/.ssh/c9/hosts/client4.hosts
# source /home/jj/.ssh/c9/hosts/client5.hosts
# source /home/jj/.ssh/WSM/wsm.hosts
# source /home/jj/.ssh/c9/hosts/client6.hosts
# source /home/jj/.ssh/c9/hosts/client7.hosts
vs.
Code:
source /home/jj/.ssh/c9/all.c9aliases
I hope this serves to illustrate how flexible the options are.

Resources:
Code:
man bash
References:
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html
http://tldp.org/LDP/abs/html/aliases.html

Last edited by Habitual; 04-11-2016 at 10:49 AM.
 
Old 04-11-2016, 10:46 AM   #7
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,316

Rep: Reputation: Disabled
In addition alias whoowns '/scripts/whoowns ' will not work, unless you really have /scripts directory - you shouldn't.
 
Old 04-16-2016, 01:37 PM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,468
Blog Entries: 32

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
Member response

Hi,

From 'man bash';
Quote:
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of
~/.bashrc.
My preferences are to use '~/.bashrc' but you could use the '--rcfile file' option to insure the file you wish to use for the alias to be stored.

Hope this helps.
Have fun & enjoy!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] scp on the file stored in / shik28 Programming 15 09-20-2011 05:05 AM
wrap lines at 80 for long aliases in .aliases.csh jhwilliams Linux - Software 0 07-26-2007 08:49 AM
what file are routes stored in? hcclnoodles Solaris / OpenSolaris 6 10-04-2006 03:46 PM
where are global aliases stored? abs Slackware 5 08-27-2004 01:34 AM
not getting /etc/aliases file sixth_sense Linux - Networking 8 04-27-2004 03:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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