Saturday 16 April 2022

How to List Added/All Repositories and PPA's in Ubuntu Debian-based System


apt policy

apt-cache policy


#saved repos

cat /etc/apt/sources.list.save


#added repos

ls /etc/apt/sources.list.d/

#example

cat /etc/apt/sources.list.d/ansible-ubuntu-ansible-focal.list

apt-cache policy | grep ansible

apt policy | grep ansible


#List all repos

sudo grep -rhE ^deb /etc/apt/sources.list* 

grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*


grep -r --include '*.list' '^deb ' /etc/apt/sources.list*

grep -r --include '*.list' '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/


grep "^[^#]" /etc/apt/sources.list /etc/apt/sources.list.d/*


grep -r --include '*.list' '^deb ' /etc/apt/ | sed -re 's/^\/etc\/apt\/sources\.list((\.d\/)?|(:)?)//' -e 's/(.*\.list):/\[\1\] /' -e 's/deb http:\/\/ppa.launchpad.net\/(.*?)\/ubuntu .*/ppa:\1/'

grep -hE '^deb\s' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | sed '/ppa/ s/deb //g' | sed -re 's#http://ppa\.launchpad\.net/([^/]+)/([^/]+)(.*?)$#ppa:\1/\2#g'


apt-cache policy | grep http | awk '{print $2" "$3}' | sort -u

sudo apt update > /dev/null 2>&1 && sudo apt-cache policy | grep http | awk '{print $2 $3}' | sort -u

find /etc/apt/sources.list* -type f -iname "*.list" -exec grep -viE '(^#|^$)' {} \; -print | column -tx

sed -r -e '/^deb /!d' -e 's/^([^#]*).*/\1/' -e 's/deb http:\/\/ppa.launchpad.net\/(.+)\/ubuntu .*/ppa:\1/' -e "s/.*/sudo add-apt-repository '&'/" /etc/apt/sources.list /etc/apt/sources.list.d/*


#Examine the origin tag (such as o=Debian) for each of your current repositories

apt-cache policy | sed -n 's/.*o=\([^,]\+\).*/\1/p' | uniq


No comments:

Post a Comment