this post was submitted on 20 Sep 2023
132 points (97.8% liked)

Linux

48338 readers
75 users here now

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

Related Communities

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

founded 5 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

For system updates:

[ -r /etc/os-release ] && . /etc/os-release
case "$ID" in
  arch|archarm)
    if which paru > /dev/null 2>&1; then
      alias updates='echo Using paru; paru'
    else
      alias updates='echo Using pacman; sudo pacman -Syu --noconfirm'
    fi
    ;;
  debian|ubuntu)
    alias updates='echo Using apt dist-upgrade; sudo apt update && sudo apt dist-upgrade -y'
    ;;
esac
[–] ShittyBeatlesFCPres 5 points 1 year ago (2 children)

I have a similar one but I did it this way:


function ins {
  PACKAGE="${1}"
  exists() {
    command -v "$1" >/dev/null 2>&1
  }

  if exists dnf; then #Fedora
    sudo dnf update && sudo dnf install -y $PACKAGE
  elif exists apt; then #Debian
    sudo apt update && sudo apt install -y $PACKAGE
  elif exists apk; then #Alpine
    apk -U upgrade && apk add $PACKAGE
  elif exists emerge; then #Gentoo
    sudo emerge $PACKAGE
  elif exists zypper; then #Suse
    sudo zypper ref && sudo zypper install $PACKAGE
  elif exists pacman; then #Arch
    pacman -S $PACKAGE
  elif exists brew; then #MacOS
    brew install $PACKAGE
  else
    echo "Error can't install package $PACKAGE. No package manager is detected."
    exit 1;
  fi
}
[–] ShittyBeatlesFCPres 3 points 1 year ago

Actually that’s the install one. Here’s the upgrade one:


function upg {
  exists() {
    command -v "$1" >/dev/null 2>&1
  }

  if exists dnf; then #Fedora
    sudo dnf update && sudo dnf -y upgrade && sudo dnf -y autoremove
  elif exists apt; then #Debian
    sudo apt update && sudo apt full-upgrade -y
  elif exists apk; then #Alpine
    apk -U upgrade
  elif exists emerge; then #Gentoo
    sudo emerge --ask --verbose --update --deep --newuse @world && sudo emerge --ask --verbose --depclean
  elif exists zypper; then #Suse
    sudo zypper ref && sudo zypper update
  elif exists pacman; then #Arch
    pacman -Syu
  elif exists brew; then #MacOS
    brew update && brew upgrade
  else
    echo "Error: cannot update packages. No package manager is detected."
    exit 1;
  fi

  if exists snap; then #Snaps
    sudo snap refresh
  fi
  if exists flatpak; then #Flatpak
    flatpak update -y
  fi
}
[–] [email protected] 1 points 1 year ago