Quantcast
Channel: Free Linux Tutorials
Viewing all 73 articles
Browse latest View live

Configuring Multiple Interfaces and Multiple Default Routes in Linux

$
0
0

Scenario: Multiple network interfaces in your server and each connected to different network and getting the IP via DHCP
Objective: Make all IP pingable and accessible remotely e.g. SSH
Solution: Configure Gateway Routing or setting up multiple default routes for each interfaces

Initially when you connect different links/network (regardless it’s in the same subnet or not) for each of the interfaces, it will end up only one interface is reachable. Why? Because by default, it can only have one default route or gateway on a system.

Example: 5 NIC in 1 Linux Server
Noted: Tested in Redhat based Linux (CentOS,Fedora). Assuming the IP dynamically assigned by the DHCP server:

eth1=ip:192.168.10.100/24 gw:192.168.10.1
eth2=ip:192.168.20.100/24 gw:192.168.20.1
eth3=ip:192.168.30.100/24 gw:192.168.30.1
eth4=ip:192.168.40.100/24 gw:192.168.40.1
eth5=ip:192.168.50.100/24 gw:192.168.50.1

1. Set eth1 as the default route and disable it from other interfaces
a. add the line “DEFROUTE=yes” (without the quote) to /etc/sysconfig/network-scripts/ifcfg-eth1
b. add the line “DEFROUTE=no” (without the quote) to /etc/sysconfig/network-scripts/ifcfg-eth2  .. to ifcfg-eth5

2. Restart the network and the IP routing table should be something like this:

[tux@freelinux ~]$ netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
192.168.40.0 0.0.0.0 255.255.255.0 U 0 0 0 eth4
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth5
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth1

From the example above, the only pingable/reachable would be the eth1 IP only as it carries the default gateway.

3. Setup additional routing table
a. Edit the file  /etc/iproute2/rt_tables and set the eth1 with preference 1, and eth2 with 2, and so on and so forth. Any name to represent it can work, this is basically creating a policy in the routing table that can be called later.  Sample content of that file will be something like:
[tux@freelinux ~]$ cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 ilove
2 free
3 linux
4 tutorials

b. Configure the routing table. Firstly, configure the 192.168.20.0/24 to tell that it can be reached in “ilove” and to find its gateway. Secondly, set interface’s default gateway
ip route add 192.168.20.0/24 dev eth2 src 192.168.20.100 table ilove
ip route add default via 192.168.20.1 dev eth2 table ilove

c. Set the policy routes for the system to know when to use that new routing table
ip rule add from 192.168.20.100 /32 table ilove
ip rule add to 192.168.20.100/32 table ilove

Do the same thing for eth3-5. These will be the configuration for the rest:
for eth3:
ip route add 192.168.30.0/24 dev eth3 src 192.168.30.100 table free
ip route add default via 192.168.30.1 dev eth3 table free
ip rule add from 192.168.30.100 /32 table free
ip rule add to 192.168.30.100/32 table free

for eth4:
ip route add 192.168.40.0/24 dev eth4 src 192.168.40.100 table linux
ip route add default via 192.168.40.1 dev eth4 table linux
ip rule add from 192.168.40.100 /32 table linux
ip rule add to 192.168.40.100/32 table linux

for eth5:
ip route add 192.168.50.0/24 dev eth5 src 192.168.50.100 table tutorials
ip route add default via 192.168.50.1 dev eth5 table tutorials
ip rule add from 192.168.50.100 /32 table tutorials
ip rule add to 192.168.50.100/32 table tutorials

Check: Ping and ssh all the IP address see if it’s already reachable
Verification (sample output)

[tux@freelinux ~]$ ip rule show
0: from all lookup local
32732: from all to 192.168.50.100 lookup tutorials
32733: from 192.168.50.100 lookup tutorials
32734: from all to 192.168.40.100 lookup linux
32735: from 192.168.40.100 lookup linux
32736: from all to 192.168.30.100 lookup free
32737: from 192.168.30.100 lookup free
32738: from all to 192.168.20.100 lookup ilove
32739: from 192.168.20.100 lookup ilove
32740: from all lookup main
32741: from all lookup default

Simple explanation: Rule 32732 means that all traffic going to eth5 will use the “tutorials” routing table.  Rule 32733 means that traffic coming from eth5 will use the”tutorials” routing table. And so on, and so forth

[tux@freelinux ~]$ ip route show table all

192.168.20.0/24 dev eth2 table ilove scope link src 192.168.20.100
default via 192.168.20.1 dev eth2 table ilove
192.168.30.0/24 dev eth3 table free scope link src 192.168.30.100
default via 192.168.30.1 dev eth3 table free
192.168.40.0/24 dev eth4 table linux scope link src 192.168.40.100
default via 192.168.40.1 dev eth4 table linux
192.168.50.0/24 dev eth5 table tutorials scope link src 192.168.50.100
default via 192.168.50.1 dev eth5 table tutorials
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.100
default via 192.168.10.1 dev eth1

Enjoy! Cheers!

Share

The post Configuring Multiple Interfaces and Multiple Default Routes in Linux appeared first on Free Linux Tutorials.


Quick Tip: Get or Find your Public IP Address using curl

$
0
0

Some sample websites that you can use with curl to display your external public IP. As you know, especially if you are connected to a router, it will provide you private IP via the DHCP and it is NAT’ed. So using ‘ifconfig’, ‘ip addr show’, ‘hostname -I’ or via the GUI won’t show the public IP.

curl ifconfig.co  
curl icanhazip.com
curl ifconfig.me
curl ipecho.net/plain ; echo
curl ident.me ; echo
curl checkip.amazonaws.com
curl bot.whatismyipaddress.com ;echo
curl myexternalip.com/raw
curl whatismyip.akamai.com ; echo
curl myip.dnsomatic.com;echo
curl -s ipinfo.io | jq .ip
#need to install jq

Or you want to challenge yourself, you can combine it with sed to do some filtering

curl -s checkip.dyndns.org | sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

Share

The post Quick Tip: Get or Find your Public IP Address using curl appeared first on Free Linux Tutorials.

Installing WordPress in Raspberry Pi with Nginx, MySQL and PHP

$
0
0

It is meant to function as a staging or testing server where you can  do compatibility test  latest wordpress version on your existing sites, or try themes, plugins,widgets or practice your coding skills in css & php before deploying into your production, then using rpi is a good option.

Components used and tested working:

Raspberry Pi Model B , installed with Raspbian GNU/Linux 8 Jessie (Kernel armv6l Linux 4.9.35+)
nginx(1.6.2-5+deb8u5) (Web Server)
php5 (php5 5.6.33)
mysql 5.5 (ver.5.5.59-0+deb8u1) (Database Server)
wordpress

Before start the actual installation, update rpi packages

pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade

Sample output:
pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade
Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [9,536 kB]
Get:3 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
Fetched 9,874 kB in 46s (210 kB/s)
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
176 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
Need to get 94.4 MB/97.3 MB of archives.
After this operation, 3,064 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Fetched 94.4 MB in 2min 47s (564 kB/s)
Reading changelogs… Done
Running hooks in /etc/ca-certificates/update.d….done.

1. Install Nginx 

pi@raspberrypi:~ $ sudo apt-get install nginx

Test if everything ok by running:

pi@raspberrypi:~ $ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Start nginx and check status if running:
pi@raspberrypi:~ $ sudo service nginx start
pi@raspberrypi:~ $ sudo service nginx status

Open your favorite web browser and test it by going to Pi’s localhost or actual IP, e.g. http://localhost , http://192.168.1.200 . If working, you will be able to see the default page which is the index.html under /var/www/html , and see message something like:

 

If any changes done, reload the config
pi@raspberrypi:~ $ sudo systemctl reload nginx

2. Install PHP

As WordPress is written in PHP, we need to install PHP as the scripting language . PHP is a server-side programming language that can serve dynamic pages and it is processed via its php module
a. Install using the following command:
pi@raspberrypi:~ $ sudo apt-get install php5 php-fpm php5-mysql

b. Configure the nginx configuration file for php module to work. Modify the default file under /etc/nginx/sites-available directory, make sure to uncomment or add the following lines:
pi@raspberrypi:~ $ sudo vi /etc/nginx/sites-available/default

server_name 192.168.1.200;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}

Test by doing the following steps:

a.  Create index.php under the default root directory (/var/www/html) with the contents below:
pi@raspberrypi:~ $ sudo vi /var/www/html/index.php

<?php
phpinfo();
?>

b. Access http://localhost or http://192.168.1.200, if you see something like this as per below image, then php was sucessfully installed.

3. Install MySQL server

pi@raspberrypi:~ $ sudo apt-get install mysql-server

root password will be asked during installation , this will use to access the MySQL engine.

Login to mysql as root with the password provided during installation. Create a database name “wordpress” and wordpress user and grant all privileges for that database  e.g. (db name: wordpress username: wpadmin pass: freelinux)

 

mysql> CREATE USER wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> FLUSH PRIVILEGES;
mysql> quit;
Query OK, 1 row affected (0.00 sec)

4. Install WordPress

Download, install, extract and change file ownership
pi@raspberrypi:~ $ cd /var/www/html
pi@raspberrypi:~ $ sudo wget http://wordpress.org/latest.tar.gz
pi@raspberrypi:~ $ sudo tar zxvf latest.tar.gz
pi@raspberrypi:~ $ sudo rm latest.tar.gz
pi@raspberrypi:~ $ sudo chown -R www-data /var/www/html/wordpress

Navigate using your browser http://192.168.1.200 and will be presented with WordPress welcome page
-Click “Let’s go” to proceed the setup
-Will be presented by the following, fill out accordingly (in case need to change, can modify the wp-config.php later on):
Database Name: wordpress
User Name: wpadmin
Password: freelinux
Database Host: localhost
Table Prefix: wp_

-Click Submit
-Click “Run the install”
-Next fill out necessary information such as Site Title, username, password and email address. Then click the “Install WordPress” button

Once done, login using the username and password provided earlier, URL is http://192.168.1.200/wp-admin

Enjoy customizing your wordpress by changing themes, installing plugins and widgets , or can edit the stylesheet css if necessary.
Now you’re ready to start adding your first ever post. Happy blogging!

Sample screencap:

 

Additional Tips or optional tasks:

1. If you have existing database and want to restore from backup database, here’s the command to restore

pi@raspberrypi:~ $ mysql -u wpadmin -p wordpress < freelinux-backup.sql

2. If migrating WordPress from Apache to Nginx, permalinks may not work even after re-saving changes (Settings > Permalinks > Save Changes). Try to change the “try_files from $uri $uri/ =404 to $uri $uri/ /index.php?$args

before:  try_files $uri $uri/ =404;
after:     try_files $uri $uri/ /index.php?$args;

3. Can create virtualhost if have multiple instances of wordpress

Share

The post Installing WordPress in Raspberry Pi with Nginx, MySQL and PHP appeared first on Free Linux Tutorials.

Installing Openstack RDO Packstack in CentOS

$
0
0

Want to deploy Openstack and experience your own cloud platform the easier way? One way is to install Openstack via RDO Packstack*.
*Packstack is a utility that uses Puppet modules to deploy various parts of OpenStack . It is suitable for deploying both single node proof of concept  or more complex multi node installations.

Components used and tested in:
CentOS 7 Linux 3.10.0-693.el7.x86_64
Openstack Packstack (latest stable release, Pike)

Advisable to stop firewalld, NetworkManager and enable network

#service firewalld stop
#chkconfig firewalld off
#service NetworkManager stop
#chkconfig NetworkManager off
#service network start
#chkconfig network on

Sample Output:

[root@freelinux vinyard]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
[root@freelinux vinyard]# chkconfig firewalld off
Note: Forwarding request to ‘systemctl disable firewalld.service’.
[root@freelinux vinyard]# service NetworkManager stop
Redirecting to /bin/systemctl stop NetworkManager.service
[root@freelinux vinyard]# chkconfig NetworkManager off
Note: Forwarding request to ‘systemctl disable NetworkManager.service’.
[root@freelinux vinyard]# service network start
Starting network (via systemctl): [ OK ]
[root@freelinux vinyard]# chkconfig network on

1. Enable repository in CentOS (latest stable release as of this writing is Pike)
# yum install -y centos-release-openstack-pike

Sample Output:
[root@freelinux ~]# yum install -y centos-release-openstack-pike
Loaded plugins: fastestmirror

================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
centos-release-openstack-pike x86_64 1-1.el7 extras 5.3 k
Installing for dependencies:
centos-release-ceph-jewel noarch 1.0-1.el7.centos extras 4.1 k
centos-release-qemu-ev noarch 1.0-2.el7 extras 11 k
centos-release-storage-common noarch 1-2.el7.centos extras 4.5 k
centos-release-virt-common noarch 1-1.el7.centos extras 4.5 k

Transaction Summary
================================================================================
Install 1 Package (+4 Dependent packages)

Installing : centos-release-virt-common-1-1.el7.centos.noarch 1/5
Installing : centos-release-qemu-ev-1.0-2.el7.noarch 2/5
Installing : centos-release-storage-common-1-2.el7.centos.noarch 3/5
Installing : centos-release-ceph-jewel-1.0-1.el7.centos.noarch 4/5
Installing : centos-release-openstack-pike-1-1.el7.x86_64 5/5

 

Installed:
centos-release-openstack-pike.x86_64 0:1-1.el7

Dependency Installed:
centos-release-ceph-jewel.noarch 0:1.0-1.el7.centos
centos-release-qemu-ev.noarch 0:1.0-2.el7
centos-release-storage-common.noarch 0:1-2.el7.centos
centos-release-virt-common.noarch 0:1-1.el7.centos

Complete!

2. Update current packages

# yum update -y

[root@freelinux ~]# yum update -y
Loaded plugins: fastestmirror
centos-ceph-jewel | 2.9 kB 00:00
centos-openstack-pike | 2.9 kB 00:00
centos-qemu-ev | 2.9 kB 00:00
(2/3): centos-openstack-pi 0% [ ] 0.0 B/s | 0 B –:– ETA (2/3): centos-openstack-pi 2% [ ] 0.0 B/s | 31 kB –:– ETA (1/3): centos-qemu-ev/7/x86_64/primary_db | 33 kB 00:15
(2/3): centos-ceph-jewel/7/x86_64/primary_db | 64 kB 00:16
(3/3): centos-openstack-pi 16% [==- ] 159 kB/s | 172 kB 00:05 ETA (3/3): centos-openstack-pi 20% [=== ] 154 kB/s | 215 kB 00:05 ETA (3/3): centos-openstack-pi 26% [==== ] 153 kB/s | 280 kB 00:05 ETA (3/3): centos-openstack-pi 31% [===== ] 150 kB/s | 338 kB 00:04 ETA (3/3): centos-openstack-pi 39% [====== ] 151 kB/s | 414 kB 00:04 ETA (3/3): centos-openstack-pi 45% [======= ] 150 kB/s | 479 kB 00:03 ETA (3/3): centos-openstack-pi 53% [========- ] 155 kB/s | 571 kB 00:03 ETA (3/3): centos-openstack-pi 63% [========== ] 163 kB/s | 678 kB 00:02 ETA (3/3): centos-openstack-pi 74% [===========- ] 172 kB/s | 793 kB 00:01 ETA (3/3): centos-openstack-pi 87% [============== ] 184 kB/s | 929 kB 00:00 ETA (3/3): centos-openstack-pike/x86_64/primary_db | 963 kB 00:20
Loading mirror speeds from cached hostfile

