bash alias disappears when opening new terminal [duplicate]










0















This question already has an answer here:



  • About .bash_profile, .bashrc, and where should alias be written in? [duplicate]

    4 answers



im setting up a new alias by typing this command:



vi ~/.bashrc 


and then placing my alias:



alias school='ssh -Y username@linux.student.cs.uwaterloo.ca'


followed by exiting the file using: wq



however when i close my terminal and open my terminal, i get a "command can't be found." error message.



if i type source ~/.bash_aliases, it will work, the alias will work, but when i open a new terminal it won't.



is my .bashrc supposed to be empty when i vi into it?










share|improve this question















marked as duplicate by melpomene, shellter, codeforester, l0b0, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 5:51


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    What's the exact error message you get?
    – melpomene
    Nov 12 '18 at 22:25






  • 1




    so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
    – Kamil Cuk
    Nov 12 '18 at 22:41










  • See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
    – codeforester
    Nov 12 '18 at 23:50
















0















This question already has an answer here:



  • About .bash_profile, .bashrc, and where should alias be written in? [duplicate]

    4 answers



im setting up a new alias by typing this command:



vi ~/.bashrc 


and then placing my alias:



alias school='ssh -Y username@linux.student.cs.uwaterloo.ca'


followed by exiting the file using: wq



however when i close my terminal and open my terminal, i get a "command can't be found." error message.



if i type source ~/.bash_aliases, it will work, the alias will work, but when i open a new terminal it won't.



is my .bashrc supposed to be empty when i vi into it?










share|improve this question















marked as duplicate by melpomene, shellter, codeforester, l0b0, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 5:51


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    What's the exact error message you get?
    – melpomene
    Nov 12 '18 at 22:25






  • 1




    so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
    – Kamil Cuk
    Nov 12 '18 at 22:41










  • See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
    – codeforester
    Nov 12 '18 at 23:50














0












0








0








This question already has an answer here:



  • About .bash_profile, .bashrc, and where should alias be written in? [duplicate]

    4 answers



im setting up a new alias by typing this command:



vi ~/.bashrc 


and then placing my alias:



alias school='ssh -Y username@linux.student.cs.uwaterloo.ca'


followed by exiting the file using: wq



however when i close my terminal and open my terminal, i get a "command can't be found." error message.



if i type source ~/.bash_aliases, it will work, the alias will work, but when i open a new terminal it won't.



is my .bashrc supposed to be empty when i vi into it?










share|improve this question
















This question already has an answer here:



  • About .bash_profile, .bashrc, and where should alias be written in? [duplicate]

    4 answers



im setting up a new alias by typing this command:



vi ~/.bashrc 


and then placing my alias:



alias school='ssh -Y username@linux.student.cs.uwaterloo.ca'


followed by exiting the file using: wq



however when i close my terminal and open my terminal, i get a "command can't be found." error message.



if i type source ~/.bash_aliases, it will work, the alias will work, but when i open a new terminal it won't.



is my .bashrc supposed to be empty when i vi into it?





This question already has an answer here:



  • About .bash_profile, .bashrc, and where should alias be written in? [duplicate]

    4 answers







bash alias






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 23:53









codeforester

17.5k83864




17.5k83864










asked Nov 12 '18 at 22:24









SqR_08SqR_08

1




1




marked as duplicate by melpomene, shellter, codeforester, l0b0, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 5:51


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by melpomene, shellter, codeforester, l0b0, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 5:51


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1




    What's the exact error message you get?
    – melpomene
    Nov 12 '18 at 22:25






  • 1




    so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
    – Kamil Cuk
    Nov 12 '18 at 22:41










  • See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
    – codeforester
    Nov 12 '18 at 23:50













  • 1




    What's the exact error message you get?
    – melpomene
    Nov 12 '18 at 22:25






  • 1




    so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
    – Kamil Cuk
    Nov 12 '18 at 22:41










  • See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
    – codeforester
    Nov 12 '18 at 23:50








1




1




What's the exact error message you get?
– melpomene
Nov 12 '18 at 22:25




What's the exact error message you get?
– melpomene
Nov 12 '18 at 22:25




1




1




so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
– Kamil Cuk
Nov 12 '18 at 22:41




so .bashrc is not sourced when you login. Search for .bash_bashrc or .bash_profile or .profile etc.
– Kamil Cuk
Nov 12 '18 at 22:41












See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
– codeforester
Nov 12 '18 at 23:50





See lhunath's very useful answer to understand how these things work: About .bash_profile, .bashrc, and where should alias be written in?.
– codeforester
Nov 12 '18 at 23:50













1 Answer
1






active

oldest

votes


















0














The reason your alias is getting lost is because you dont have your bashrc sourced in a new terminal.



Same will happen even if you create a new alias file and source it in bashrc because its scope gets limited to the terminal you are editing in.



