Linux очистить папку var

Как почистить /var/cache?

Пространство используется /var/cache/polipo (2.7G). Как я могу очистить это безопасно?
Я пытался перезагрузки => не работает
Используется bleachbit=> пространство не обнаружено в предварительном просмотре очистки

PS: я сделал rm -rf youtube внутри / var / cache / polipo, и это освободило пространство 2G. Не знаю, если это было безопасно, хотя

6 ответов

Polipo, программа веб-кэширования, может хранить много данных в кеше на диске.

Один из способов прояснить это — выполнить команду sudo polipo -x — это заставит polipo очистить кэш локального диска.

sudo apt-get autoclean sudo apt-get autoremove 

Запустите bleachbit от имени пользователя root: на диске нет места; sudo apt-get clean не работает

Самая мощная из всех команд для очистки кэша для пользователей командной строки, конечно,

Который также удалит все кэшированные файлы.

Это звучит так очевидно, и все же есть вероятность, что вы этого не сделали.

По умолчанию Ubuntu хранит каждое загружаемое обновление и устанавливает его в кэш на вашем диске, на случай, если вам когда-нибудь понадобится это снова.

Это полезно, если вы регулярно добавляете и удаляете приложения, вам необходимо перенастроить / переустановить конкретный пакет или просто иметь плохое соединение.

Но с другой стороны, кеш пакетов apt может быстро увеличиться до нескольких сотен МБ. Эта команда сообщает вам, насколько велик ваш apt-кеш:

du -sh / var / cache / apt / archives

Чтобы очистить кэш apt в Ubuntu, просто выполните следующую команду.

Команда apt clean удаляет ВСЕ пакеты, хранящиеся в кэше apt, независимо от возраста или необходимости. Если у вас медленное, ограниченное или прерывистое соединение, вы можете пропустить этот шаг.

Источник

Can I safely remove /var/cache?

I am running out of disk space and noted that I have a large /var/cache directory. Can I safely remove this? (using Arch Linux, BTW).

I’d check through what’s in there, but given that’s where pacman store’s it’s packages you might want to run pacman -Sc or even pacman -Scc if you want to clean your entire package cache.