* base: centos.usonyx.net
* extras: centos.usonyx.net
* updates: centos.usonyx.net
Resolving Dependencies
–> Running transaction check
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
—> Package mariadb-libs.x86_64 3:10.1.20-2.el7 will be an update
–> Processing Dependency: mariadb-common(x86-64) = 3:10.1.20-2.el7 for package: 3:mariadb-libs-10.1.20-2.el7.x86_64
–> Running transaction check
—> Package mariadb-common.x86_64 3:10.1.20-2.el7 will be installed
–> Processing Dependency: /etc/my.cnf for package: 3:mariadb-common-10.1.20-2.el7.x86_64
–> Running transaction check
—> Package mariadb-config.x86_64 3:10.1.20-2.el7 will be installed
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
mariadb-libs x86_64 3:10.1.20-2.el7 centos-openstack-pike 643 k
Installing for dependencies:
mariadb-common x86_64 3:10.1.20-2.el7 centos-openstack-pike 63 k
mariadb-config x86_64 3:10.1.20-2.el7 centos-openstack-pike 26 k

Transaction Summary
================================================================================
Install ( 2 Dependent packages)
Upgrade 1 Package

Dependency Installed:
mariadb-common.x86_64 3:10.1.20-2.el7 mariadb-config.x86_64 3:10.1.20-2.el7
Updated:
mariadb-libs.x86_64 3:10.1.20-2.el7
Complete!

3. Install Openstack Packstack Installer

# yum install -y openstack-packstack

Sample output:

[root@freelinux ~]# yum install -y openstack-packstack
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.usonyx.net
* extras: centos.usonyx.net
* updates: centos.usonyx.net
Resolving Dependencies
–> Running transaction check
—> Package openstack-packstack.noarch 1:11.0.1-1.el7 will be installed
–> Processing Dependency: openstack-packstack-puppet = 1:11.0.1-1.el7 for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: pyOpenSSL >= 16.2.0 for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-setuptools for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-pbr for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-netifaces for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-netaddr for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-docutils for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: PyYAML for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Running transaction check
—> Package PyYAML.x86_64 0:3.10-11.el7 will be installed

Installed:
openstack-packstack.noarch 1:11.0.1-1.el7

Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7
augeas-libs.x86_64 0:1.4.0-2.el7_4.2
facter.x86_64 1:2.4.4-4.el7
hiera.noarch 1:1.3.4-5.el7
jbigkit-libs.x86_64 0:2.0-11.el7
lcms2.x86_64 0:2.6-3.el7
libimagequant.x86_64 0:2.8.2-2.el7
libjpeg-turbo.x86_64 0:1.2.90-5.el7
libselinux-ruby.x86_64 0:2.5-11.el7
libtiff.x86_64 0:4.0.3-27.el7_3
libwebp.x86_64 0:0.3.0-7.el7
libyaml.x86_64 0:0.1.4-11.el7_0
openjpeg2.x86_64 0:2.1.2-1.el7
openstack-packstack-puppet.noarch 1:11.0.1-1.el7
pciutils.x86_64 0:3.5.1-2.el7
puppet.noarch 0:4.8.2-1.el7
puppet-aodh.noarch 0:11.4.0-1.el7
puppet-apache.noarch 0:2.0.0-1.e31a682git.el7
puppet-ceilometer.noarch 0:11.5.0-1.el7
puppet-certmonger.noarch 0:1.1.1-2.d09f0f2git.el7
puppet-cinder.noarch 0:11.5.0-1.el7
puppet-concat.noarch 0:4.0.1-1.b783e1egit.el7
puppet-corosync.noarch 0:5.0.0-4.527cda5git.el7
puppet-firewall.noarch 0:1.8.2-2.2f892e9git.el7
puppet-glance.noarch 0:11.5.0-1.el7
puppet-gnocchi.noarch 0:11.5.0-1.el7
puppet-heat.noarch 0:11.5.0-1.el7
puppet-horizon.noarch 0:11.5.0-1.el7
puppet-inifile.noarch 0:2.0.0-1.16fd47dgit.el7
puppet-ironic.noarch 0:11.5.0-1.el7
puppet-keystone.noarch 0:11.4.0-1.el7
puppet-magnum.noarch 0:11.3.2-1.el7
puppet-manila.noarch 0:11.4.0-1.el7
puppet-memcached.noarch 0:3.0.2-1.adf8b63git.el7
puppet-mysql.noarch 0:3.11.0-1.920dd76git.el7
puppet-neutron.noarch 0:11.5.0-1.el7
puppet-nova.noarch 0:11.5.1-1.el7
puppet-nssdb.noarch 0:1.0.1-1.el7
puppet-openstack_extras.noarch 0:11.5.0-1.el7
puppet-openstacklib.noarch 0:11.5.0-1.el7
puppet-oslo.noarch 0:11.4.0-1.el7
puppet-ovn.noarch 0:11.4.0-1.el7
puppet-panko.noarch 0:11.5.0-1.el7
puppet-rabbitmq.noarch 0:5.6.0-4.5ac45degit.el7
puppet-redis.noarch 0:3.2.0-1.8c61533git.el7
puppet-remote.noarch 0:0.0.1-3.7420908git.el7
puppet-rsync.noarch 0:0.4.0-2.295cfcegit.el7
puppet-sahara.noarch 0:11.4.0-1.el7
puppet-ssh.noarch 0:3.0.1-3.3fb5405git.el7
puppet-staging.noarch 0:1.0.4-1.b466d93git.el7
puppet-stdlib.noarch 0:4.18.0-2.el7
puppet-swift.noarch 0:11.4.0-1.el7
puppet-sysctl.noarch 0:0.0.11-1.el7
puppet-tempest.noarch 0:11.5.0-1.el7
puppet-trove.noarch 0:11.4.0-1.el7
puppet-vcsrepo.noarch 0:2.0.0-1.e3d28c6git.el7
puppet-vswitch.noarch 0:7.4.0-1.el7
puppet-xinetd.noarch 0:2.0.0-4.1d1e6d4git.el7
python-docutils.noarch 0:0.11-0.2.20130715svn7687.el7
python-enum34.noarch 0:1.0.4-1.el7
python-ipaddress.noarch 0:1.0.16-3.el7
python-netaddr.noarch 0:0.7.18-1.el7
python-netifaces.x86_64 0:0.10.4-3.el7
python-ply.noarch 0:3.4-11.el7
python-pycparser.noarch 0:2.14-1.el7
python2-cffi.x86_64 0:1.5.2-1.el7
python2-cryptography.x86_64 0:1.7.2-1.el7_4.1
python2-idna.noarch 0:2.5-1.el7
python2-olefile.noarch 0:0.44-1.el7
python2-pbr.noarch 0:3.1.1-1.el7
python2-pillow.x86_64 0:4.0.0-1.el7
python2-pyOpenSSL.noarch 0:16.2.0-3.el7
python2-pyasn1.noarch 0:0.1.9-7.el7
python2-setuptools.noarch 0:22.0.5-1.el7
python2-six.noarch 0:1.10.0-9.el7
ruby.x86_64 0:2.0.0.648-30.el7
ruby-augeas.x86_64 0:0.5.0-1.el7
ruby-irb.noarch 0:2.0.0.648-30.el7
ruby-libs.x86_64 0:2.0.0.648-30.el7
ruby-shadow.x86_64 0:1.4.1-23.el7
rubygem-bigdecimal.x86_64 0:1.2.0-30.el7
rubygem-io-console.x86_64 0:0.4.2-30.el7
rubygem-json.x86_64 0:1.7.7-30.el7
rubygem-psych.x86_64 0:2.0.0-30.el7
rubygem-rdoc.noarch 0:4.0.0-30.el7
rubygem-rgen.noarch 0:0.6.6-2.el7
rubygems.noarch 0:2.0.14.1-30.el7

Complete!

4. Install Openstack by running Packstack

#packstack –allinone

Sample output:

root@freelinux ~]# packstack –allinone
Welcome to the Packstack setup utility

The installation log file is available at: /var/tmp/packstack/20180210-134441-WQ3ii9/openstack-setup.log
Packstack changed given value to required value /root/.ssh/id_rsa.pub

