How to empty a file on your server
Managing files on a server often includes tasks like clearing logs or resetting configuration files. If you need to empty a file without deleting it, there are several quick and efficient methods to achieve this.
Recently, during a review of log files, I noticed an unusually large file: access_ssl_log.processed, which was a substantial 8.77 GB. After reviewing and backing up the data, I needed to empty the file to free up space and maintain server performance.
Checking if a file exists using command line queries in Ubuntu with Nginx
On a server directory with over 100,000 PDF files, I needed to verify the existence of specific documents. Whether there are a few hundred or whatever the number of files, this article explores the practical use of command-line tools to quickly ascertain whether a file is present. In the area of server management or application development, especially on systems like Ubuntu equipped with Nginx, it's crucial to perform routine checks to ensure that all necessary files are in place.
Create a copy of files that go to the tmp directory
To review the content of files being generated in the /tmp directory on an Ubuntu server before Microsoft Defender removes them, you can use several approaches. Following is the approach we took.
Real-Time Monitoring
You can set up a script to monitor the /tmp directory and log the contents of new files. Use inotifywait to watch for new files and then copy them to another directory for review.
Install inotify-tools:
Common commands used in Ubuntu - in progress
No results showing for your Solr instance - solr.service: Failed with result 'exit-code'
When Solr is displaying results on the site, first step is to log in the server and check its status
Terminal command to find and replace
In many terminal text editors, you use find command as reference in Terminal commands - find. How about find and replace. This action depends on the specific text editor you're using in the terminal. Here are a few common terminal text editors and how you can find and replace strings within them:
Vim
To find: Press / followed by the search term and then Enter.
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE, potentially allowing shell command injection.
The current less version is 551, which is vulnerable. You'll need to upgrade "less" to a version at or beyond 606.
How to check if Apache Struts 2 is installed on an Ubuntu
You can perform the following steps:
Check Apache Modules
Apache Struts 2 is typically integrated with Java applications and runs on servlet containers like Apache Tomcat. However, if you want to check for any signs of Struts 2 on Apache, you can look for loaded Apache modules. Run the following command:
PermissionError: [Errno 13] Permission denied
Using OpenAI to summarise PDF
To use OpenAI to summarise text from a PDF using Python 3.11.6, you'll first need to extract the text from the PDF and then send it to the OpenAI API for summarisation.
Preparation
Set-up
pip install python-dotenv langchain openai tiktoken pypdf pymupdf
Code
The current code is on my Summaries GitHub page.