Skip to main content

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:

Efficiently managing large file archives in Linux: excluding directories with Zip

Managing large directories, especially those filled with a diverse mix of media such as documents and images, can quickly become cumbersome. In my latest project, dealing with a directory that totals a whopping 87GB, the need for efficient file compression and selective archiving became apparent. How can we streamline this process using the zip command, particularly when we want to exclude non-essential files and directories?


Exploring historical memory usage monitoring with Sysstat

In the realm of system administration and monitoring, understanding memory usage trends is crucial for maintaining system health and performance. While tools like htop offer real-time insights into memory usage, they lack the capability to provide historical data. So, what if you need to analyze memory usage over the past 24 hours or even a week? Fear not, as Sysstat comes to the rescue with its powerful sar command.


This command will help you spot any unusually large directories

The red flag was when I saw the server disk space is showing a site is taking up 57992.5 MB, where locally the site size is showing 957MB.  There is something serious happening here and I need to establish the problem quickly.  When dealing with a significant discrepancy in site size between a local environment and a server, it's important to identify the root cause of the larger disk usage on the server. 


How to determine the size of a directory in Terminal

To determine the size of a directory using the terminal, you can use the du (disk usage) command. The syntax for this command can vary slightly depending on the operating system you are using, but a common way to use it is as follows:


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:


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 update installed Python packages

You can use the pip list --outdated command to view a list of installed Python packages that have newer versions available. This command will show you which packages are outdated and can be updated to the latest versions.

Here's how you can use it

keytool error: keystore password was incorrect

The "keystore password was incorrect" error in keytool indicates that the password you provided when trying to access or modify a keystore is incorrect. To resolve this issue, you can follow these steps:


Verify the Correct Password

Double-check that you are entering the correct password for the keystore. Passwords are case-sensitive, so make sure that the case of the characters in the password matches the one you used when creating or modifying the keystore.

Subscribe to Terminal