Thứ Ba, 17 tháng 11, 2015

How to install configure printers on Linux

Install required packages
apt-get install cups cups-client "foomatic-db".
Add user to lpadmin group
adduser root lpadmin
Output
 Adding user `root' to group `lpadmin' ...
 Adding user root to group lpadmin
 Done.
Restart cups and samba service
service cups restart 
service samba restart
 Find USB printer
netstat -ant | grep 631 
lsusb
Configuring Printer
     Open browser and type:
    http://127.0.0.1:631/
    In semicolon: CUPS for Administrators
    Click on Adding Printers and Classes
    Click on Add printer
    Type your username(system account) and password(system password)
    Choose your printer
    Follow instructions to complete rest of the installation……
    In System Settings: Go and check
        Printers
    You’ll see your installed printer
Is the printer on Win7 shared? 
try adding it directly using one of the following URI examples:

smb://WORKGROUP_NAME/MACHINE_NAME/PrinterName
smb://MACHINE_NAME/PrinterName
smb://192.168.0.100/PrinterName
List samba shares
smbclient -L < Windows host name > -U < Windows Administrator account >

Read More

Chủ Nhật, 15 tháng 11, 2015

Start/stop iptables on Ubuntu

Iptables is a firewall, installed by default on all official Ubuntu distributions (Ubuntu, Kubuntu, Xubuntu).
Iptables is a command it's not a service, so generally it's not possible to use commands like
service iptables start
or
service iptables stop
In order to start and stop the firewall, but some distros like centos have installed a service called iptables to start and stop the firewall and a configuration file to configure it. Anyway it's possible to make a service to manage iptables editing or installing a script for this scope. All services in linux, ubuntu is not an exception, are executable scripts inside /etc/init.d folder, that implements a standard interface (start,stop,restart) A possible script looks like this:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          iptables
# Required-Start:    mountvirtfs ifupdown $local_fs
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

# July 9, 2007
# James B. Crocker <ubuntu@james.crocker.name>
# Creative Commons Attribution - Share Alike 3.0 License (BY,SA)
# Script to load/unload/save iptables firewall settings.

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"

IPTABLES=/sbin/iptables
IPTABLES_SAVE=/sbin/iptables-save
IPTABLES_RESTORE=/sbin/iptables-restore

IPTABLES_CONFIG=/etc/iptables.conf

[ -x $IPTABLES ] || exit 0

. /lib/lsb/init-functions


case "$1" in
start)
 log_action_begin_msg "Starting firewall"
        type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 120" || true
 if $IPTABLES_RESTORE < $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
        type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 15" || true
 ;;

stop)
 log_action_begin_msg "Saving current firewall configuration"
 if $IPTABLES_SAVE > $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 log_action_begin_msg "Flushing ALL firewall rules from chains!"
 if $IPTABLES -F ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 log_action_begin_msg "Deleting ALL firewall chains [Warning: ACCEPTING ALL PORT SERVICES!]"
 if $IPTABLES -X ; then
  $IPTABLES -P INPUT ACCEPT
  $IPTABLES -P FORWARD ACCEPT
  $IPTABLES -P OUTPUT ACCEPT
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

save)
 log_action_begin_msg "Saving current firewall configuration"
 if $IPTABLES_SAVE > $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

force-reload|restart)
 log_action_begin_msg "Reloading firewall configuration [Warning: POTENTIAL NETWORK INSECURITY DURING RELOAD]"
 $IPTABLES -F
 $IPTABLES -X
 if $IPTABLES_RESTORE < $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

*)
 echo "Usage: /etc/init.d/iptables {start|stop|save|restart|force-reload}"
 exit 1
 ;;
esac

exit 0
This script is part of this tutorial, all the commands to configure the firewall must be inserted, according to the script above, into /etc/iptables.conf file. This script must be inserted into a file called iptables in /etc/init.d and make it executable using

chmod+x *iptables*

and add the service to runlevels using

update-rc.d iptables defaults