Installing:
Clean Up                                                                                           [ DONE ]
Discovering ip protocol version                                                        [ DONE ]
Setting up ssh keys                                                                           [ DONE ]
Preparing servers                                                                              [ DONE ]
Pre installing Puppet and discovering hosts’ details                         [ DONE ]
Preparing pre-install entries                                                              [ DONE ]
Setting up CACERT                                                                            [ DONE ]
Preparing AMQP entries                                                                   [ DONE ]
Preparing MariaDB entries                                                                [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty       [ DONE ]
Preparing Keystone entries                                                               [ DONE ]
Preparing Glance entries                                                                   [ DONE ]
Checking if the Cinder server has a cinder-volumes vg                    [ DONE ]
Preparing Cinder entries                                                                   [ DONE ]
Preparing Nova API entries                                                               [ DONE ]
Creating ssh keys for Nova migration                                               [ DONE ]
Gathering ssh host keys for Nova migration                                     [ DONE ]
Preparing Nova Compute entries                                                      [ DONE ]
Preparing Nova Scheduler entries                                                     [ DONE ]
Preparing Nova VNC Proxy entries                                                    [ DONE ]
Preparing OpenStack Network-related Nova entries                        [ DONE ]
Preparing Nova Common entries                                                      [ DONE ]
Preparing Neutron LBaaS Agent entries                                            [ DONE ]
Preparing Neutron API entries                                                           [ DONE ]
Preparing Neutron L3 entries                                                             [ DONE ]
Preparing Neutron L2 Agent entries                                                  [ DONE ]
Preparing Neutron DHCP Agent entries                                             [ DONE ]
Preparing Neutron Metering Agent entries                                        [ DONE ]
Checking if NetworkManager is enabled and running                       [ DONE ]
Preparing OpenStack Client entries                                                    [ DONE ]
Preparing Horizon entries                                                                   [ DONE ]
Preparing Swift builder entries                                                            [ DONE ]
Preparing Swift proxy entries                                                              [ DONE ]
Preparing Swift storage entries                                                            [ DONE ]
Preparing Gnocchi entries                                                                    [ DONE ]
Preparing Redis entries                                                                         [ DONE ]
Preparing Ceilometer entries                                                                 [ DONE ]
Preparing Aodh entries                                                                          [ DONE ]
Preparing Puppet manifests                                                                   [ DONE ]
Copying Puppet modules and manifests                                               [ DONE ]
Applying 192.168.1.112_controller.pp

Additional information:
* A new answerfile was created in: /root/packstack-answers-20180210-134442.txt
* Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
* File /root/keystonerc_admin has been created on OpenStack client host 192.168.1.112. To use the command line tools you need to source the file.
* To access the OpenStack Dashboard browse to http://192.168.1.112/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.

5. Login to Openstack Dashboard

http://<server.ip> /dashboard

username: admin
pass:  (refer to /root/keystonerc_admin file), sample below

 

[root@freelinux vinyard]# cat /root/keystonerc_admin
unset OS_SERVICE_TOKEN
export OS_USERNAME=admin
export OS_PASSWORD=’4b5264f3f5674888′
export OS_AUTH_URL=http://192.168.1.112:5000/v3
export PS1='[\u@\h \W(keystone_admin)]\$ ‘

export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3

 

Share

The post Installing Openstack RDO Packstack in CentOS appeared first on Free Linux Tutorials.

Installation of KVM( Kernel-based Virtual Machine) Virtualization and Eve-NG in CentOS

$
0
0

Installation of KVM and Eve-NG

 Kernel-based Virtual Machine or KVM is an open source virtualization solution that can make your Linux Server as hypervisor. I will demonstrate also how to install Virtual Machine (VM), for this example I will install Eve-NG (Emulated Virtual Environment) which is used by Network Engineers or Security and DevOps professionals to emulate different network devices/platforms such as Cisco,Juniper, Arista, Linux and so much more, mainly for POC, testing and learning.

Tested in CentOS 7
See first if your server supports Virtualization

# lscpu | grep Virt
Virtualization: VT-x

  1. Install KVM
    yum install qemu-kvm virt-install libvirt libvirt-python libguestfs-tools

Start the libvirtd service
systemctl enable libvirtd
systemctl start libvirtd

Check if it is running:

# systemctl status libvirtd
● libvirtd.service – Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-08-02 22:05:35 +08; 23h ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 14880 (libvirtd)
Tasks: 20 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─14880 /usr/sbin/libvirtd
├─14979 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper
└─14980 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper

Verify if kvm is installed

# lsmod | grep -i kvm
kvm_intel 183737 10
kvm 615914 1 kvm_intel
irqbypass 13503 4 kvm

2.Configure bridge network
e.g. primary interface = enp3s0f0
a. add line BRIDGE=br0 under /etc/sysconfig/network-scripts/enp3s0f0 , save and exit
b. configure bridge interface,e.g. br0
if dhcp:
Add the follwowing in /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=”br0″
BOOTPROTO=”dhcp”
IPV6INIT=”yes”
IPV6_AUTOCONF=”yes”
ONBOOT=”yes”
TYPE=”Bridge”

if static:(IP: 192.168.0.200/24, GW: 192.168.0.1, DNS:192.168.0.10
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

Restart network service
service network restart

Verify:
brctl show

For OpenVswitch:
sample contents of /etc/sysconfig/network-scripts/enp3s0f0

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=enp3s0f0
DEVICE=enp3s0f0
ONBOOT=yes
TYPE=”OVSPort”
DEVICETYPE=”ovs”
OVS_BRIDGE=”br0

sample contents of /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
UUID=1e9b47ec-a06e-4e9e-a78d-ffae0571bed7
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

3. Install Eve-NG as Virtual Machine
Specifications:
OS:Ubuntu/EVE-NG
RAM: 4GB
VCPU: 4
Image Loc: /home/images
Disk Size: 40GB

Download the ISO of EVE-NG Community version at https://www.eve-ng.net/downloads/eve-ng-2. Upload it on your server
cd /var/lib/libvirt/boot/

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge=br0,model=virtio –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04

For OVS, need to add the option (virtualport_type=openvswitch) else you will get this error message (“ERROR Unable to add bridge brX port vnet0: Operation not supported)

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge:br-ex,model=virtio,virtualport_type=openvswitch –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04
Domain installation still in progress. Waiting for installation to complete.

Open a new session and check the vnc port settings

# virsh dumpxml eve-ng | grep vnc

Setup SSH tunnel to access the remove VNC server
ssh tux@192.168.0.200 -L 5900:127.0.0.1:5900

4. Connect to VM
Open VNC client and input settings as below. Start the Eve-NG installation(Install EVE as Bare).
Host: localhost or 127.0.0.1
Port: 5900

During installation, you will be prompted to configure the network settings

Test Eve-NG by accessing through the browser or SSH it

Web:http://192.168.0.200
SSH: ssh root@192.168.0.200
root@eve-ng:~# cat /etc/network/interfaces

iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.10

Authenticating Ubuntu Client to Windows Active Directory

$
0
0

I got the chance to configure one of the old system of my friend running Windows 2000 and Ubuntu 7, (yes it’s not typo) and he wants to authenticate some of his old Ubuntu PCs to Windows AD. Here’s the tutorial for adding Ubuntu box in a Active Directory domain and to authenticate the users with AD

Needed software:
Windows 2000 Advanced Server (function as Domain Controller, AD)
Linux (Ubuntu 6,7)
Winbind
Samba
krb-user
libpam-krb5

Used terms:
AD.freelinuxtutorials.com –> AD Domain
10.201.0.251 –> DC IP address
AD.freelinuxtutorials.com –> Kerberos Realm
10.201.0.193 –> NTP server

Step1: Confirm Connectivity
Confirm network connectivity and name resolution for the Active Directory domain controller. Ping the fully-qualified domain name (FQDN) of the AD DC on your network

root@ubuntuclient#ping AD.freelinuxtutorials.com

If not successful, it could be a DNS issue, you can change the right DNS or add the info using /etc/hosts

Step2: Set the time settings
Time is important for Kerberos, which is used for authentication in Active Directory networks.
/usr/sbin/ntpdate 10.201.0.193

Step3:Setup Kerberos

Install the appropriate client software. This process assumes that you have opened up all the Breezy main and security sources in your sources.list as well as the Universe repository /etc/apt/sources.list
Install the necessary Kerberos packages, you should use the following apt-get command to install the software:
$sudo apt-get install krb5-user libpam-krb5
Modify the /etc/krb5.conf

[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = AD.freelinuxtutorials.com
default_etypes = des-cbc-crc des-cbc-md5
default_etypes_des = des-cbc-crc des-cbc-md5
default_tgs_enctypes = des-cbc-crc des-cbc-md5
default_tkt_enctypes = des-cbc-crc des-cbc-md5
dns_lookup_realm = false
dns_lookup_kdc = true
ticket_lifetime = 24h

[realms]
AD.freelinuxtutorials.com = {
kdc = AD.freelinuxtutorials.com:88
admin_server = AD.freelinuxtutorials.com:749
default_domain = freelinuxtutorials.com
}

[domain_realm]
.freelinuxtutorials.com = freelinuxtutorials.com
freelinuxtutorials.com = freelinuxtutorials.com

[kdc]
profile = /var/kerberos/krb5kdc/kdc.conf

[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}

Step4: Testing

Request a Ticket-Granting Ticket (TGT) by issuing the kinit command and Check if ticket request was valid using the klist command.

Sample output:

root@ubuntu:~# kinit Administrator@AD.freelinuxtutorials.com
Password for Administrator@AD.freelinuxtutorials.com:
root@ubuntu:~# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: Administrator@AD.freelinuxtutorials.com

Valid starting Expires Service principal
06/21/19 14:52:09 06/22/19 00:56:06 krbtgt/AD.freelinuxtutorials.com@AD.freelinuxtutorials.com
renew until 06/22/19 14:52:09

Kerberos 4 ticket cache: /tmp/tkt0
klist: You have no tickets cached

At this point, your Kerberos installation and configuration is operating correctly

Step5: Join AD domain
Install winbind and samba
apt-get install winbind samba

Modify the /etc/samba/smb.conf

[global]
workgroup = AD
hosts allow = 10.201.0. 10.200.0. 127.
password server = AD.freelinuxtutorials.com
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/bash
winbind use default domain = yes
winbind separator = /
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%D/%U

realm = AD.freelinuxtutorials.com

Be sure to restart the Samba and Winbind services after changing the /etc/samba/smb.conf file:
root@ubuntu:~# /etc/init.d/winbind stop
root@ubuntu:~# /etc/init.d/samba restart
root@ubuntu:~# /etc/init.d/winbind start

Join the domain:
net ads join –U Administrator@AD.freelinuxtutorials.com
password:XXXXXXXXXXXX
Using short domain name – AD
Joined ‘ubuntu’ to realm ‘AD.freelinuxtutorials.com’

Step6: Testing the AD join
wbinfo -u

You should get a list of the users of the domain.
And a list of the groups.
wbinfo -g

Step7: Setup the Authentication

Modify /etc/nsswitch.conf

passwd: files winbind
group: files winbind
shadow: files compat winbind
hosts: files dns wins winbind
networks: files
protocols: db files winbind
services: db files winbind
ethers: db files
rpc: db files
netgroup: nis files winbind

Step8: Testing winbind nsswitch

Check Winbind nsswitch module with getent.
getent passwd
getent group

Step9: Modify PAM
Go to /etc/pam.d

/etc/pam.d/common-account

account sufficient pam_winbind.so
account sufficient pam_krb5.so minimum_uid=1000
account required pam_unix.so nullok_secure
account [default=bad success=ok user_unknown=ignore service_err=ignore system_er
r=ignore] pam_krb5.so

/etc/pam.d/common-auth

auth sufficient pam_winbind.so
auth sufficient pam_krb5.so minimum_uid=1000 use_first_pass
auth required pam_unix.so
auth sufficient pam_group.so use_first_pass

/etc/pam.d/common-session

session required pam_unix.so
session optional pam_foreground.so
session optional pam_krb5.so
session required pam_mkhomedir.so umask=0022 skel=/etc/skel

/etc/pam.d/sudo

#%PAM-1.0
auth sufficient pam_winbind.so
auth sufficient pam_unix.so use_first_pass
auth required pam_deny.so
@include common-account

/etc/pam.d/samba

@include common-auth
@include common-account
@include common-session
@include common-password

/etc/pam.d/common-password

password required pam_unix.so nullok obscure min=4 max=8 md5
password required pam_unix.so nullok obscure min=4 max=50 md5

Step10: Create the domain directory in /home
#mkdir /home/AD

Easy steps for the configuration files

All config files can be get via wget on http://10.201.0.193/script
Nsswitch.conf, krb5.conf , smb.conf located on script folder
Pam.d config files located on script/pam
e.g
#cd /etc/
#wget http://10.201.0.193/script/krb5.conf

#cd /etc/samba
#wget http://10.201.0.193/script/smb.conf

You can add boot up script on /etc/rc.local
vi /root/script.sh

/usr/sbin/ntpdate 10.201.0.193
/etc/init.d/winbind stop
/etc/init.d/samba restart
/etc/init.d/winbind start

Save and exit.

Make the script executable
#chmod +x /root/script

Under /etc/rc.local, append the script so it will run during start-up
/root/script.sh




The post Authenticating Ubuntu Client to Windows Active Directory appeared first on Free Linux Tutorials.

Quick Tip: Installing GNS3 in Ubuntu (64-bit)

$
0
0

Installing a graphical network simulator GNS3 is quite easy for Ubuntu based distribution for 64-bit systems. Tested using Ubuntu 16.04.

sudo add-apt-repository ppa:gns3/ppa
sudo apt-get update
sudo apt-get install gns3-gui

few packages will be installed aside from the gns3-gui , gns3-server

qemu
wireshark
dynamips
cpu-checker

Type “gns3” in command line to launch the application. Enjoy!

tux@freelinux:~$ sudo add-apt-repository ppa:gns3/ppa

Swipe your finger across the fingerprint reader
PPA for GNS3 and Supporting Packages. Please see http://www.gns3.com for more details
More info: https://launchpad.net/~gns3/+archive/ubuntu/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmplevn08nn/secring.gpg’ created
gpg: keyring `/tmp/tmplevn08nn/pubring.gpg’ created
gpg: requesting key A2E3EF7B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmplevn08nn/trustdb.gpg: trustdb created
gpg: key A2E3EF7B: public key “Launchpad PPA for GNS3” imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK

tux@freelinux:~$ sudo apt-get update

tux@freelinux:~$ sudo apt-get install gns3-gui

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following package was automatically installed and is no longer required:
ubuntu-core-launcher
Use ‘sudo apt autoremove’ to remove it.
The following additional packages will be installed:
cpu-checker cpulimit dynamips freerdp-x11 geoip-database-extra gns3-server
ipxe-qemu javascript-common libaio1 libavahi-gobject0 libboost-random1.58.0
libboost-thread1.58.0 libc-ares2 libcacard0 libfdt1 libfreerdp-rail1.1
libgtk-vnc-2.0-0 libgvnc-1.0-0 libiscsi2 libjs-openlayers libnl-route-3-200
libqgsttools-p1 libqt5clucene5 libqt5designer5 libqt5help5
libqt5multimedia5-plugins libqt5multimediawidgets5 librados2 librbd1
libsdl1.2debian libsmi2ldbl libspice-client-glib-2.0-8
libspice-client-gtk-3.0-4 libspice-server1 libusbredirhost1
libusbredirparser1 libvncserver1 libwireshark-data libwireshark6 libwiretap5
libwsutil6 libxen-4.6 libxenstore3.0 libxfreerdp-client1.1 msr-tools
python3-pyqt5 python3-pyqt5.qtsvg python3-sip qemu-block-extra qemu-kvm
qemu-system-arm qemu-system-common qemu-system-x86 qemu-utils seabios
sharutils spice-client-glib-usb-acl-helper ubridge vinagre vpcs wireshark
wireshark-common wireshark-qt x11vnc x11vnc-data xvfb
Suggested packages:
gns3 apache2 | lighttpd | httpd snmp-mibs-downloader wireshark-doc
python3-pyqt5-dbg samba vde2 sgabios ovmf debootstrap bsd-mailx | mailx

The following NEW packages will be installed:
cpu-checker cpulimit dynamips freerdp-x11 geoip-database-extra gns3-gui
gns3-server ipxe-qemu javascript-common libaio1 libavahi-gobject0
libboost-random1.58.0 libboost-thread1.58.0 libc-ares2 libcacard0 libfdt1
libfreerdp-rail1.1 libgtk-vnc-2.0-0 libgvnc-1.0-0 libiscsi2 libjs-openlayers
libnl-route-3-200 libqgsttools-p1 libqt5clucene5 libqt5designer5 libqt5help5
libqt5multimedia5-plugins libqt5multimediawidgets5 librados2 librbd1
libsdl1.2debian libsmi2ldbl libspice-client-glib-2.0-8
libspice-client-gtk-3.0-4 libspice-server1 libusbredirhost1
libusbredirparser1 libvncserver1 libwireshark-data libwireshark6 libwiretap5
libwsutil6 libxen-4.6 libxenstore3.0 libxfreerdp-client1.1 msr-tools
python3-pyqt5 python3-pyqt5.qtsvg python3-sip qemu-block-extra qemu-kvm
qemu-system-arm qemu-system-common qemu-system-x86 qemu-utils seabios
sharutils spice-client-glib-usb-acl-helper ubridge vinagre vpcs wireshark
wireshark-common wireshark-qt x11vnc x11vnc-data xvfb
0 upgraded, 67 newly installed, 0 to remove and 0 not upgraded.
Need to get 67.0 MB of archives.
After this operation, 279 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

–omitted–

Fetched 67.0 MB in 3min 15s (343 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages …

To run, use the command “gns3 &”

tux@freelinux:~$ gns3 &
[1] 4049
tux@freelinux:~$ GNS3 GUI version 1.5.3
Copyright (c) 2007-2017 GNS3 Technologies Inc.
2017-02-05 15:47:44 INFO logger.py:107 Log level: INFO
2017-02-05 15:47:44 ERROR __init__.py:144 vmware command not found
2017-02-05 15:47:44 INFO servers.py:103 New local server connection http://127.0.0.1:3080 registered
2017-02-05 15:47:44 INFO __init__.py:181 VPCS module reset
2017-02-05 15:47:44 INFO __init__.py:322 Dynamips module reset
2017-02-05 15:47:44 INFO __init__.py:262 IOU module reset
2017-02-05 15:47:44 INFO __init__.py:256 QEMU module reset
2017-02-05 15:47:44 INFO __init__.py:302 VirtualBox module reset
2017-02-05 15:47:44 INFO __init__.py:369 VMware module reset
2017-02-05 15:47:44 INFO __init__.py:193 Docker module reset
2017-02-05 15:47:44 INFO __init__.py:70 Built-in module reset
2017-02-05 15:47:44 INFO topology.py:408 Topology reset
2017-02-05 15:47:45 INFO servers.py:540 Starting local server process with “/usr/bin/gns3server” –host=127.0.0.1 –port=3080 –local –controller –log=”/home/tux/.config/GNS3/gns3_server.log” –pid=”/home/tux/.config/GNS3/gns3_server.pid”
2017-02-05 15:47:45 INFO servers.py:553 Local server process has started (PID=4058)

To install a shortcut launcher for GNS3, follow this simple step below:

https://freelinuxtutorials.com/quick-tips-and-tricks/quick-tip-create-gns3-launcher-ubuntu-linux/

The post Quick Tip: Installing GNS3 in Ubuntu (64-bit) appeared first on Free Linux Tutorials.

Quick Tip: Installation of Sublime Text in Ubuntu Linux

$
0
0

Sublime Text is one of the best text or code editor that you can have in Linux as it supports different programming languages and markup languages. There’s a list of features that you can check from the Sublime Text official website, one of my favorites is the python-based plugin API and “Goto Anything” feature.
The only downfall I find is Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use.

Installing Sublime Text ver.3 in Ubuntu 16.04 LTS can be done in just 3 steps. As it is not available in Ubuntu Software Center, need to add first the repository before installing it.

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

Type “subl” to launch Sublime Text

tux@freelinux:~$ sudo add-apt-repository ppa:webupd8team/sublime-text-3

Swipe your finger across the fingerprint reader
Sublime Text 3 Installer: the package in this PPA downloads and installs the latest Sublime Text 3 beta builds.
For more info, see: http://www.webupd8.org/2013/07/sublime-text-3-ubuntu-ppa-now-available.html
More info: https://launchpad.net/~webupd8team/+archive/ubuntu/sublime-text-3
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpnj7nb47v/secring.gpg’ created
gpg: keyring `/tmp/tmpnj7nb47v/pubring.gpg’ created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpnj7nb47v/trustdb.gpg: trustdb created
gpg: key EEA14886: public key “Launchpad VLC” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK

tux@freelinux:~$sudo apt-get update

tux@freelinux:~$ sudo apt-get install sublime-text-installer

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following package was automatically installed and is no longer required:
ubuntu-core-launcher
Use ‘sudo apt autoremove’ to remove it.
The following NEW packages will be installed:
sublime-text-installer
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,566 B of archives.
After this operation, 26.6 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial/main amd64 sublime-text-installer all 3126-2~webupd8~1 [9,566 B]
Fetched 9,566 B in 1s (9,062 B/s)
Preconfiguring packages …
Selecting previously unselected package sublime-text-installer.
(Reading database … 224696 files and directories currently installed.)
Preparing to unpack …/sublime-text-installer_3126-2~webupd8~1_all.deb …
Downloading…
–2016-12-26 11:20:11– https://download.sublimetext.com/sublime_text_3_build_3126_x64.tar.bz2
Resolving download.sublimetext.com (download.sublimetext.com)… 104.236.0.104
Connecting to download.sublimetext.com (download.sublimetext.com)|104.236.0.104|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 9313954 (8.9M) [application/octet-stream]
Saving to: ‘sublime_text_3_build_3126_x64.tar.bz2’
0K …….. …….. …….. …….. …….. …….. 33% 1.14M 5s
3072K …….. …….. …….. …….. …….. …….. 67% 1.44M 2s
6144K …….. …….. …….. …….. …….. …… 100% 803K=8.4s
2016-12-26 11:20:22 (1.06 MB/s) – ‘sublime_text_3_build_3126_x64.tar.bz2’ saved [9313954/9313954]
Download done.
Removing outdated cached downloads…
sublime_text_3/
sublime_text_3/Packages/
sublime_text_3/Packages/Pascal.sublime-package
sublime_text_3/Packages/Matlab.sublime-package
sublime_text_3/Packages/Go.sublime-package
sublime_text_3/Packages/Graphviz.sublime-package
sublime_text_3/Packages/Haskell.sublime-package
sublime_text_3/Packages/Clojure.sublime-package
sublime_text_3/Packages/TCL.sublime-package
sublime_text_3/Packages/C++.sublime-package
sublime_text_3/Packages/C#.sublime-package
sublime_text_3/Packages/Textile.sublime-package
sublime_text_3/Packages/Text.sublime-package
sublime_text_3/Packages/XML.sublime-package
sublime_text_3/Packages/D.sublime-package
sublime_text_3/Packages/Lisp.sublime-package
sublime_text_3/Packages/Objective-C.sublime-package
sublime_text_3/Packages/Vintage.sublime-package
sublime_text_3/Packages/Groovy.sublime-package
sublime_text_3/Packages/Theme – Default.sublime-package
sublime_text_3/Packages/LaTeX.sublime-package
sublime_text_3/Packages/Color Scheme – Default.sublime-package
sublime_text_3/Packages/Python.sublime-package
sublime_text_3/Packages/R.sublime-package
sublime_text_3/Packages/PHP.sublime-package
sublime_text_3/Packages/ActionScript.sublime-package
sublime_text_3/Packages/OCaml.sublime-package
sublime_text_3/Packages/Language – English.sublime-package
sublime_text_3/Packages/Rails.sublime-package
sublime_text_3/Packages/Regular Expressions.sublime-package
sublime_text_3/Packages/Erlang.sublime-package
sublime_text_3/Packages/Batch File.sublime-package
sublime_text_3/Packages/Markdown.sublime-package
sublime_text_3/Packages/ASP.sublime-package
sublime_text_3/Packages/Perl.sublime-package
sublime_text_3/Packages/Ruby.sublime-package
sublime_text_3/Packages/Makefile.sublime-package
sublime_text_3/Packages/Default.sublime-package
sublime_text_3/Packages/Scala.sublime-package
sublime_text_3/Packages/YAML.sublime-package
sublime_text_3/Packages/JavaScript.sublime-package
sublime_text_3/Packages/ShellScript.sublime-package
sublime_text_3/Packages/Lua.sublime-package
sublime_text_3/Packages/Diff.sublime-package
sublime_text_3/Packages/RestructuredText.sublime-package
sublime_text_3/Packages/SQL.sublime-package
sublime_text_3/Packages/CSS.sublime-package
sublime_text_3/Packages/Rust.sublime-package
sublime_text_3/Packages/Java.sublime-package
sublime_text_3/Packages/AppleScript.sublime-package
sublime_text_3/Packages/HTML.sublime-package
sublime_text_3/changelog.txt
sublime_text_3/sublime_text
sublime_text_3/python3.3.zip
sublime_text_3/plugin_host
sublime_text_3/crash_reporter
sublime_text_3/sublime_text.desktop
sublime_text_3/Icon/
sublime_text_3/Icon/16×16/
sublime_text_3/Icon/16×16/sublime-text.png
sublime_text_3/Icon/32×32/
sublime_text_3/Icon/32×32/sublime-text.png
sublime_text_3/Icon/128×128/
sublime_text_3/Icon/128×128/sublime-text.png
sublime_text_3/Icon/48×48/
sublime_text_3/Icon/48×48/sublime-text.png
sublime_text_3/Icon/256×256/
sublime_text_3/Icon/256×256/sublime-text.png
sublime_text_3/sublime.py
sublime_text_3/sublime_plugin.py
Unpacking sublime-text-installer (3126-2~webupd8~1) …
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) …
Rebuilding /usr/share/applications/bamf-2.index…
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) …
Processing triggers for desktop-file-utils (0.22-1ubuntu5) …
Processing triggers for mime-support (3.59ubuntu1) …
Setting up sublime-text-installer (3126-2~webupd8~1) …
tux@freelinuxt:~$

 

The post Quick Tip: Installation of Sublime Text in Ubuntu Linux appeared first on Free Linux Tutorials.


Quick Tip: Install Spotify in Ubuntu or Debian Linux

$
0
0

Spotify is considered the king of digital music streaming service that offers millions of songs.  There are 4 steps to install Spotify client in Debian-based Linux.

Tested in Ubuntu 16.04 LTS. Enjoy!

1.Add Spotify’s repository signing key to verify downloaded packages
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886

2. Add Spotify repository
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list

3. Check and update latest version
sudo apt-get update

4. Install the Spotify client
sudo apt-get install spotify-client

Run “spotify” in the command-line or find from the Applications

tux@freelinux:~$ sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
Swipe your finger across the fingerprint reader
Executing: /tmp/tmp.4ToCaqi4Sq/gpg.1.sh –keyserver
hkp://keyserver.ubuntu.com:80
–recv-keys
BBEBDCB318AD50EC6865090613B00F1FD2C19886
gpg: requesting key D2C19886 from hkp server keyserver.ubuntu.com
gpg: key D2C19886: public key “Spotify Public Repository Signing Key <operations@spotify.com>” imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

tux@freelinux:~$ echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
Swipe your finger across the fingerprint reader
deb http://repository.spotify.com stable non-free

tux@freelinux:~$ sudo apt-get update
Hit:1 http://sg.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://sg.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Hit:4 http://ppa.launchpad.net/fingerprint/fingerprint-gui/ubuntu xenial InRelease
Hit:5 http://ppa.launchpad.net/fingerprint/fprint/ubuntu xenial InRelease
Get:6 http://repository.spotify.com stable InRelease [3,302 B]
Get:7 http://sg.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Hit:8 http://ppa.launchpad.net/gns3/ppa/ubuntu xenial InRelease
Hit:9 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease
Get:10 http://repository.spotify.com stable/non-free amd64 Packages [1,592 B]
Get:11 http://repository.spotify.com stable/non-free i386 Packages [1,136 B]
Ign:12 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:13 http://dl.google.com/linux/chrome/deb stable Release
Fetched 313 kB in 10s (29.5 kB/s)
Reading package lists… Done

tux@freelinux:~$ sudo apt-get install spotify-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
kde-l10n-engb ubuntu-core-launcher
Use ‘sudo apt autoremove’ to remove them.
Recommended packages:
libavcodec54 | libavcodec-extra-54 libavformat54
The following NEW packages will be installed:
spotify-client
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 71.7 MB of archives.
After this operation, 166 MB of additional disk space will be used.
Get:1 http://repository.spotify.com stable/non-free amd64 spotify-client amd64 1:1.0.44.100.ga60c0ce1-89 [71.7 MB]
Fetched 71.7 MB in 2min 4s (577 kB/s)
Selecting previously unselected package spotify-client.
(Reading database … 226829 files and directories currently installed.)
Preparing to unpack …/spotify-client_1%3a1.0.44.100.ga60c0ce1-89_amd64.deb …
Unpacking spotify-client (1:1.0.44.100.ga60c0ce1-89) …
Setting up spotify-client (1:1.0.44.100.ga60c0ce1-89) …

tux@freelinux:~$

The post Quick Tip: Install Spotify in Ubuntu or Debian Linux appeared first on Free Linux Tutorials.

Quick Tip: Create GNS3 Launcher in Ubuntu Linux

$
0
0

After installing GNS3 or Graphical Network Simulator 3 in Ubuntu Linux, you can run it via the command “gns3” but it does not come with a default launcher or shortcut. To have a nice shortcut to place under your launcher bar or dock, here are the steps:

1. Go to /usr/share/applications folder

tux@freelinux:~$ cd /usr/share/applications

2. Create a filename with extension “desktop” , e.g. gns3.desktop . Configure the following desktop entries as per below. The contents are quite self-explanatory. Save and exit

tux@freelinux:/usr/share/applications$ sudo vi gns3.desktop

[Desktop Entry]
Name=GNS3
Comment=GNS3 Network Simulator
Exec=/usr/bin/gns3
Icon=/home/tux/GNS3/gns3-icon.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Application;

3. Search the launcher under Applications
Enjoy!

The post Quick Tip: Create GNS3 Launcher in Ubuntu Linux appeared first on Free Linux Tutorials.

Configuring Multiple Interfaces and Multiple Default Routes in Linux

$
0
0

Scenario: Multiple network interfaces in your server and each connected to different network and getting the IP via DHCP
Objective: Make all IP pingable and accessible remotely e.g. SSH
Solution: Configure Gateway Routing or setting up multiple default routes for each interfaces

Initially when you connect different links/network (regardless it’s in the same subnet or not) for each of the interfaces, it will end up only one interface is reachable. Why? Because by default, it can only have one default route or gateway on a system.

Example: 5 NIC in 1 Linux Server
Noted: Tested in Redhat based Linux (CentOS,Fedora). Assuming the IP dynamically assigned by the DHCP server:

eth1=ip:192.168.10.100/24 gw:192.168.10.1
eth2=ip:192.168.20.100/24 gw:192.168.20.1
eth3=ip:192.168.30.100/24 gw:192.168.30.1
eth4=ip:192.168.40.100/24 gw:192.168.40.1
eth5=ip:192.168.50.100/24 gw:192.168.50.1

1. Set eth1 as the default route and disable it from other interfaces
a. add the line “DEFROUTE=yes” (without the quote) to /etc/sysconfig/network-scripts/ifcfg-eth1
b. add the line “DEFROUTE=no” (without the quote) to /etc/sysconfig/network-scripts/ifcfg-eth2  .. to ifcfg-eth5

2. Restart the network and the IP routing table should be something like this:

[tux@freelinux ~]$ netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
192.168.40.0 0.0.0.0 255.255.255.0 U 0 0 0 eth4
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth5
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth1

From the example above, the only pingable/reachable would be the eth1 IP only as it carries the default gateway.

3. Setup additional routing table
a. Edit the file  /etc/iproute2/rt_tables and set the eth1 with preference 1, and eth2 with 2, and so on and so forth. Any name to represent it can work, this is basically creating a policy in the routing table that can be called later.  Sample content of that file will be something like:
[tux@freelinux ~]$ cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 ilove
2 free
3 linux
4 tutorials

b. Configure the routing table. Firstly, configure the 192.168.20.0/24 to tell that it can be reached in “ilove” and to find its gateway. Secondly, set interface’s default gateway
ip route add 192.168.20.0/24 dev eth2 src 192.168.20.100 table ilove
ip route add default via 192.168.20.1 dev eth2 table ilove

c. Set the policy routes for the system to know when to use that new routing table
ip rule add from 192.168.20.100 /32 table ilove
ip rule add to 192.168.20.100/32 table ilove

Do the same thing for eth3-5. These will be the configuration for the rest:
for eth3:
ip route add 192.168.30.0/24 dev eth3 src 192.168.30.100 table free
ip route add default via 192.168.30.1 dev eth3 table free
ip rule add from 192.168.30.100 /32 table free
ip rule add to 192.168.30.100/32 table free

for eth4:
ip route add 192.168.40.0/24 dev eth4 src 192.168.40.100 table linux
ip route add default via 192.168.40.1 dev eth4 table linux
ip rule add from 192.168.40.100 /32 table linux
ip rule add to 192.168.40.100/32 table linux

for eth5:
ip route add 192.168.50.0/24 dev eth5 src 192.168.50.100 table tutorials
ip route add default via 192.168.50.1 dev eth5 table tutorials
ip rule add from 192.168.50.100 /32 table tutorials
ip rule add to 192.168.50.100/32 table tutorials

Check: Ping and ssh all the IP address see if it’s already reachable
Verification (sample output)

[tux@freelinux ~]$ ip rule show
0: from all lookup local
32732: from all to 192.168.50.100 lookup tutorials
32733: from 192.168.50.100 lookup tutorials
32734: from all to 192.168.40.100 lookup linux
32735: from 192.168.40.100 lookup linux
32736: from all to 192.168.30.100 lookup free
32737: from 192.168.30.100 lookup free
32738: from all to 192.168.20.100 lookup ilove
32739: from 192.168.20.100 lookup ilove
32740: from all lookup main
32741: from all lookup default

Simple explanation: Rule 32732 means that all traffic going to eth5 will use the “tutorials” routing table.  Rule 32733 means that traffic coming from eth5 will use the”tutorials” routing table. And so on, and so forth

[tux@freelinux ~]$ ip route show table all

192.168.20.0/24 dev eth2 table ilove scope link src 192.168.20.100
default via 192.168.20.1 dev eth2 table ilove
192.168.30.0/24 dev eth3 table free scope link src 192.168.30.100
default via 192.168.30.1 dev eth3 table free
192.168.40.0/24 dev eth4 table linux scope link src 192.168.40.100
default via 192.168.40.1 dev eth4 table linux
192.168.50.0/24 dev eth5 table tutorials scope link src 192.168.50.100
default via 192.168.50.1 dev eth5 table tutorials
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.100
default via 192.168.10.1 dev eth1

Enjoy! Cheers!

The post Configuring Multiple Interfaces and Multiple Default Routes in Linux appeared first on Free Linux Tutorials.

Quick Tip: Get or Find your Public IP Address using curl

$
0
0

Some sample websites that you can use with curl to display your external public IP. As you know, especially if you are connected to a router, it will provide you private IP via the DHCP and it is NAT’ed. So using ‘ifconfig’, ‘ip addr show’, ‘hostname -I’ or via the GUI won’t show the public IP.

curl icanhazip.com
curl ifconfig.me
curl ipecho.net/plain ; echo
curl ident.me ; echo
curl checkip.amazonaws.com
curl bot.whatismyipaddress.com ;echo
curl myexternalip.com/raw
curl whatismyip.akamai.com ; echo
curl myip.dnsomatic.com;echo
curl -s ipinfo.io | jq .ip #need to install jq

Or you want to challenge yourself, you can combine it with sed to do some filtering

curl -s checkip.dyndns.org | sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

The post Quick Tip: Get or Find your Public IP Address using curl appeared first on Free Linux Tutorials.

Installing WordPress in Raspberry Pi with Nginx, MySQL and PHP

$
0
0

It is meant to function as a staging or testing server where you can  do compatibility test  latest wordpress version on your existing sites, or try themes, plugins,widgets or practice your coding skills in css & php before deploying into your production, then using rpi is a good option.

Components used and tested working:

Raspberry Pi Model B , installed with Raspbian GNU/Linux 8 Jessie (Kernel armv6l Linux 4.9.35+)
nginx(1.6.2-5+deb8u5) (Web Server)
php5 (php5 5.6.33)
mysql 5.5 (ver.5.5.59-0+deb8u1) (Database Server)
wordpress

Before start the actual installation, update rpi packages

pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade

Sample output:
pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade
Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [9,536 kB]
Get:3 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
Fetched 9,874 kB in 46s (210 kB/s)
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
176 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
Need to get 94.4 MB/97.3 MB of archives.
After this operation, 3,064 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Fetched 94.4 MB in 2min 47s (564 kB/s)
Reading changelogs… Done
Running hooks in /etc/ca-certificates/update.d….done.

1. Install Nginx 

pi@raspberrypi:~ $ sudo apt-get install nginx

Test if everything ok by running:

pi@raspberrypi:~ $ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Start nginx and check status if running:
pi@raspberrypi:~ $ sudo service nginx start
pi@raspberrypi:~ $ sudo service nginx status

Open your favorite web browser and test it by going to Pi’s localhost or actual IP, e.g. http://localhost , http://192.168.1.200 . If working, you will be able to see the default page which is the index.html under /var/www/html , and see message something like:

 

If any changes done, reload the config
pi@raspberrypi:~ $ sudo systemctl reload nginx

2. Install PHP

As WordPress is written in PHP, we need to install PHP as the scripting language . PHP is a server-side programming language that can serve dynamic pages and it is processed via its php module
a. Install using the following command:
pi@raspberrypi:~ $ sudo apt-get install php5 php-fpm php5-mysql

b. Configure the nginx configuration file for php module to work. Modify the default file under /etc/nginx/sites-available directory, make sure to uncomment or add the following lines:
pi@raspberrypi:~ $ sudo vi /etc/nginx/sites-available/default

server_name 192.168.1.200;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}

