From bash to zsh and everywhere in between, show me yours and I’ll show you mines. Inspire others or get some feedback.

Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.

Edit: Kbin users, click ‘More’ on a comment and use the fediverse link to read responses that have funky formatting

2 points
*

Some random ones I created over the last week or so:

alias clipboard=‘xclip -selection clipboard’ # Allows me to pipe output directly to my keyboard. good for pwd for example.

Function allows me to get tldr and cheat responses to commands quickly
function cht() {
curl cheat.sh/$1
}

Easy calculator so that I can do math w/o launching a specific app
function calc()
echo “scale=3; $@” bc

permalink
report
reply
2 points
*

(NOTE: A lot of my more interesting “aliases” are actually short functions, but I’m keeping myself to alias.)

Some of mine that I haven’t seen yet:

# Simple python calculator
alias pycalc='python3 -ic "
from math import *\nimport cmath as C
try:
    import numpy as np
except:
    pass
i, j = 1j, 1j
"'

# Defaults
alias cp='cp --interactive --reflink=auto'
alias gcc='gcc -fdiagnostics-color=auto'
# Lemmy doesn't handle ampersands in codeblocks correctly
alias rg='rg --max-columns=$((COLUMNS > 60 && ! ZSH_SUBSHELL ? COLUMNS - 30 : 0))'
alias rj='rg --json'
alias rm='rm -s'
alias rscp='rsync -azP --human-readable --info=flist0,progress2,stats1'
alias rust-c='rustc --out-dir build -O'

# Shorter forms
alias g=git
alias v=$VISUAL
alias py=python
alias jfeu='journalctl --user -xfeu'
alias sys='systemctl --user'
alias Jfeu='journalctl -xfeu'
alias Sys=systemctl

# Desktop stuff
alias trash='gio trash'
alias ud=udisksctl
alias y=wl-copy
alias Y='wl-copy -p'
alias p=wl-paste
alias P='wl-paste -p'

# Colorize with acolor/grc
alias GRC='grc -es'
alias LA='acol ls -lFAhb --color'
alias LS='acol ls -lFhb --color'
alias df='GRC df -hT'
alias dig='GRC dig'
alias docker='GRC docker'
alias docker-machine='GRC docker-machine'
alias env='acol env'
alias lsblk='acol lsblk'
alias lsmount='command mount | rg --color=never "^/" | acol -i -o mount'
alias lspci='acol lspci'
alias mount='acol mount'
alias nmap='acol nmap'
alias ping='GRC ping'
alias ps='GRC ps --columns $COLUMNS'
alias traceroute='GRC traceroute'
permalink
report
reply
2 points

alias upgrade="sudo dnf upgrade --yes && flatpak update && flatpak remove --unused"

Or something like that, also a dnf remove unused command in there. Writing this from my phone so might be written wrong.

permalink
report
reply
8 points

alias nano='nano -l'

my only one, to have line numbers when searching for errors in log files

permalink
report
reply
2 points

Copying multiple lines will be more difficult. You can use Ctrl+C to display the current position, use page up/down for coarse navigation.

permalink
report
parent
reply
5 points

A bit long, but here goes:

Start gomuks Matrix Client

alias gomuks=/home/craig/.local/bin/gomuks-linux-arm64

walk: Terminal File Manager

https://github.com/antonmedv/walk

alias walk=“walk --icons”

Weather:https://github.com/chubin/wttr.in

alias weather=“/home/craig/.local/bin/weather.sh”

Onelinershell https://github.com/Onelinerhub/shellhub

alias oh=“/home/craig/.local/bin/oh.sh”

Show open ports

alias ports=‘sudo netstat -tulanp’

Refresh .bashrc

alias bashrc=“source ~/.bashrc”

become root

alias root=‘sudo -i’ alias su=‘sudo su’

Fix which

alias which=‘command -v’

APT User Commands

alias search=‘apt search’ alias file=‘apt-file search’ alias policy=‘apt policy’ alias show=“nala show”

if user is not root, pass all commands via sudo

