I did an alias for su=sudo -i and another reload='source ~/.bash_aliases'
Thanks to all.
Michel
Announcement
Collapse
No announcement yet.
How do I create aliases?
Collapse
This topic is closed.
X
X
-
Basically, possibly some pam related stuff but I am not entirely sure... the difference on a default kubuntu install is very minimal though, you only really need to worry about this (and probably already understand more about it) if you customise the login process at all.Originally posted by kubicle View PostI take it the difference is reading the various profile files or not.
- Top
- Bottom
Leave a comment:
-
I take it the difference is reading the various profile files or not.Originally posted by james147 View PostAnother difference is -i starts a full login shell, -s only starts an interactive shell... This makes most difference when you have customised the shell login some how over just the interactive starting.
- Top
- Bottom
Leave a comment:
-
You can just do something like:Originally posted by michel View PostThanks for the clarifications I get most of it except the saving as .bash_aliases if you could give a concrete example I would appreciate it.
which will create your first alias and the file ~/.bash_aliases (if it doesn't exist).Code:echo "alias su='sudo -i'" >> ~/.bash_aliases
You can then edit the file with a text editor or use another echo command to add additional aliases. Remember to 'source ~/.bash_aliases' or restart your shell for your new aliases to take effect.
- Top
- Bottom
Leave a comment:
-
Another difference is -i starts a full login shell, -s only starts an interactive shell... This makes most difference when you have customised the shell login some how over just the interactive starting.Originally posted by kubicle View PostThe immediately apparent difference between 'sudo -sH' and 'sudo -i' is the $PWD, the former keeps the current working directory (comparable to 'su') while the latter switches to root's home directory (comparable to 'su -', 'su -l' or 'su --login')...of course you can set an alias for both.
- Top
- Bottom
Leave a comment:
-
Thanks for the clarifications I get most of it except the saving as .bash_aliases if you could give a concrete example I would appreciate it.Originally posted by Snowhog View PostTake a look at your .bashrc file. You will see:
When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.Code:# Alias definitions.# You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:
alias name=command
This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
Thanks to all the other feedback and clarifications.
Michel
- Top
- Bottom
Leave a comment:
-
The immediately apparent difference between 'sudo -sH' and 'sudo -i' is the $PWD, the former keeps the current working directory (comparable to 'su') while the latter switches to root's home directory (comparable to 'su -', 'su -l' or 'su --login')...of course you can set an alias for both.Originally posted by michel View Postwhat is the su alias you both agree to.Last edited by kubicle; Nov 24, 2012, 10:16 PM.
- Top
- Bottom
Leave a comment:
-
One I use a lot, and in my .bash_aliases, is:
alias a='clear && alias | more'
- Top
- Bottom
Leave a comment:
-
I try to do that to, but more importantly I need something I can remember. reload is easy to remember and is still shorter that the original command. I used to try to make very short commands, but couldnt remember them and got confused alot.Originally posted by Snowhog View PostMine is: alias ua='source ~/.bash_aliases'
Most of my aliases use less keystrokes (saves time) than the actual command.
- Top
- Bottom
Leave a comment:
-
Mine is: alias ua='source ~/.bash_aliases'
Most of my aliases use less keystrokes (saves time) than the actual command.
- Top
- Bottom
Leave a comment:
-
I make that an alias.Originally posted by Snowhog View PostYou don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:
Code:source ~/.bash_aliases
alias reload='source ~/.bashrc'
- Top
- Bottom
Leave a comment:
-
live and learn , niceOriginally posted by Snowhog View PostYou don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:
Code:source ~/.bash_aliases
VINNY
- Top
- Bottom
Leave a comment:
-
You don't even have to do that. If you edit .bash_aliases while in a console, when finished and the file is closed, just type:Originally posted by vinnywright View Post
yes this is working out just fine ......did not even half to log out after making the .bash_aliases file with one alias per line ,just close and reopen the terminal .
VINNY
Code:source ~/.bash_aliases
- Top
- Bottom
Leave a comment:
-
Originally posted by Snowhog View PostTake a look at your .bashrc file. You will see:
When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.Code:# Alias definitions.# You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:
alias name=command
This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
yes this is working out just fine ......did not even half to log out after making the .bash_aliases file with one alias per line ,just close and reopen the terminal .
VINNY
- Top
- Bottom
Leave a comment:
-
Take a look at your .bashrc file. You will see:
When present in your home directory. the .bash_aliases file will be used. It is better to put your custom aliases in this file, rather than adding them to .bashrc.Code:# Alias definitions.# You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
Creating the .bash_aliases file is simple. Just use your favorite text editor and save it as .bash_aliases (note the leading period). The syntax for a basic alias takes the form:
alias name=command
This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word.
- Top
- Bottom
Leave a comment:
Users Viewing This Topic
Collapse
There are 0 users viewing this topic.
Leave a comment: