Show me your aliases and i'll show you mine ;-)

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
modele62
Level 2
Level 2
Posts: 64
Joined: Sun Apr 10, 2016 5:28 am

Show me your aliases and i'll show you mine ;-)

Post by modele62 »

Hi,

Aliases are a great way of turning often used slightly and complicated commands into short easy to use and remember ones.
Don't you think so ?
So why not share our favourite aliases ?

Here's some of mine (some need some extra package installation btw), would you share yours ?

Code: Select all

alias ..='cd ..'
alias ...='cd ../..'
alias B='upower -i /org/freedesktop/UPower/devices/battery_BAT0'
alias b='acpi -b'
alias bdf='df -HT'
alias bigdir='du -hsx * | sort -h'
alias bloc='grep BLOCK /var/log/ufw.log'
alias bootb='systemd-analyze blame'
alias bootc='systemd-analyze critical-chain'
alias bootl='journalctl --list-boots'
alias boott='systemd-analyze time'
alias cnx='netstat -ptu'
alias cnz='lsof -P -i -n'
alias cput='sudo sensors'
alias cronlog='cat /var/log/syslog* | grep -i cron'
alias dfh='df -aH'
alias dft='df -aHT'
alias dmod='find . -type d -exec chmod -v 750 {} \;'
alias dodo='sudo pm-suspend'
alias down='sudo systemctl poweroff'
alias dpath="echo $PATH | awk -v RS=: '1'"
alias dssh='grep sshd /var/log/auth.log'
alias dua='du -ach'
alias dus='du -abc | sort -n'
alias duu='du -hs'
alias edit='nano -m'
alias f1y='find . -type f -mtime +365 -exec ls -l {} \;'
alias fkrnl='cat /var/log/kern.log* | grep -i $1'
alias fmod='find . -type f -exec chmod -v 640 {} \;'
alias fresh='find -type f -mtime 0 -exec ls -altr {} \;'
alias fresh2='ls -alR --time-style="+%Y-%m-%d %H:%M" |grep `date +%Y-%m-%d`'
alias fsysl='cat /var/log/syslog* | grep -i $1'
alias h='history'
alias hiddend='find . -type d -iname ".*"'
alias hiddenf='find . -type f -iname ".*"'
alias hires='find . -type f -name *.flac -size +100M -exec ls -lh {} \;'
alias homenet='sudo nmap -PR -sP 192.168.0.1/24'
alias k9='kill -9 $1'
alias l='ls -CF'
alias la='ls -al --time-style="+%Y-%m-%d %H:%M"'
alias lah='ls -ahl --time-style="+%Y-%m-%d %H:%M"'
alias ld='ls -dl */'
alias ll='ls -l --time-style="+%Y-%m-%d %H:%M"'
alias lld='tree -d'
alias llf='ls -aF'
alias llh='ls -hl --time-style="+%Y-%m-%d %H:%M"'
alias loff='sudo /usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon/csd-backlight-helper --set-brightness 0 -b firmware -b platform -b raw'
alias lon='sudo /usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon/csd-backlight-helper --set-brightness 1000 -b firmware -b platform -b raw'
alias ls='ls --color=auto'
alias lsf='ls -F'
alias lt='ls -alrt --time-style="+%Y-%m-%d %H:%M"'
alias lupd='find . -type f -printf "%TY-%Tm-%Td %TT %p\n" | sort -r | head -50'
alias mt='mount | column -t'
alias nbF='tree |grep files'
alias nbf='ls -AlF | grep -v "/" | wc -l'
alias netlog='grep NetworkManager /var/log/syslog* |more'
alias nettst='mtr fsf.org'
alias pkgh='cat /var/log/dpkg.log* | grep " install " | sort -t " " -k1'
alias pkgi='apt show $1'
alias ploc='locate -d ~/data/plocate.db -i $1'
alias psl='ps aux | head -1 ; ps aux | grep -i $1'
alias pubip='curl https://ipinfo.io/ip'
alias rmf='rm -Irfv $1'
alias slog='cd /var/log'
alias sudo='sudo '
alias svlog='journalctl | grep -i $1'
alias svrst='sudo systemctl restart $1'
alias svstart='sudo systemctl start $1'
alias svstatus='systemctl status $1'
alias svstop='sudo systemctl stop $1'
alias topcpu='ps -eo pid,ppid,cmd,etime,%mem,%cpu --sort=-%cpu | head -50'
alias topmem='ps -eo pid,ppid,cmd,etime,%mem,%cpu --sort=-%mem | head -50'
alias wifil='nmcli -p device wifi'
alias woff='sudo ip link set dev wlp3s0 down'
alias won='sudo ip link set dev wlp3s0 up'
alias xmod='find . -type f -exec chmod 750 {} \;'
alias xxed='xed admin://$1'
alias zerok='find -type f -size 0'
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Nicolas

