pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

20220311-make_me_a_sandwich.md (833B)


      1 #### TL;DR
      2 Alias to allow aliases with `sudo`
      3 ```
      4 alias sudo='sudo '
      5 ```
      6 
      7 ---
      8 
      9 I am a big fan of using command aliases on my Linux systems.  If you are too you may have also been hit by the `command not found` error when attempting to run `sudo <alias>`.
     10 
     11 As an example I have an alias for `ls`, which is based on the `ll` alias common on Red Hat systems
     12 ```
     13 alias ll='ls -lahF --color=auto'
     14 ```
     15 
     16 If you try to run as sudo it won't work
     17 ```
     18 sudo ll
     19 sudo: ll: command not found
     20 ```
     21 
     22 We can change that by adding another alias
     23 ```
     24 alias sudo='sudo '
     25 ```
     26 
     27 Now we can run our aliases as sudo.  This also works for `unbuffer`, which as I mentioned in [a previous post](20220303-unbuff_colours.html) doesn't recognise aliases.
     28 ```
     29 alias unbuffer='unbuffer '
     30 unbuffer ap playbook.yml | tee results.out
     31 ```
     32 
     33 Do you have any fun alias hacks?