Post

My Bash Aliases

to edit bash, must be in /home

1
nano .bashrc

to load new edits into bash

1
source .bashrc

clear screen, windows command
1
alias cls='clear'
put the apt update and upgrade in one command, creates a dated log file
1
alias update='sudo apt update && sudo apt upgrade -y 2>&1 | tee ~/.loggy/"$(date +%F-%S)-upgrade.log" '
search apt for packages
1
alias pksearch='sudo apt search'
typical cleanup commands
1
alias cleanup='sudo apt autoremove && sudo apt autoclean && sudo apt clean'
automatically set to resume partially downloaded file
1
alias wget='wget -c'
executes neofetch
1
alias nn='neofetch'
displays system information and current dns
1
alias ii='inxi -b -A -i && nmcli dev show | grep 'IP4.DNS' '
systemctl start
1
alias sstart='sudo systemctl start'
systemctl stop
1
alias sstop='sudo systemctl stop'
systemctl restart
1
alias srestart='sudo systemctl restart' 
systemctl status
1
alias sstatus='sudo systemctl status'
ping tester with log file
1
alias pingtest='ping -i 1 -s 1472 8.8.8.8 | while read line; do echo "$(date "+%Y-%m-%d %H:%M:%S") - $line"; done | tee -a ~/logs/"$(date "+%F")-ping.log"'
local ip address
1
alias myip="ip -o -4 addr show | awk '{print \$2, \$4}'"
get your current public ip with command pubip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pubip() {
    # Define the API URL (you can change it if needed)
    local api_url="http://ipinfo.io/json"
    
    # Fetch data using curl and parse it with jq
    if command -v jq >/dev/null 2>&1; then
        # Ensure jq is installed
        curl -s "$api_url" | jq -r '
            "IP: \(.ip)",
            "Hostname: \(.hostname)",
            "City: \(.city)",
            "Region: \(.region)",
            "Country: \(.country)",
            "Org: \(.org)"
        '
    else
        echo "jq is required but not installed. Install jq and try again."
    fi
}
This post is licensed under CC BY 4.0 by the author.