You can add new rules from shell, these rules will be immediatly active and will be added to /etc/iptables.conf when service stops(it means them will be saved for sure when system shutdown).
Read More

Thứ Tư, 11 tháng 11, 2015

CentOS / Xampp how to install mod_ruid2

CentOS / Xampp how to install mod_ruid2

1. First install its dependencies:
yum install libcap libcap-devel -y
2. Download lastest version of mod_ruid2 and unpack it
wget http://sourceforge.net/projects/mod-ruid/files/latest/download
tar xvjf mod_ruid2-0.9.8.tar.bz2
cd mod_ruid2-0.9.8
/opt/lampp/bin/apxs -a -i -l cap -c mod_ruid2.c

If it installed correctly, it should say it added a line to the httpd.conf. You can easily check if it's indeed there by the following command.
grep mod_ruid2 /opt/lampp/etc/httpd.conf

it should output something similar as

LoadModule ruid2_module       modules/mod_ruid2.so
3. Configure virtual host
vi /opt/lampp/etc/extra/httpd-vhosts.conf

<VirtualHost *:80>
...
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid 10tut 10tut
    </IfModule>
</VirtualHost>

Read More

CentOS / Xampp Install PHP 5.x FCGID

CentOS / Xampp Install PHP 5.x FCGID

1. Download lastest version from apache.org and unpack.
2. Entering the extracted folder and change the file configure.aspx:
//original
if test "$APXS" = ""; then
  APXS=`which apxs 2>/dev/null`
fi;

//changed
if test "$APXS" = ""; then
  APXS=`which /opt/lampp/bin/apxs 2>/dev/null`
fi;

3. Open Terminal, stop Xampp server, navigate to the extracted folder and run the commands:
./configure.apxs
sudo make
sudo make install
4. Open file lampp/etc/extra/httpd-vhosts.conf and submit FCGID setting:
    <IfModule fcgid_module>
    FcgidInitialEnv PHPRC "/opt/lampp/etc/"
    FcgidInitialEnv SystemRoot "/"
    # FcgidInitialEnv SystemDrive "C:"
    FcgidInitialEnv TEMP "/opt/lampp/temp"
    FcgidInitialEnv TMP "/opt/lampp/temp"
    # FcgidInitialEnv windir "C:/WINDOWS"
    FcgidIOTimeout 64
    FcgidConnectTimeout 16
    FcgidMaxRequestsPerProcess 1000
    FcgidMaxProcesses 3
    FcgidMaxRequestLen 8131072
    # Location php.ini:
    # FcgidInitialEnv PHPRC "/opt/lampp/htdocs"
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000

    <Files ~ "\.php$">
    Options Indexes FollowSymLinks ExecCGI
    AddHandler fcgid-script .php
    FcgidWrapper "/opt/lampp/bin/php-cgi-5.5.30" .php
    </Files>
    </IfModule>
5. Start Xampp server. Create a phpinfo.php file with the contents:
<?php phpinfo();?>
then retrieve the browser and search for the line "Find Server API". If you did everything right, the line looks approximately like this:

Server API     CGI/FastCGI

Read More

Setting Security for XAMPP CentOS 6

To make xampp secure do following.
1. Open terminal and login as root.
2. Then type in:
/opt/lampp/lampp security
XAMPP:  Quick security check...
XAMPP:  Your XAMPP pages are NOT secured by a password.
XAMPP: Do you want to set a password? [yes]
XAMPP:  MySQL is accessable via network.
XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes]
XAMPP:  The MySQL/phpMyAdmin user pma has no password set!!!
XAMPP: Do you want to set a password? [yes]
XAMPP:  MySQL has no root passwort set!!!
XAMPP: Do you want to set a password? [yes]
XAMPP:  The FTP password for user 'daemon' is still set to 'xampp'.
XAMPP: Do you want to change the password? [yes]
XAMPP:  Done.





Read More

Thứ Ba, 10 tháng 11, 2015

Running Vhosts Under Separate UIDs/GIDs With Apache mpm-itk on Xampp