What you can do is logout once and then log in back so that bashrc entries gets updated for your user account or you can source in each terminal by typing



source ~/.bashrc


By adding the same entry to '''.profile''' you are making sure the alias is set on each system boot.



So its better to set the alias in .bashrc rather than .profile



Another major point to nite here is to make sure you dont delete anything in bashrc since that will do catastrophic changes to you session.






share|improve this answer




















  • is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
    – SqR_08
    Nov 14 '18 at 2:43










  • As i commented in my answer you do a logout/login session and that should work for you.
    – Amit Bhardwaj
    Nov 14 '18 at 10:56










  • how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
    – SqR_08
    Nov 15 '18 at 18:28

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The reason your alias is getting lost is because you dont have your bashrc sourced in a new terminal.



Same will happen even if you create a new alias file and source it in bashrc because its scope gets limited to the terminal you are editing in.



What you can do is logout once and then log in back so that bashrc entries gets updated for your user account or you can source in each terminal by typing



source ~/.bashrc


By adding the same entry to '''.profile''' you are making sure the alias is set on each system boot.



So its better to set the alias in .bashrc rather than .profile



Another major point to nite here is to make sure you dont delete anything in bashrc since that will do catastrophic changes to you session.






share|improve this answer




















  • is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
    – SqR_08
    Nov 14 '18 at 2:43










  • As i commented in my answer you do a logout/login session and that should work for you.
    – Amit Bhardwaj
    Nov 14 '18 at 10:56










  • how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
    – SqR_08
    Nov 15 '18 at 18:28















0














The reason your alias is getting lost is because you dont have your bashrc sourced in a new terminal.



Same will happen even if you create a new alias file and source it in bashrc because its scope gets limited to the terminal you are editing in.



What you can do is logout once and then log in back so that bashrc entries gets updated for your user account or you can source in each terminal by typing



source ~/.bashrc


By adding the same entry to '''.profile''' you are making sure the alias is set on each system boot.



So its better to set the alias in .bashrc rather than .profile



Another major point to nite here is to make sure you dont delete anything in bashrc since that will do catastrophic changes to you session.






share|improve this answer




















  • is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
    – SqR_08
    Nov 14 '18 at 2:43










  • As i commented in my answer you do a logout/login session and that should work for you.
    – Amit Bhardwaj
    Nov 14 '18 at 10:56










  • how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
    – SqR_08
    Nov 15 '18 at 18:28













0












0








0






The reason your alias is getting lost is because you dont have your bashrc sourced in a new terminal.



Same will happen even if you create a new alias file and source it in bashrc because its scope gets limited to the terminal you are editing in.



What you can do is logout once and then log in back so that bashrc entries gets updated for your user account or you can source in each terminal by typing



source ~/.bashrc


By adding the same entry to '''.profile''' you are making sure the alias is set on each system boot.



So its better to set the alias in .bashrc rather than .profile



Another major point to nite here is to make sure you dont delete anything in bashrc since that will do catastrophic changes to you session.






share|improve this answer












The reason your alias is getting lost is because you dont have your bashrc sourced in a new terminal.



Same will happen even if you create a new alias file and source it in bashrc because its scope gets limited to the terminal you are editing in.



What you can do is logout once and then log in back so that bashrc entries gets updated for your user account or you can source in each terminal by typing



source ~/.bashrc


By adding the same entry to '''.profile''' you are making sure the alias is set on each system boot.



So its better to set the alias in .bashrc rather than .profile



Another major point to nite here is to make sure you dont delete anything in bashrc since that will do catastrophic changes to you session.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 5:32









Amit BhardwajAmit Bhardwaj

1638




1638











  • is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
    – SqR_08
    Nov 14 '18 at 2:43










  • As i commented in my answer you do a logout/login session and that should work for you.
    – Amit Bhardwaj
    Nov 14 '18 at 10:56










  • how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
    – SqR_08
    Nov 15 '18 at 18:28
















  • is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
    – SqR_08
    Nov 14 '18 at 2:43










  • As i commented in my answer you do a logout/login session and that should work for you.
    – Amit Bhardwaj
    Nov 14 '18 at 10:56










  • how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
    – SqR_08
    Nov 15 '18 at 18:28















is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
– SqR_08
Nov 14 '18 at 2:43




is there a way to make my alias permanent instead of doing "source ~/.bashrc" every time?
– SqR_08
Nov 14 '18 at 2:43












As i commented in my answer you do a logout/login session and that should work for you.
– Amit Bhardwaj
Nov 14 '18 at 10:56




As i commented in my answer you do a logout/login session and that should work for you.
– Amit Bhardwaj
Nov 14 '18 at 10:56












how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
– SqR_08
Nov 15 '18 at 18:28




how exactly do i logout/login? i closed the terminal, opened a new one and it didnt work. also tried restarting my computer
– SqR_08
Nov 15 '18 at 18:28



這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto