You are not logged in.

#1 2010-03-23 10:41:39

samuele.mattiuzzo
Member
From: Treviso, IT
Registered: 2009-10-12
Posts: 307
Website

Keeping arch system clean

Hi archers,
what do you do to keep your system clean? You surely have / had orphan packages, or packages no more used, so i was wondering what operation you perform to check for installed useless packages and remove them from the system, to keep your arch clean and slim everyday!

Offline

#2 2010-03-23 10:48:25

Meyithi
Member
From: Wirral, UK
Registered: 2009-06-21
Posts: 550
Website

Re: Keeping arch system clean

I run this daily after an update (pacman -Syyu), works for me.

#!/bin/bash

tar -cjf /store/bak/pacman-database.tar.bz2 /var/lib/pacman/local
pacman -Rscn $(pacman -Qtdq)
pacman -Sc
pacman-optimize && sync
updatedb

exit 0

The mind roams more freely in empty rooms.
dwm - colours - ncmpcpp - system
irc://irc.freenode.net:meyithi

Offline

#3 2010-03-23 10:52:22

droog
Member
Registered: 2004-11-18
Posts: 877

Re: Keeping arch system clean

I use these 2 aliases in my zshrc, got them off the forum or wiki a long time ago.

alias lsorhpans='sudo pacman -Qdt'
alias rmorphans='sudo pacman -Rs $(pacman -Qtdq)'

Offline

#4 2010-03-23 11:06:53

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Keeping arch system clean

my update script checks for and removes orphans once the update is done so as I update at least once a day then the system should be always clean.

The idea by droog above is slick

Offline

#5 2010-03-23 11:21:51

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Keeping arch system clean

A couple of questions:  With the scripts above how do you prevent it removing needed packages.  For example, in my case it would remove gksu which I use.  Also, I can run "pacman -Qdt" as a normal user, so why is the sudo required?


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#6 2010-03-23 11:25:10

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: Keeping arch system clean

loafer wrote:

A couple of questions:  With the scripts above how do you prevent it removing needed packages.  For example, in my case it would remove gksu which I use.

Install the package explicitly:

pacman --asexplicit -S gksu
loafer wrote:

Also, I can run "pacman -Qdt" as a normal user, so why is the sudo required?

It isn't.

Offline

#7 2010-03-23 11:26:50

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: Keeping arch system clean

loafer got there before me - droog's second command wants to wipe some 800MB off my system, most of which I appear to use all the time (kde-pim being a particularly important candidate). Methinks I don't fully understand pacman. Correct that, meknows I don't fully understand pacman smile


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#8 2010-03-23 11:53:31

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

Re: Keeping arch system clean

Meyithi wrote:

I run this daily after an update (pacman -Syyu), works for me.

#!/bin/bash

tar -cjf /store/bak/pacman-database.tar.bz2 /var/lib/pacman/local
pacman -Rscn $(pacman -Qtdq)
pacman -Sc
pacman-optimize && sync
updatedb

exit 0

I have a couple of question about your script.
1. What is the utility of the sync and updatedb commands? As far as I see they're not related to pacman.
2. Wouldn't run pacman-optimize before an update be more useful?
3. Do you always remove your packages with the -c option? Isn't this dangerous?

Thanks! smile


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

#9 2010-03-23 12:01:36

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Keeping arch system clean

did anyone mention this yet?

pacman -Qqdt

lists orphans

Offline

#10 2010-03-23 12:10:44

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Keeping arch system clean

tawan wrote:

did anyone mention this yet?

pacman -Qqdt

lists orphans

It's in one of the posts above.

Last edited by loafer (2010-03-23 12:10:58)


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#11 2010-03-23 12:21:02

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Keeping arch system clean

lol my dyslexia failed to see the same set of letters in a different order, sorry tongue

Offline

#12 2010-03-23 17:21:23

Meyithi
Member
From: Wirral, UK
Registered: 2009-06-21
Posts: 550
Website