Installing apache2-mpm-itk on xampp
# wget http://mpm-itk.sesse.net/mpm-itk-2.4.7-03.tar.gz
# tar -zxvf mpm-itk-2.4.7-03.tar.gz
# cd mpm-itk-2.4.7-03
[root@10tut mpm-itk-2.4.7-03]# ./configure  --with-apxs=/opt/lampp/bin/apxs
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for cap_init in -lcap... no
checking for --with-apxs... /opt/lampp/bin/apxs
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
[root@10tut mpm-itk-2.4.7-03]#


# make && make install
...


See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /opt/lampp/modules/mpm_itk.so

[root@10tut mpm-itk-2.4.7-03]#
# vi /opt/lampp/etc/httpd.conf
...
LoadModule mpm_itk_module modules/mpm_itk.so
Configuring apache2-mpm-itk
Open vhost configuration and add the following lines to it:
[...]
<IfModule mpm_itk_module>
AssignUserId web1_user web1group
</IfModule>
[...]

Sometime vhost folder have error 403, you need to make the public_html and the files there readable by the web server.
One way is to run chmod o+x /home/user (allow everyone to switch to the home directory) and chmod -R o+rX /home/user/public_html (make public_html and files there readable by everyone).
Read More

How to install XAMPP on CentOS/RHEL 6.5

How to install XAMPP on CentOS/RHEL 6.5

XAMPP is a open source cross platform software stack package mainly used for web server solution. XAMPP is available for Windows,MAC OSX,Solaris and Linux(WAMP, MAMP, SAMP, LAMP).
XAMPP stands for –
X = Cross Platform (Windows,MAC OSX,Solaris and Linux)
A = Apache
M = MySQL
P = PHP
P = Perl

NOTE: SELINUX is in Enforcing mode

Step 1: Download the XAMPP
yum install wget
wget https://www.apachefriends.org/xampp-files/5.5.30/xampp-linux-x64-5.5.30-0-installer.run
Step 2:  Give executable permission to downloaded XAMPP script
chmod +x xampp-linux-x64-5.5.30-0-installer.run
Step 3: Run XAMPP installer script
[root@localhost src]# ./xampp-linux-x64-5.5.30-0-installer.run
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :y

Is the selection above correct? [Y/n]: y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.

[root@localhost src]#
Step 4: Allow ALL network to access XAMPP Server
Edit the last section of file called httpd-xampp.conf. Add new line Require all granted and comment the line Require local by using # sign
vi /opt/lampp/etc/extra/httpd-xampp.conf
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    # Require local
    Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
Step 5 : Restart all services by using lampp script
Restart all the services by using below given command
/opt/lampp/lampp restart
Below given is the reference from my system
[root@localhost src]# /opt/lampp/lampp restart
Restarting XAMPP for Linux 5.5.30-0...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...ok.
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
[root@localhost src]#

Step 6: Now open the XAMPP in Web browser

Now open the web browser and type the URL or ip-address in address bar
The XAMPP dashboard will be open






Read More

Thứ Ba, 3 tháng 11, 2015

VMWare Image Clone Problem: eth0 Renamed As eth1

VMWare Image Clone Problem: eth0 Renamed As eth1

This is due to wrong or duplicate mac address. To fix this problem login to your CentOS Linux server using console and type the following commands:
# cd /etc/udev/rules.d
# cp 70-persistent-net.rules /root/
# rm 70-persistent-net.rules
# reboot
This file was automatically generated by the /lib/udev/write_net_rules program, run by the persistent-net-generator.rules rules file. Simple delete it and reboot the system to recreate the same. This should fix the problem

You need to remove the MAC address in /etc/sysconfig/network-scripts/ifcfg-eth*. To find out current MAC address, enter:
# ifconfig -a | grep eth1 | grep HWaddr | awk '{ print $5}'
# ifconfig -a | grep eth2 | grep HWaddr | awk '{ print $5}'
Update your /etc/sysconfig/network-scripts/ifcfg-eth0 with eth1 HWaddr (MAC address)
Save and close the file. Restart the network service, enter:
# service network restart