Custom laptop (i7 / 16 Gb RAM / 256 Gb NVMe + 2 Tb SSD) LM 21.2 Cinnamon, LM 21.2 XFCE, Fedora 39 KDE
Clevo W670 (i5 / 8 Gb RAM / 2 Tb SSHD) LM 20.3 XFCE
Acer Swift 1 (Pentium N4200 / 4 Gb RAM / 128 Gb SSD) LM 21.2 XFCE
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by rene »

modele62 wrote: Thu Jul 16, 2020 1:38 pm Aliases are a great way of turning often used slightly and complicated commands into short easy to use and remember ones. Don't you think so ?
No. I think they are a great way of forgetting how to use slightly complicated commands whenever you're not on your own system.
matrovska
Level 4
Level 4
Posts: 226
Joined: Tue Jan 21, 2020 3:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by matrovska »

I do not use a lot of aliases personalised

.bash_aliases

Code: Select all

alias c='clear'
alias grep='grep -i --color=auto'
alias fgrep='fgrep -i --color=auto'
alias egrep='egrep -i --color=auto'
alias ls='ls --color=auto --time-style=long-iso'
Linux Mint 21 Vanessa. Lenovo thinkpad T460
User avatar
Pippin
Level 4
Level 4
Posts: 441
Joined: Wed Dec 13, 2017 11:14 am
Location: The Shire

Re: Show me your aliases and i'll show you mine ;-)

Post by Pippin »

rene wrote: Thu Jul 16, 2020 5:07 pm No. I think they are a great way of forgetting how to use slightly complicated commands whenever you're not on your own system.
A simple

Code: Select all

cat .bash_aliases
will reveal the slightly complicated commands ;)

Code: Select all

# cat .bash_aliases

alias exit='systemctl stop openvpn-client@* && exit'
alias c='clear'
alias df='df --sync -hT'
alias ls='ls -ahl --color=auto'
alias free='free -htw'
alias ..='cd ..'
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm --preserve-root -v'
alias chmod='chmod -c'
alias chown='chown -c'
alias netstat='netstat -atunp'
alias dmesg='dmesg -Hw'
alias lsblk='lsblk -f'
alias lsmount='mount |column -t'
alias htop='htop -d 15'
alias whois='whois -B'
alias watch='watch -n1'
alias age='tune2fs -l /dev/sdb1 | grep "Filesystem created:"'

#Edits
alias nanodh='nano /etc/dhcp/dhclient.conf'
alias nanoalias='nano /root/.bash_aliases'
alias nanogrub='nano /etc/default/grub'
alias grepalias='grep backups /root/.bash_aliases'

#Other
alias extip='curl icanhazip.com'
alias intip='sh /root/intip.sh'
alias dnsip='sh /root/dnsip.sh'
alias maxmtu='sh maxmtu.sh'
alias pb=' | pastebinit'
alias gsmartup='sh /root/gsmartup.sh'

