Category Archives: configuration

Encrypt/Decrypt File with Vim Editor

In this howto we will see how to encrypt and decrypt a file with Vim editor.

Lets Encrypt a file:

linux-06ac:/opt # vim -x encryptedfile.txt
Warning: Using a weak encryption method; see :help 'cm'
Press ENTER or type command to continue

Now Press enter and it will ask you to set a password.

Enter encryption key: **********
Enter same key again: **********

Once you setup the password, you will be presented with the blank page where  you can start writing to the file as you do with Vim.

I am writing ” Helo Linux World” as an example to my encryptedfile.txt , save and quit with :wq

Not cat the file

linux-06ac:/opt # cat encryptedfile.txt 
VimCrypt~01!q"[�HY�&!���+B]3linux-06ac:/opt #

We can see that the file is Encrypted.

 

Decrypt the File:

To Decrypt permanently, open the file as following:

linux-06ac:/opt # vim encryptedfile.txt

Give the password to the file , you set while encrypting it.

Then type :X and press enter twice (without typing anything) when asked for “Enter encryption key:”

Now save and exit with :wq and viola the file is decrypted.

linux-06ac:/opt # cat encryptedfile.txt 
Helo Linux World

Thanks & Regards,

Salman A. Francis

YouTube: YouTube.com/Linuxking
Twitter: linuxking77
Facebook: https://www.facebook.com/groups/LZHProject/

HowTo Mount 8TB USB in CentoS 7 Server.

This howto is about “How To mount 8TB External USB” in CentOs 7 server.

# yum – y install epel-release

# yum -y install ntfs-3g

# lsblk

sdc 8:32 0 7.3T 0 disk
└─sdc1 8:33 0 7.3T

# mount -t ntfs /dev/sdc1 /mnt/

# ls -ltr /mnt

You will see it’s mounted.

Thanks,

Salman A. Francis

YouTube: LinuxKing

Facebook: Linuxking77 – LZHProject

How to Install PhPMyAdmin on Centos 7 from source

Dear Friends,

First of all we will install required repositories.

[root@itpings opt]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@itpings opt]# yum -y install epel-release

Now we will install apache, mariadb, mariadb-server and php56

[root@itpings opt]# yum -y install httpd mariadb mariadb-server php56w php-mbstring php-mysql php-soap

Once installed we will download phpmyadmin from phpmyadmin.net

[root@itpings opt]# wget https://files.phpmyadmin.net/phpMyAdmin/4.7.2/phpMyAdmin-4.7.2-all-languages.zip

unzip the content and move it to /var/www/html and rename the unzipped content to phpmyadmin

[root@itpings html]# unzip phpMyAdmin-4.7.2-all-languages.zip
[root@itpings html]# mv phpMyAdmin-4.7.2-all-languages.zip phpmyadmin

Now Change the ownership of the folder

[root@red html]# chown -R apache.apache phpMyAdmin
[root@red html]# chmod -R 755 phpMyAdmin

Now we will copy config.sample file to config.ini.php

[root@itpings html]# cp config.sample.inc.php config.inc.php

Now we will edit config.inc.php and only add root user and password of mysql ( Make sure you have root user and password of mysql)

/* User used to manipulate with storage */
 $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
 $cfg['Servers'][$i]['controluser'] = 'root';
 $cfg['Servers'][$i]['controlpass'] = 'itpings123';

Now to visit phpmyadmin visit http://<your-ip-address>/phpmyadmin and provide the above user and password.

Done

Thanks,

Salman A. Francis
YouTube: Linuxking
Facebook: LZHProject, Linuxking77

How to Add Physical Disk to Increase Size of /dev/mapper/centos-root

Dear Friends,

I ran into a problem where my openstack machine ran out of space. My Logical FS /dev/mapper/centos-root was only 50GB and most of the space was lost.

Solution:
LVM

I Added a new 500GB HDD (sdb), created partition with parted (sdb1) and gave the below commands:

[root@stack opt]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

Next Check your Volumes with “vgdisplay” command

