Saturday, June 6, 2015

my blogs redirect to http://linuxoperatingsystem.info/

Leave a Comment

http://huuphang.blogspot.com/ my blogs  redirect to http://linuxoperatingsystem.info/
Thanks^_^
Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Sunday, April 12, 2015

MySQL database on Linux Tutorial

Leave a Comment

Create password root the first

# mysqladmin -u root password NEWPASSWORD

Change password user root

# mysqladmin -u root -p'oldpassword' password newpass

Create a MySQL Database

# mysql -u root -p
mysql> CREATE DATABASE myDB;

How To Create a New User and Grant Permissions in MySQL

mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
mysql> FLUSH PRIVILEGES;

How To Grant Different User Permissions

  • ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
  • CREATE- allows them to create new tables or databases
  • DROP- allows them to them to delete tables or databases
  • DELETE- allows them to delete rows from tables
  • INSERT- allows them to insert rows into tables
  • SELECT- allows them to use the Select command to read through databases
  • UPDATE- allow them to update table rows
  • GRANT OPTION- allows them to grant or remove other users' privileges
mysql> GRANT ALL PRIVILEGES  ON [database name].[table name] TO ‘[username]’@'localhost’; 
Note: All permission user for database name
mysql> GRANT [type of permission] UPDATE,INSERT ON [database name].[table name] TO ‘[username]’@'localhost’;

Backup and restore mysql database

# mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
For example

Backup
# mysqldump -u user01 -p123 mydb  > dumpfilename.sql
Restore
# mysql -u user01 -p123 mydb  < dumpfilename.sql

Query to determine the size of tables in a database

mysql> SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema;

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Wednesday, March 25, 2015

How to stop a background process in linux system

Leave a Comment
How to stop a background process in linux system? How many to stop a background process in linux system

For example running a background process:
# python server.py &

Method 1: use jobs command

[root@localhost project]# jobs
[1]+  Running                 python server.py &
[root@localhost project]# kill %1
[root@localhost project]# jobs
[1]+  Terminated              python server.py

Method 2: use ps command

[root@localhost project]# ps aux | grep server.py
root      1244  0.0  0.8  11068  4312 pts/0    S    16:47   0:00 python server.py
root      1246  0.0  0.1   4356   740 pts/0    S+   16:47   0:00 grep server.py
[root@localhost project]# kill -9 1244

Method 3: use fg to bring a background job back to foreground.

[root@localhost project]# jobs
[1]+  Running                 python server.py &
[root@localhost project]# fg 1
python server.py
^C
Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Wednesday, March 18, 2015

ldap server configuration in centos 6 step by step

Leave a Comment
In this articles, how to install and configuration openldap in centos 6 step by step. openldap run 2 port: 389 ( insecure ) and 636 ( secure )

What does CN, OU, DC mean?

CN = infomon Name
OU = Organizational Unit
DC = Domain infoponent

Installing and configuration openldap server on in centos 6 

Step 1: Install LDAP
# yum install openldap*
Step 2: Now generate a encrypted password for Administrator User That is "Admin"
# slappasswd
NOTE: You need to copy above generated password to text

Step 3: Edit the following file:
# vi /etc/openldap/slapd.d/"cn=config"/"olcDatabase={2}bdb.ldif"
Change
olcSuffix: dc=linuxoperatingsystem,dc=info
olcRootDN: cn=Admin,dc=linuxoperatingsystem,dc=info
olcRootPW: <paste encrypted="" here="" password="" your=""> ( copy password at step 2 )
olcTLSCertificateFile: /etc/pki/tls/certs/linuxoperatingsystem.pem
olcTLSCertificateKeyFile: /etc/pki/tls/certs/linuxoperatingsystemkey.pem
Step 4: Now specify the Monitoring privileges
# vi /etc/openldap/slapd.d/"cn=config"/"olcDatabase={1}monitor.ldif"
Chage
"cn=manager,dc=linuxoperatingsystem,dc=info" 
 to
