Tuesday, October 27, 2009
Wednesday, August 26, 2009
Few MySQL Commands
#mysql -h [hostname] -u root -p
2. Create a new database
mysql> create database [database name]
3. To delete a database.
mysql> drop database [database name]
4. Display all the databases on the server
mysql> show databases;
5. Switch to database
mysql> use [database];
6. To see database's field formats.
mysql> describe [table];
7. To show all the tables in selected database.
mysql> show [tables];
8. Show all data in a table.
mysql> SELECT * FROM [table name];
9. Show the columns.
mysql> show columns from [table name];
10. Search a particular entry in table
mysql> SELECT * FROM [table name] WHERE [field name] = "???????";
eg. mysql> SELECT * FROM [user] WHERE User = "testuser" AND Host = 'localhost';
11.
Tuesday, March 31, 2009
Different ways of identifying whoe is logged on linux server
$ w
23:04:27 up 29 days, 7:51, 3 users, load average: 0.04, 0.06, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ramesh pts/0 dev-db-server 22:57 8.00s 0.05s 0.01s sshd: ramesh [priv]
jason pts/1 dev-db-server 23:01 2:53 0.01s 0.01s -bash
john pts/2 dev-db-server 23:04 0.00s 0.00s 0.00s w
$ w -h
ramesh pts/0 dev-db-server 22:57 17:43 2.52s 0.01s sshd: ramesh [priv]
jason pts/1 dev-db-server 23:01 20:28 0.01s 0.01s -bash
john pts/2 dev-db-server 23:04 0.00s 0.03s 0.00s w -h
$ w -u
23:22:06 up 29 days, 8:08, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ramesh pts/0 dev-db-server 22:57 17:47 2.52s 2.49s top
jason pts/1 dev-db-server 23:01 20:32 0.01s 0.01s -bash
john pts/2 dev-db-server 23:04 0.00s 0.03s 0.00s w -u
$ w -s
23:22:10 up 29 days, 8:08, 3 users, load average: 0.00, 0.00, 0.00
USER TTY FROM IDLE WHAT
ramesh pts/0 dev-db-server 17:51 sshd: ramesh [priv]
jason pts/1 dev-db-server 20:36 -bash
john pts/2 dev-db-server 1.00s w -s
2. Get the user name and process of logged in user using who and users command
who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.
$ who
ramesh pts/0 2009-03-28 22:57 (dev-db-server)
jason pts/1 2009-03-28 23:01 (dev-db-server)
john pts/2 2009-03-28 23:04 (dev-db-server)
To get a list of all usernames that are currently logged in, use the following:
$ who | cut -d’ ‘ -f1 | sort | uniq
john
jason
ramesh
Users Command
users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version. If the user using, ‘n’ number of terminals, the user name will shown in ‘n’ number of time in the output.
$ users
john jason ramesh
3. Get the username you are currently logged in using whoami
whoami command is used to print the loggedin user name.
$ whoami
john
whoami command gives the same output as id -un as shown below:
$ id -un
john
who am i command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.
$ who am i
john pts/2 2009-03-28 23:04 (dev-db-server)
$ who mom likes
john pts/2 2009-03-28 23:04 (dev-db-server)
Warning: Don’t try “who mom hates” command.
Also, if you do su to some other user, this command will give the information about the logged in user name details.
4. Get the user login history at any time
last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:
- User name
- Tty device number
- Login date and time
- Logout time
- Total working time
$ last jason
jason pts/0 dev-db-server Fri Mar 27 22:57 still logged in
jason pts/0 dev-db-server Fri Mar 27 22:09 - 22:54 (00:45)
jason pts/0 dev-db-server Wed Mar 25 19:58 - 22:26 (02:28)
jason pts/1 dev-db-server Mon Mar 16 20:10 - 21:44 (01:33)
jason pts/0 192.168.201.11 Fri Mar 13 08:35 - 16:46 (08:11)
jason pts/1 192.168.201.12 Thu Mar 12 09:03 - 09:19 (00:15)
jason pts/0 dev-db-server Wed Mar 11 20:11 - 20:50 (00:39
Sunday, February 8, 2009
Multiple DNS and Virtual Hosting
Three types of virtual hosts can be configured on Apache :
An IP-based virtual host looks at the IP address of the requested site and then connects the Apache configuration file to find the location of the content that serves that IP address. This method requires a separate IP address for each host installed on the Apache server. In DNS, each Web site also has its own IP address.
IP-based virtual hosts allow to run multiple Web sites on the same physical hardware. Unlike name-based hosts, however, IP-based virtual hosts generally require that additional IP addresses be assigned to the host. This doesn't necessarily need multiple physical network adapters
A name-based virtual host uses the headers sent from the requesting client to determine which content to send back to the client. This type of virtual hosting arrangement can be supported with a single IP address. In DNS, all Web sites that reside on the particular server share the same IP address.
Setting up the names in DNS is much easier than trying to rely on local hosts files. If you don't control your DNS server and just want to test virtual hosting, set up a DNS such as BIND on your Linux server. If you decide to do this, do it in a lab first so you don’t cause total network confusion by adding unknown DNS servers on the production network.
A port-based virtual host allows the server to take advantage of port redirection. With this type of virtual host, a server can be running hosts on the same IP address on ports 80, 8080, etc.
In addition to using names and IP addresses, Apache can listen for traffic on other TCP ports and serve up content to requests that come in to that port. Port-based virtual servers are often used in conjunction with load-balancing equipment. The load balancers are configured with the DNS name and the TCP port that serves the content. This TCP port matches the Apache virtual server configuration.
Advanatages / Disadvantages :
1. IP based virtual hosting requires, individual IP addresse.
2. Name based virtual hosting cannot be used with SSL
3. For SSL setup is possible only with IP based virtual hosting.
Contents taken from link :
http://articles.techrepublic.com.com/5100-10878_11-5031750.html