> For the complete documentation index, see [llms.txt](https://cyber-salih.gitbook.io/cyber-salih/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cyber-salih.gitbook.io/cyber-salih/linux/update-upgrade-and-clean-linux.md).

# Update, Upgrade, and Clean Linux

<figure><img src="/files/QTMQuKfxzN6M1BReejnJ" alt=""><figcaption><p>Script running</p></figcaption></figure>

{% embed url="<https://www.youtube.com/watch?t=699s&v=bdHoS996vq4>" %}
Watch my YouTube video explaining this
{% endembed %}

### The script:&#x20;

```
#!/bin/bash/ 

echo 

echo -e "\e[1;32m Step 1: Updating packages \e[0m"
sudo apt-get update

echo

echo -e "\e[1;32m Step 2: Upgrading packages \e[0m" 
sudo apt-get upgrade -y
sudo apt-get dist upgrade -y 
sudo apt-get update

echo 

echo -e "\e[1;32m Step 3: Cleaning up \e[0m"
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove

exit 
```

### Could be better…

So the output of this script is good, but technically speaking, we are missing a few major pieces here.&#x20;

Firstly – What happens if the script fails? We could have a red text that comes up telling us how or why the script failed to run.

Secondly – We are not logging anything here. We can add this to system logs or our own personal log files. This would become more important if you were tracking when the Linux system was last updated for audit purposes.&#x20;

### Why don’t you try and make this script better?&#x20;

Build on it, edit it, and use it. Then share this with me, I would be really interested in seeing what changes you can come up with for this.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cyber-salih.gitbook.io/cyber-salih/linux/update-upgrade-and-clean-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
