Difference between revisions of "System Maintenance"

Marked this version for translation
m (added languages and translate tags)
(Marked this version for translation)
Line 3: Line 3:


<translate>
<translate>
=Overview=
=Overview= <!--T:1-->


<!--T:2-->
This article contains tips and best practices for keeping your system in optimal condition.
This article contains tips and best practices for keeping your system in optimal condition.




=Home Cache=
=Home Cache= <!--T:3-->


<!--T:4-->
The hidden {{ic|.cache}} folder in your home directory is used by many parts of your system. This includes downloads, thumbnails, desktop resources, and more.<br />
The hidden {{ic|.cache}} folder in your home directory is used by many parts of your system. This includes downloads, thumbnails, desktop resources, and more.<br />
While it is generally safe to remove everything in your {{ic|~/.cache}} folder, it may be more advisable to inspect its contents and selectively remove items instead.<br />
While it is generally safe to remove everything in your {{ic|~/.cache}} folder, it may be more advisable to inspect its contents and selectively remove items instead.<br />


<!--T:5-->
To generate a sorted list of contents and sizes:
To generate a sorted list of contents and sizes:
{{UserCmd|command=du -sh ~/.cache/* | sort -h}}
{{UserCmd|command=du -sh ~/.cache/* | sort -h}}


<!--T:6-->
To automatically purge all {{ic|.cache}} files that have not been accessed in 100 days:
To automatically purge all {{ic|.cache}} files that have not been accessed in 100 days:
{{UserCmd|command=find ~/.cache/ -type f -atime +100 -delete}}
{{UserCmd|command=find ~/.cache/ -type f -atime +100 -delete}}


=Journal and Logs=
=Journal and Logs= <!--T:7-->


<!--T:8-->
Log files & the systemd journal do the same thing in different ways. They keep a record of everything that happens on your system.<br />
Log files & the systemd journal do the same thing in different ways. They keep a record of everything that happens on your system.<br />
For more information and tips on automated maintenance please see the dedicated page [[Limit the size of .log files %26 the journal]]
For more information and tips on automated maintenance please see the dedicated page [[Limit the size of .log files %26 the journal]]


==Systemd Journal==
==Systemd Journal== <!--T:9-->


<!--T:10-->
The journal keeps logs of system activity. This can be important for troubleshooting, but sometimes the log size can grow rather large.  
The journal keeps logs of system activity. This can be important for troubleshooting, but sometimes the log size can grow rather large.  


<!--T:11-->
To report the current size:
To report the current size:
{{UserCmd|command=journalctl --disk-usage}}
{{UserCmd|command=journalctl --disk-usage}}


<!--T:12-->
To remove all but the most recent entries by size or time:
To remove all but the most recent entries by size or time:
{{UserCmd|command=journalctl --vacuum-size=50M}}
{{UserCmd|command=journalctl --vacuum-size=50M}}
{{UserCmd|command=journalctl --vacuum-time=2weeks}}
{{UserCmd|command=journalctl --vacuum-time=2weeks}}


<!--T:13-->
To set a maximum size for the journal you can uncomment and edit the following line in {{ic|/etc/systemd/journald.conf}}:
To set a maximum size for the journal you can uncomment and edit the following line in {{ic|/etc/systemd/journald.conf}}:
  SystemMaxUse=50M
  SystemMaxUse=50M


==System logs at /var/log/*==
==System logs at /var/log/*== <!--T:14-->


<!--T:15-->
While most things use the newer systemd journal (journalctl), there is still some software that uses the older /var/log/ directory.<br />
While most things use the newer systemd journal (journalctl), there is still some software that uses the older /var/log/ directory.<br />
For more information and some tips on maintaining it, please see the relevant section of [[Limit the size of .log files & the journal#Managing /var/log/* files|this page]].
For more information and some tips on maintaining it, please see the relevant section of [[Limit the size of .log files & the journal#Managing /var/log/* files|this page]].




=Packages and Updates=
=Packages and Updates= <!--T:16-->


==Keeping your System Updated==
==Keeping your System Updated== <!--T:17-->


<!--T:18-->
On a rolling release distribution it is essential to keep your system fully updated.  Manjaro provides a few ways to keep your system updated.
On a rolling release distribution it is essential to keep your system fully updated.  Manjaro provides a few ways to keep your system updated.


<!--T:19-->
* You can use the GUI tool [[Pamac]] directly or via the update notifier
* You can use the GUI tool [[Pamac]] directly or via the update notifier
* You can use the GUI tool [[Octopi]] directly or via the update notifier
* You can use the GUI tool [[Octopi]] directly or via the update notifier
Line 55: Line 67:
* You can use the [[Pacman_Overview#Installing_Updates|Pacman CLI]]
* You can use the [[Pacman_Overview#Installing_Updates|Pacman CLI]]


==Avoiding Partial Updates==
==Avoiding Partial Updates== <!--T:20-->


<!--T:21-->
{{warning|Partial updates are not supported under any circumstances}}
{{warning|Partial updates are not supported under any circumstances}}


<!--T:22-->
It is of critical importance to ensure you don't end up in a state where your system is partially upgraded.<br />
It is of critical importance to ensure you don't end up in a state where your system is partially upgraded.<br />
It is not uncommon for systems in partially updated state to end up in a critical failure state.<br />
It is not uncommon for systems in partially updated state to end up in a critical failure state.<br />
Here are some important rules to help you avoid this dangerous situation.
Here are some important rules to help you avoid this dangerous situation.


<!--T:23-->
* Always ensure your system is fully up-to-date before installing software.
* Always ensure your system is fully up-to-date before installing software.
* Don't downgrade packages, this will always result in a partial update scenario.
* Don't downgrade packages, this will always result in a partial update scenario.
Line 70: Line 85:
* When [[Switching_Branches|switching branches]] or [[Pacman-mirrors|switching mirrors]] always use {{ic|pamac update --force-refresh}} or {{ic|pacman -Syyu}} to ensure that the databases for your new mirrors are being used.
* When [[Switching_Branches|switching branches]] or [[Pacman-mirrors|switching mirrors]] always use {{ic|pamac update --force-refresh}} or {{ic|pacman -Syyu}} to ensure that the databases for your new mirrors are being used.


==Removing Orphans==
==Removing Orphans== <!--T:24-->


<!--T:25-->
As packages are added, built and removed it is not uncommon to have unneeded dependencies, also called orphans, building up over time.  While orphans are not harmful, they take up space on the disk and consume network bandwidth as they are continually updated.  Luckily, there are a couple of easy ways to view and remove orphans.
As packages are added, built and removed it is not uncommon to have unneeded dependencies, also called orphans, building up over time.  While orphans are not harmful, they take up space on the disk and consume network bandwidth as they are continually updated.  Luckily, there are a couple of easy ways to view and remove orphans.


<!--T:26-->
To use pamac follow [[Pamac#Dealing_with_Orphaned_Packages|this guide]].   
To use pamac follow [[Pamac#Dealing_with_Orphaned_Packages|this guide]].   


<!--T:27-->
To use pacman follow [[Pacman_Overview#Viewing_and_Removing_Orphans|this guide]].
To use pacman follow [[Pacman_Overview#Viewing_and_Removing_Orphans|this guide]].


==Package Cache==
==Package Cache== <!--T:28-->


<!--T:29-->
By default both pamac and pacman keep a cache of downloaded packages on the system. This can be helpful if you need to copy or downgrade a package.<br />
By default both pamac and pacman keep a cache of downloaded packages on the system. This can be helpful if you need to copy or downgrade a package.<br />
But the cache can grow to include dozens of each package resulting in gigabytes of space.
But the cache can grow to include dozens of each package resulting in gigabytes of space.


<!--T:30-->
To use pamac follow [[Pamac#Cleaning_the_Cache|this guide]].   
To use pamac follow [[Pamac#Cleaning_the_Cache|this guide]].   


<!--T:31-->
To use pacman follow [[Pacman_Overview#Cleaning_the_Cache|this guide]].
To use pacman follow [[Pacman_Overview#Cleaning_the_Cache|this guide]].


==Pacnew and Pacsave files==
==Pacnew and Pacsave files== <!--T:32-->


<!--T:33-->
A .pacnew file may be created during a package upgrade to avoid overwriting a file which already exists. A .pacsave file may be created during a package removal, or by a package installation of a package that was removed. These files require manual intervention from the user and it is good practice to handle them regularly.  The program {{ic|pacdiff}} can help manage this process. For example, here is what it looks like when the {{ic|/etc/default/grub}} grub file has changed:
A .pacnew file may be created during a package upgrade to avoid overwriting a file which already exists. A .pacsave file may be created during a package removal, or by a package installation of a package that was removed. These files require manual intervention from the user and it is good practice to handle them regularly.  The program {{ic|pacdiff}} can help manage this process. For example, here is what it looks like when the {{ic|/etc/default/grub}} grub file has changed:
  sudo DIFFPROG=diff pacdiff|result=
  sudo DIFFPROG=diff pacdiff|result=
Line 94: Line 116:
  :: (V)iew, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/s/r/o/q]
  :: (V)iew, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/s/r/o/q]


<!--T:34-->
* {{ic|V}} shows the differences between the two files
* {{ic|V}} shows the differences between the two files
* {{ic|S}} skips to the next change and allows you to deal with it later or manually
* {{ic|S}} skips to the next change and allows you to deal with it later or manually
Line 100: Line 123:
* {{ic|Q}} quits the process without making further changes
* {{ic|Q}} quits the process without making further changes


<!--T:35-->
Unfortunately, there is no perfect road map for how to deal with these files. If you keep the original config file, and the syntax has changed, the program may stop working or fail to use the existing config. If you remove the original file and use the new file without any changes, all your configuration settings can be overwritten.  Sometimes, you need to combine pieces from the new and old files to make everything to work.  In these situations it is better to integrate the files manually.
Unfortunately, there is no perfect road map for how to deal with these files. If you keep the original config file, and the syntax has changed, the program may stop working or fail to use the existing config. If you remove the original file and use the new file without any changes, all your configuration settings can be overwritten.  Sometimes, you need to combine pieces from the new and old files to make everything to work.  In these situations it is better to integrate the files manually.


<!--T:36-->
For more detailed information, please see review the Arch Wiki [[#See_Also|linked below]].
For more detailed information, please see review the Arch Wiki [[#See_Also|linked below]].




=Time and Date=
=Time and Date= <!--T:37-->
[[File:Msm-time-date.png|thumb|left|350px]]
[[File:Msm-time-date.png|thumb|left|350px]]


<!--T:38-->
Keeping the system time accurate may seem unimportant but certain network related services may malfunction if the time is out of sync.
Keeping the system time accurate may seem unimportant but certain network related services may malfunction if the time is out of sync.


<!--T:39-->
The easiest way to ensure the time is being properly synchronized is the GUI tool included in '''Manjaro Settings Manager''' which is pictured to the left. Simply check the box next to "Set time and date automatically".
The easiest way to ensure the time is being properly synchronized is the GUI tool included in '''Manjaro Settings Manager''' which is pictured to the left. Simply check the box next to "Set time and date automatically".


<!--T:40-->
An alternative is to use systemd via the systemd-timesyncd service. This can be easily enabled with one of these commands:
An alternative is to use systemd via the systemd-timesyncd service. This can be easily enabled with one of these commands:
{{UserCmd|command=timedatectl set-ntp true}}
{{UserCmd|command=timedatectl set-ntp true}}


<!--T:41-->
{{UserCmd|command=sudo systemctl enable --now systemd-timesyncd}}
{{UserCmd|command=sudo systemctl enable --now systemd-timesyncd}}


<!--T:42-->
<div style="clear: both"></div>
<div style="clear: both"></div>


=See Also=
=See Also= <!--T:43-->
* The Arch Wiki guide on [https://wiki.archlinux.org/index.php/System_maintenance System Maintenance]
* The Arch Wiki guide on [https://wiki.archlinux.org/index.php/System_maintenance System Maintenance]
* The Arch Wiki guide on [https://wiki.archlinux.org/index.php/Pacman/Pacnew_and_Pacsave Pacnew and Pacsave] files
* The Arch Wiki guide on [https://wiki.archlinux.org/index.php/Pacman/Pacnew_and_Pacsave Pacnew and Pacsave] files