Sunday, 4 March 2018

commands of mariadb database in linux

To install maria db
[root@localhost Desktop]# yum install mariadb* -y

To start and enable mariadb
[root@localhost Desktop]# systemctl enable mariadb; systemctl start mariadb

[root@localhost Desktop]# mysql_secure_installation

To check socket number of  mariadb 
[root@localhost Desktop]# ss –tulpn | grep mysql

To enable or disable mariadb in network (0=enable, 1=disable)
[root@localhost Desktop]# vi /etc/my.cnf
[mysqld]
Skip-networking=1
:wq

[root@localhost Desktop]# systemctl start mariadb

To login on mariadb
[root@localhost Desktop]# mysql –u root –p redhat 

To check databases in mariadb
Show databases; 

To open database
Use mysql;

To create new database
Create database testing; 

To check tables in database
Show tables;

To create table in database
Create table abc (user_name varchar(20),mod integer(10)); 
                      or
Create table abc (
Name varchar(20),
Name1 integer(5),
Name2 integer(5),
Primary key (name2));

To insert values in table
Insert into abc values (‘kuldeep’,1234567890);

To check details of table
Describe abc

To check the values of table
Select * from abc

To check the specific values of specific column in table 
Select * from abc where amp=’kuldeep'

To add or remove column in table 
Alter table abc add newcolumn varchar(5) notnull;

Alter table abc drop newcolumn; 

To rename column
Alter table abc change column_name new_name varchar(30);

To modify column property
Alter table abc modify column_name varchar(50);

To rename table name
Rename table old_name to new_name;

To create user 
Create user user1@localhost identified by ‘password’;

To delete user 
Drop user user1@localhost; 

To check users
Select host,user,password from user1;

To set privilege for the user 
Grant select,update,insert,drop on databasename.tablename to user1@hostname;

To remove privilege from the user
Revoke select,drop on databasename.tablename form user1@hostname;

To give all privilege
Grant all on databasename.* to user1@hostname; 

To change password for user 
Set password for user1 = password(‘123456’);

To take backup of mariadb database
Mysqldump –u –p databasename > backupfile.dump 

To restore mariadb database
Mysql –u –p databasename < backupfile.dump

To bind the range through we can connect to database remotely
[root@localhost Desktop]#vi /etc/my.cnf 
[mysql]
Bind-address=0.0.0.0 
:wq

[root@localhost Desktop]#mysql –u root –p

Grant all privillages on database.* to ducat@’%’ identifiedby ‘1234’

To login on database server remotely
[root@localhost Desktop]#mysql –u u1 –p databasename –h 15.0.0.1 



Friday, 16 February 2018

basic commands of router

To change user mode to privilege mode
Router> en or enable

To change enable mode to configuration mode
Router# conf t or configure terminal

To change configuration mode to interface mode
Router(config)# int f0/0 or interface fastethernet 0/0
Router(config-if)# exit
Router(config)# 
            Or
Router(config-if)#end

To change configuration mode to line interactive mode
Router(config)#line c 0

To check the running configuration of router (RAM)
Router# sh run or show running-config

To check the saved configuration of router (NVRAM)
Router#sh start or show startup-config

To check flash
Router#sh flash

To check interface status of router
Router#sh ip int brief

To check date & time of router
Router#sh clock

To set date & time of router
Router#clock set 10:21:00 Jan 3 2014

To check the hardware, software versions & router run time
Router#sh ver

To check login details
Router#sh users or sh line

To check router routing table
Router#sh ip route

To set hostname on router
Router#conf t
Router(config)#hostname R1

To remove hostname
R1(config)#no hostname

To run enable mode command on configuration mode
Router(config)#do sh ip int brief

To set login message on router
Router(config)#banner motd  "welcome to cisco world"

To set time zone of router
Router(config)#clock timezone GMT 23
Router(config)#exit

To save configuration
Router#write
            Or
Router#copy run start


Saturday, 21 October 2017

Basic Linux Commands


To check server uptime
[root@ducat Desktop]#uptime
To check which users has logged in on you server and there terminals
[root@ducat Desktop]#who
           Or
[root@ducat Desktop]#w
To check login details of the users
[root@ducat Desktop]#lastlog 
To check the linux operating system
[root@ducat Desktop]#cat /etc/redhat-release
To check the kernel of operating system
[root@ducat Desktop]#uname
                     uname –s    (only for kernel name)
                     uname –m    (machine architecture)
                                                  uname –a    (for complete details)
                     uname –n    (for computer name)
                     uname –v    (kernel version)
                                                  uname –r    (kernel release)
                     uname –i
                     uname –o    (OS name)
To check computer name
[root@ducat Desktop]#hostname
      Or
[root@ducat Desktop]#hostnamectl    (only for rhel 7 or centos 7)
To change computer name
[root@ducat Desktop]#hostnamectl set-hostname “redhatserver”
To check date and time of system
[root@ducat Desktop]#date
                  Or
[root@ducat Desktop]#timedatectl    (only for rhel7 or centos 7)
To change date and time of system
[root@ducat Desktop]#date 020114252014
                  Or
[root@ducat Desktop]#timedatectl set-time “2017-07-18 10:32:00”
To change timezone
[root@ducat Desktop]#timedatectl set-timezone “Asia/Kolkata”
To check available timezone
[root@ducat Desktop]#timedatectl list-timezones
To check the calendar of current month
[root@ducat Desktop]#cal
                        cal -3      (last, current and next month)
                        cal 2014    (year)
                        cal 5 2014  (specific month of the year)
To print hardware details
[root@ducat Desktop]#lspci
To print cpu details
[root@ducat Desktop]#lscpu
To check the directory structure
[root@ducat Desktop]#dir
      Or
[root@ducat Desktop]#ls
[root@ducat Desktop]#ls –l or ll (for complete details)
[root@ducat Desktop]#ls –lh   (size in human readable formate)
[root@ducat Desktop]#ls –la   (print hiden files and folders)
To check the working directory
[root@ducat Desktop]#pwd
To create a directory
[root@ducat Desktop]#mkdir
To create directory tree
[root@ducat Desktop]#mkdir –p /test/{a/{ab,ab1,ab2},b,c}
To change working directory
[root@ducat Desktop]#cd directory path
                     cd    (switch into home directory)
                                                  cd ..       (Execute parent directory)
To remove directour
[root@ducat Desktop]#rmdir directory name
To create empty file
[root@ducat Desktop]#touch file name
To check the contents of file
[root@ducat Desktop]#cat file name                     
To rename file
[root@ducat Desktop]#mv koko.txt koko1.txt
To copy file
[root@ducat Desktop]#cp koko1.txt /kuldeep/1/a
To show the directory tree
[root@ducat Desktop]#tree /kuldeep/
To move file
[root@ducat Desktop]#mv koko1.txt /kuldeep/2
To delete directory
[root@ducat Desktop]#rm -rf /kuldeep1?
To delete all directories starts with kul keyword
[root@ducat Desktop]#rm -rf /kul*
To show the history
[root@ducat Desktop]#history
To print last number of commands
[root@ducat Desktop]#history 5
To check the login user name
[root@ducat Desktop]#whoami


how to set time for internet use

this will allow internet access for a particular time interval. R4(config)#int f0/0 R4(config-if)#ip nat inside R4(config-...