#Copy
alias cpkee='cp -up /home/pippin/pippin.kdbx /home/pippin/Data/backups/kpxc/pippin.kdbx'
alias cpcon='cp -up /etc/NetworkManager/system-connections/* /home/pippin/Data/backups/bu_connections/'
alias cpalias='cp -up /root/.bash_aliases /home/pippin/Data/backups/.bash_aliases'
alias cphist='cp -up /root/.bash_history /home/pippin/Data/backups/.bash_history'
alias cphex='cp -upr /home/pippin/.config/hexchat/scrollback/* /home/pippin/Data/backups/hexchat/scrollback/'
alias cpdesk='cp -upr /home/pippin/Desktop/* /home/pippin/Data/backups/Desktop/'
alias cpbook='cp -upr /home/pippin/.mozilla/firefox/mwad0hks.default/bookmarks.html /home/pippin/Data/backups/ff'

#SSH
alias sshnas='ssh -v admin@x.x.x.x -p xxxxx'
alias sshserver='ssh -v root@x.x.x.x -p xxxxx'

#NAS
alias udpup='systemctl start openvpn-client@443'
alias udpdown='systemctl stop openvpn-client@443'
alias udplog='cat /etc/openvpn/client/443.log'

alias tcpup='systemctl start openvpn-client@443tcp'
alias tcpdown='systemctl stop openvpn-client@443tcp'
alias tcplog='cat /etc/openvpn/client/443tcp.log'

#Proton
alias nl1up='systemctl start openvpn-client@nl1'
alias nl1down='systemctl stop openvpn-client@nl1'
alias nl1log='cat /etc/openvpn/client/nl1.log'

alias nl2up='systemctl start openvpn-client@nl2'
alias nl2down='systemctl stop openvpn-client@nl2'
alias nl2log='cat /etc/openvpn/client/nl2.log'

alias nl3up='systemctl start openvpn-client@nl3'
alias nl3down='systemctl stop openvpn-client@nl3'
alias nl3log='cat /etc/openvpn/client/nl3.log'

alias us1up='systemctl start openvpn-client@us1'
alias us1down='systemctl stop openvpn-client@us1'
alias us1log='cat /etc/openvpn/client/us1.log'

alias us2up='systemctl start openvpn-client@us2'
alias us2down='systemctl stop openvpn-client@us2'
alias us2log='cat /etc/openvpn/client/us2.log'

alias us3up='systemctl start openvpn-client@us3'
alias us3down='systemctl stop openvpn-client@us3'
alias us3log='cat /etc/openvpn/client/us3.log'

alias jp1up='systemctl start openvpn-client@jp1'
alias jp1down='systemctl stop openvpn-client@jp1'
alias jp1log='cat /etc/openvpn/client/jp1.log'

alias jp2up='systemctl start openvpn-client@jp2'
alias jp2down='systemctl stop openvpn-client@jp2'
alias jp2log='cat /etc/openvpn/client/jp2.log'

alias jp3up='systemctl start openvpn-client@jp3'
alias jp3down='systemctl stop openvpn-client@jp3'
alias jp3log='cat /etc/openvpn/client/jp3.log'
I gloomily came to the ironic conclusion that if you take a highly intelligent person and give them the best possible, elite education, then you will most likely wind up with an academic who is completely impervious to reality.
Halton Arp
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by rene »

Pippin wrote: Thu Jul 16, 2020 5:32 pm
rene wrote: Thu Jul 16, 2020 5:07 pm No. I think they are a great way of forgetting how to use slightly complicated commands whenever you're not on your own system.
A simple cat .bash_aliases will reveal the slightly complicated commands ;)
Clearly not when you're not on said own system.
modele62
Level 2
Level 2
Posts: 64
Joined: Sun Apr 10, 2016 5:28 am

Re: Show me your aliases and i'll show you mine ;-)

Post by modele62 »

No. I think they are a great way of forgetting how to use slightly complicated commands whenever you're not on your own system.
That may be a wise answer in a professional context, but we're on the Mint forum and thus talking about domestic usage aren't we ? :wink:
Nicolas

Custom laptop (i7 / 16 Gb RAM / 256 Gb NVMe + 2 Tb SSD) LM 21.2 Cinnamon, LM 21.2 XFCE, Fedora 39 KDE
Clevo W670 (i5 / 8 Gb RAM / 2 Tb SSHD) LM 20.3 XFCE
Acer Swift 1 (Pentium N4200 / 4 Gb RAM / 128 Gb SSD) LM 21.2 XFCE
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by rene »