"cn=Admin,dc=linuxoperatingsystem,dc=info"
Step 5:  Now copy the sample database file
#cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
#chown -R ldap:ldap /var/lib/ldap/
Step 6: Configure OpenLDAP to listen on SSL/TLS
# vi /etc/sysconfig/ldap
SLAPD_LDAPS=yes #(default is no)
Step 7: Now you need to create a certificate for OpenLDAP Server.
# openssl req -new -x509 -nodes -out /etc/pki/tls/certs/linuxoperatingsystem.pem -keyout /etc/pki/tls/certs/linuxoperatingsystemkey.pem -days 365
Step 8:You need to change owner and group ownership of certificate and keyfile
#chown -Rf root:ldap /etc/pki/tls/certs/linuxoperatingsystem.pem
#chown -Rf root:ldap /etc/pki/tls/certs/linuxoperatingsystemkey.pem
Step 9:  Start/Restart the service of OpenLDAP
# service slapd restart
# chkconfig slapd on
Step 10: Now you need to create base objects in OpenLDAP.

Create it manually or use migration tools to automation

I use tool to create .ldif file :
# yum install migrationtools
# cd /usr/share/migrationtools/
# ls
# vi migrate_common.ph
on the Line Number 61, change "ou=Groups"
  $NAMINGCONTEXT{'group'}             = "ou=Groups";
  on the Line Number 71, change your domain name
$DEFAULT_MAIL_DOMAIN = "linuxoperatingsystem.info";
on the line number 74, change your base name
$DEFAULT_BASE = "dc=linuxoperatingsystem,dc=info";
on the line number 90, change schema value
$EXTENDED_SCHEMA = 1;
For example: Creating 2 local users and groups and then I will migrate to LDAP
# useradd -d /home/ldapuser1 ldapuser1
# useradd -d /home/ldapuser2 ldapuser2
Now assign the password
# passwd ldapuser1
# passwd ldapuser2
Now you need to filter out these users from /etc/passwd to another file:
# getent passwd | tail -n 2 > /root/users
Now you need to filter out password information from /etc/shadow to another file:
# getent shadow | tail -n 2 > /root/passwords
Now you need to filter out user groups from /etc/group to another file:
# getent group | tail -n 2 > /root/groups
So Open the following file to change the location of password file
# vi migrate_passwd.pl
Inside this file search /etc/shadow and change it to /root/passwords and then save and exit.

Now generate a base.ldif file for your Domain, use the following:
#./migrate_base.pl > /root/base.ldif
Now generate a ldif file for users
# ./migrate_passwd.pl /root/users > /root/users.ldif
Now Generate a ldif file for groups
# ./migrate_group.pl /root/groups > /root/groups.ldif
Step 11: Now it' time to upload these ldif file to LDAP Server
# ldapadd -x -W -D "cn=Admin,dc=linuxoperatingsystem,dc=info" -f /root/base.ldif
# ldapadd -x -W -D "cn=Admin,dc=linuxoperatingsystem,dc=info" -f /root/users.ldif
# ldapadd -x -W -D "cn=Admin,dc=linuxoperatingsystem,dc=info" -f /root/groups.ldif

Enable log openldap Server

# vi /etc/rsyslog.conf
Add line following below into rsyslog.conf
# LDAP
local4.* /var/log/ldap.log
Restart Rsyslog server
# /etc/init.d/rsyslog restart

Restart openldap server

# /etc/init.d/slapd restart
Now you can use "ldapsearch" command
# ldapsearch -x -b "dc=linuxoperatingsystem,dc=info"

Test connect to Openldap server

I use JXplorer software as picture below :


Output:


Link youtube ldap server configuration in centos 6 step by step


Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Sunday, March 15, 2015

Centos grub boot missing

Leave a Comment
Redhat/Centos grub boot  missing. in order to boot from the Redhat/CentOS box with grub problems, you need to know 2 things:
  • The /boot partition
  • The root (/) partition.
Problem Redhat/centos grub boot missing not login into server.

grub boot

Step 1: find the /boot partition/

