
10 handy Bash aliases for Linux - jhibbets
https://opensource.com/article/18/9/handy-bash-aliases
======
BeetleB
From HN Guidelines:

If the original title begins with a number or number + gratuitous adjective,
we'd appreciate it if you'd crop it. E.g. translate "10 Ways To Do X" to "How
To Do X," and "14 Amazing Ys" to "Ys." Exception: when the number is
meaningful, e.g. "The 5 Platonic Solids."

~~~
jhibbets
Noted.

------
LinuxBender
Here is one that should reset your terminal after accidentally reading a
binary file, in most cases. Some of these are different on linux vs. unix vs.
mac. You could put these in a file in /etc/profile.d/ or in your ~/.bashrc

    
    
        alias fix='reset; stty sane; tput rs1; clear; echo -e "\033c"'
    

List only directories:

    
    
        alias lsd='ls -h -b --color=auto -d */'
    

List by size:

    
    
        alias lss='ls -Ao --sort=s'
    

Hand dyslexia, or the alternate to installing "sl"

    
    
        alias sl=ls
        alias xit=exit
        alias moer="more"
        alias mroe="more"
    

Long PS

    
    
        alias p="ps -Hefcwww"
    

Shorthand for disk and memory usage:

    
    
        alias f="df -Ph;free -m"
    

Bash function to display colors:

    
    
        function colors()
        {
        for fgbg in 38 48 ; do
        for color in {0..256} ; do
        echo -en "\e[${fgbg};5;${color}m ${color}\t\e[0m"
        if [ $((($color + 1) % 10)) == 0 ] ; then
        echo
        fi
        done
        echo
        done
        }
    

Functions to do rot13 and rot47 to get around word filters

    
    
        function rot13() { if [ -r $1 ]; then cat $1 | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; else echo $* | tr '[N-ZA-Mn-za-m5-90-4]' '[A-Za-z0-9]'; fi }
        function rot47() { if [ -r $1 ]; then cat $1 | tr '\!-~' 'P-~\!-O' ; else echo $* | tr '\!-~' 'P-~\!-O'; fi }
    
    

A couple of memory stat functions

    
    
        function memfree() {
        free|awk '/^Mem/ {printf "%4.1f",($2-$4-$6-$7)/$2*100}'
        }
    
        function memperuser() {
        ps aux | awk 'NR != 1 {x[$1] += $4} END{ for(z in x) {print z, x[z]"%"}}'
        }

------
nieve
These are pretty neat, but weirdly uninformed on some things .

If you're using GNU tar the alias should just be "tar -xvf" since it can
autodetect compression (though I'm not sure if that's suffix-based or file
type). This also means you can append your own -j or whatever for different
compression types if you need to do so manually.

Specifying "wget -c" does not mean you'll be able to resume if something goes
wrong, it forces resumption from a partial file you already have on a
subsequent invocation. The reason to specify it on the first invocation is
just so that you can be lazy and reuse that command line.

The shasum command is from Perl on most (all?) platforms, sha256sum from GNU
coreutils or equivalent may be needed if it's missing and may have higher
performance.

Probably most importantly, ipconfig is OS and distro-specific. It was missing
on the first linux systems I checked (Ubuntu and openSUSE). It's useful, but
it's a bit like listing a launchctl alias without specifying it's largely
macOS-specific.

------
coderobe
This article covers gems like `alias c='clear'` - very handy! scnr

~~~
lousken
I prefer ctrl+L

~~~
MaxBarraclough
They're not quite equivalent. `clear` clears the scroll-buffer, but ctrl+l
doesn't, it just clears the screen.

ctrl+l is generally the one I want.

