Skip to main content

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:

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 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: java.io.IOException: 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.

Python absolute or relative path

The os.makedirs(directory_path) function in Python can be used with both absolute and relative paths. Whether you should use an absolute or relative path depends on your specific use case and the location where you want to create the directory:

 

Absolute Path

Use an absolute path when you want to specify the exact location in the file system, starting from the root directory (e.g., /path/to/new/directory).

Move a file from one directory to another in Python

You can move a file from one directory to another in Python using the shutil module.  The shutil module provides functions to perform various file operations, including moving files.  How you can move a file from one directory to another:

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.

How to add an environment variable in Ubuntu

To set an environment variable on Ubuntu, can be achieved via a few options.  This depends on whether you want the variable to be system-wide or specific to a user's session.  Here are a couple of more common methods for setting environment variables:

Subscribe to Terminal