Announcement

Collapse
No announcement yet.

How do I create aliases?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • michel
    replied
    I did an alias for su=sudo -i and another reload='source ~/.bash_aliases'

    Thanks to all.

    Michel

    Leave a comment:


  • james147
    replied
    Originally posted by kubicle View Post
    I take it the difference is reading the various profile files or not.
    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.

    Leave a comment:


  • kubicle
    replied
    Originally posted by james147 View Post
    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.
    I take it the difference is reading the various profile files or not.

    Leave a comment:


  • kubicle
    replied
    Originally posted by michel View Post
    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.
    You can just do something like:
    Code:
    echo "alias su='sudo -i'" >> ~/.bash_aliases
    which will create your first alias and the file ~/.bash_aliases (if it doesn't exist).
    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.

    Leave a comment:


  • james147
    replied
    Originally posted by kubicle View Post
    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.
    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.

    Leave a comment:


  • michel
    replied
    Originally posted by Snowhog View Post
    Take a look at your .bashrc file. You will see:
    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
    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.

    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 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.

    Thanks to all the other feedback and clarifications.

    Michel

    Leave a comment:


  • kubicle
    replied
    Originally posted by michel View Post
    what is the su alias you both agree to.
    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.
    Last edited by kubicle; Nov 24, 2012, 10:16 PM.

    Leave a comment:


  • Snowhog
    replied
    One I use a lot, and in my .bash_aliases, is:

    alias a='clear && alias | more'

    Leave a comment:


  • whatthefunk
    replied
    Originally posted by Snowhog View Post
    Mine is: alias ua='source ~/.bash_aliases'

    Most of my aliases use less keystrokes (saves time) than the actual command.
    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.

    Leave a comment:


  • Snowhog
    replied
    Mine is: alias ua='source ~/.bash_aliases'

    Most of my aliases use less keystrokes (saves time) than the actual command.

    Leave a comment:


  • whatthefunk
    replied
    Originally posted by Snowhog View Post
    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:
    Code:
    source ~/.bash_aliases
    I make that an alias.
    alias reload='source ~/.bashrc'

    Leave a comment:


  • vinnywright
    replied
    Originally posted by Snowhog View Post
    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:
    Code:
    source ~/.bash_aliases
    live and learn , nice

    VINNY

    Leave a comment:


  • Snowhog
    replied
    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
    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:
    Code:
    source ~/.bash_aliases

    Leave a comment:


  • vinnywright
    replied
    Originally posted by Snowhog View Post
    Take a look at your .bashrc file. You will see:
    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
    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.

    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

    Leave a comment:


  • Snowhog
    replied
    Take a look at your .bashrc file. You will see:
    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
    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.

    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.

    Leave a comment:

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X