Skip to main content

5 posts tagged with "linux"

View All Tags

How to find and delete files that are "eating up" space on the server

· 2 min read
Customer Care Engineer

Running out of space on your server? This may cause the site and database to malfunction. To free up space, you need to identify the files taking up the most room and delete them. In this article, we’ll explain how to easily accomplish this using the ncdu utility and how to safely clean up logs.


Step 1: Installing and running ncdu

ncdu  is a handy tool for disk space analysis. It displays all folders and files sorted by size in an easy-to-use text interface.

To use this program, you’ll need to connect to your server via SSH.  

Installation

  • Debian/Ubuntu:
sudo apt update && sudo apt install ncdu
  • CentOS/AlmaLinux/Rocky Linux:
sudo yum install ncdu

Running disk analysis

  • To scan the root directory /, execute:
sudo ncdu -x /

The -x option in ncdu restricts the scan to a single file system, excluding mounted virtual directories (e.g., /proc, /dev, /sys) and any other volumes mounted via separate mount points (e.g., network or external drives).

  • To analyze a specific directory:
sudo ncdu /path/to/directory

For example, to scan only the logs directory, run:

sudo ncdu /var/log

Step 2: Analyzing and deleting unnecessary files

After running ncdu, you will see a list of files and folders sorted by size. Navigation is simple:

  • Up/Down arrow keys — move through the list.
  • Enter — navigate into a directory.
  • D — delete the selected file or folder.

Ncdu inctruction 1

danger

Be careful when deleting system files. Delete only those files that you are sure of.

When files are deleted in Linux, they are permanently removed! Recovery is only possible through backups, and only if available.

It is safer to create a list of files and directories taking up significant space (highlight rows in ncdu and copy them to a notepad on your local PC), then review each individually and delete them using the command line.

To delete a file, run:

sudo rm -f /path/to/file

To delete a directory:

sudo rm -rf /path/to/directory

  Here's a list of the major directories that tend to take up a lot of space:

  1. /var/www/ - directory with your sites

Often, the largest directories are upload and cache in the root directory of the website, containing user-uploaded files and the site cache, respectively. For example:

/var/www/user/data/www/yoursite.com/upload/

Files in these directories are relatively safe to delete. However, only you, as the administrator of your website, know which files in the upload directory are important and which are no longer needed. It is recommended to leave the directory itself intact to avoid errors. 

  1. /var/lib/mysql/

This is the directory containing your website databases. 

danger

Please do not delete anything from this directory!

If it is taking up an unusually large amount of space, contact your hosting provider for a deeper analysis of the issue. 

  1. /var/log/

This directory stores logs generated by software running on your server. Logs have specific characteristics, and their cleanup is covered in a separate article.


Step 3: Finalizing and verifying

After deleting unnecessary files, check how much space has been freed using the command:

df -h

Working with TAR Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

The TAR format is extremely popular in the Linux world and is the de facto data archiving standard. It can’t compress files by itself but perfectly cooperates with such compression utilities as gzip or bzip2. Therefore, most archives packed with this format that you can find on the web will look as archive_name.tar.gz.

Before You Begin

In most cases, tar is installed by default. To be 100% sure, run the command to install this archiver:

For Debian and Ubuntu:

sudo apt update && sudo apt install tar

For CentOS and Rocky Linux/AlmaLinux:

sudo yum makecache && sudo yum install tar

How to Create a TAR Archive

Without compression:

tar -cvf archive.tar /file/path

Where:

  • -c — to create an archive
  • -v — show details in the terminal (you’ll find it useful if you want to see what’s going on)
  • -f — specify the name of the archive file

With additional compression (for example, gzip):

tar -czvf archive.tar.gz /file/path
  • -z — adds gzip compression.

The second command is preferable in most cases, since additional compression will save time for downloading or uploading a file from or to the server, and the archive will take up less drive space.

How to extract a TAR Archive

For gzip:

tar -xzvf archive.tar.gz

For bzip2:

tar -xjvf archive.tar.bz2

For a uncompressed archive:

tar -xvf archive.tar

Additional Useful Options

  • -t — view the archive contents without unpacking:
tar -tvf archive.tar

Shows a list of archive files in the console, but doesn’t unpack it.

  • -u — update files within the archive:
tar -uf archive.tar /path/to/new_files

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