Most, but not all, files under /var/cache are safe to delete. Don’t delete the directories or change their ownership. Run du /var/cache/* | sort -n to see what’s taking room. Ask here if you don’t know whether the large directories are safe to clean.

7 Answers 7

Sorry for the (very) late answer, but I believe it’s important to include this bit for future reference.

Highlighted the bit which does answer this question.

The /var/cache directory contains cached files, i.e. files that were generated and can be re-generated any time, but they are worth storing to save time of recomputing them.

Any application can create a file or directory here. It is assumed that files stored here are not critical, so the system can delete the contents of /var/cache either periodically, or when its contents get too large.

Any application should take into account that the file stored here can disappear any time, and be ready to recompute its contents (with some time penalty).

So yes, you may remove these files without expecting anything bad to happen.

Читайте также:  Удалить оперу из линукса

@MatthiasBraun — For those of us not in the know, is lindevdoc.org a canonical source of truth for this sort of thing?

The Wayack Machine has that page archived (but only once): web.archive.org/web/20130511220135/http://www.lindevdoc.org/… . The original poster here literally did more work than the author of that page, as you’ll see, since they at least bolded and formatted the text 😉

For one, I believe that /var/cache/bind/ is the default directory where bind9 expects its zone files to be stored (at least on Debian; I don’t know offhand if other distros follow suit)

For another, according to this documentation, pacman (the package manager used by Arch linux) stores its package cache under /var/cache/pacman/pkg/ and it most likely expects nothing but itself to modify the contents.

I recommend you read through the documentation more closely and decide whether this is a good time to clear the package cache.

Yes, don’t delete /var/cache/apt/archives dir, but you can delete files: /var/cache/apt/pkgcache.bin and /var/cache/apt/srcpkgcache.bin, but them will be recreated by «apt-get update».

On Debian, /var/cache/bind contains zone files transferred from other nameservers—it shouldn’t contain master zones. Debian follows FHS, and FHS requires that files under /var/cache be deletable. Of course, the question is about Arch, and further one shouldn’t delete files without first at least figuring out what they are.

That’s like saying you shouldn’t delete files in the temporary directory in windows without knowing what they are. If the folder is intended for temp files and your program puts non-temporary data there, then that’s a huge problem for your program, not for /var/cache

@TorValamo Unfortunate, isn’t it? The dynamic bind data and dpkg are still in that folder. plus a few other things. What’s 200% temporary is under /run (a RAM disk) and what’s mostly temporary under /tmp . Generally, anything under /var is data used by apps and that data may be «cache» or not really «cache».

As others have said, /var/cache/ can be used by any application to store information to save on retrieval time. In my experience though, most of the space taken up in there is from the system’s package manager.

pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically, therefore it is necessary to deliberately clean up that folder periodically to prevent such folder to grow indefinitely in size.

However, unless storage space is a desperate issue, to save headache later from future incompatibility; one of these other tools should be utilized: paccache , pkgcacheclean , or pacleaner .

Redhat based (Fedora, CentOS, SL, . )

yum clean all # or dnf clean all 

+1! I noticed today that I am running out of disk space. a short du -hs /* 2> /dev/null revealed that /var was very big. Turned out that my pacman cache was 91GB. pacman -Sc cleaned up the old packages and reduced the pacman cache to 5GB!

Found this post interesting in that I was looking to delete from /var/cache on Ubuntu 15.10 for disk space improvement, this is what I have found:

Читайте также:  Linux pinging a port

/var/cache/apt cache files are removed after ‘sudo apt-get clean’ has been run, however the directory structure remains which is no problem if you are looking for disk space improvements; ‘apt-get clean’ should be run last if you are to get any disk space improvement with apt-get [auto]remove/[auto]clean etc.

As for everything else in the directory, I couldn’t agree more with ‘Tor Valamo’ and his explanation. It’s cache, the system and apps that use cache should be able to regenerate anything they have created there. You just have minor performance overheads as cache is regenerated from app to app

In saying that, every system may not conform to this principal, do some testing, try moving everything in your cache directory to a new location and test that your system and all your applications work before removing the cache permanently.

Источник

How to clean /var/cache?

The space is used by /var/cache/polipo (2.7G). How can I clean this up safely?
I tried restarts=>didn’t work
Used bleachbit=>the space is not detected in the cleanup preview PS: I did rm -rf youtube inside /var/cache/polipo and it freed up 2G space. Dunno if it was safe though

6 Answers 6

sudo apt-get autoclean sudo apt-get autoremove 

All these were already done. The problem is in /var/cache. I want to know how to clean /var/cache safely.

Polipo, a web caching program may store a lot of data in an on-disk cache.

One way to clear this up is to issue the command sudo polipo -x — this will cause polipo to clear the local disk cache.

This is the ONLY right answer to this question (regarding polipo)! Why the hell does it not already have enough votes to make that clear.

The most powerful of all commands to clean the cache for command line users is of course

Which will also delete all the cached files.

I don’t know what this command did but it didn’t clear /var/cache, space is nearly double after I ran it!

Try cleaning ubuntu unnecesarry files using bleachbit. It is a tool that will help you clean your cache, temp files, cookies and it has other features also.

sudo apt-get install bleachbit 

It sounds so obvious, and yet chances are you haven’t done this.

By default Ubuntu keeps every update it downloads and installs in a cache on your disk, just in case you ever need it again.

This is useful if you regularly add and remove apps, find yourself needing to reconfigure/reinstall a specific package, or simply have a poor connection.

But the flip side is that the apt package cache can quickly swell to several hundred MBs. This command tells you how big your apt cache is:

du -sh /var/cache/apt/archives 

To clean the apt cache on Ubuntu simply run the following command.

The apt clean command removes ALL packages kept in the apt cache, regardless of age or need. If you’re on a slow, capped or intermittent connection you may want to consider skipping this step.

Источник

/var is Full: How to clear /var in Linux

var is Full - How to clear var in Linux

/var is a standard subdirectory of the root directory in Linux and other Unix-like operating systems that contains files to which the system writes data during the course of its operation.

Читайте также:  Linux set default gateway

/var is specific for each computer; that is, it is not shared over a network with other computers, in contrast to many other high-level directories. Its contents are not included in /usr because situations can occur in which it is desired to mount /usr as read-only, such as when it is on a CDROM or on another computer. /usr, which is generally the largest directory (at least on a newly installed system) and is used to store application programs, should only contain static data.

Among the various subdirectories within /var are /var/cache (contains cached data from application programs), /var/games (contains variable data relating to games in /usr), /var/lib (contains dynamic data libraries and files), /var/lock (contains lock files created by programs to indicate that they are using a particular file or device), /var/log (contains log files), /var/run (contains PIDs and other system information that is valid until the system is booted again) and /var/spool (contains mail, news and printer queues).

Follow the below steps to clear /var in Linux:

Before clearing the var partition, enter the following command to see its size. We can see that the var partition is 90% full.

Filesystem Type Size Used Avail Use% Mounted on /dev/edumotivation/rhel-var ext4 20G 17G 1.9G 90% /var

Let us now check the Logs size in the var partition. To check the log size, enter the command cd/var/log so that we go to the log path in the var partition.

Then you can check each log size by entering the command du -sch * .

20G audit 0 boot.log 12G sssd 40K tallylog 2.0M sudo.log 4.0K yum.log

In the above output, the size of the audit and sssd the log is more, so you need to clear that log.

First, we will clear the logs in audit, to go to the audit path enter the following cd /var/log/audit command.

Enter ll the command to view audit logs.

Enter rm -rf audit.log* command to clear audit logs.

Now to clear the sssd logs, first enter the following command to go to sssd Path.

Enter the following command to check the size of logs in sssd.

12G sssd_nss.log
4.0K sssd_nss.log-20220522.gz
181M sssd_nss.log-20220529

In the above output, the size of the sssd_nss.log file is more, so you need to clear that log.

Enter > and .log file name to clear audit logs.

After clearing the var partition, enter the following command to see its size. We can see that 13G space is now available in the var partition.

Filesystem Type Size Used Avail Use% Mounted on /dev/edumotivation/rhel-var ext4 20G 5.8G 13G 31% /var

That’s all, In this article, we have explained How to clear /var in Linux.

Conclusion

I hope you have learned something from this article.

Now I’d like to hear your thoughts.

Was this guide useful to you?

Or maybe you have some queries.

Have I not included any command in this guide?

Источник

Оцените статью
Adblock
detector