if [ $UID -ne 0 ]; then alias update=‘sudo apt update’ alias ainstall=‘sudo apt install’ alias apurge=‘sudo apt purge -y --autoremove’ alias upgrade=‘sudo nala upgrade’ alias aremove=‘sudo apt autoremove -y’ alias clean=‘sudo nala clean’ alias reboot=‘sudo reboot’ alias shutdown=“sudo shutdown -P now” fi

Handy-dandy aliases for journalctl and systemctl

alias jc=‘sudo journalctl -b’ alias jca=‘sudo journalctl’ alias jcf=‘sudo journalctl -f’ alias jcr=‘sudo journalctl --list-boots’ alias sc=‘sudo systemctl’

Making files immortal & executable

alias im+=“sudo chattr +i” alias im-=“sudo chattr -i” alias exe=“sudo chmod +x”

#Add safety nets

do not delete / or prompt if deleting more than 3 files at a time

alias rm=‘rm -I --preserve-root’

confirmation

alias mv=‘mv -i’ alias cp=‘cp -i’ alias ln=‘ln -i’

Parenting changing perms on /

alias chown=‘chown --preserve-root’ alias chmod=‘chmod --preserve-root’ alias chgrp=‘chgrp --preserve-root’

copy the current working directory to the clipboard

alias cpwd=‘pwd | xclip -selection clipboard’

Clipboard

alias cpy=“xclip -selection clipboard”

quick directory movement

alias …=‘cd …’ alias …=‘cd …/…’ alias …=‘cd …/…/…’

go to the last directory you were in

alias back=‘cd $OLDPWD’

quickly find files and directory

alias ff=‘find . -type f -name’ alias fd=‘find . -type d -name’

Create Python virtual environment

alias ve=‘python3 -m venv ./venv’ alias va=‘source ./venv/bin/activate’

Ping Commands

Stop after sending count ECHO_REQUEST packets

alias ping=‘ping -c 5’ alias pg=“ping google.com -c 5”

alias shortcuts

alias rpi=“sudo rpi-update” alias rpi-next=“sudo BRANCH=next rpi-update” alias raspi=“sudo raspi-config” alias clr=“clear” alias clrh=“history -c -w ~/.bash_history” alias df=‘df -H’ alias du=‘du -ch’ alias mk=“mkdir -p” alias loading=“sudo dmesg > ~/dmesg.txt”

ls Commands

Colorize the ls output and human readable sizes

alias ls=‘ls --color=auto --human-readable -al’

Use a long listing format

alias ll=‘ls -la’

Show hidden files

alias l.=‘ls -d .* --color=auto’

Listing files in folder

alias listkb=“ls -l --block-size=K” alias listmb=“ls -l --block-size=M”

Colorize the grep command output for ease of use (good for log files)##

alias grep=‘grep --color=auto’ alias egrep=‘egrep --color=auto’ alias fgrep=‘fgrep --color=auto’

Colorize diff output

alias diff=‘colordiff’

Start calculator with math support

alias bc=“bc -l”

Resume wget by default

alias wget=“wget -c”

ps Commands

alias ps=“ps auxf”

Get top process eating cpu

alias pscpu=“ps auxf | sort -nr -k 3” alias pscpu10=“ps auxf | sort -nr -k 3 | head -10”

Get top process eating memory

alias psmem=‘ps auxf | sort -nr -k 4’ alias psmem10=‘ps auxf | sort -nr -k 4 | head -10’

Free and Used Ram

alias meminfo=‘free -l’ alias free=‘free -mt’

Run top in alternate screen

alias top=‘tput smcup; top; tput rmcup’

permalink
report
reply
6 points

i wanna see u try use a vanilla profile

permalink
report
parent
reply
2 points

The struggle I sometimes face when I SSH into somewhere, lol! Fortunately, there’s a lot of differences that it’s easy realize that “this is a different machine”, and I just open a different terminal tab/window to look up the pure command versions if I need to.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 8.5K

    Monthly active users

  • 6.3K

    Posts

  • 174K

    Comments