tar -uf archive.tar /path/to/new_files/*.txt

This command will update all txt files in the archive and will add new ones if they haven’t been added before.

Working with RAR Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

The RAR format is famous for its high compression level, support for data recovery, and high tamper resistance, which made it quite popular in the Windows community. But yet, it’s less popular among Linux users and administrators than a number of other archives. However, you may need to be able to work with it on the server, so let’s take a look at the basic commands and options you’ll need to confidently work with RAR archives in a command prompt.

Before You Begin

Make sure that you have all the required packages installed.

For Debian and Ubuntu:

sudo apt update && sudo apt install rar unrar

For CentOS and Rocky Linux/AlmaLinux:

# Add an additional EPEL repository, since the system ones contain no rar
sudo yum install epel-release
sudo yum makecache && sudo yum install rar unrar

How to Create a RAR Archive

Use the following command to create an archive:

rar a archive.rar /directory/path/

For example:

rar a backup.rar /var/www/html/

How to extract a RAR Archive

To extract the archive in the current directory, use the following command:

unrar x archive.rar

To extract the archive to a directory other than the current one, you need to specify the path to it at the end. For example:

unrar x backup.rar /home/user/backup/

Additional Useful Options

  • -l — show a list of files within the archive without extracting it:
unrar l archive.rar
  • -u — update files within the archive:
rar u archive.rar /path/to/new_files

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

rar u archive.rar *.txt

This command will update all txt files in the archive and will add new ones if they haven’t been added before.

  • -p — set a password for the archive:
rar a -p archive.rar /file/path

Working with ZIP Archives in Linux Command Prompt

· 2 min read
Customer Care Engineer

ZIP is one of the most popular archiving formats. Unlike a home PC that allows you to work with such archives in a convenient graphical interface, most servers don’t provide such an opportunity. So, be sure to know the basic commands to perform typical tasks via a command prompt.

Before You Begin

Make sure that you have all the required packages installed.

For Debian and Ubuntu:

sudo apt update && sudo apt install zip unzip

For CentOS and Rocky Linux/AlmaLinux:

sudo yum makecache && sudo yum install zip unzip

How to Create a ZIP Archive

Use the following command to create an archive:

zip -r archive_name.zip /directory/path/

The -r is used to recursively add all files and subdirectories to the archive.

How to extract a ZIP Archive

To extract zip archive you can use the following command:

unzip archive.zip

The contents will be unzipped in the current directory by default. If you want to unzip the archive into another place, use the -d option.

For example:

unzip backup.zip -d /home/user/backup/

Additional Useful Options

  • -l — show a list of files within the archive without unzipping it:
unzip -l archive.zip
  • -u — update a file within the archive:
zip -u archive.zip new_file.txt

Consider the following details when updating a file within the archive:

  • If the archive contains no new_file.txt, it will be added.
  • If the archive already contains a file of the same name, but its contents on the drive have changed, then this file will be updated to the latest version.

You can also use this command to update multiple files at once, for example:

zip -u archive.zip *.txt

This command will update all .txt files in the archive and will add new ones if they haven’t been added before.

  • -e — set a password for the archive:
zip -e archive.zip /file/path

Linux VPS Hosting - What is and How to Choose?

· 3 min read
Customer Care Engineer

What is a Linux VPS?

VPS (Virtual Private Server) is a virtual dedicated server, which is part of a physical server divided into several virtual machines. VPS with Linux is a virtual server running the free and open source Linux operating system. It is a go-to solution for 95-99% of cases.

Benefits of VPS with Linux

A Linux VPS has all the benefits of a physical server, but Linux is free, open source, and gives you full access and control to customize your server as you see fit. There are many Linux distributions available, including CentOS and Ubuntu, each with its own benefits and use cases. Windows operating systems are expensive and offer much less flexibility and customization options.

Linux VPS illustration 1

VPS with Linux provides:

Dedicated Resources:

A certain amount of CPU, RAM, and disk space is guaranteed.

Full control:

Full access to the server and you can install any software compatible with Linux and necessary for your tasks.

Scalability:

It's easy to increase or decrease the resources of your VPS depending on your needs.

Use Cases for a Linux VPS

A Linux VPS can be used for a variety of purposes, including:

Web hosting:

A Linux VPS is a great solution for hosting websites on WordPress, Drupal, OpenCart, Joomla, Magento, and other applications. It provides high performance, reliability, and security.

Development and testing:

A Linux VPS is a great platform for developing and testing software. It allows you to create an isolated development environment that helps to avoid conflicts with other applications.

Data storage:

A Linux VPS can be used to store data. It provides high reliability and security.

Game servers:

A Linux VPS is a popular solution for hosting game servers. It provides high performance and low latency, which is necessary for a good gaming experience.

How to Choose a Linux VPS

When choosing a Linux VPS, you should consider:

Your needs:

What do you need the VPS for? What applications will you be running on it? How many users will be working with the server simultaneously?

The resources you need:

How much CPU, RAM, and storage space will you need?

The Linux distribution:

There are many distributions of Linux available, each with its own features.

The cost:

Consider the price of the hosting itself, as well as any additional costs for a control panel and technical support.

Which disks to choose for a VPS (SSD, NVMe, HDD)

HDD:

The most affordable type of disk. They have a large capacity but low read/write speed, suitable for backup, data storage, and streaming, e.g. video encoding.

SSD:

They are characterized by high read and write speed, but have limitations on data rewriting up to several million operations. Used for databases, high-load applications, and file storage, which require fast access.

NVMe:

They have the highest read and write speeds, several times higher than regular SSDs, but their rewrite resource is no higher than that of regular SSDs. When working with applications requiring high performance, the disk resource can be exhausted quickly. Suitable for storing a lot of files, or for a database if the main load is reading.

Linux VPS illustration 2

We regularly update our OS templates, so you can always install the latest version of a particular Linux distribution on your server.

The most popular distributions are: Ubuntu, Debian, Alma, and Rocky.

Ubuntu:

One of the most popular Linux distributions. It is easy to use and has a large community of users. Suitable for beginners and experienced users. Offers a wide range of software. If you need help deciding which distribution to choose, we recommend starting with Ubuntu.

Debian:

A stable and reliable Linux distribution. Suitable for servers that need to run without interruption. Offers a wide selection of software packages. Ideal for those who value stability and security.

AlmaLinux:

A new distribution created by the CentOS community. Compatible with CentOS Stream. Offers high stability and security. Ideal for those who want to use CentOS Stream without a subscription.

Rocky Linux:

Another new distribution created by the CentOS community. Compatible with Red Hat Enterprise Linux. High performance and reliability. Ideal for those who want to use Red Hat Enterprise Linux without paying.

Configure your Linux VPS

Choose one of our tariffs, according to the parameters of your project and your server management skills:

Virtual servers VPS

Fully managed VPS hosting

kodu.cloud tariff includes:

–automatic backup

24/7/365 premium technical support

free, easy, and intuitive server control panel FASPANEL