Files
Boilerplates/Linux/Neofetch/README.md

4.0 KiB
Raw Blame History

Description

Neofetch is a tool to display system information inside the shell with an ASCII-Logo of the given Linux Distribution.

Example Output:

Neofetch


Installation of Neofetch

You can install Neofetch by copying the following code snippets to any of the given Linux Distributions.

Code Snippets

Click the little squares at the top right of the code window to quick and easy copy the code. Paste the code into your shell and thats it.

AlpineLinux

# Update Packages
apk update

# Install Neofetch
apk add neofetch

# Create new message of the day file
tee /etc/profile.d/motd.sh <<EOF
#!/bin/bash
printf "\n"
neofetch
EOF

# Make it executable
chmod +x /etc/profile.d/motd.sh

# Get rid of default Message Of The Day
echo "" > /etc/motd

Debian / Ubuntu

# Update Packages
sudo apt update

# Install Neofetch
sudo apt install -y neofetch

# Create new message of the day file
tee /etc/profile.d/motd.sh <<EOF
#!/bin/bash
printf "\n"
neofetch
EOF

# Make it executable
sudo chmod +x /etc/profile.d/motd.sh

# Get rid of default Message Of The Day
echo "" > /etc/motd


AlmaLinux / RockyLinux

# Update Packages
sudo dnf update -y

# Install EPEL-Release
sudo dnf install -y epel-release

# Update EPEL-Release
sudo dnf clean all && dnf update -y

# Install Neofetch
sudo dnf install -y neofetch

# Create new message of the day file
tee /etc/profile.d/motd.sh <<EOF
#!/bin/bash
printf "\n"
neofetch
EOF

# Make it executable
chmod +x /etc/profile.d/motd.sh

# Zielbenutzer (aktueller Benutzer standardmäßig)
TARGET_USER=${1:-$USER}
TARGET_HOME=$(eval echo ~$TARGET_USER)

# Überprüfen, ob sudo installiert ist
if ! command -v sudo &> /dev/null; then
    echo "sudo ist nicht installiert. Installiere sudo..."
    SUDO_INSTALLED=false
    if [ -f /etc/debian_version ]; then
        apt update && apt install -y sudo
    elif [ -f /etc/redhat-release ]; then
        yum install -y sudo
    else
        echo "Nicht unterstütztes Linux-System. Bitte sudo manuell installieren."
        exit 1
    fi
else
    echo "sudo ist bereits installiert."
    SUDO_INSTALLED=true
fi

# Passe Bash-Prompt und Farben an
echo "Passe Bash-Prompt und Farben für Benutzer $TARGET_USER an..."

sudo tee -a $TARGET_HOME/.bashrc > /dev/null <<'EOL'

# Farbiges Bash-Prompt mit grauem Hostname und gelbem @
if [ "$EUID" -eq 0 ]; then
    # Root-Prompt: Benutzer rot, @ gelb, Hostname dunkelgrau, Verzeichnis gelb
    PS1='\[\e[1;31m\]\u\[\e[0;33m\]@\[\e[1;30m\]\h \[\e[1;33m\]\w\[\e[0m\] # '
else
    # Normaler Benutzer: Benutzer grün, @ gelb, Hostname dunkelgrau, Verzeichnis blau
    PS1='\[\e[1;32m\]\u\[\e[0;33m\]@\[\e[1;30m\]\h \[\e[1;34m\]\w\[\e[0m\] \$ '
fi

# Farbiges ls und grep
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
EOL

# Rechte anpassen und Änderungen aktivieren
sudo chown $TARGET_USER:$TARGET_USER $TARGET_HOME/.bashrc
sudo chmod 644 $TARGET_HOME/.bashrc

# Änderungen für aktuelle Sitzung aktivieren
sudo -u $TARGET_USER source $TARGET_HOME/.bashrc

echo "Farbanpassung abgeschlossen! Starte ein neues Terminal oder lade die .bashrc neu mit:"
echo "source ~/.bashrc"

# sudo deinstallieren, falls es vorher nicht installiert war
if [ "$SUDO_INSTALLED" = false ]; then
    echo "Deinstalliere sudo..."
    if [ -f /etc/debian_version ]; then
        apt remove -y sudo
    elif [ -f /etc/redhat-release ]; then
        yum remove -y sudo
    fi
    echo "sudo wurde entfernt."
fi

ArchLinux

# Update Packages
sudo pacman -Syu

# Install Neofetch
sudo pacman -S neofetch -noconfirm

# Create new message of the day file
tee /etc/profile.d/motd.sh <<EOF
#!/bin/bash
printf "\n"
neofetch
EOF

# Make it executable
sudo chmod +x /etc/profile.d/motd.sh

# Get rid of default Message Of The Day
echo "" > /etc/motd