Linux: Compress PDF – Reduce PDF Size

A scanned document saved as PDF can be too large, that is not always good.

For example, the large size of a PDF file won’t permit to send it by email because of the probable limitation on the maximum size of attachments.

In Linux you can compress a PDF file from the command line without losing its quality, with the help of ps2pdf tool, that is a part of ghostscript suite.

From this article you will learn how to compress a PDF file and significantly reduce its size from the Linux command line. (more…)

SED – Find and Replace a String in a File

The substitution option is one of the most useful options of a sed command.

In particular, it allows to search a text file for lines that contain particular string (SEARCH_STRING), word or match some regular expression and replace all occurrences of such lines with some REPLACEMENT_LINE.

To replace the whole line using sed, it is needed to add wildcards (.*) before and after a SEARCH_STRING. (more…)

MySQL: Database Size

It is often required to get the size of a database in MySQL to understand how much disk space does it need.

It is especially useful to check the size of a database if you prepare to migrate it somewhere or going to setup database backup and it needs to choose the storage capacity.

In this short note i will show the SQL queries that get the information about the required databases from the information_schema and print their sizes in megabytes. (more…)

Tor Browser for Linux – How To Download and Install

Tor Browser is widely used for anonymous web-surfing and protection against traffic analysis.

It is also can help to bypass Internet filters and access blocked websites.

This is a simple step by step guide that covers the installation process of the Tor Browser on such Linux systems as Ubuntu, Kali Linux, Debian, Linux Mint, Fedora etc.

Frankly speaking, there is no need to perform the classical installation, as it is just enough to download an archive with the latest stable version of the Tor Browser for Linux, unpack it and start the launcher. (more…)

MySQL: Table Size

Sometimes it is required to find out the size of a table in MySQL database.

For example, if it is needed to perform an optimization and you analyze if some tables have become too large and it is time to tweak them somehow.

In this short note i will show the SQL query that gets the information about the required table from the information_schema and prints the table’s size in megabytes. (more…)

MySQL: Checksum Table

Sometimes it is required to compare two tables to check if they are the same or not.

For this you can calculate and compare the checksums of each table, using the CHECKSUM TABLE command in MySQL.

This command is especially useful if you’re using MySQL replication and want to ensure that master and slave are consistent by verifying that their tables are identical. (more…)

Show Git Branch In Terminal – Command Prompt

When you are working inside a Git repository it is important to realize what is the currently checked out Git branch.

You can make it easier to track where you are, by showing the name of the current Git branch in the terminal (command prompt).

In the almost any Linux distribution, including Ubuntu and CentOS, this can be easily done by configuring a primary prompt string, that is controlled via a special shell variable PS1 (more…)

MySQL: Show Users, Privileges and Passwords

In this article i will show how to list MySQL users, their passwords and granted privileges from the command-line prompt.

MySQL account consists of two components: user and host.

This allows the same user to use different MySQL accounts with different privileges, depending on which host they are connecting from.

In the Host field, besides of the common IP addresses and host names, you can see the % sign, that is a wildcard character that means “any” host. (more…)