Identifying the CentOS Release version

How to check CentOS version

The purpose of this tutorial is to show how to check the CentOS version of your Linux system. It’s possible to do this from either command line or GUI, so you can use whichever method is more convenient for you. Classic CentOS is nearing its end of life and will be replaced by CentOS Stream. Knowing your CentOS version will give you some insight into how long your system will continue to be supported.

Read more

How to extract a specific file from gzip compressed archive tarball

In order to extract a specific file from gzip compressed archive tarball you first need to know the full path to this file. Consider a following example.

$ tar tzf to-gzip.tar.gz
to-gzip/
to-gzip/file10.txt
to-gzip/file9.txt
to-gzip/file8.txt
to-gzip/file7.txt
to-gzip/file6.txt
to-gzip/file5.txt
to-gzip/file4.txt
to-gzip/file3.txt
to-gzip/file2.txt
to-gzip/file1.txt

Read more

Searching for two different file name patterns in a compressed archive on Linux

Search the contents of compressed gzip archive file on Linux

Archives compressed with gzip have the .tar.gz or .tgz file extension. It’s easy enough to extract the contents from these files, but what if you only need a certain file? There’s not much sense in extracting hundreds or thousands of files from an archive if you’re only looking for a few files.

Fortunately, we can utilize the Linux command line and even GUI archive managers to search the contents of gzip compressed archives. Once we identify the file we want, it’s possible to extract the file by itself, rather than extracting every single file.

In this guide, we’ll show how to search one or multiple gzip archives for a particular file from both command line and GUI.

In this tutorial you will learn:

  • How to search the contents of a compressed gzip archive via command line
  • How to search the contents of a compressed gzip archive via GUI
  • How to search the contents of multiple gzip archives
  • How to extract a particular file from a gzip archive

Read more

Compress file or directory using RAR archive tool on Linux shell

Here is a quick config tip on how to compress and extract files using RAR archive utility. First let’s see how we can compress directory using RAR. In our example we have a directory called my_files containing five files:

$ mkdir my_files
$ touch my_files/file{1..5}
$ ls my_files/
file1  file2  file3  file4  file5

To compress entire directory using RAR archive tool we use rar’s a command. The below command will create a RAR archive called my_files.rar containing all five above files:

$ rar a my_files.rar my_files/

Creating archive my_files.rar

Adding    my_files/file5                                              OK 
Adding    my_files/file4                                              OK 
Adding    my_files/file3                                              OK 
Adding    my_files/file2                                              OK 
Adding    my_files/file1                                              OK 
Done
$ ls -l my_files.rar 
-rw-rw-r--. 1 lrendek lrendek 307 Nov  3 06:55 my_files.rar

Read more

Create a random character text file using Linux shell

Here is a nice trick on how to create a dummy character text file consisting of any chosen or random characters. In the first example we will create and simple file consisting of a single character X with a size of 1000 bytes:

$  < /dev/urandom tr -dc "X" | head -c1000 > file.txt
SAMPLE:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

or we can create a file consisting of an alphabetic and numeric character:

$ < /dev/urandom tr -dc "[:alnum:]" | head -c1000 > file.txt
SAMPLE:
CCjeuAhJNc4yxBfeMbbYX1U1TnSCVS5oiV53MtGoA6s45FAw9H9PyfZJHrA421

Read more

Installation of missing php-mbstring on RHEL 7 Linux

The php-mbstring is part of Redhat’s server optional packages. If you have a current subscirption all you need to do is to enable this repository using:

[root@rhel7 ~]# subscription-manager repos --enable=rhel-7-server-optional-rpms

and use yum to install php-mbstring. In case that you do not have a current Redhat subscription you can install php-mbstring directly from IUS project repository:

[root@rhel7 ~]# wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/7/x86_64/ius-release-1.0-13.ius.el7.noarch.rpm
[root@rhel7 ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
[root@rhel7 ~]# rpm -Uvh *release*.rpm

Read more