How to change the linux hostname?


# hostname
test.com

# hostname server.com

# hostname
server.com

# vi /etc/hostname
server.com

Now restart and see the changes.

How to change MySql root password?

For every database, you should set the root or sa passwords to something other than the default, unless you want to get hacked. For mysql, the system administrator user is called root. You will use the mysqladmin utility from a command line to set the new password.

Syntax:

# mysqladmin -u root password “new_password”

# mysqladmin -u root -h host_name password “new_password”

Example:

# mysqladmin -u root password Pa55w0rD

# mysqladmin -u root -h localhost password linuxgEEks

You need to restart the database server after this change

# /etc/init.d/mysql restart

How To Backup MySQL Database to a file?

Backing up your database is a very important system administration task, and should generally be run from a cron job at scheduled intervals. We will use the mysqldump utility included with mysql to dump the contents of the database to a text file that can be easily re-imported.

Syntax:

# mysqldump -h localhost -u root -pmypassword database_name > dumpfile_name.sql

Example:

# mysqldump -h localhost -u root -pPa55w0rD database110 > backup_file.sql

This will give you a text file containing all the commands required to re-create the database.

How To Set SSH Login Message?

To set ssh login message, its very easy and interesting.
# vi /etc/motd
write the message of your own

######### Welcome to the SSH World #########
### This is the Email Server, please exit properly ###
########################################

Save and Quit

// To check quit the ssh terminal and re-login...


######### Welcome to the SSH World #########
### This is the Email Server, please exit properly ###
########################################

Thats all, Enjoy!!!!!

nmap in details

nmap is a tool to check the status of ports in any machine

Example1 : To scan a particular system for open ports
#nmap hostname

Example2 : Scanning for a single port on a machine
#nmap –p 22 hostname
–p indicates port.

Example3 : For scanning only ports
#nmap –F hostname

-F is for fast scan and this will not do any other scanning like IP address, hostname, operating system, and uptime etc.

Example4 : Scanning only TCP ports
#nmap –sT hostname
-s is for scanning and T is for only scanning of TCP ports

Example5 : Scanning only UDP ports
#nmap –sU hostname
-U indicates UDP port scanning

Exmaple6 : Scan for ports and get the version of different services running on that machine
#nmap –sV hostname
-V indicates version of each network service running on that host

Example7 : Check which protocol is supported by the remote machine
#nmap –sO hostname

Example8 : Scan a system for operating system and uptime details
# nmap -O hostname
-O is for operating system scan along with default port scan

Example9 : Scan a network
#nmap networkID/subnetmask
For the above command you can try in this way
#nmap x.x.x.x/24