List available disks at grub prompt
grub> find (hd        -->TAB key
List available disk partition at grub prompt
grub> find (hd0,        -->TAB key
Examples of find command a grub.conf file

grub> find (hd0,0)//grub/grub.conf
   (hd0,0)
   (hd0,1)
   (hd0,2)

grub> find (hd0,0)/boot/grub/grub.conf
   Error 15: File not found

Step 2: The root (/) partition.

grub> root (hd0,0)
grub> kernel /vmlinuz-2.6.32-431.el6.i686 ro root=/dev/sda1
grub> initrd /initramfs-2.6.32-431.el6.i686.img
grub> boot
For example my system:
# fdisk -l
grub boot 02

# ls -la  /boot
grub boot 01

Redhat/Centos grub boot  missing, the linux commands above helpful you! 

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Friday, February 27, 2015

How to install ibus-unikey ubuntu 14.10

Leave a Comment
Step by step install ibus-unikey on ubuntu 14.10. solve problem Error: "Can’t connect to iBus".

Step 1: The first install "m17n engine" in Ubuntu Software Center
Step 2: Open terminal or press ctr+alt+T, type commands as below:
$ sudo apt-get update
$ sudo apt-get install ibus-unikey
$ sudo reboot

Run ibus on ubuntu 14.10

$ ibus-daemon -d

Setup ibus on ubuntu 14.10

$ ibus-setup
ibus-unikey ubuntu 14.10

Configuration ibus-unikey

when reboot lose ibus-unikey, then you startup application system as picture bellow:

Fix error ibus-unikey with skype, firefox,....

Install packages ibus-qt4
#sudo apt-get install ibus-qt4
 Add line following below /etc/X11/xinit/xinput.d/default file :
 
# /etc/X11/xinit/xinput.d/default 

#
XIM=ibus
XIM_PROGRAM=/usr/bin/ibus-daemon
XIM_ARGS="--xim"
XIM_PROGRAM_XTRA=
# Set following variable to non-zero string if program set itself as deamon
XIM_PROGRAM_SETS_ITSELF_AS_DAEMON=
#
# Define GTK and QT IM module
# They may or may not be using xim as the IM.
#
GTK_IM_MODULE=ibus
QT_IM_MODULE=ibus

#
# Define lists of packages neded for above IM to function
#
DEPENDS="ibus, ibus-gtk, ibus-gt4"

#
# Define X start up hook script to update IM environment
#
Reboot system
# reboot
Output:

Link youtube how to install ibus-unikey ubuntu 14.10


I hope will this help you

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...

Wednesday, February 25, 2015

ubuntu commands

Leave a Comment

ubuntu commands

Seach the cached list of packages the contain a command or description
$ apt-cache search nload
Search the list of installed packages
$ dpkg-query -S mount
List all the files contained in the initscripts package
$ dpkg -L initscripts
Refresh the list of cached packages
$ sudo apt-get update

  • APT: Use APT to download and install packages form online repositories.
  • dpkg: Use dpkg to work with .deb files
  • aptitude: Use aptitude at the command line for working with online repositories


To report on the total number of packages available
$ apt-cache stats
Output:
Total package names: 60926 (1,219 k)
Total package structures: 102901 (5,762 k)
  Normal packages: 71359
  Pure virtual packages: 1187
  Single virtual packages: 9068
  Mixed virtual packages: 1825
  Missing: 19462
........

Enabling More Repositories for apt
$ sudo vim /etc/apt/sources.list
In a minimal system install, adding software collections with tasksel
$ sudo tasksel

Managing software with APT

check for updates to the packages
$ sudo apt-get update
To fid packages in any available repository
$ apt-cache search [package-name]
Install package
$ sudo apt-get install [package-name]
Display information about the software
$ apt-cache show [package-name]
Check updates for all installed packages and then prompt to download and install them with this command
$ sudo apt-get upgrade
Run this command anytime to delete partially downloaded packages, or packages no longer installed
$ sudo apt-get autoclean
Remove all cached packages from /var/cache/apt/archives to free up disk space using this command
$ sudo apt-get clean
This command removes the named package and all its confiuration fies
$ sudo apt-get --purge remove [package-name]
This command does a sanity check for broken packages. This tries to fix any
$ sudo apt-get -f install
This command lists GPG keys that APT knows about
$ sudo apt-key list
Check for dependencies the packages
$ sudo apt-cache depends [package-name]
Removing packages
$ sudo apt-get remove [package-name]
Clean up packages
$ find /var/cache/apt/ -name \*.deb
$ sudo apt-get clean
Downloading packages
$ sudo apt-get download [package-name]

Managing software with dpkg

This command lists all installed packages
$ dpkg -l
This command lists all the files that have been installed from a package
$ dpkg -L [package-name]
Install a package
$ sudo dpkg -i [package-name]
Remove a package
$ sudo dpkg -r [package-name]
Remove package and configuration file
$ sudo dpkg -P [package-name]
Verifying install packages with debsums
$ debsums -a Check all files, include config files left out by default
$ debsums –e Check config files for packages only
$ debsums –c List only changed files to stdout
$ debsums –l List files that don't have md5sum info
$ debsums –s List only errors; otherwise be silent
$ debsums package List the packages you want debsums to analyze

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4
Read More...