Read More

RHEL / Centos 7 Change and Set Hostname Command

RHEL / Centos 7 Change and Set Hostname Command

On a CentOS Linux 7 server you can use any one of the following tool to manage hostnames:
  1. hostnamectl command : Control the system hostname. This is recommended method.
  2. nmtui command : Control the system hostname using text user interface (TUI).
  3. nmcli command : Control the system hostname using CLI part of NetworkManager.

Method #1: hostnamectl command

Let us see how to use the hostnamectl command.
$ hostnamectl

## OR ##
$ hostnamectl status
Sample outputs:
   Static hostname: centos-7-vm
         Icon name: computer
           Chassis: n/a
        Machine ID: 663f697442a7d2c736c892230000002f
           Boot ID: c1ab056f60170cc0c9b63e1d1ea9c8fb
    Virtualization: oracle
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.1.2.el7.x86_64
      Architecture: x86_64


How do I set the host name?
The syntax is:
# hostnamectl set-hostname Your-New-Host-Name-Here
# hostnamectl set-hostname "Your New Host Name Here" --pretty
# hostnamectl set-hostname Your-New-Host-Name-Here --static
# hostnamectl set-hostname Your-New-Host-Name-Here --transient
To verify new settings, enter:
# hostnamectl status
How do I delete a particular host name?
The syntax is:
# hostnamectl set-hostname ""
# hostnamectl set-hostname "" --static
# hostnamectl set-hostname "" --pretty

Method #2: nmtui command

You can set host name using nmtui command which has text user interface for new users:
# nmtui
Use the Down arrow key > select the "Set system hostname" menu option > Press the "Ok" button
Finally, restart hostnamed service by typing the following command
# systemctl restart systemd-hostnamed
To verify new hostname, enter:
# hostnamectl status

Method #3: nmcli command

To view the host name using nmcli command:
The syntax is:
# nmcli general hostname
To set the host name using nmcli command:
The syntax is:
# nmcli general hostname 10tut
# nmcli general hostname 10tut.localdomain
Finally, restart the systemd-hostnamed service:
# systemctl restart systemd-hostnamed
check cat /etc/sysconfig/network /etc/hostname

Read More

How Do I Find My Linux Gateway / Router IP Address

How Do I Find My Linux Gateway / Router IP Address

[1] Find out Gateway / router IP address under Linux / UNIX using route command
    You need to use route command. This command can manipulates the kernel’s IP routing tables.
$ route -n
Output:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.1.1 is gateway IP address for our computer. The flag U indicates that route is up and G indicates that it is gateway. You can print gateway name, enter:

[2] Find out Gateway / router IP address under Linux / UNIX using netstat command
Open a terminal and type the following command:
# netstat -r -n
Sample outputs:
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1   0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0



Read More

Set Hostname on CentOS

Set Hostname on CentOS

Change and Set Hostname Command for RHEL / Centos 7 , refer to here

Step 1: Login to your CentOS Server

Locate the IP address of your Server and login as the root user.

ssh root@server

Step 2: Use the hostname utility

Change your hostname to a different name of your choosing. For example:

hostname 10tut.localdomain
Step 3: Edit /etc/hosts

Open the /etc/hosts file with your favorite text editor. For example:

nano /etc/hosts

Change the first line and replace your old hostname with the new one. Save the file and exit the editor.

Step 4: Edit /etc/sysconfig/network

This file also contains your hostname. Open the /etc/sysconfig/network file with your favorite text editor.

Change HOSTNAME=localhost to your desired hostname. For example: HOSTNAME=10tut.localdomain

Step 5: Check your hostname

Run the following command to check your new hostname:

hostname

The new hostname will be displayed in your ssh terminal.
Read More

Thứ Hai, 2 tháng 11, 2015

Booting into a Graphical Environment

Booting into a Graphical Environment