Re: Keeping arch system clean

rent0n wrote:

I have a couple of question about your script.
1. What is the utility of the sync and updatedb commands? As far as I see they're not related to pacman.

The sync just makes sure that everything is written to physical media, the updatedb because I call this script after an update script, so I have lots of new ABS files and stuff that I might want to locate.

2. Wouldn't run pacman-optimize before an update be more useful?

Nah, pacman-optimize defrags in effect, update will mess it up again.  Update, clean and defrag, sounds about right to me.

3. Do you always remove your packages with the -c option? Isn't this dangerous?

It would be it was anything other than orphans being removed, dependences of orphans can safely go on my system.

Thanks! smile


The mind roams more freely in empty rooms.
dwm - colours - ncmpcpp - system
irc://irc.freenode.net:meyithi

Offline

#13 2010-03-23 18:01:43

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

Re: Keeping arch system clean

Meyithi wrote:
rent0n wrote:

I have a couple of question about your script.
1. What is the utility of the sync and updatedb commands? As far as I see they're not related to pacman.

The sync just makes sure that everything is written to physical media, the updatedb because I call this script after an update script, so I have lots of new ABS files and stuff that I might want to locate.

2. Wouldn't run pacman-optimize before an update be more useful?

Nah, pacman-optimize defrags in effect, update will mess it up again.  Update, clean and defrag, sounds about right to me.

3. Do you always remove your packages with the -c option? Isn't this dangerous?

It would be it was anything other than orphans being removed, dependences of orphans can safely go on my system.

Thanks! smile

Thank you, very clear!


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

#14 2010-03-23 19:12:41

Meskarune
Member
From: Helsinki, Finland
Registered: 2009-03-21
Posts: 361
Website

Re: Keeping arch system clean

I have about 30 orphan programs, but I use pretty much all of them. One of the orphans was supertuxcart. o_0


Homepage  | Arch Linux Women | Arch Linux Classroom
Acer Aspire E5-575G-53VG:
Intel Dual-Core i5-6200U 2.3 GHz; Skylake rev3 | 8GB DDR4 ram | Intel HD Graphics 520 + NVIDIA GeForce 940MX
Qualcomm Atheros QCA9377 802.11ac | Realtek RTL8111/8168/8411 Gigabit Ethernet Controller

Offline

#15 2010-03-23 19:32:10

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Keeping arch system clean

Meskarune made me laugh. Shame on her, I'm supposed to be a tragic figure. O woe is me...

Methinks orphans can adopt themselves, no?


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#16 2010-03-24 00:40:41

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: Keeping arch system clean

I can also recommend "pacman -Rns $(pacman -Qdtq)". 

Once you've gotten rid of your orphans (or explicitly installed the ones you actually want) I would recommend this script that displays every package you've explicitly installed, excluding base and base-devel packages.  Very useful for finding packages you don't really want anymore.

pacman-explicit

#!/bin/bash
pacman -Qei | awk '/^Name/ { name=$3 } /^Groups/ { if ( $3 != "base" && $3 != "base-devel" ) { print name } }'

Last edited by Odysseus (2010-03-24 00:59:18)


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#17 2010-03-24 08:20:38

pickboy87
Member
From: Minnesota
Registered: 2010-02-12
Posts: 84
Website

Re: Keeping arch system clean

Odysseus wrote:

I can also recommend "pacman -Rns $(pacman -Qdtq)". 

Once you've gotten rid of your orphans (or explicitly installed the ones you actually want) I would recommend this script that displays every package you've explicitly installed, excluding base and base-devel packages.  Very useful for finding packages you don't really want anymore.

pacman-explicit

#!/bin/bash
pacman -Qei | awk '/^Name/ { name=$3 } /^Groups/ { if ( $3 != "base" && $3 != "base-devel" ) { print name } }'

Oooh, I like that. I modified it slightly to save to a text document, but that's a very useful command. Saving to my ~/.scripts folder.

Offline

