Author Archives: Daniel Sobrinho

Changing the keyboard layout in CentOS 7 via terminal

Which of us has never been through the situation of typing a bar and exiting a semicolon on the console? yes, we know it's awful. So here's a simple tip on how to change your keyboard layout in CentOS 7.

To see your current layout, go with the command:
localectl

In the output of this command, look for the VC Keymap property, which will probably be us. Now, let's change it to the good old ABNT2 keyboard by entering with the command:
localectl set-keymap b
r-abnt2

One more tip: if you need to see what layouts are available, just enter the following command:

list-keymaps localectl

File Compression and Unpacking on Linux

This is a very complete article on handling compressed files that I found on one of the blogs I always access,the Always Update. In it you will understand everything about all file formats… I leave here my opinion about the preference for bz2 compaction, as it is not, fast and super strong.

When we talk about compressing and unpacking files within Linux systems, we usually think of something simple and that no one needs to know, here's a big mistake. A good Linux system administrator needs to have extensive knowledge, and this item is highly recommended, especially when we deal only with terminal. After all, in some cases there will be no graphical environment and for this, you need to be aware of how to compress or unpack the files on Linux.

When it comes to Linux we have several types of files, however the most famous are gzip and bzip2 and so the extensions that will be displayed would be respectively .gz and bz2.Among the two types of files we quote, bzip2 is the best option when it comes to file compression, it can make compressed files smaller than if gzip were used, but in case of emergency know that bzip2 takes a while to unpack or compress.

But before you go around compressing everything, know that large files or directories need to be compressed with .tar and only then can be compressed in gz or gz2.

Files .tar

Now, let's use a nomenclature which may be strange to some, it would be packaging, the term is used to define the act of gathering multiple files making them one, as long as it is one inside the other, which is also called a package file. Usually this final file has the same size corresponding to the size of each unified, or packaged, file.

Currently even after so long, the most used utility still remains the .tar.

How to package using .tar

Because it is recursive, the tar command can be used not only in applications, it can also package files from an entire directory. It would basically be what happens in the supermarket, a tray of eggs, meat and so many other things and we insert all of them inside a bag or box, at this point we can use the act of putting everything together in a single packaging package.

To package using the .tar see how simple it is. Let's say you want to package the /opt directory so here's what the command syntax would look like.

sudo tar cvf empacotamento_opt.tar /opt

And so our /opt directory packaging will have the size equivalent to the actual size of all the files contained there!

How to unpack using .tar

Without much to explain, unpacking is similar to packaging, the command is very similar.

sudo tar xvf empacotamento_opt.tar

And then you might think that in the syntax of the command it is possible to identify the xvf and the cvf that appear in the syntax composition, but let's understand that as well.

  • c -> the file or directory that will be packaged.
  • f -> Item required to manipulate the file, the letter "f" comes from file.
  • v -> With v verbose mode is activated, i.e. you will know everything that is happening, the output of what is being done will be displayed. You no longer need to use the '-' to specify the TAR options.
  • x -> is used to extract the file or directory.

Compressing with compress, gzip and bzip2

Unlike packaging, compression as the name already says serves to compress the compressed files or items, for the purpose of decreasing the file size, this is due to the fact that compression acts on repeated bit sequences and that they are present in a file or package.

Common and still widely used compactors are:

  • Compress
  • Gzip
  • Bzip2

For starters let's install the much talked about compress:

For Ubuntu, Debian, Linux Mint:

sudo apt install ncompress

For Fedora and derivatives:

sudo dnf install ncompress
Note: The package name is usually the same for any distribution, so we only mention two examples!

Identified the result of the compactions of each compactor

Although it seems redundant, and it is, you need to understand when a file is compressed with each item.

  • extension.Z – Compressed with compress
  • Extension .gz – Compressed with gzip
  • Extension .bz2 – Compressed with bzip2

And how to compress with Compress, gzip and bzip 2?

To compress run:

compress -c aquivo > file. z

For gzip run:

gzip -c file > file.gz

For bzip2 run:

bzip2 -c file >.bz2

And how to unpack with Compress, gzip and bzip 2?

To compress run:

uncompress file. z

For gzip run:

gzip -d file.gz

For bzip2 run:

bzip2 -dc file.bz2 > file

Compressing and packaging at the same time .tar.bz2 and .tar.gz

Let's use the example of the first packaging we empacotamento_opt.tar

With .tar.gz:

sudo tar czvf empacotamento_opt.tar.gz /opt

With .tar.bz2:

sudo tar cjvf empacotamento_opt.tar.bz2 /opt

Unpacking and unpacking at the same time .tar.bz2 and .tar.gz

With .tar.gz:

sudo tar xzvf empacotamento_opt.tar.gz

With .tar.bz2:

sudo tar xjvf empacotamento_opt.tar.bz2

And to be no different, let's then understand the options of the commands we use as examples:

  • c -> the file or directory that will be packaged.
  • f -> Item required to manipulate the file, the letter "f" comes from file.
  • v -> With v verbose mode is activated, i.e. you will know everything that is happening, the output of what is being done will be displayed. You no longer need to use the '-' to specify the TAR options.
  • x -> is used to extract the file or directory.
  • Z-> Indicates that it will be compressed with compress
  • j -> Indicates that it will be compressed with bzip2

Source: Always Update .com.br

How to install dnsonly cPanel on CentOS server with 512Mb Ram

Sometimes we need or want to have a DNS server for WHM cPanel for external synchronization/mirroring, without having to spend too much. By purchasing a cheap VPS of 512Mb of ram (minimum to have quality, experience of our own), we can circumvent the installation process by changing the minimum server requirements. Here are the steps:

  1. Download installer: curl -the latest-dnsonly -L https://securedownloads.cpanel.net/latest-dnsonly
  2. Start custom installation: sh latest-dnsonly --keep
  3. Edit the installation file inside the created folder: vi /installd/install
  4. Change the key below:
    my $min_memory_rules = {
    default => 512, # CentOS 5/6 => in a better world should be 512
    7 => 1_024, #CentOS 7
    };
  5. Save the file and continue the installation: sh bootstrap-dnsonly

Change cPanel DNS record via terminal

To change, add or remove some account record of WHM cPanel via terminal use the steps below, before just remember that you must have minimal knowledge of what you are doing, change a key erroneously may suspend the operation of your domain, we are not responsible for any results … follow the steps:

In the terminal as root server access the domain files in: /var/named
Edi
t the file for the domain: nano /var/named/domain.com.br.db
To term
inate after editing the keys you need to restart the DNS server and reload your cache, the steps are: systemctl restart named and after rndc reload

ready!

We emphasize that the whole procedure is the entire responsibility of those who are performing it, this above is knowledge of personal use that is being shared.
For any questions I leave a comment or send a message.