Thursday, 29 November 2012

Tutorial on UML

coming soon...

INTERVIEW QUESTIONS

coming soon...

MySql


MYSQL QUERIES


1.  root@host# mysql -u root -p password;
2.  Enter password:*******
3.  mysql> use TUTORIALS;
4.  Database changed
5.  DELETE FROM table_name [WHERE Clause]
6.  Update table_name set column_name=value where condition
7.  Alter table table_name constraint PK PRIMARY KEY (column_name)
8.  Alter table table_name constraint FK FOREIGN KEY(COLUMN_NAME) refrences table_name(columns_name)
9.  Show databases;
10.   Show tables;
11.   Insert into table_name values(data_value according to column_type)
12.  Renaming a Table
13.  mysql> ALTER TABLE users RENAME public;
14.  Changing a columns datatype
15.  mysql> ALTER TABLE public MODIFY name CHAR(150);
16.  Renaming a Table and Changing its datatype at once
17.  mysql> ALTER table users CHANGE
-> email emailaddy CHAR (100);
18.  Adding a Column
19.  mysql> ALTER TABLE public ADD time TIMESTAMP;
20.  Remove a Column
21.  mysql> ALTER TABLE public DROP COLUMN time;
22.  SELECT c.contentid, c.contenttext, u.name
FROM content c, users u
WHERE c.contentid = $cntntid
AND c.userid = u.userid
23.   update user set password=PASSWORD("NEWPASSWORD") where User='vivek';
24.   mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
25.       ->                   WHERE User='root';
26.   mysql> FLUSH PRIVILEGES;
27.    
28.  BACKUP

C:\Documents and Settings\jagdeep.singh>mysqldump -u root -pnvish test>"c:\test.sql"
COMMAND  FOR LOGIN IN LINUX:  mysql -u root -p
RUN SQL SCRIPT ON LINUX: \. /soft/config/data.sql
\. /soft/2_Dec_2011/downloaded.sql [ \. Sql file path ][ source  Sql file path]
MYSQL ON LINUX
* To start mysql server:             
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
 /etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start
# service mysqld stop
# service mysqld restart

LIMIT and OFFSET SQL Pagination

Both MySQL and PostgreSQL support a really cool feature called OFFSET that is usually used with a LIMIT clause.
The LIMIT clause is used to limit the number of results returned in a SQL statement. So if you have 1000 rows in a table, but only want to return the first 10, you would do something like this:
SELECT column FROM table LIMIT 10
This is similar to the TOP clause on Microsoft SQL Server. However the LIMIT clause always goes at the end of the query on MySQL, and PostgreSQL.
Now suppose you wanted to show results 11-20. With the OFFSET keyword its just as easy, the following query will do:
SELECT column FROM table LIMIT 10 OFFSET 10
This makes it easy to code multi page results or pagination with SQL. Often the approach used is to SELECT all the records, and then filter through them on the application server tier, rather than directly on the database. As you would imagine doing this on the database yields much better performance.
I have known that PostgreSQL supports the OFFSET keyword for quite some time, and for some reason I always thought it was not supported by MySQL. Well it turns out that it is supported now.

 

Return Random Records in MySQL

SELECT product_id, title, description
FROM products
WHERE active = 1
AND stock > 0
ORDER BY RAND()
LIMIT 4


UPDATE FOR DATE CASTING
SELECT CAST(Datetimefield AS DATE) as DateField, SUM(intfield) as SumField
FROM MyTable
GROUP BY CAST(Datetimefield AS DATE)
http://www.yolinux.com/TUTORIALS/LinuxTutorialMySQL.html
http://theos.in/desktop-linux/tip-that-matters/how-do-i-restart-mysql-server/
http://www.petefreitag.com/item/451.cfm

Reset Root Password
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;



Store Procedure:-

DELIMITER $$

USE `jagdeep_live`$$