If you have installed the X Window System but are not seeing a graphical desktop environment once you log into your Red Hat Enterprise Linux system, you can start the X Window System graphical interface using the command startx.
Once you enter this command and press Enter, the graphical desktop environment is displayed.
 
Note, however, that this is just a one-time fix and does not change the log in process for future log ins. 

To set up your system so that you can log in at a graphical login screen, you must edit one file, /etc/inittab, by changing just one number in the runlevel section. When you are finished, reboot the computer. The next time you log in, you are presented with a graphical login prompt.
Open a shell prompt. If you are in your user account, become root by typing the su command.
Now, type gedit /etc/inittab to edit the file with gedit. The file /etc/inittab opens. Within the first screen, a section of the file which looks like the following appears:
# Default runlevel. The runlevels used by RHS are: 
#   0 - halt (Do NOT set initdefault to this) 
#   1 - Single user mode 
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking) 
#   3 - Full multiuser mode 
#   4 - unused 
#   5 - X11 
#   6 - reboot (Do NOT set initdefault to this) 
#  id:3:initdefault:
 To change from a console to a graphical login, you should change the number in the line id:3:initdefault: from a 3 to a 5.

When you are satisfied with your change, save and exit the file using the Ctrl-Q keys. A window appears and asks if you would like to save the changes. Click Save.
The next time you log in after rebooting your system, you are presented with a graphical login prompt.


 


Read More

Install Xrdp Server

Install Xrdp Server

Install Xrdp server to connect to CentOS from Windows clients with the Remote Desktop function. 
[1] Install Xrdp server and start it. 
# install from EPEL

[root@dlp ~]# yum --enablerepo=epel -y install xrdp tigervnc-server
[root@dlp ~]# /etc/rc.d/init.d/xrdp start

Starting xrdp:                       [  OK  ]
Starting xrdp-sesman:                [  OK  ]

[root@dlp ~]# chkconfig xrdp on 
[2] Connect from Windows clients. For example on Windows 7, input "mstsc" to start the remote desktop function. 
[3] Input the hostname or IP address you'd like to connect and push the "Connect" button.
[4] Answer with "Yes". 
[5] Input a user which is in CentOS to authenticate.
[6] Just connected. If failed to login at first time (sometimes happens at first login), retry to login again.
Read More

How to Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x

How to Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x

What is EPEL

EPEL (Extra Packages for Enterprise Linux) is open source and free community based repository project from Fedora team which provides 100% high quality add-on software packages for Linux distribution including RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux.

Why we use EPEL repository? 

  1. Provides lots of open source packages to install via Yum.
  2. Epel repo is 100% open source and free to use.
  3. It does not provide any core duplicate packages and no compatibility issues.
  4. All epel packages are maintained by Fedora repo

How To Enable EPEL Repository in RHEL/CentOS 7/6/5?

First, you need to download the file using Wget and then install it using RPM on your system to enable the EPEL repository. Use below links based on your Linux OS versions. (Make sure you must be root user).

RHEL/CentOS 7 64 Bit

## RHEL/CentOS 7 64-Bit ##
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -ivh epel-release-7-5.noarch.rpm

RHEL/CentOS 6 32-64 Bit

## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

RHEL/CentOS 5 32-64 Bit

## RHEL/CentOS 5 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

## RHEL/CentOS 5 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

RHEL/CentOS 4 32-64 Bit

## RHEL/CentOS 4 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/4/i386/epel-release-4-10.noarch.rpm
# rpm -ivh epel-release-4-10.noarch.rpm

## RHEL/CentOS 4 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/4/x86_64/epel-release-4-10.noarch.rpm
# rpm -ivh epel-release-4-10.noarch.rpm

How Do I Use EPEL Repo?

You need to use YUM command for searching and installing packages. For example we search for Zabbix package using epel repo, lets see it is available or not under epel.
# yum --enablerepo=epel info zabbix
Let’s install Zabbix package using epel repo option –enablerepo=epel switch.
# yum --enablerepo=epel install zabbix
From: tecmint[.]com

 



Read More