#18 2010-03-24 14:49:02

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Keeping arch system clean

Odysseus wrote:

I can also recommend "pacman -Rns $(pacman -Qdtq)". 

Once you've gotten rid of your orphans (or explicitly installed the ones you actually want) I would recommend this script that displays every package you've explicitly installed, excluding base and base-devel packages.  Very useful for finding packages you don't really want anymore.

pacman-explicit

#!/bin/bash
pacman -Qei | awk '/^Name/ { name=$3 } /^Groups/ { if ( $3 != "base" && $3 != "base-devel" ) { print name } }'

I also really like this. Very simple, very easy - the sort of thing that makes one say "why didn't I think of that?" I put it in a shell function rather than a separate script since it's so small.

Offline

#19 2010-03-24 23:03:18

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Keeping arch system clean

Oh I like it too!!
Small modification so that I can also see the description.

pacman -Qei $(pacman -Qu|cut -d" " -f 1)|awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'

Modified because someone asked for it.

Last edited by marxav (2010-09-18 23:30:04)

Offline

#20 2010-03-26 19:29:51

lasu1
Member
Registered: 2010-02-10
Posts: 83

Re: Keeping arch system clean

Oooh...thanks for the script. Funny enough, I'd designated today as system clean up day, lol. smile

Offline

#21 2010-03-26 19:46:25

keenerd
Package Maintainer (PM)
Registered: 2007-02-22
Posts: 647
Website

Re: Keeping arch system clean

I wrote pacgraph for a very similar purpose.  Basically it tells you how much space a "pacman -Rssc" would free up for any given package.  Use the --console switch for quickest results.

Offline

#22 2010-03-28 04:01:55

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: Keeping arch system clean

Hadn't thought much about it but:

pacman -S $(pacman -Qqe | grep -vx "$(pacman -Qqm)")

will reinstall your explicits.  Sorry, it's late and need to go to bed big_smile.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#23 2011-07-21 08:09:47

DasFox
Member
Registered: 2010-11-24
Posts: 107

Re: Keeping arch system clean

Meyithi wrote:

I run this daily after an update (pacman -Syyu), works for me.

#!/bin/bash

tar -cjf /store/bak/pacman-database.tar.bz2 /var/lib/pacman/local
pacman -Rscn $(pacman -Qtdq)
pacman -Sc
pacman-optimize && sync
updatedb

exit 0

What's with this /store path?

I run this and I get this back;

[root@arch ~]# ./pacclean_1
tar: Removing leading `/' from member names
tar (child): /store/bak/pacman-database.tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
error: no targets specified (use -h for help)
Cache directory: /var/cache/pacman/pkg/
Packages to keep:
  All locally installed packages
Do you want to remove all other packages from cache? [Y/n] y
removing old packages from cache...

Database directory: /var/lib/pacman/
Do you want to remove unused repositories? [Y/n] y
Database directory cleaned up
==> MD5sum'ing the old database...
==> Tar'ing up /var/lib/pacman...
==> Making and MD5sum'ing the new database...
==> Syncing database to disk...
==> Checking integrity...
==> Rotating database into place...

==> Finished. Your pacman database has been optimized.


THANKS


12 Year Linux Vet, Don't Let The Post Count Fool Ya! But Sure I Don't Know Everything, Who Does? That's Why I Ask. smile

Offline

#24 2011-07-21 08:21:13

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Keeping arch system clean

DasFox wrote:

What's with this /store path?

That's the path to file that Meyithi used to create a backup of the database.

The script worked OK for you, nothing to worry about.

Offline

#25 2011-07-21 08:30:39

DasFox
Member
Registered: 2010-11-24
Posts: 107

Re: Keeping arch system clean

So how would we use it to do that as well?


THANKS


12 Year Linux Vet, Don't Let The Post Count Fool Ya! But Sure I Don't Know Everything, Who Does? That's Why I Ask. smile

Offline

Board footer

Powered by FluxBB