DROP PROCEDURE IF EXISTS `procedureTest`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `procedureTest`(IN productId VARCHAR(20))
BEGIN
 DECLARE profit DECIMAL(18,2) default 0;
  DECLARE mrp DECIMAL(18,2) default 0;
  DECLARE sale DECIMAL(18,2) default 0;
  DECLARE b1 DECIMAL(18,2) DEFAULT 0;
  DECLARE b2 DECIMAL(18,2) DEFAULT 0;
  declare mrpCursor
   CURSOR FOR SELECT MAX(CASE WHEN pp.product_price_Type_id='LIST_PRICE' THEN pp.price END) AS "pMrp",   MAX(CASE WHEN pp.product_price_Type_id='DEFAULT_PRICE' THEN pp.price END) AS "pSale" 
    FROM product_price pp where (pp.product_id = convert(productId using latin1) collate latin1_general_ci ) GROUP BY pp.product_id;
   OPEN mrpCursor;
   FETCH mrpCursor INTO mrp,sale;
    set b1=(+mrp)-(+sale);
    set b2=(+b1)/(+mrp);
    SET profit :=(+b2)*100;
  select ROUND((+b2)*100,2);
END$$

DELIMITER ;

CALL procedureTest('JSDHJKHJH67687');



MySQL Config Settings:-
[mysqld]
lower-case-table-names=1
datadir=/var/lib/mysql/
# symbolic-links=0
#max-connections=10000
server-id=1
#log-bin=/var/log/mysqllogs/mysql-bin.log
#log-bin-index=/var/log/mysqllogs/mysql-bin.index
expire_logs_days=10
binlog_format=MIXED
key_buffer_size = 2147483648
max_allowed_packet=640M
table_cache=2400
max_connections=256
table_definition_cache=2400
max_heap_table_size=512M
tmp_table_size=512M
join_buffer_size=5M
query_cache_type=1
query_cache_size =128M
query_cache_limit=64M
expire_logs_days=10
open_files_limit=30000
innodb_lock_wait_timeout=300

Linux For JAVA




Q. Set JAVA_HOME and PATH variables for every user in Linux system?
A. ~/.bash_profile is a startup script which generally runs once. This particular file is used for commands which run when the normal user logs in. Common uses for .bash_profile are to set environment variables such as PATH, JAVA_HOME, to create aliases for shell commands, and to set the default permissions for newly created files.
Set JAVA_HOME / PATH for single user
Login to your account and open .bash_profile file
$ vi ~/.bash_profile
Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. If your path is set to /usr/java/jdk1.7.0_07/bin/java, set it as follows:
export JAVA_HOME=/usr/java/jdk1.7.0_07/bin/java
Set PATH as follows:
export PATH=$PATH:/usr/java/jdk1.7.0_07/bin
Save and close the file. Just logout and login back to see new changes:
$ echo $JAVA_HOME
$ echo $PATH
Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java
Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.
Set JAVA_HOME / PATH for all user
You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:
export PATH=$PATH:/usr/java/jdk1.7.0_07/bin
export PATH=$PATH:/usr/java/jdk1.7.0_07/bin

Save and close the file.
@For update changes immediately use following command:-
  # source ~/.bash_profile
  # source /etc/profile
  # . /etc/profile

UPDATE:-


update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.7.0_11/bin/java" 2
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.7.0_11/bin/javac" 2
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/jdk1.7.0_11/bin/javaws" 2
sudo update-alternatives --config java

JAGDEEP_CONFIG="/soft/config/JAGDEEP_config.properties"
export JAGDEEP_CONFIG

ANT_INSTALL:-

Firstly download ant package from Apache site.
http://ant.apache.org/antlibs/bindownload.cgi

After downloading the ant package extract the package and follow below metioned steps:-

How to set Environment variable in linux
Create a file with name of ant_file.sh  in directory (i.e.  /etc/profile.d/ )

vi /etc/profile.d/ant_file.sh
Add the following contents:

#!/bin/bash
ANT_HOME=/opt/ant
PATH=$ANT_HOME/bin:$PATH
export PATH ANT_HOME
export CLASSPATH=.

Save and close the file.  (:wq!)

#> chmod +x /etc/profile.d/ant_file.sh
Set environment variables permanently by running the following command:

#> source /etc/profile.d/ant_file.sh

Now, check the ant install with ant version using command:

#> ant -version

DB Commands

For MySQL: -
  >  /etc/init.d/mysqld start
  >  /etc/init.d/mysqld stop
  >   /etc/init.d/mysqld restart
 GRANT ALL PRIVILEGES  ON *.* TO root@'%' IDENTIFIED BY 'test';
 flush privileges;

If you are using mysql on Debian / Ubuntu Linux then use following command:
  > /etc/init.d/mysql start
  > /etc/init.d/mysql stop
  > /etc/init.d/mysql restart
  > /etc/init.d/mysqld start
> mysql -h localhost -u root -pyour_password


For ORACLE:-

You can connect using either “/ as sysdba” or an oracle account that has DBA privilege.
 $ sqlplus '/ as sysdba'

Start Oracle server in UNIX
 $ su - oracle

 2. Connect to oracle sysdba
 Make sure ORACLE_SID and ORACLE_HOME are set properly as shown below.
 $ env | grep ORA
 ORACLE_SID=DEVDB
 ORACLE_HOME=/u01/app/oracle/product/10.2.0

ORACLE_HOME_LISTNER=$ORACLE_HOME
Now use lsnrctl command to start service (usually located at /home/oracle/oracle/product/10.2.0/db_1/bin directory):
 $ lsnrctl start
Next start database:
 $ dbstart
 $ dbstart $ORACLE_HOME
 $ sysadmin as sysdba
 $ sqlplus / as sysdba
 $ startup

3. Start Oracle Database

The default SPFILE (server parameter file) is located under $ORACLE_HOME/dbs. Oracle will use this SPFILE during startup, if you don’t specify PFILE.

Oracle will look for the parameter file in the following order under $ORACLE_HOME/dbs. If any one of them exist, it will use that particular parameter file.

1.spfile$ORACLE_SID.ora
2.spfile.ora
3.init$ORACLE_SID.ora

Type “startup” at the SQL command prompt to startup the database as shown below.
SQL> startup
ORACLE instance started.

Total System Global Area  812529152 bytes
Fixed Size                  2264280 bytes
Variable Size             960781800 bytes
Database Buffers           54654432 bytes
Redo Buffers                3498640 bytes
Database mounted.
Database opened.
SQL>
If you want to startup Oracle with PFILE, pass it as a parameter as shown below.

SQL> STARTUP PFILE=/u01/app/oracle/product/10.2.0/dbs/init.ora

How To Shutdown Oracle Database : -


To stop Oracle servuice type following two commands:
 $ lsnrctl stop
 $ dbshut
 $ shutdown or shutdown immediate
 $ shut immediate

Following three methods are available to shutdown the oracle database:

1.Normal Shutdown
2.Shutdown Immediate
3.Shutdown Abort

1. Normal Shutdown
During normal shutdown, before the oracle database is shut down, oracle will wait for all active users to disconnect their sessions. As the parameter name (normal) suggest, use this option to shutdown the database under normal conditions.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
2. Shutdown Immediate
During immediate shutdown, before the oracle database is shut down, oracle will rollback active transaction and disconnect all active users. Use this option when there is a problem with your database and you don’t have enough time to request users to log-off.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
3. Shutdown Abort
During shutdown abort, before the oracle database is shutdown, all user sessions will be terminated immediately. Uncomitted transactions will not be rolled back. Use this option only during emergency situations when the “shutdown” and “shutdown immediate” doesn’t work.
$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Jan 18 11:11:33 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to an idle instance.

SQL> shutdown abort
ORACLE instance shut down.
SQL>


http://www.thegeekstuff.com/2009/05/oracle-lsnrctl-listener-shutdown-and-startup-procedures/
Oracle:--> http://www.cyberciti.biz/faq/linux-start-oracle-as-a-service/
http://www.cyberciti.biz/tips/linux-iptables-examples.html
http://www.ducea.com/2006/05/15/linux-tips-take-control-of-your-bash_history/
https://sites.google.com/site/viragsharma/1testtop