Test by doing the following steps:

a.  Create index.php under the default root directory (/var/www/html) with the contents below:
pi@raspberrypi:~ $ sudo vi /var/www/html/index.php

<?php
phpinfo();
?>

b. Access http://localhost or http://192.168.1.200, if you see something like this as per below image, then php was sucessfully installed.

3. Install MySQL server

pi@raspberrypi:~ $ sudo apt-get install mysql-server

root password will be asked during installation , this will use to access the MySQL engine.

Login to mysql as root with the password provided during installation. Create a database name “wordpress” and wordpress user and grant all privileges for that database  e.g. (db name: wordpress username: wpadmin pass: freelinux)

 

mysql> CREATE USER wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> FLUSH PRIVILEGES;
mysql> quit;
Query OK, 1 row affected (0.00 sec)

4. Install WordPress

Download, install, extract and change file ownership
pi@raspberrypi:~ $ cd /var/www/html
pi@raspberrypi:~ $ sudo wget http://wordpress.org/latest.tar.gz
pi@raspberrypi:~ $ sudo tar zxvf latest.tar.gz
pi@raspberrypi:~ $ sudo rm latest.tar.gz
pi@raspberrypi:~ $ sudo chown -R www-data /var/www/html/wordpress

Navigate using your browser http://192.168.1.200 and will be presented with WordPress welcome page
-Click “Let’s go” to proceed the setup
-Will be presented by the following, fill out accordingly (in case need to change, can modify the wp-config.php later on):
Database Name: wordpress
User Name: wpadmin
Password: freelinux
Database Host: localhost
Table Prefix: wp_