Wise or not, it's certainly both my opinion and experience, and you explicitly asked. I'll otherwise though get out of the way of people posting lists...
User avatar
BenTrabetere
Level 7
Level 7
Posts: 1890
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: Show me your aliases and i'll show you mine ;-)

Post by BenTrabetere »

I highly recommend alias rm='rm -i'.
Patreon sponsor since August 2022
Image
Fuzzy
Level 4
Level 4
Posts: 251
Joined: Thu Jul 28, 2011 11:54 am

Re: Show me your aliases and i'll show you mine ;-)

Post by Fuzzy »

modele62 wrote: Fri Jul 17, 2020 12:30 am That may be a wise answer in a professional context, but we're on the Mint forum and thus talking about domestic usage aren't we ? :wink:
I utilize many computers, so count me in with the folks who would rather remember or otherwise document syntax/options.

Since we're talking about Mint in general; the pertinent file for LMDE users is ~/.bashrc instead of ~/.bash_alias isn't it?

Does non-Debian Mint list aliases when a user types

Code: Select all

alias
at the terminal? (It does in LMDE)

Fuzzy
User avatar
deck_luck
Level 7
Level 7
Posts: 1577
Joined: Mon May 27, 2019 6:57 pm
Location: R-4808 North

Re: Show me your aliases and i'll show you mine ;-)

Post by deck_luck »

Fuzzy wrote: Fri Jul 17, 2020 5:44 pm
Since we're talking about Mint in general; the pertinent file for LMDE users is ~/.bashrc instead of ~/.bash_alias isn't it?

Does non-Debian Mint list aliases when a user types

Code: Select all

alias
at the terminal? (It does in LMDE)

Fuzzy
It is common for the ~/.bashrc script to source the ~/.bash_aliases file. The ~/.bash_aliases file should contain user specific aliases.

The alias command is a builtin bash command. As long you are using bash as your shell, the alias command will display your bash aliases.

EDIT: .bashaliases instead of .bashalias
Last edited by deck_luck on Tue Jul 21, 2020 12:13 pm, edited 1 time in total.
🐧Linux Mint 20.3 XFCE (UEFI - Secure Boot Enabled) dual boot with Windows 11

Give a friend a fish, and you feed them for a day. Teach a friend how to fish, and you feed them for a lifetime. ✝️
modele62
Level 2
Level 2
Posts: 64
Joined: Sun Apr 10, 2016 5:28 am

Re: Show me your aliases and i'll show you mine ;-)

Post by modele62 »

rene wrote: Fri Jul 17, 2020 12:50 am Wise or not, it's certainly both my opinion and experience, and you explicitly asked. I'll otherwise though get out of the way of people posting lists...
Hi Rene,
Sorry but my question was: "would you share your aliases", and your answer is "i don't use aliases"...
Btw i'm working on linux machines for my job as well and as i'm not a sysadm i don't have the choice but use standard commands.
Last edited by modele62 on Sat Jul 18, 2020 3:31 am, edited 1 time in total.
Nicolas

Custom laptop (i7 / 16 Gb RAM / 256 Gb NVMe + 2 Tb SSD) LM 21.2 Cinnamon, LM 21.2 XFCE, Fedora 39 KDE
Clevo W670 (i5 / 8 Gb RAM / 2 Tb SSHD) LM 20.3 XFCE
Acer Swift 1 (Pentium N4200 / 4 Gb RAM / 128 Gb SSD) LM 21.2 XFCE
User avatar
Pippin
Level 4
Level 4
Posts: 441
Joined: Wed Dec 13, 2017 11:14 am
Location: The Shire

Re: Show me your aliases and i'll show you mine ;-)

Post by Pippin »