[root@stack opt]# vgdisplay 
 --- Volume group ---
 VG Name centos
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 4
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 3
 Open LV 3
 Max PV 0
 Cur PV 1
 Act PV 1
 VG Size 465.27 GiB
 PE Size 4.00 MiB
 Total PE 119109
 Alloc PE / Size 119109 / 465.27 GiB
 Free PE / Size 0 / 0 
 VG UUID TrvUI3-Xt7U-6vzF-5RtW-OfK0-OCOy-Tejrb6
 
 --- Volume group ---
 VG Name cinder-volumes
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 5
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 0
 Open LV 0
 Max PV 0
 Cur PV 1
 Act PV 1
 VG Size 20.60 GiB
 PE Size 4.00 MiB
 Total PE 5273
 Alloc PE / Size 0 / 0 
 Free PE / Size 5273 / 20.60 GiB
 VG UUID 9LDtLm-52Un-1QJA-yc3q-13vE-LqEc-hX0kiU

Continue reading

How to Bring back eth0 on CentOS 7 ( No Dynamic Ethernet Names)

To Install CentOS 7 without dynamic Ethernet names such as enps2001 use the following technique.

Edit the grub file

Go to /etc/default/grub and add the following lines

In front of /root add the following

biosdevname=0 net.ifnames=0

Then issue the following command

grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the machine and you will see eth0 and eth1 instead of enps2001 etc.

Thanks,
Salman

Linux Tips ( chmod tip )

Hey Guys this is going to be a new series of posts in which i will be sharing some cool linux tips.  You can watch the video of this post on http://www.youtube.com/linuxking

So here is the first tip Chmod:

I hope you guys are already familiar with chmod command if not checkout my Youtube “Linuxking” channel for theses commands.

With Chmod you can change the mode of the files and directories.
e.g
chmod 775 dir  command will change the permission on directory with rwxrwxrw-

Also using -R option with chmod will change the permission on the directory as well the content within the directory with same permissions.

However lets say you want to change the permissions of a directories to executable within a directory without changing permissions of file use the below tip.

Lets say you have a directory “test1” & “test2” inside “test” directory

test directory has also a  file inside it called file1.txt

file1.txt has permission rw——-

directory test1 has permission rwx——

directory test2 has permission rw——-

linux-11oz:/test # ls -ltr
total 0
-rw------- 1 root root 0 Mar 22 17:06 file.txt
drwx------ 1 root root 0 Mar 22 17:07 test2
drwx------ 1 root root 0 Mar 22 17:07 test1

Now if you try to change the permission with a simple ” chmod -R command ” of all the directories to “executable” inside test directory you could also change permission of the file inside test diretory.

Example:

linux-11oz:/ # chmod -R ug+x test/
linux-11oz:/ # cd test/
linux-11oz:/test # ls -ltr
total 0
-rwx--x--- 1 root root 0 Mar 22 17:06 file.txt  (You can see that the file also became executable)
drwx--x--- 1 root root 0 Mar 22 17:07 test2
drwx--x--- 1 root root 0 Mar 22 17:07 test1

Now to avoid such situation we will use X instead of x, lets see the impact of X with chmod command

linux-11oz:/ # chmod -R ug+X test/
linux-11oz:/ # cd test/
linux-11oz:/test # ls -ltr
total 0
-rw------- 1 root root 0 Mar 22 17:06 file.txt (You can see the file's permission has not changed to executable)
drwx--x--- 1 root root 0 Mar 22 17:07 test2
drwx--x--- 1 root root 0 Mar 22 17:07 test1
linux-11oz:/test #

I hope you have Enjoyed this tip, keep visiting our site for more information.

Linux Practical Security Course

Dear Members ,
I am happy to announce that Linux Practical Security by LZH Project is complete. We will launch it shortly. Please support us by buying and rating this course. For first 20 buyers there will be a discount of $5. Total cost is $25. You can also book your copy by sending me email to learning@itpings.com Please take a look at the introductory video here:

Unable to Connect “The Squid Error “

So today i had a strange problem when i was only able to access google.com and not other sites. I was able to browse gmail, but not mail ru. Everything was working fine but out of no where this error “Unable to Connect” appeared on my Browsers. It was kinda strange, since i made no changes to my system” Also i was not sure if it’s the system or the Gateway.
Observation on System:
1) Both Firefox and Chrome giving the same problem.
2) I was able to browse with Chrome if Ultrasuf Extension was enabled.
3) Firebug reported “Aborted” in the Net tab

Steps taken:

Restarted the System
Changed the IP address
Result:
System Not Fixed Continue reading