Sunday, November 21, 2010

Impotant Port Numbers

To configure network services/servers, administrator must have a Knowledge of  Port numbers,. So you can  easily find out whether service/daemon is running or not. It will be very helpful when you are configuring iptables/firewall. Ex: You can block unwanted port numbers, it will reduce the risk of hack to the servers.
Here i am listing very common ports which we will use in everyday tasks.


Services                             Portnumber
FTP                                      20 and 21
SSH                                     22
TELNET                               23
SMTP                                  25
DNS                                    53
DHCP                                  67 and 68
TFTP                                   69
HTTP                                   80
NTP                                    123
POP3                                  110
IMAP                                  143
HTTPS                                443
IMAPS                                993
POP3S                                995
SWAT                                 901
SQUID                                3128
MYSQL                              3306
X-WINDOW                        6000
WEBMIN                           10000

Tuesday, November 9, 2010

Backup and Restore Mysql database

It is very important to backup databases to prevent any  loss of data. The easiest way backup the database is Mysqldump and we can restore it with mysql command...

Backup Syntax:
 #mysqldump -u [username] -p [databasename]  > dumpfilename.sql

Ex: you assume that you want to backup a database called users and with username root, then the command would be....
#mysqldump -u root -p users > users.sql
In the above example "-p" will prompt for password, and  if your mysql doesnot have any password then no need to use "-p".

Restore Syntax:
Mysqldump file can easily be restored by using the following command
#mysql -u root -p [databasename] < [mysqldumpfile.sql]

EX: #mysql -u root -p users < users.sql


























 

Sunday, October 24, 2010

List users or groups with IDs of 500 or greater

Listing all the users created by System administrator can be done with the powerful "awk" command...

#awk -F: '($3>=500)  && ($3!=65534)' /etc/passwd

Here the "awk" command will check the 3rd filed(uid) in the /etc/passwd file
and it will list uids which are equal and greater than 500. And here we are
mentioning not to list uid 65534, because this is nfs account account created
by system when we have installed nfs pakage.....


  
 

Tuesday, September 28, 2010

Check Date and Time in mysql

Sometimes we may need to check the time when we are working with mysql.
To do this login to mysql and use the following command

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2010-09-28 14:49:57 |
+---------------------+
1 row in set (0.06 sec)

How to create SVN repository

Creating SVN repository on linux machine is  easy......
1. Install the subversion
        yum install subversion ( RHEL , Fedora, Centos)
        apt-get install subversion (ubuntu,debian)

2. Install open-ssh for secure connection (If repositoy on remote system)
# yum install openssh-server openssh-client (RHEL, Fedora, Centos)
# apt-get install openssh-server openssh-client (ubuntu, debian)

3. use svnadmin command to create the repositorty.....
# svnadmin create <path to repo>
ex:  svnadmin create /var/www/repo

4. Now change the directory to /var/www/repo
# cd /var/www/repo

5. Edit the configuration file
# vi /var/www/repo/conf/svnserve.conf
uncomment the following lines
anon-access = none
auth-access = write
password-db = passwd

6.create the users
# useradd -s /sbin/nologin user1

7.set the password for user1
# passwd user1
 
8.Now edit the passwd file
# vi /var/www/repo/conf/passwd

add the following line and save the file
user1 = password
 
9. Import your Project to repository
# svn import <path of project data> <path to repo>
ex: # svn import /home/sourcecode/project1 file:///var/www/repo/project1

10.Check out the data to your system
# svn co svn+ssh://user1@192.168.1.10/var/www/repo/project1