-Click Submit
-Click “Run the install”
-Next fill out necessary information such as Site Title, username, password and email address. Then click the “Install WordPress” button

Once done, login using the username and password provided earlier, URL is http://192.168.1.200/wp-admin

Enjoy customizing your wordpress by changing themes, installing plugins and widgets , or can edit the stylesheet css if necessary.
Now you’re ready to start adding your first ever post. Happy blogging!

Sample screencap:

 

Additional Tips or optional tasks:

1. If you have existing database and want to restore from backup database, here’s the command to restore

pi@raspberrypi:~ $ mysql -u wpadmin -p wordpress < freelinux-backup.sql

2. If migrating WordPress from Apache to Nginx, permalinks may not work even after re-saving changes (Settings > Permalinks > Save Changes). Try to change the “try_files from $uri $uri/ =404 to $uri $uri/ /index.php?$args

before:  try_files $uri $uri/ =404;
after:     try_files $uri $uri/ /index.php?$args;

3. Can create virtualhost if have multiple instances of wordpress

The post Installing WordPress in Raspberry Pi with Nginx, MySQL and PHP appeared first on Free Linux Tutorials.

Installing Openstack RDO Packstack in CentOS

$
0
0

Want to deploy Openstack and experience your own cloud platform the easier way? One way is to install Openstack via RDO Packstack*.
*Packstack is a utility that uses Puppet modules to deploy various parts of OpenStack . It is suitable for deploying both single node proof of concept  or more complex multi node installations.

Components used and tested in:
CentOS 7 Linux 3.10.0-693.el7.x86_64
Openstack Packstack (latest stable release, Pike)

Advisable to stop firewalld, NetworkManager and enable network

#service firewalld stop
#chkconfig firewalld off
#service NetworkManager stop
#chkconfig NetworkManager off
#service network start
#chkconfig network on

Sample Output:

[root@freelinux vinyard]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
[root@freelinux vinyard]# chkconfig firewalld off
Note: Forwarding request to ‘systemctl disable firewalld.service’.
[root@freelinux vinyard]# service NetworkManager stop
Redirecting to /bin/systemctl stop NetworkManager.service
[root@freelinux vinyard]# chkconfig NetworkManager off
Note: Forwarding request to ‘systemctl disable NetworkManager.service’.
[root@freelinux vinyard]# service network start
Starting network (via systemctl): [ OK ]
[root@freelinux vinyard]# chkconfig network on

1. Enable repository in CentOS (latest stable release as of this writing is Pike)

# yum install -y centos-release-openstack-pike

Sample Output:
[root@freelinux ~]# yum install -y centos-release-openstack-pike
Loaded plugins: fastestmirror

================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
centos-release-openstack-pike x86_64 1-1.el7 extras 5.3 k
Installing for dependencies:
centos-release-ceph-jewel noarch 1.0-1.el7.centos extras 4.1 k
centos-release-qemu-ev noarch 1.0-2.el7 extras 11 k
centos-release-storage-common noarch 1-2.el7.centos extras 4.5 k
centos-release-virt-common noarch 1-1.el7.centos extras 4.5 k

Transaction Summary
================================================================================
Install 1 Package (+4 Dependent packages)

Installing : centos-release-virt-common-1-1.el7.centos.noarch 1/5
Installing : centos-release-qemu-ev-1.0-2.el7.noarch 2/5
Installing : centos-release-storage-common-1-2.el7.centos.noarch 3/5
Installing : centos-release-ceph-jewel-1.0-1.el7.centos.noarch 4/5
Installing : centos-release-openstack-pike-1-1.el7.x86_64 5/5

Installed:
centos-release-openstack-pike.x86_64 0:1-1.el7

Dependency Installed:
centos-release-ceph-jewel.noarch 0:1.0-1.el7.centos
centos-release-qemu-ev.noarch 0:1.0-2.el7
centos-release-storage-common.noarch 0:1-2.el7.centos
centos-release-virt-common.noarch 0:1-1.el7.centos

Complete!

2. Update current packages

# yum update -y

[root@freelinux ~]# yum update -y
Loaded plugins: fastestmirror
centos-ceph-jewel | 2.9 kB 00:00
centos-openstack-pike | 2.9 kB 00:00
centos-qemu-ev | 2.9 kB 00:00
(2/3): centos-openstack-pi 0% [ ] 0.0 B/s | 0 B –:– ETA (2/3): centos-openstack-pi 2% [ ] 0.0 B/s | 31 kB –:– ETA (1/3): centos-qemu-ev/7/x86_64/primary_db | 33 kB 00:15
(2/3): centos-ceph-jewel/7/x86_64/primary_db | 64 kB 00:16
(3/3): centos-openstack-pi 16% [==- ] 159 kB/s | 172 kB 00:05 ETA (3/3): centos-openstack-pi 20% [=== ] 154 kB/s | 215 kB 00:05 ETA (3/3): centos-openstack-pi 26% [==== ] 153 kB/s | 280 kB 00:05 ETA (3/3): centos-openstack-pi 31% [===== ] 150 kB/s | 338 kB 00:04 ETA (3/3): centos-openstack-pi 39% [====== ] 151 kB/s | 414 kB 00:04 ETA (3/3): centos-openstack-pi 45% [======= ] 150 kB/s | 479 kB 00:03 ETA (3/3): centos-openstack-pi 53% [========- ] 155 kB/s | 571 kB 00:03 ETA (3/3): centos-openstack-pi 63% [========== ] 163 kB/s | 678 kB 00:02 ETA (3/3): centos-openstack-pi 74% [===========- ] 172 kB/s | 793 kB 00:01 ETA (3/3): centos-openstack-pi 87% [============== ] 184 kB/s | 929 kB 00:00 ETA (3/3): centos-openstack-pike/x86_64/primary_db | 963 kB 00:20
Loading mirror speeds from cached hostfile

* base: centos.usonyx.net
* extras: centos.usonyx.net
* updates: centos.usonyx.net
Resolving Dependencies
–> Running transaction check
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
—> Package mariadb-libs.x86_64 3:10.1.20-2.el7 will be an update
–> Processing Dependency: mariadb-common(x86-64) = 3:10.1.20-2.el7 for package: 3:mariadb-libs-10.1.20-2.el7.x86_64
–> Running transaction check
—> Package mariadb-common.x86_64 3:10.1.20-2.el7 will be installed
–> Processing Dependency: /etc/my.cnf for package: 3:mariadb-common-10.1.20-2.el7.x86_64
–> Running transaction check
—> Package mariadb-config.x86_64 3:10.1.20-2.el7 will be installed
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
—> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be updated
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
mariadb-libs x86_64 3:10.1.20-2.el7 centos-openstack-pike 643 k
Installing for dependencies:
mariadb-common x86_64 3:10.1.20-2.el7 centos-openstack-pike 63 k
mariadb-config x86_64 3:10.1.20-2.el7 centos-openstack-pike 26 k

Transaction Summary
================================================================================
Install ( 2 Dependent packages)
Upgrade 1 Package

Dependency Installed:
mariadb-common.x86_64 3:10.1.20-2.el7 mariadb-config.x86_64 3:10.1.20-2.el7
Updated:
mariadb-libs.x86_64 3:10.1.20-2.el7
Complete!

3. Install Openstack Packstack Installer

# yum install -y openstack-packstack

Sample output:

[root@freelinux ~]# yum install -y openstack-packstack
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.usonyx.net
* extras: centos.usonyx.net
* updates: centos.usonyx.net
Resolving Dependencies
–> Running transaction check
—> Package openstack-packstack.noarch 1:11.0.1-1.el7 will be installed
–> Processing Dependency: openstack-packstack-puppet = 1:11.0.1-1.el7 for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: pyOpenSSL >= 16.2.0 for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-setuptools for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-pbr for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-netifaces for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-netaddr for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: python-docutils for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Processing Dependency: PyYAML for package: 1:openstack-packstack-11.0.1-1.el7.noarch
–> Running transaction check
—> Package PyYAML.x86_64 0:3.10-11.el7 will be installed

Installed:
openstack-packstack.noarch 1:11.0.1-1.el7

Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7
augeas-libs.x86_64 0:1.4.0-2.el7_4.2
facter.x86_64 1:2.4.4-4.el7
hiera.noarch 1:1.3.4-5.el7
jbigkit-libs.x86_64 0:2.0-11.el7
lcms2.x86_64 0:2.6-3.el7
libimagequant.x86_64 0:2.8.2-2.el7
libjpeg-turbo.x86_64 0:1.2.90-5.el7
libselinux-ruby.x86_64 0:2.5-11.el7
libtiff.x86_64 0:4.0.3-27.el7_3
libwebp.x86_64 0:0.3.0-7.el7
libyaml.x86_64 0:0.1.4-11.el7_0
openjpeg2.x86_64 0:2.1.2-1.el7
openstack-packstack-puppet.noarch 1:11.0.1-1.el7
pciutils.x86_64 0:3.5.1-2.el7
puppet.noarch 0:4.8.2-1.el7
puppet-aodh.noarch 0:11.4.0-1.el7
puppet-apache.noarch 0:2.0.0-1.e31a682git.el7
puppet-ceilometer.noarch 0:11.5.0-1.el7
puppet-certmonger.noarch 0:1.1.1-2.d09f0f2git.el7
puppet-cinder.noarch 0:11.5.0-1.el7
puppet-concat.noarch 0:4.0.1-1.b783e1egit.el7
puppet-corosync.noarch 0:5.0.0-4.527cda5git.el7
puppet-firewall.noarch 0:1.8.2-2.2f892e9git.el7
puppet-glance.noarch 0:11.5.0-1.el7
puppet-gnocchi.noarch 0:11.5.0-1.el7
puppet-heat.noarch 0:11.5.0-1.el7
puppet-horizon.noarch 0:11.5.0-1.el7
puppet-inifile.noarch 0:2.0.0-1.16fd47dgit.el7
puppet-ironic.noarch 0:11.5.0-1.el7
puppet-keystone.noarch 0:11.4.0-1.el7
puppet-magnum.noarch 0:11.3.2-1.el7
puppet-manila.noarch 0:11.4.0-1.el7
puppet-memcached.noarch 0:3.0.2-1.adf8b63git.el7
puppet-mysql.noarch 0:3.11.0-1.920dd76git.el7
puppet-neutron.noarch 0:11.5.0-1.el7
puppet-nova.noarch 0:11.5.1-1.el7
puppet-nssdb.noarch 0:1.0.1-1.el7
puppet-openstack_extras.noarch 0:11.5.0-1.el7
puppet-openstacklib.noarch 0:11.5.0-1.el7
puppet-oslo.noarch 0:11.4.0-1.el7
puppet-ovn.noarch 0:11.4.0-1.el7
puppet-panko.noarch 0:11.5.0-1.el7
puppet-rabbitmq.noarch 0:5.6.0-4.5ac45degit.el7
puppet-redis.noarch 0:3.2.0-1.8c61533git.el7
puppet-remote.noarch 0:0.0.1-3.7420908git.el7
puppet-rsync.noarch 0:0.4.0-2.295cfcegit.el7
puppet-sahara.noarch 0:11.4.0-1.el7
puppet-ssh.noarch 0:3.0.1-3.3fb5405git.el7
puppet-staging.noarch 0:1.0.4-1.b466d93git.el7
puppet-stdlib.noarch 0:4.18.0-2.el7
puppet-swift.noarch 0:11.4.0-1.el7
puppet-sysctl.noarch 0:0.0.11-1.el7
puppet-tempest.noarch 0:11.5.0-1.el7
puppet-trove.noarch 0:11.4.0-1.el7
puppet-vcsrepo.noarch 0:2.0.0-1.e3d28c6git.el7
puppet-vswitch.noarch 0:7.4.0-1.el7
puppet-xinetd.noarch 0:2.0.0-4.1d1e6d4git.el7
python-docutils.noarch 0:0.11-0.2.20130715svn7687.el7
python-enum34.noarch 0:1.0.4-1.el7
python-ipaddress.noarch 0:1.0.16-3.el7
python-netaddr.noarch 0:0.7.18-1.el7
python-netifaces.x86_64 0:0.10.4-3.el7
python-ply.noarch 0:3.4-11.el7
python-pycparser.noarch 0:2.14-1.el7
python2-cffi.x86_64 0:1.5.2-1.el7
python2-cryptography.x86_64 0:1.7.2-1.el7_4.1
python2-idna.noarch 0:2.5-1.el7
python2-olefile.noarch 0:0.44-1.el7
python2-pbr.noarch 0:3.1.1-1.el7
python2-pillow.x86_64 0:4.0.0-1.el7
python2-pyOpenSSL.noarch 0:16.2.0-3.el7
python2-pyasn1.noarch 0:0.1.9-7.el7
python2-setuptools.noarch 0:22.0.5-1.el7
python2-six.noarch 0:1.10.0-9.el7
ruby.x86_64 0:2.0.0.648-30.el7
ruby-augeas.x86_64 0:0.5.0-1.el7
ruby-irb.noarch 0:2.0.0.648-30.el7
ruby-libs.x86_64 0:2.0.0.648-30.el7
ruby-shadow.x86_64 0:1.4.1-23.el7
rubygem-bigdecimal.x86_64 0:1.2.0-30.el7
rubygem-io-console.x86_64 0:0.4.2-30.el7
rubygem-json.x86_64 0:1.7.7-30.el7
rubygem-psych.x86_64 0:2.0.0-30.el7
rubygem-rdoc.noarch 0:4.0.0-30.el7
rubygem-rgen.noarch 0:0.6.6-2.el7
rubygems.noarch 0:2.0.14.1-30.el7