deck_luck wrote: Fri Jul 17, 2020 6:00 pm It is common for the ~/.bashrc script to source the ~/.bash_alias file. The ~/.bash_alias file should contain user specific aliases.
Little correction, it's ~/.bash_aliases
I gloomily came to the ironic conclusion that if you take a highly intelligent person and give them the best possible, elite education, then you will most likely wind up with an academic who is completely impervious to reality.
Halton Arp
Moonstone Man
Level 16
Level 16
Posts: 6054
Joined: Mon Aug 27, 2012 10:17 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by Moonstone Man »

modele62 wrote: Thu Jul 16, 2020 1:38 pm So why not share our favourite aliases ?
I have only one alias: alias oops='format C:'.
modele62
Level 2
Level 2
Posts: 64
Joined: Sun Apr 10, 2016 5:28 am

Re: Show me your aliases and i'll show you mine ;-)

Post by modele62 »

Kadaitcha Man wrote: Sat Jul 18, 2020 3:25 am
I have only one alias: alias oops='format C:'.
:lol:
Nicolas

Custom laptop (i7 / 16 Gb RAM / 256 Gb NVMe + 2 Tb SSD) LM 21.2 Cinnamon, LM 21.2 XFCE, Fedora 39 KDE
Clevo W670 (i5 / 8 Gb RAM / 2 Tb SSHD) LM 20.3 XFCE
Acer Swift 1 (Pentium N4200 / 4 Gb RAM / 128 Gb SSD) LM 21.2 XFCE
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by rene »

modele62 wrote: Sat Jul 18, 2020 2:08 am Sorry but my question was: "would you share your aliases"
See that question mark after the bit of your post I in fact quoted, as a customary method of indicating what precisely is being responded to? The "Don't you think so ?" part?

No, I do not think so, indicated such, and when you responded to that with yet another question considered it, as is again fairly customary, uncourteous to not respond to it although I did so by indicating I wouldn't do so further. I.e., if your reply now indicates that you feel this part of the thread is derailing your thread, then please stop derailing your thread.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Show me your aliases and i'll show you mine ;-)

Post by Flemur »

Code: Select all

alias Su='su - '
alias h='history'
alias hg='history | grep $1'
alias sud='sudo env PATH=$PATH'  # let's you use your USER's custom PATH with sudo
alias cdm='. ccdm'    # these next three are 'cd' shortcuts ...
alias data='. ddata'  # typing 'data xx' is the same as typing 'cd /mnt/DATA/xx'
alias down='. ddown'  # similar 
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
majpooper
Level 8
Level 8
Posts: 2084
Joined: Thu May 09, 2013 1:56 pm
Location: North Carolina, USA

Re: Show me your aliases and i'll show you mine ;-)

Post by majpooper »

Well I suppose whatever works for each individual - if you work on the same computer all the time doing the same routine repetitive tasks aliases might make things easier and faster. For me I tried them and found they were actually inconvenient because:
1.) I had to remember the alias - which I forgot
2.) I had to remember what I actually put in the alias when the output was not what I expected
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Show me your aliases and i'll show you mine ;-)

Post by rene »

Have together with as said not remembering the generic method had that very same experience ever since maintaining extensive lists of 4DOS (actually, NDOS) aliases on DOS coming up on 30 years ago now and seeing my eilte computer skills dwindle decidedly upon leaving my smelly dark bedroom to handle another computer.

Admittedly I'm to this day somewhat uncertain if the main mistake there was the list of aliases or leaving my smelly dark bedroom in the first place, but, well, life and all...
detimo

Re: Show me your aliases and i'll show you mine ;-)

Post by detimo »

Just using oh my zshell, which has a lot of aliases by default, like .. or ...
I like having cd tab and a menu of directories to chose from

This is an alias I use a lot:

Code: Select all

alias e='emacs'
User avatar
lsemmens
Level 11
Level 11
Posts: 3949
Joined: Wed Sep 10, 2014 9:07 pm
Location: Rural South Australia

Re: Show me your aliases and i'll show you mine ;-)

Post by lsemmens »

If I told you my aliases, I'd have to kill you.........................signed 007 :D
Fully mint Household
Out of my mind - please leave a message
Locked

Return to “Scripts & Bash”