Start Services: -
# service mysqld start
# service mysqld stop
# service mysqld restart

Apache Command:

/etc/httpd/conf/httpd.conf
# service httpd status (start|stop|restart)

Weblogic Startup commands:

 ulimit -n 9999
 cd /disk2/weblogic/user_projects/domains/jsddev/bin
 ps -ef | grep weblogic
 # kill -9 processId(root process id)
 nohup ./startWeblogic.sh &
 tail -f nohup.out



Samba :-
 # /etc/samba/smb.conf
 /etc/rc.d/init.d/smb status (stop|start|restart)


Vi/vim editor:-

show line number in vi editor
example :-
(1) vi jsd.txt
(2) press Ecp & type ':'
(3) type 'set number' or 'set nu'






CHANGE OWN OF FILE OR FOLDER
#chown -R username file/folder
Note: –
#drwxr-xr-x. 2 jagdeep root     4096 Apr  7 09:45 contents_dir
#-rw-r--r--. 1 jagdeep root     9909 Apr  7 09:45 test.html
here red mark 'd' is denoted to directories
here red mark '-' is denoted to file
and 'l' or 'I' is denoted to link
-rwxr--r--
0123456789
Symbol in the position 0 ("-")is the type of the file. It is either "d" if the item is a directory, or "l" if it is a link, or "-" if the item is a regular file.
Symbols in positions 1 to 3 ("rwx") are permissions for the owner of the file.
Symbols in positions 4 to 6 ("r--") are permissions for the group.
Symbols in positions 7 to 9 ("r--") are permissions for others.
r Read access is allowed
w Write access is allowed
x Execute access is allowed
- Replaces "r", "w" or "x" if according access type is denied
http://www.tuxfiles.org/linuxhelp/fileowner.html
< chown - change the owner of a file >
You can change the owner and group of a file or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file.
Set the file's owner:
$ chown username somefile
After giving this command, the new owner of a file called somefile will be the user username. The file's group owner will not change. Instead of a user name, you can also give the user's numeric ID here if you want.
You can also set the file's group at the same time. If the user name is followed by a colon and a group name, the file's group will be changed as well.
$ chown username:usergroup somefile
After giving this command, somefile's new owner would be user username and the group usergroup.
You can set the owner of a directory exactly the same way you set the owner of a file:
$ chown username somedir
Note that after giving this command, only the owner of the directory will change. The owner of the files inside of the directory won't change.
In order to set the ownership of a directory and all the files in that directory, you'll need the -R option:
$ chown -R username somedir
Here, R stands for recursive because this command will recursively change the ownership of directories and their contents. After issuing this example command, the user username will be the owner of the directory somedir, as well as every file in that directory.
Tell what happens:
$ chown -v username somefile
changed ownership of 'somefile' to username
Here, v stands for verbose. If you use the -v option, chown will list what it did (or didn't do) to the file.
The verbose mode is especially useful if you change the ownership of several files at once. For example, this could happen when you do it recursively:
$ chown -Rv username somedir
changed ownership of 'somedir/' to username
changed ownership of 'somedir/boringfile' to username
changed ownership of 'somedir/somefile' to username
As you can see, chown nicely reports to you what it did to each file.
http://www.zzee.com/solutions/linux-permissions.www


================ADD USER IN LINUX:=====================
# useradd jagdeep
#passwd jagdeep
### cahnge user directories ---
sudo nano /etc/passwd
Q. By default user is added to /home directory. I'd like to add user to /iscsi/home/${user} directory instead of default /home. How do I force useradd to add user to /iscsi/home under CentOS / RHEL / Fedora Linux?

A. Default values for account creation defined in /etc/default/useradd file under CentOS / RHEL / Fedora / Debian / Ubuntu and other Linux distros. Simply open this file using a text editor:
# vi /etc/default/useradd
The default home directory defined by HOME variable, find line that read as follows:
HOME=/home
Replace with:
HOME=/iscsi/user
Save and close the file. Now you can add user using regular useradd command:
# useradd jagdeep
# passwd jagdeep
Verify user information:
# finger jagdeep
Output:
Login: jagdeep                           Name: Jagdeep Singh
Directory: /iscsi/user/jagdeep                Shell: /bin/bash
Last login Thu Sep 13 07:58 2007 (IST) on pts/1 from 10.16.15.2
No mail.
No Plan.

Linux Add User To Group
(http://linuxconfig.org/linux-add-user-to-group )
/etc/group file contains all groups available on the Linux systems. You can read all groups available with cat /etc/group command. To find out into which linux group you belong to you can use a following command:
groups
another way to access your personal group information is with id command:
id
id command will return group names you belong to as well as group numbers. to add a user to a group on your linux systems type ( only as a root ):
# usermod -G group-name user-name
Previous command will add user-name user to a group group-name. If the group does not exists you will get a following error:
usermod: unknown group group-name
In this case you can create a new group with ( only as a root ):
# groupadd group-name
There is also another way to add user to a group manually by editing /etc/group file, but this is not recommended.
=========ANOTHER WAY TO ADD USER DIRECT TO GROU==========
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
How can I add a user to a group under Linux operating system?

You can use the useradd or usermod commands to add a user to a group. The useradd command creates a new user or update default new user information. The usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.
useradd Example - Add A New User To Secondary Group
You need to the useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. The syntax is as follows:
useradd -G {group-name} username
In this example, create a new user called vivek and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group
Output:
developers:x:1124:
If you do not see any output then you need to add group developers using groupadd command:
# groupadd developers
Next, add a user called vivek to group developers:
# useradd -G developers vivek
Setup password for user vivek:
# passwd vivek
Ensure that user added properly to group developers:
# id vivekOutput:
uid=1122(vivek) gid=1125(vivek) groups=1125(vivek),1124(developers)
Please note that capital G (-G) option add user to a list of supplementary groups. Each group is separated from the next by a comma, with no intervening whitespace. For example, add user jerry to groups admins, ftp, www, and developers, enter:
# useradd -G admins,ftp,www,developers jerry
useradd example - Add a new user to primary group
To add a user tony to group developers use following command:
# useradd -g developers tony
# id tony
Sample outputs:
uid=1123(tony) gid=1124(developers) groups=1124(developers)
Please note that small -g option add user to initial login group (primary group). The group name must exist. A group number must refer to an already existing group.
usermod example - Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with usermod command using -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option :
# usermod -a -G ftp tony
Change existing user tony primary group to www:
# usermod -g www tony

===========JIVE  :
/etc/init.d/jive-application stop
/etc/init.d/jive-eae-service stop
su – oracle
 reboot

Jive – Troubleshooting: -
vi jive-httpd.conf
  931  /etc/init.d/jive-httpd restart
  932  ps -ef | grep httpd
  933  ps -ef | grep jive-httpd
  934  apachectl stop
  935  iptables -L
  936  iptables -f
  937  iptables -F
  938  /etc/init.d/jive-httpd status
  939  iptables -L
  940  iptables -F
  941  /etc/init.d/jive-application statyus
  942  /etc/init.d/jive-application status
  943  /etc/init.d/jive-application status
  944  /etc/init.d/jive-httpd status
  945  /etc/init.d/jive-httpd start
  946  vi /usr/local/jive/httpd/conf/jive-httpd.conf
  947  getenforce
  948  sudo netstat -ltnp | grep ':80'
  949  sudo netstat -ltnp | grep ':98'
  950  netstat -A inet -lnp
  951  lsof -i tcp:98
  952  sudo netstat -ltnp | grep ':98'
  953  sudo netstat -ltnp | grep ':80'
  954  /etc/init.d/mysqld status
  955  /etc/init.d/jive-httpd status
  956  /etc/init.d/jive-httpd restart
  957  /usr/sbin/lsof -i | grep http
958  history
  959  history
  960  /etc/init.d/jive-application status
  961  exit
  962  iptables -L
  963  /etc/init.d/jive-httpd status
  964  /etc/init.d/jive-httpd start
  965  /etc/init.d/jive-database start
  966  tail -f /usr/local/jive/var/logs/postgres.log
  967  rm -rf /usr/local/jive/var/data/postgres-8.3/backup_label
  968  /etc/init.d/jive-database start
  969  telnet  localhost 5432
  970  /etc/init.d/jive-application start
  971  ifconfig
  972  exit
  973  ps -ef | grep java
  974  /etc/init.d/jive-httpd status
  975  /etc/init.d/jive-application status
  976  /etc/init.d/jive-application status
  977  /etc/init.d/jive-httpd status
  978  ps -ef | grep java
  979  cd /usr/local/jive
  980  ll
  981  cd tomcat/bin/
  982  ll
  983  ps -ef | grep java
  984  killall -9 jva
  985  killall -9 java
  986  killall -9 java
  987  killall -9 java
  988  ./startup.sh
  989  tail -f ../logs/catalina.out
  990  ps -ef | grep java
  991  /etc/init.d/jive-application status
  992  /etc/init.d/jive-application start
  993  /etc/init.d/jive-application status
  994  /etc/init.d/jive-httpd status
  995  ps -ef | grep java
  996  /etc/init.d/jive-eae-service status
  997  /etc/init.d/jive-eae-service start
  998  ps -ef | grep java
  999  iptables -L
 1000  history

================= RELEASE PORT======================


'lsof -w -n -i tcp:8080' or 'fuser -n tcp 8080' or 'netstat -anp|grep :8080[[:blank:]]' should show you the process ID. If there is no (init)script to use to shut down the offending service (since TCP/8080 means proxy) to kill you can by PID 'kill -9 pidnumber'.

SHOW WHAT PID IS LISTENING ON PORT LIKE 80 ON LINUX
$fuser -v 80/tcp
or
$netstat -alnp | grep ::80
or
$lsof -nPi tcp:80
TO VIEW THE PORT IN USE BY APPLICATION
$netstat -tan
$netstat -ant grep LISTEN

elinks http://www.google.com

http://www.cyberciti.biz/faq/list-the-contents-of-a-tar-or-targz-file/

Exclude Certain Files When Creating A Tarball Using Tar Command
The GNU version of the tar archiving utility has --exclude and -X options. So to exclude abc and xyz file you need to type the command as follows:
$ tar -zcvf /tmp/mybackup.tar.gz --exclude='abc' --exclude='xyz' /home/me
If you have more than 2 files use -X option to specify multiple file names. It reads list of exclude file names from a text file. For example create a file called exclude.txt:
$ vi exclude.txtAppend file names:
abc
xyz
*.bak
Save and close the file. This lists the file patterns that need to be excluded. Now type the command:
$ tar -zcvf /tmp/mybackup.tar.gz -X exclude.txt /home/me
Where,
-X file.txt :exclude files matching patterns listed in FILE file.txt


Example for Secure Copy (scp)

NAME

scp - secure copy (remote file copy program)

SYNOPSIS

scp [-pqrvBC46 ] [-ssh_config ] [-program ] [-port ] [-cipher ] [-identity_file ] [-ossh_option ] [[user@ ] host1 : file1 ] [... ] [[user@ ] host2 : file2 ]

What is Secure Copy?

scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

Examples

Copy the file "test.txt" from a remote host to the local host

    $ scp root@localhost:test.txt /usr/home

Copy the file "test.txt"  from the local host to a remote host

    $ scp test.txt root@localhost:/usr/home

Copy the directory "test" from the local host to a remote host's directory "test2"

    $ scp -r test root@localhost:/usr/home/test2

Copy the file "test.txt" from remote host "rh1.edu" to remote host "rh2.edu"

    $ scp root@localhost:/usr/home/test.txt \
    root@localhost2:/usr/home/test2

Copying the files "test.txt" and "test2.txt" from the local host to your home directory on the remote host

    $ scp test.txt test2.txt root@localhost:~

Copy the file "test.txt" from the local host to a remote host using port 8080

    $ scp -P 8080 test.txt root@localhost:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

    $ scp root@localhost:/usr/home/\{a,b,c\} .
    $ scp root@localhost:~/\{test.txt,test2.txt\} .

scp Performance

By default scp uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.
    $ scp -c blowfish some_file root@remotehost:~
It is often suggested that the -C option for compression should also be used to increase speed. The effect of compression, however, will only significantly increase speed if your connection is very slow. Otherwise it may just be adding extra burden to the CPU. An example of using blowfish and compression:
    $ scp -c blowfish -C local_file root@remotehost:~


Find Command

    $ find / -name file_name


PUTTY SETTINGS:-

putty.exe root@server_add -pw your_password
With -ssh
putty.exe -ssh root@server_add -pw your_password

Save password in putty.exe:-
Create a shortcut on desktop to putty.exe
Right-click shortcut and choose Properties
Modify the target similar to:
"C:\Users\Jagdeep\Desktop\SHORTCUTS\putty.exe" user@server_add -pw your_password
Click OK

Commands For VI editor
1. vi command for open vi editor
2. press Esc, then press colon(:) and type set nu, for show line number
3. press Esc then type line number, and press shift-G for goto line number
    Or
    press Esc, then type colon(:) with line number and press enter for goto particular line number
4. To make vi start at a particular line in a file, add +line_num to the command you use to start vi.   Replace line_num with the line number, for example: vi +36 test.txt
Command  for trouble shooting

http://www.linuxquestions.org/questions/linux-software-2/98-address-already-in-use-make_sock-could-not-bind-to-address-0-0-0-0-443-a-110753/
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch14_:_Linux_Firewalls_Using_iptables
*sudo netstat -ltnp | grep ':80'  (===========) iptable command
*netstat -A inet -lnp
 netstat -an | grep 80
 netstat -at | more
 netstat -at | grep localhost | wc -l
 netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
 getenforce
 setenforce 0

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443

I then stopped the httpd service starting at bootup to check if anything else was using the ports.

By using the netstat -A inet -lnp and lsof -i tcp:443 commands, i realised that there were no services listening on ports 80 and 443 when the httpd service was not running. Also, the lsof -i tcp:443 and lsof -i tcp:80 commands returned nothing.

I have tried starting the apache and httpd services, but both return the same error message.

It seems very strange as there are no other processes using posts 80 or 443 therefore, it is confilicting with itself?!

HOW CHECK MEMORY:-
TOP command provide dynamic view of current linux system
# top
# less /proc/meminfo
# cat /proc/meminfo
# free -m
# free -g
VMSTAT: display memory statistics including additional information about processes, paging, block IO, traps, and cpu activity.
# vmstat -s
#which java
#which locate
HOW CHECK LINUX VERSION:-
#cat /etc/*-release
#uname -a
#uname -mrs
@ check kernel version and gcc version "
#/cat /proc/version
SET SUDO:
visudo
example ALL=(ALL) ALL
User_Alias ADMINS = example
Cmnd_Alias HTTPD = /etc/init.d/httpd

ADMINS ALL = HTTPD
ADMINS ALL = NOPASSWD: HTTPD
 usermod -G root useraccount
su root
adduser YOURUSERNAME sudo

SVN INSTALLATION:

Centos Linux

# yum install subversion
# yum install mod_dav_svn

Debian Linux

# apt-get install subversion
# apt-get install libapache2-svn

Fedora Linux

Fedora Project (maintained by Joe Orton)
# yum install subversion


FreeBSD Project

# cd /usr/ports/devel/subversion
# make install

NetBSD 
# cd /usr/pkgsrc/devel/subversion
# make install clean

OpenBSD Project (client and server; svnserve is part of the subversion package, mod_dav_svn is in the separate ap2-subversion package)

# pkg_add subversion
# pkg_add ap2-subversion

Red Hat (client and server)

# yum install subversion
# yum install mod_dav_svn


SUSE Linux

# zypper install subversion
# zypper install subversion-server


Ubuntu Linux

# apt-get install subversion
# apt-get install libapache2-svn

Process checking command

ps -ef | grep sendmail|wc -l
ps -ef |wc -l