Complete!

4. Install Openstack by running Packstack

#packstack –allinone

Sample output:

root@freelinux ~]# packstack –allinone
Welcome to the Packstack setup utility

The installation log file is available at: /var/tmp/packstack/20180210-134441-WQ3ii9/openstack-setup.log
Packstack changed given value to required value /root/.ssh/id_rsa.pub

Installing:
Clean Up                                                                                           [ DONE ]
Discovering ip protocol version                                                        [ DONE ]
Setting up ssh keys                                                                           [ DONE ]
Preparing servers                                                                              [ DONE ]
Pre installing Puppet and discovering hosts’ details                         [ DONE ]
Preparing pre-install entries                                                              [ DONE ]
Setting up CACERT                                                                            [ DONE ]
Preparing AMQP entries                                                                   [ DONE ]
Preparing MariaDB entries                                                                [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty       [ DONE ]
Preparing Keystone entries                                                               [ DONE ]
Preparing Glance entries                                                                   [ DONE ]
Checking if the Cinder server has a cinder-volumes vg                    [ DONE ]
Preparing Cinder entries                                                                   [ DONE ]
Preparing Nova API entries                                                               [ DONE ]
Creating ssh keys for Nova migration                                               [ DONE ]
Gathering ssh host keys for Nova migration                                     [ DONE ]
Preparing Nova Compute entries                                                      [ DONE ]
Preparing Nova Scheduler entries                                                     [ DONE ]
Preparing Nova VNC Proxy entries                                                    [ DONE ]
Preparing OpenStack Network-related Nova entries                        [ DONE ]
Preparing Nova Common entries                                                      [ DONE ]
Preparing Neutron LBaaS Agent entries                                            [ DONE ]
Preparing Neutron API entries                                                           [ DONE ]
Preparing Neutron L3 entries                                                             [ DONE ]
Preparing Neutron L2 Agent entries                                                  [ DONE ]
Preparing Neutron DHCP Agent entries                                             [ DONE ]
Preparing Neutron Metering Agent entries                                        [ DONE ]
Checking if NetworkManager is enabled and running                       [ DONE ]
Preparing OpenStack Client entries                                                    [ DONE ]
Preparing Horizon entries                                                                   [ DONE ]
Preparing Swift builder entries                                                            [ DONE ]
Preparing Swift proxy entries                                                              [ DONE ]
Preparing Swift storage entries                                                            [ DONE ]
Preparing Gnocchi entries                                                                    [ DONE ]
Preparing Redis entries                                                                         [ DONE ]
Preparing Ceilometer entries                                                                 [ DONE ]
Preparing Aodh entries                                                                          [ DONE ]
Preparing Puppet manifests                                                                   [ DONE ]
Copying Puppet modules and manifests                                               [ DONE ]
Applying 192.168.1.112_controller.pp

Additional information:
* A new answerfile was created in: /root/packstack-answers-20180210-134442.txt
* Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
* File /root/keystonerc_admin has been created on OpenStack client host 192.168.1.112. To use the command line tools you need to source the file.
* To access the OpenStack Dashboard browse to http://192.168.1.112/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.

5. Login to Openstack Dashboard

http://<server.ip> /dashboard

username: admin
pass:  (refer to /root/keystonerc_admin file), sample below

[root@freelinux vinyard]# cat /root/keystonerc_admin
unset OS_SERVICE_TOKEN
export OS_USERNAME=admin
export OS_PASSWORD=’4b5264f3f5674888′
export OS_AUTH_URL=http://192.168.1.112:5000/v3
export PS1='[\u@\h \W(keystone_admin)]\$ ‘

export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3

The post Installing Openstack RDO Packstack in CentOS appeared first on Free Linux Tutorials.

Installation of KVM( Kernel-based Virtual Machine) Virtualization and Eve-NG in CentOS

$
0
0

Installation of KVM and Eve-NG

 Kernel-based Virtual Machine or KVM is an open source virtualization solution that can make your Linux Server as hypervisor. I will demonstrate also how to install Virtual Machine (VM), for this example I will install Eve-NG (Emulated Virtual Environment) which is used by Network Engineers or Security and DevOps professionals to emulate different network devices/platforms such as Cisco,Juniper, Arista, Linux and so much more, mainly for POC, testing and learning.

Tested in CentOS 7
See first if your server supports Virtualization

# lscpu | grep Virt
Virtualization: VT-x

  1. Install KVM
    yum install qemu-kvm virt-install libvirt libvirt-python libguestfs-tools

Start the libvirtd service
systemctl enable libvirtd
systemctl start libvirtd

Check if it is running:

# systemctl status libvirtd
● libvirtd.service – Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-08-02 22:05:35 +08; 23h ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 14880 (libvirtd)
Tasks: 20 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─14880 /usr/sbin/libvirtd
├─14979 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper
└─14980 /usr/sbin/dnsmasq –conf-file=/var/lib/libvirt/dnsmasq/default.conf –leasefile-ro –dhcp-script=/usr/libexec/libvirt_leaseshelper

Verify if kvm is installed

# lsmod | grep -i kvm
kvm_intel 183737 10
kvm 615914 1 kvm_intel
irqbypass 13503 4 kvm

2.Configure bridge network
e.g. primary interface = enp3s0f0
a. add line BRIDGE=br0 under /etc/sysconfig/network-scripts/enp3s0f0 , save and exit
b. configure bridge interface,e.g. br0
if dhcp:
Add the follwowing in /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=”br0″
BOOTPROTO=”dhcp”
IPV6INIT=”yes”
IPV6_AUTOCONF=”yes”
ONBOOT=”yes”
TYPE=”Bridge”

if static:(IP: 192.168.0.200/24, GW: 192.168.0.1, DNS:192.168.0.10
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

Restart network service
service network restart

Verify:
brctl show

For OpenVswitch:
sample contents of /etc/sysconfig/network-scripts/enp3s0f0

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=enp3s0f0
DEVICE=enp3s0f0
ONBOOT=yes
TYPE=”OVSPort”
DEVICETYPE=”ovs”
OVS_BRIDGE=”br0

sample contents of /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=br0
UUID=1e9b47ec-a06e-4e9e-a78d-ffae0571bed7
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.0.200
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.10

3. Install Eve-NG as Virtual Machine
Specifications:
OS:Ubuntu/EVE-NG
RAM: 4GB
VCPU: 4
Image Loc: /home/images
Disk Size: 40GB

Download the ISO of EVE-NG Community version at https://www.eve-ng.net/downloads/eve-ng-2. Upload it on your server
cd /var/lib/libvirt/boot/

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge=br0,model=virtio –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04

For OVS, need to add the option (virtualport_type=openvswitch) else you will get this error message (“ERROR Unable to add bridge brX port vnet0: Operation not supported)

#virt-install –virt-type=kvm –name eve-ng –ram 8192 –vcpus=8 –os-variant=ubuntu16.04 –cdrom=/var/lib/libvirt/boot/EVE-20171007.iso –network=bridge:br-ex,model=virtio,virtualport_type=openvswitch –graphics vnc –disk path=/home/images/eve-ng.qcow2,size=40,bus=virtio,format=qcow2

WARNING Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING No console to launch for the guest, defaulting to –wait -1

Starting install…
Allocating ‘eve-ng.qcow2’ | 40 GB 00:00:04
Domain installation still in progress. Waiting for installation to complete.

Open a new session and check the vnc port settings

# virsh dumpxml eve-ng | grep vnc

Setup SSH tunnel to access the remove VNC server
ssh tux@192.168.0.200 -L 5900:127.0.0.1:5900

4. Connect to VM
Open VNC client and input settings as below. Start the Eve-NG installation(Install EVE as Bare).
Host: localhost or 127.0.0.1
Port: 5900

During installation, you will be prompted to configure the network settings

Test Eve-NG by accessing through the browser or SSH it

Web:http://192.168.0.200
SSH: ssh root@192.168.0.200
root@eve-ng:~# cat /etc/network/interfaces

iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.10

The post Installation of KVM( Kernel-based Virtual Machine) Virtualization and Eve-NG in CentOS appeared first on Free Linux Tutorials.


Authenticating Ubuntu Client to Windows Active Directory

$
0
0

I got the chance to configure one of the old system of my friend running Windows 2000 and Ubuntu 7, (yes it’s not typo) and he wants to authenticate some of his old Ubuntu PCs to Windows AD. Here’s the tutorial for adding Ubuntu box in a Active Directory domain and to authenticate the users with AD

Needed software:
Windows 2000 Advanced Server (function as Domain Controller, AD)
Linux (Ubuntu 6,7)
Winbind
Samba
krb-user
libpam-krb5

Used terms:
AD.freelinuxtutorials.com –> AD Domain
10.201.0.251 –> DC IP address
AD.freelinuxtutorials.com –> Kerberos Realm
10.201.0.193 –> NTP server

Step1: Confirm Connectivity
Confirm network connectivity and name resolution for the Active Directory domain controller. Ping the fully-qualified domain name (FQDN) of the AD DC on your network

root@ubuntuclient#ping AD.freelinuxtutorials.com

If not successful, it could be a DNS issue, you can change the right DNS or add the info using /etc/hosts

Step2: Set the time settings
Time is important for Kerberos, which is used for authentication in Active Directory networks.


/usr/sbin/ntpdate 10.201.0.193

Step3:Setup Kerberos

Install the appropriate client software. This process assumes that you have opened up all the Breezy main and security sources in your sources.list as well as the Universe repository /etc/apt/sources.list
Install the necessary Kerberos packages, you should use the following apt-get command to install the software:



$sudo apt-get install krb5-user libpam-krb5
Modify the /etc/krb5.conf

[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = AD.freelinuxtutorials.com
default_etypes = des-cbc-crc des-cbc-md5
default_etypes_des = des-cbc-crc des-cbc-md5
default_tgs_enctypes = des-cbc-crc des-cbc-md5
default_tkt_enctypes = des-cbc-crc des-cbc-md5
dns_lookup_realm = false
dns_lookup_kdc = true
ticket_lifetime = 24h

[realms]
AD.freelinuxtutorials.com = {
kdc = AD.freelinuxtutorials.com:88
admin_server = AD.freelinuxtutorials.com:749
default_domain = freelinuxtutorials.com
}

[domain_realm]
.freelinuxtutorials.com = freelinuxtutorials.com
freelinuxtutorials.com = freelinuxtutorials.com

[kdc]
profile = /var/kerberos/krb5kdc/kdc.conf

[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}

Step4: Testing

Request a Ticket-Granting Ticket (TGT) by issuing the kinit command and Check if ticket request was valid using the klist command.

Sample output:

root@ubuntu:~# kinit Administrator@AD.freelinuxtutorials.com
Password for Administrator@AD.freelinuxtutorials.com:
root@ubuntu:~# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: Administrator@AD.freelinuxtutorials.com

Valid starting Expires Service principal
06/21/19 14:52:09 06/22/19 00:56:06 krbtgt/AD.freelinuxtutorials.com@AD.freelinuxtutorials.com
renew until 06/22/19 14:52:09

Kerberos 4 ticket cache: /tmp/tkt0
klist: You have no tickets cached

At this point, your Kerberos installation and configuration is operating correctly

 

Step5: Join AD domain
Install winbind and samba


apt-get install winbind samba

 /etc/samba/smb.conf

[global]
workgroup = AD
hosts allow = 10.201.0. 10.200.0. 127.
password server = AD.freelinuxtutorials.com
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/bash
winbind use default domain = yes
winbind separator = /
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%D/%U
realm = AD.freelinuxtutorials.com

Be sure to restart the Samba and Winbind services after changing the /etc/samba/smb.conf file:   



root@ubuntu:~# /etc/init.d/winbind stop
root@ubuntu:~# /etc/init.d/samba restart
root@ubuntu:~# /etc/init.d/winbind start

 


Join the domain:
net ads join –U Administrator@AD.freelinuxtutorials.com
password:XXXXXXXXXXXX
Using short domain name – AD
Joined ‘ubuntu’ to realm ‘AD.freelinuxtutorials.com’

Step6: Testing the AD join


wbinfo -u

You should get a list of the users of the domain.
And a list of the groups.


wbinfo -g

Step7: Setup the Authentication

Modify /etc/nsswitch.conf

passwd: files winbind
group: files winbind
shadow: files compat winbind
hosts: files dns wins winbind
networks: files
protocols: db files winbind
services: db files winbind
ethers: db files
rpc: db files
netgroup: nis files winbind

Step8: Testing winbind nsswitch

Check Winbind nsswitch module with getent.
getent passwd
getent group

Step9: Modify PAM
Go to /etc/pam.d

/etc/pam.d/common-account

account sufficient pam_winbind.so
account sufficient pam_krb5.so minimum_uid=1000
account required pam_unix.so nullok_secure
account [default=bad success=ok user_unknown=ignore service_err=ignore system_er
r=ignore] pam_krb5.so

/etc/pam.d/common-auth

auth sufficient pam_winbind.so
auth sufficient pam_krb5.so minimum_uid=1000 use_first_pass
auth required pam_unix.so
auth sufficient pam_group.so use_first_pass

/etc/pam.d/common-session

session required pam_unix.so
session optional pam_foreground.so
session optional pam_krb5.so
session required pam_mkhomedir.so umask=0022 skel=/etc/skel

/etc/pam.d/sudo

#%PAM-1.0
auth sufficient pam_winbind.so
auth sufficient pam_unix.so use_first_pass
auth required pam_deny.so
@include common-account

/etc/pam.d/samba

@include common-auth
@include common-account
@include common-session
@include common-password

/etc/pam.d/common-password

password required pam_unix.so nullok obscure min=4 max=8 md5
password required pam_unix.so nullok obscure min=4 max=50 md5

Step10: Create the domain directory in /home


#mkdir /home/AD

Easy steps for the configuration files

All config files can be get via wget on http://10.201.0.193/script
Nsswitch.conf, krb5.conf , smb.conf located on script folder
Pam.d config files located on script/pam
e.g
#cd /etc/
#wget http://10.201.0.193/script/krb5.conf

#cd /etc/samba
#wget http://10.201.0.193/script/smb.conf

You can add boot up script on /etc/rc.local
vi /root/script.sh

/usr/sbin/ntpdate 10.201.0.193
/etc/init.d/winbind stop
/etc/init.d/samba restart
/etc/init.d/winbind start

Save and exit.

Make the script executable


#chmod +x /root/script

Under /etc/rc.local, append the script so it will run during start-up


/root/script.sh

The post Authenticating Ubuntu Client to Windows Active Directory appeared first on Free Linux Tutorials.

Top 20 Must Know Basic Commands in Linux with Examples Part 1

$
0
0

Here’s the list of basic commands a Linux user  needs to know and familiarize  for them to feel comfortable in working with command line interface/shell/terminal. We all know that mostly all Linux distribution now comes with their own GUIs or Graphical User Interfaces but not can be managememanagement of tasks but not are good for all tasks especially when you need to do some 
I’ll break down into two parts for nicer readability and to emphasize with the examples for better understanding.

  1. ls
    – command to list directory contents
    Useful options with “ls”
    ls -l –> list files,directory,size,date/time,owner,permission

tux@freelinux:/usr/local$ ls -l
total 32
drwxr-xr-x 2 root root 4096 Jan 8 2018 bin
drwxr-xr-x 2 root root 4096 Jan 8 2018 etc
drwxr-xr-x 2 root root 4096 Jan 8 2018 games
drwxr-xr-x 2 root root 4096 Jan 8 2018 include
drwxr-xr-x 3 root root 4096 Feb 16 2018 lib
lrwxrwxrwx 1 root root 9 Feb 16 2018 man -> share/man
drwxr-xr-x 2 root root 4096 Jan 8 2018 sbin
drwxr-xr-x 4 root root 4096 Feb 16 2018 share
drwxr-xr-x 2 root root 4096 Jan 8 2018 src

ls -a –> list all files (including starting with .)

tux@freelinux:/usr/local$ ls -a

. .. bin etc games include lib man sbin share src

ls -s –> list in sorted order by file size

tux@freelinux:/usr/local$ ls -s
total 32
4 bin 4 etc 4 games 4 include 4 lib 0 man 4 sbin 4 share 4 src

ls -t –> list and sort by modification time, newest first

tux@freelinux:/usr/local$ ls -t
lib man share bin etc games include sbin src

ls -r –> list in reverse order

tux@freelinux:/usr/local$ ls -r
src share sbin man lib include games etc bin

ls -R –> list sub-directories recursively

tux@freelinux:/usr/local$ ls -R
.:
bin etc games include lib man sbin share src
./bin:
./etc:
./games:
./include:
./lib:
python3.6
./lib/python3.6:
dist-packages
./lib/python3.6/dist-packages:
./sbin:
./share:
ca-certificates man
./share/ca-certificates:
./share/man:
./src:


Sample combine options.
ls -ltr –> list files and show oldest first

tux@freelinux:/usr/local$ ls -ltr
total 32
drwxr-xr-x 2 root root 4096 Jan 8 2018 src
drwxr-xr-x 2 root root 4096 Jan 8 2018 sbin
drwxr-xr-x 2 root root 4096 Jan 8 2018 include
drwxr-xr-x 2 root root 4096 Jan 8 2018 games
drwxr-xr-x 2 root root 4096 Jan 8 2018 etc
drwxr-xr-x 2 root root 4096 Jan 8 2018 bin
drwxr-xr-x 4 root root 4096 Feb 16 2018 share
lrwxrwxrwx 1 root root 9 Feb 16 2018 man -> share/man
drwxr-xr-x 3 root root 4096 Feb 16 2018 lib

 

2. pwd
– command to print name of current/working directory

tux@freelinux:~$ pwd
/home/tux

 

3. cd
– command to allow user to change directories.
Useful options with ‘cd’ (I’ll be adding the pwd command to understand the current directory)
cd [full path]

tux@freelinux:~$ pwd
/home/tux
tux@freelinux:~$ cd /usr/local
tux@freelinux:/usr/local$ pwd
/usr/local


cd ~ –> change to home directory ( or just type ‘cd’ without options)

tux@freelinux:/usr/local$ cd ~
tux@freelinux:~$ pwd
/home/tux

cd .. –> change to parent directory (one directory up)

tux@freelinux:~$ pwd
/home/tux
tux@freelinux:~$ cd ..
tux@freelinux:/home$ pwd
/home

cd – –> change to previous working directory

tux@freelinux:~$ cd /var/www/html
tux@freelinux:/var/www/html$ cd –
/home/tux

 

4. su
-command to change user ID or become superuser. su short for switch user

Useful options with ‘su’ command

su [username] –> switch to username, if no username , it will default to root

tux@freelinux:~$ whoami
tux
tux@freelinux:~$ su darwin
Password:
darwin@freelinux:/home/tux$ su
Password:
root@freelinux:/home/tux#

su – –> if added with hypen, it will provide an environment similar to what the user would expect had the user logged in directly. Compare below the current directory,with and without the “-” . You can also use “-l” or ‘–login’

tux@freelinux:~$ su darwin
Password:
darwin@freelinux:/home/tux$ pwd
/home/tux
darwin@freelinux:/home/tux$ exit
exit
tux@freelinux:~$ su – darwin
Password:
darwin@freelinux:~$ pwd
/home/darwin

su -s –> use ‘-s’ to specify the shell environment

darwin@freelinux:~$ echo $SHELL
/bin/bash
darwin@freelinux:~$ su -s /bin/sh tux
Password:
$ echo $SHELL
/bin/sh
$ whoami
tux

 

5. passwd
-command to change user password.

Useful options with ‘passwd’ command

passwd [username] –> if no username is specified, it will reset password of logged-in user. The “root” user has the full privilege to change the password for any user, while normal user can only change his/her own account

tux@freelinux:~$ passwd
Changing password for tux.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
tux@freelinux:~$ passwd darwin
passwd: You may not view or modify password information for darwin.

root@freelinux:~# passwd darwin
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


passwd -S [username]–> will show password status info of a user

tux@freelinux:~$ passwd -S
tux P 01/03/2021 0 99999 7 -1

“root” user command options

passwd -e [username]–> to set account’s password expiry immediately, which whill force a user to change his/her password at next user’s login

root@freelinux:~# passwd -S darwin
darwin P 01/03/2021 0 99999 7 -1
root@freelinux:~# passwd -e darwin
passwd: password expiry information changed.
root@freelinux:~# passwd -S darwin
darwin P 01/01/1970 0 99999 7 -1

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for darwin.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

passwd -l –> lock the password of user

root@freelinux:~# passwd -l darwin
passwd: password expiry information changed.
root@freelinux:~# passwd -S darwin
darwin L 01/03/2021 0 99999 7 -1

passwd -u –> unlock user password

root@freelinux:~# passwd -S darwin
darwin L 01/03/2021 0 99999 7 -1
root@freelinux:~# passwd -u darwin
passwd: password expiry information changed.
root@freelinux:~# passwd -S darwin
darwin P 01/03/2021 0 99999 7 -1

passwd -w (value) –> set number of days of warning before a change of password is required

root@freelinux:~# passwd -S tux
tux P 01/03/2021 0 99999 7 -1
root@freelinux:~# passwd -w 2 tux
passwd: password expiry information changed.
root@freelinux:~# passwd -S tux
tux P 01/03/2021 0 99999 2 -1

passwd -n [value] –> set minimum number of days between password changes,e.g. set to 30 days

root@freelinux:~# passwd -S darwin
darwin P 01/03/2021 0 99999 7 -1
root@freelinux:~# passwd -n 30 darwin
passwd: password expiry information changed.
root@freelinux:~# passwd -S darwin
darwin P 01/03/2021 30 99999 7 -1

 

6. cp
– command to copy files and directories

Useful options with ‘cp’ command
cp {options} Source Destination

root@freelinux:/mnt# cp /etc/passwd /mnt/archives/
root@freelinux:/mnt# ls -l /mnt/archives/
total 4
-rw-r–r– 1 root root 1711 Jan 3 18:32 passwd

cp {options} Source Source Source Source Destination

root@freelinux:~#cp /var/log/wtmp /etc/shadow /etc/group /mnt/archives
root@freelinux:~# ls /mnt/archives
group passwd shadow wtmp

cp -i –> short for interactive, prompt before overwrite

root@freelinux:~# cp -i /etc/fstab /mnt/archives/
cp: overwrite ‘/mnt/archives/fstab’? y

cp -v –> verbose

root@freelinux:~# cp -v /etc/gshadow /mnt/archives/
‘/etc/gshadow’ -> ‘/mnt/archives/gshadow’

cp -r (or cp -R or cp –recursive) –> copy directories recursively

root@freelinux:~# cp -r /home/tux /mnt/archives/


7. rm
-command to remove files or directories
rm {file}
rm {file1} {file2}

tux@freelinux:~$ ls -l
total 0
-rw-rw-r– 1 tux tux 0 Jan 4 00:30 testfile1
-rw-rw-r– 1 tux tux 0 Jan 4 00:30 testfile2
-rw-rw-r– 1 tux tux 0 Jan 4 00:30 testfile3
tux@freelinux:~$ rm testfile1
tux@freelinux:~$ rm testfile2 testfile3
tux@freelinux:~$ ls -l
total 0

Useful options with ‘rm’ command
rm -i –> will prompt before every removal

tux@freelinux:~$ ls -l
total 0
-rw-rw-r– 1 tux tux 0 Jan 4 00:31 file1
-rw-rw-r– 1 tux tux 0 Jan 4 00:31 file2
tux@freelinux:~$ rm -i file1
rm: remove regular empty file ‘file1’? y
tux@freelinux:~$ ls -l
total 0
-rw-rw-r– 1 tux tux 0 Jan 4 00:31 file2

rm -r –> recursively remove directories and contents

tux@freelinux:~$ ls -R folder1/
folder1/:
folder2

folder1/folder2:
folder3

folder1/folder2/folder3:
tux@freelinux:~$ rm folder1/
rm: cannot remove ‘folder1/’: Is a directory
tux@freelinux:~$ rm -r folder1/
tux@freelinux:~$ ls -l
total 0


rm -f –> force remove, will ignore nonexistent files, never prompt 

tux@freelinux:~$ rm testfile1
rm: remove write-protected regular empty file ‘testfile1’? n
tux@freelinux:~$ rm -f testfile1

8. mv
-command to move or rename files
mv [filename/dir] [new_filename/new_dir] –> rename
mv [source][destination] –> move

tux@freelinux:~$ ls -l
total 0
-rw-rw-r– 1 tux tux 0 Jan 4 00:41 file111
tux@freelinux:~$ mv file111 file222
tux@freelinux:~$ ls -l
total 0
-rw-rw-r– 1 tux tux 0 Jan 4 00:41 file222

tux@freelinux:~$ ls -R folder1/
folder1/:
folder2 testfile1

folder1/folder2:
folder3

folder1/folder2/folder3:
tux@freelinux:~$ mv /home/tux/folder1/testfile1 /home/tux/folder1/folder2/
tux@freelinux:~$ ls -R folder1/
folder1/:
folder2

folder1/folder2:
folder3 testfile1

folder1/folder2/folder3:

Useful options with ‘mv’ command
mv -i –> prompt before overwrite

tux@freelinux:~$ mv -i /home/tux/dir1/file1 /home/tux/dir1/dir2
mv: overwrite ‘/home/tux/dir1/dir2/file1’? n


mv -f -> force move, will not prompt when overwriting

tux@freelinux:~$ mv -f /home/tux/dir1/file1 /home/tux/dir1/dir2

 


9. find
-command to search files in a directory hierarchy

Useful options with ‘find’ command

find / -name [filename] –> find all the files starting from the root directory (/) with  name “filename” 

tux@freelinux:~$ find / -name filename1
find: /mnt/archives/tux/.cache: Permission denied
find: /home/darwin/.cache: Permission denied
/home/tux/filename1

find -type d –> find in the specific path and look only for directories

darwin@freelinux:~$ ls -l
total 8
drwxrwxr-x 2 darwin darwin 4096 Jan 4 02:31 dir1
drwxrwxr-x 2 darwin darwin 4096 Jan 4 02:31 dir2
-rw-rw-r– 1 darwin darwin 0 Jan 4 02:31 filename1
-rw-rw-r– 1 darwin darwin 0 Jan 4 02:32 filename2
darwin@freelinux:~$ find . -type d
.
./dir2
./dir1
./.cache

find -type f–> find in the specific path and look only for files

darwin@freelinux:~$ ls -l
total 8
drwxrwxr-x 2 darwin darwin 4096 Jan 4 02:31 dir1
drwxrwxr-x 2 darwin darwin 4096 Jan 4 02:31 dir2
-rw-rw-r– 1 darwin darwin 0 Jan 4 02:31 filename1
-rw-rw-r– 1 darwin darwin 0 Jan 4 02:32 filename2
darwin@freelinux:~$ find . -type f
./.profile
./.bashrc
./.bash_history
./filename2
./.bash_logout
./filename1
./.cache/motd.legal-displayed

find . -type -f -perm xxx –>  find files with specified permission

darwin@freelinux:~$ find . -type f -perm 775
./filename2

find -size[+/-] –> find files less or greater than specified size
e.g. find files larger than 100Mb

tux@freelinux:~$ sudo find / -type f -size +100M
/proc/kcore
tux@freelinux:~$ ls -l /proc/kcore
-r——– 1 root root 140737477881856 Jan 4 02:47 /proc/kcore
tux@freelinux:~$ ls -lh /proc/kcore
-r——– 1 root root 128T Jan 4 02:47 /proc/kcore

 

10. grep
-command to print lines matching a pattern
Syntax:
grep “word to search” filename
grep “string1 string2 string3” filename
command | grep “word”

tux@freelinux:~$ grep darwin /etc/passwd
darwin:x:1001:1001:,,,:/home/darwin:/bin/bash

Note: you can use -r to search recursively, or use -i to ignore case

tux@freelinux:~$ cat /etc/passwd | grep darwin
darwin:x:1001:1001:,,,:/home/darwin:/bin/bash

grep – w –> to select only containing matches or word-regexp
See the difference between the two examples: (will only select the file with the exact matching

darwin@freelinux:~$ cat filename1
coffee123
darwin@freelinux:~$ cat filename2
coffee
darwin@freelinux:~$ grep -w “coffee” filename*
filename2:coffee

grep -c –> to count number of matches

darwin@freelinux:~$ grep -c “coffee” filename*
filename1:1
filename2:1

grep -c –> count number of matches

tux@freelinux:/var/log$ grep -c “user” /var/log/auth.log
310

grep -r –> to read all files recursively under directory
grep -i –> print only matching and ignore case

The post Top 20 Must Know Basic Commands in Linux with Examples Part 1 appeared first on Free Linux Tutorials.

Top 20 Must Know Basic Commands in Linux with Examples Part 2

$
0
0

11. chmod
-command to change file mode bits. This is used to assign or change permissions of files and directories. We need to understand first the file permission 

Three types of permissions (can assign using the text(r,w,x) or using numeric (4,2,1)
4 – read(r)
2 – write(w)
1 – execute(x)

Three different roles or ownership
u – user or owner of the file
g – group 
o – others

+ = means adding
– = means removing

Samples:
-Adding execute permission for all roles, use a+x (without a, it will only applies to user and group)

tux@freelinux:~$ ls -l file1
-rw-rw-r– 1 tux tux 0 Jan 17 15:18 file1
tux@freelinux:~$ chmod a+x file1
tux@freelinux:~$ ls -l
total 8
-rwxrwxr-x 1 tux tux 0 Jan 17 15:18 file1

-Adding execute permission for user role only, use u+x

tux@freelinux:~$ ls -l file2
-rw-rw-r– 1 tux tux 0 Jan 17 15:16 file2
tux@freelinux:~$ chmod u+x file2
tux@freelinux:~$ ls -l file2
-rwxrw-r– 1 tux tux 0 Jan 17 15:16 file2

– Removing write permission for multiple roles (u-w,g-w)

tux@freelinux:~$ ls -l file2
-rwxrw-r– 1 tux tux 0 Jan 17 15:16 file2
tux@freelinux:~$ chmod u-w,g-w file2
tux@freelinux:~$ ls -l file2
-r-xr–r– 1 tux tux 0 Jan 17 15:16 file2

-Using numeric to chmod, as mentioned 4=read,2=write,1=execute so can be broken down something like -421-421-421 in a file considering the u,g,o structure
rwx =7
r-x =5
r– =4
e.g. changing permission to all read for a file

tux@freelinux:~$ ls -l file3
-rw-rw-r– 1 tux tux 0 Jan 17 15:25 file3
tux@freelinux:~$ chmod 444 file3
tux@freelinux:~$ ls -l file3
-r–r–r– 1 tux tux 0 Jan 17 15:25 file3

e.g. changing all permissions for a file

tux@freelinux:~$ ls -l file4
-rw-rw-r– 1 tux tux 0 Jan 17 15:26 file4
tux@freelinux:~$ chmod 777 file4
tux@freelinux:~$ ls -l file4
-rwxrwxrwx 1 tux tux 0 Jan 17 15:26 file4

chmod -R  –> to recursively change files and directories permissions

e.g. change user and group to all permission, and no write permission for others,  recursively for sampledir1 folder

tux@freelinux:~/sampledir1/sampledir2$ ls -lR /home/tux/sampledir1/
/home/tux/sampledir1/:
total 4
drwxrwxr-x 2 tux tux 4096 Jan 17 15:29 sampledir2
/home/tux/sampledir1/sampledir2:
total 0
-rw-rw-r– 1 tux tux 0 Jan 17 15:29 ABC

tux@freelinux:~$ chmod 775 -R /home/tux/sampledir1/
tux@freelinux:~$ ls -lR /home/tux/sampledir1/
/home/tux/sampledir1/:
total 4
drwxrwxr-x 2 tux tux 4096 Jan 17 15:29 sampledir2

/home/tux/sampledir1/sampledir2:
total 0
-rwxrwxr-x 1 tux tux 0 Jan 17 15:29 ABC

 

12. chown
-command to change file owner and group
Syntax :
chown [OPTION]… [OWNER][:[GROUP]] FILE…

Change ownership of a file

root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 tux tux 0 Jan 17 17:11 file1
root@freelinux:/home/tux# chown darwin file1
root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 darwin tux 0 Jan 17 17:11 file1

Change the group ownership of a file

root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 darwin tux 0 Jan 17 17:11 file1
root@freelinux:/home/tux# chown :admins file1
root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 darwin admins 0 Jan 17 17:11 file1

Change user and group of a file

root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 darwin admins 0 Jan 17 17:11 file1
root@freelinux:/home/tux# chown tux:tux file1
root@freelinux:/home/tux# ls -l file1
-rw-rw-r– 1 tux tux 0 Jan 17 17:11 file1

13. tail
-command to output the last part of files

Syntax:
tail [OPTION]… [FILE]…

Useful options with “tail”

tail -f –> to output appended data as file grows. It is useful in troubleshooting or debugging
e.g.
(Let say want to see your web server error logs in real-time)

root@freelinux:/var/log/apache2# tail -f /var/log/apache2/error.log  

tail -n [N] –> to output the last [N] lines from file

tux@freelinux:~$ tail -n 2 /var/log/apache2/error.log
[Sun Jan 03 14:09:45.116780 2021] [mpm_prefork:notice] [pid 897] AH00163: Apache/2.4.27 (Ubuntu) configured — resuming normal operations
[Sun Jan 03 14:09:45.121054 2021] [core:notice] [pid 897] AH00094: Command line: ‘/usr/sbin/apache2’

tail -c [N] –> to output the last [N] bytes from file

tux@freelinux:~$ tail -c 100 /var/log/apache2/error.log
Sun Jan 03 14:09:45.121054 2021] [core:notice] [pid 897] AH00094: Command line: ‘/usr/sbin/apache2’

 

14. ps
– command to report a snapshot of the current processes

Syntax:
ps [options]

Useful options with “ps”

ps -ef –> e is to output all the process and f is to display in full listing format

tux@freelinux:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Jan28 ? 00:00:02 /sbin/init
root 2 0 0 Jan28 ? 00:00:00 [kthreadd]
root 4 2 0 Jan28 ? 00:00:00 [kworker/0:0H]
root 6 2 0 Jan28 ? 00:00:00 [mm_percpu_wq]
root 7 2 0 Jan28 ? 00:00:00 [ksoftirqd/0]
root 8 2 0 Jan28 ? 00:00:00 [rcu_sched]

ps -aux” (BSD format) will give the same output as ps -ef 
where -a to display all process from all users; -u to output in user-oriented format; -x list background processes and started upon system boot

ps -u [UID]–> show all processes running with specific user 

tux@freelinux:~$ ps -u www-data
PID TTY TIME CMD
29015 ? 00:00:00 apache2
29016 ? 00:00:00 apache2
29017 ? 00:00:00 apache2
29018 ? 00:00:00 apache2
29019 ? 00:00:00 apache2
30187 ? 00:00:00 apache2

ps -p [PID] –> to select process ID, you can also use -q in quick mode

tux@freelinux:~$ ps -p 29015
PID TTY TIME CMD
29015 ? 00:00:00 apache2

Sample useful command for troubleshooting,e.g. sort by memory or cpu

ps -eo pid,cmd,%mem,%cpu –sort=-%mem | head
ps -eo pid,cmd,%mem,%cpu –sort=-%cpu | head


tux@freelinux:~$ ps -eo pid,cmd,%mem,%cpu –sort=-%mem | head
PID CMD %MEM %CPU
28672 qemu-system-x86_64 -enable- 16.7 204
8261 qemu-system-x86_64 -enable- 12.4 47.6
28321 ovs-vswitchd unix:/var/snap 0.1 1.6



tux@freelinux:~$ ps -eo pid,cmd,%mem,%cpu –sort=-%cpu | head
PID CMD %MEM %CPU
28672 qemu-system-x86_64 -enable- 16.7 204
8261 qemu-system-x86_64 -enable- 12.4 47.6
28321 ovs-vswitchd unix:/var/snap 0.1 1.6

15. top
-command to display Linux processes

Sample popular options:

top -u [UID] 

tux@freelinux:~$ top -u www-data


Sample Output:

top – 12:58:54 up 429 days, 2:32, 2 users, load average: 6.32, 6.17, 6.16
Tasks: 467 total, 1 running, 466 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.8 us, 14.6 sy, 0.0 ni, 84.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 26394596+total, 17867691+free, 45759684 used, 39509372 buff/cache
KiB Swap: 26815590+total, 26815590+free, 0 used. 21245590+avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
29015 www-data 20 0 71648 4400 2996 S 0.0 0.0 0:00.00 apache2
29016 www-data 20 0 71448 4132 2896 S 0.0 0.0 0:00.00 apache2
29017 www-data 20 0 71648 4540 3124 S 0.0 0.0 0:00.00 apache2


Inside the top display, here’s some useful keys 
(capital letters)
M – to sort by memory usage
P – to sort by CPU usage
N – to sort by process id
T – to sort by running time

16. cat
-command to concatenate files and print on standard output

Syntax:
cat [OPTION]… [FILE]…

tux@freelinux:~$ cat testfile1
This is a test file1

or multiple files:

tux@freelinux:~$ cat testfile1 testfile2
This is a test file1
This is a test file2

Some options with ‘cat’ command:

cat > [filename] –> use with > to create new file (Hold ‘Ctrl’ key and press d to exit and save changes
cat >>[filename] –> to append to the file

tux@freelinux:~$ cat >testfile3
This is a testfile3
tux@freelinux:~$ cat testfile3
This is a testfile3


tux@freelinux:~$ cat >>testfile3
2nd line
tux@freelinux:~$ cat testfile3
This is a testfile3
2nd line

cat [filename1] > [filename2] –> redirect contents from one file to another. Note: if file is existing, it will overwrite, so be careful.

tux@freelinux:~$ cat testfile3 > testfile4
tux@freelinux:~$ cat testfile4
This is a testfile3
2nd line

cat -n [filename] –> to display contents with line numbers

tux@freelinux:~$ cat -n testfile3
1 This is a testfile3
2 2nd line

17. mkdir
-command to make directories

Syntax:
mkdir [OPTION]… DIRECTORY…

mkdir -p –> to make parent directories, quite useful so for user not to create multiple sub-directories one by one

tux@freelinux:~$ mkdir -p /home/tux/dir1/dir2/dir3

mkdir -m –> to set custom file mode (as in chmod), default permission is 775 if not using this option

tux@freelinux:~$ mkdir -p -m 777 /home/tux/folder1/folder2/folder3

18. rmdir
-command to remove empty directories

Syntax:
rmdir [OPTION]… DIRECTORY…

rmdir -p –> to remove directory and its ancestors

tux@freelinux:~$ rmdir -p /home/tux/dir1
rmdir: failed to remove ‘/home/tux/dir1’: Directory not empty
tux@freelinux:~$ rmdir -p /home/tux/dir1/dir2/
rmdir: failed to remove ‘/home/tux/dir1/dir2/’: Directory not empty
tux@freelinux:~$ rmdir -p /home/tux/dir1/dir2/dir3/
rmdir: failed to remove directory ‘/home/tux’: Permission denied
tux@freelinux:~$ ls -l /home/tux/dir1
ls: cannot access ‘/home/tux/dir1’: No such file or directory


18. history
-command to show last commands that have been recently used. This is useful in case you forget what command was executed

19. clear
-command to clear the terminal screen

20. man
-command to show on-line reference manuals for commands. It will show details like syntax, description and options.

Sample:

tux@freelinux:~$ man kill

Sample output:

KILL(1) User Commands KILL(1)

NAME
kill – send a signal to a process

SYNOPSIS
kill [options] <pid> […]

Honorable mentions:
more – command to display file or text files one screen at a time
less – command to display contents of a file one page at a time, similar to more but has advanced features of allowing user to navigate backward and forward through the file
df – command to report file system disk space usage
du – command to estimate file space usage

The post Top 20 Must Know Basic Commands in Linux with Examples Part 2 appeared first on Free Linux Tutorials.

Top 10 Basic virsh commands for KVM Hypervisor management

$
0
0

The virtual shell or  virsh program is the main interface for managing virsh guest domains. This program can be used to list, create, pause, and shutdown domains.

1. Display information about the hypervisor

virsh nodeinfo

Sample output:
tux@ubuntuserver:~$ virsh nodeinfo
CPU model: x86_64
CPU(s): 40
CPU frequency: 1199 MHz
CPU socket(s): 1
Core(s) per socket: 10
Thread(s) per core: 2
NUMA cell(s): 2
Memory size: 263945968 KiB

2. List all domains

virsh list –all

Sample output: (with –all options, it will display also those shut off domains)

tux@ubuntuserver:~$ virsh list –all
Id   Name    State
—————————————————-
4   eve-ng     running
–    redhat    shut off
–    debian   shut off

3.  Display domain information

virsh dominfo [domain id/name]

Sample Output:

tux@ubuntuserver:~$ virsh dominfo eve-ng
Id: 4
Name: eve-ng
UUID: afac7793-29f9-4754-84f3-42157e41934b
OS Type: hvm
State: running
CPU(s): 16
CPU time: 64353519.3s
Max memory: 67108864 KiB
Used memory: 67108864 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: apparmor
Security DOI: 0
Security label: libvirt-afac7793-29f9-4754-84f3-42157e41934b (enforcing)

4.  Output domain/guest XML configuration

virsh dumpxml [domain id/name]

Sample output:
tux@ubuntuserver:~$ virsh dumpxml 4
<domain type=’kvm’ id=’4′>
<name>eve-ng</name>
<uuid>afac7793-29f9-4754-84f3-42157e41934b</uuid>
<memory unit=’KiB’>67108864</memory>
<currentMemory unit=’KiB’>67108864</currentMemory>
<vcpu placement=’static’>16</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch=’x86_64′ machine=’pc-i440fx-trusty’>hvm</type>
<boot dev=’hd’/>
</os>
<source file=’/home/tux/images/eve-ng.qcow2’/>
<interface type=’bridge’>
<mac address=’11:24:30:56:38:28’/>
<source bridge=’br0’/>
<target dev=’vnet0’/>
<model type=’rtl8139’/>
</domain>

5.  Edit guest/domain configuration file (can  be done while running or offline)

virsh edit [domain id/name]

6.  Shutdown a guest/domain

virsh shutdown [domain id/name]

Sample Output:

tux@ubuntuserver:~$ virsh list
Id Name State
—————————————————-
4   eve-ng   running
10 server1 running

tux@ubuntuserver:~$ virsh shutdown 10
Domain 10 is being shutdown

7. Start a guest/domain

virsh start [domain id/name]

Sample Output:

tux@ubuntuserver:~/$ virsh start eve-ng
Domain eve-ng started

8. Suspend a guest/domain ( when in a suspended state, it still consumes system RAM but disk and network I/O will not occur). State will be “paused”.

virsh suspend [domain id/name]

Sample Output:

tux@ubuntuserver:~$ virsh list
Id Name State
—————————————————-
4 eve-ng  running
11 server1 running

tux@ubuntuserver:~$ virsh suspend server1
Domain server1 suspended

tux@ubuntuserver:~$ virsh list
Id Name State
—————————————————-
4 eve-ng running
11 server1 paused

9. Resume a guest/domain (to resume from the “suspend” command)

virsh resume [domain id/name]

Sample Output:

tux@ubuntuserver:~$ virsh resume server1
Domain server1 resumed

10.  Connect the virtual serial console for the guest.

virsh console [domain id/name]

The post Top 10 Basic virsh commands for KVM Hypervisor management appeared first on Free Linux Tutorials.

Fixing KVM guest virsh console hangs at Escape character

$
0
0

virsh is a tool to manage virsh guest domains and the command “virsh console [domain id/name]” can be use to connect the virtual serial console for the guest. But sometimes the connection with the serial console  hangs or stucked at the “escape character ^] ” and not bringing you to the guest login after pressing “Enter” , it looks something like this:

tux@ubuntuserver1:~$ virsh console 11
Connected to domain eve-ng
Escape character is ^]

In order to exit, need to use Escape character depending on type of keyboard. Typically, for English keybord “Ctrl+]” will work.

Here are few steps  you can try to fix this:

1. Edit/update the /etc/default/grub configuration (some distribution maybe different). Tested working in Ubuntu.

From:
GRUB_TERMINAL=console
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash vga=788″

To:

GRUB_CMDLINE_LINUX_DEFAULT=”console=tty0 console=ttyS0″
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND=”serial –unit=0 –speed=115200 –word=8 –parity=no –stop=1″

2. Update the config and reboot

#update-grub

Sample output:

root@eve-ng:~# update-grub
Generating grub configuration file …
Found linux image: /boot/vmlinuz-4.9.40-eve-ng-ukms-2+
Found initrd image: /boot/initrd.img-4.9.40-eve-ng-ukms-2+
Found linux image: /boot/vmlinuz-4.4.0-179-generic
Found linux image: /boot/vmlinuz-4.4.0-178-generic
done

3.    Enable and start serial getty

# systemctl enable serial-getty@ttyS0.service
# systemctl start serial-getty@ttyS0.service

4. Reboot

#reboot

Verify:

tux@ubuntuserver1:~$ virsh list
Id Name State
—————————————————-
4 eve-ng running

tux@labucs1:~$ virsh console 4
Connected to domain eve-ng
Escape character is ^]

Eve-NG (default root password is ‘eve’)
Use http://192.168.10.21/

eve-ng login:

The post Fixing KVM guest virsh console hangs at Escape character appeared first on Free Linux Tutorials.

Viewing all 73 articles
Browse latest View live