Alias a tool for shortening long commands

Discussion in 'Linux' started by Abarbarian, Sep 2, 2018.

  1. Abarbarian

    Abarbarian Acruncher

    Joined:
    Sep 30, 2005
    Likes Received:
    839
    Location:
    By a river
    How to Create Aliases for Customizing Commands in Ubuntu

    If you are new to linux then one useful tool to make life easier is the alias tool. The example in the article shows how to simplify a long command to a short usable one.

    Here are a few of my own aliases.

    Code:
    alias sudo="sudo " #Create an alias for sudo with a space at the end then all other aliases will work with #sudo.
    
    alias   w7="sudo mount /dev/nvme0n1p3 /mnt"
    
    alias   w7u="sudo umount /dev/nvme0n1p3"
    
    alias  ls="ls --color=auto"
    
    alias    x="startx"
    
    alias  pacu="pacaur -Syu"
    
    alias  paci="pacaur -S"
    
    alias  pacr="pacaur -Rns"
    
    alias  pacq="pacaur -Q"
    
    alias pacor="pacaur -Rns $(pacman -Qtdq)"
    
    alias  rbs="firejail --private --dns=8.8.8.8 --dns=8.8.4.4 firefox -no-remote"
    
    alias   gf="grim-fandango"
    
    alias   ha="hangman"
    
    alias   boa="flatpak run com.realm667.WolfenDoom_Blade_of_Agony"
    
    alias    ss="scrot -s"
    The first alias on my list is a very useful one to implement as it takes away the need to always input a password if some sudo command requires it.

    If you do make some aliases then always remember to,

    Code:
    $ source ~/.bashrc
    as your normal user to allow you to use the alias without having to reboot.

    :cool:
     
    Abarbarian, Sep 2, 2018
    #1
    Ian and Abraham Andres Luna like this.
    1. Advertisements

  2. Abarbarian

    Ian Administrator

    Joined:
    Feb 23, 2002
    Likes Received:
    864
    A handy tip - I didn't know this was possible!

    I often have to run the same long commands on one of the servers, so this is going to save me a lot of typing :).
     
    Ian, Sep 4, 2018
    #2
    1. Advertisements

  3. Abarbarian

    Abarbarian Acruncher

    Joined:
    Sep 30, 2005
    Likes Received:
    839
    Location:
    By a river
    You can do some pretty clever stuff with alisa's. Here are some more articles with some complicated examples.

    https://shapeshed.com/unix-alias/
    http://www.linuxhowtos.org/Tips and Tricks/command_aliases.htm


    http://www.linfo.org/alias.html

    Bash Shell Temporarily Disable an Alias

    Bash aliases not running or working over ssh client on Unix based system

    30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X

    Hope some of that is useful to folks. The articles contain most information that an ordinary user would likely need with some more complicated information for folk running servers and remotely accessible pc's.

    :cool:
     
    Abarbarian, Sep 5, 2018
    #3
    Ian likes this.
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.