Friday, April 3, 2009

All Linux Commands in One Blog...

Please note that ">xxxx>" and ">>xxx>>" represents the dynamic content, you need to replace the xxxx with your content.

**********Windows Machine Remote Access**********
rdesktop -a >IP>
full-Screen:
rdesktop -a 16 -f >IP>
full-Screen with color support:
rdesktop -a 24 -f >IP>
**********************************************

**********Disk space***************************
df -h
*********************************************

**********Disk space used***********************
du -h -s >>path>>
*********************************************

*********Partions Details************************
fdisk -l
*********************************************

**********STARTUP SCRIPTS FILES*************
/etc/rc.d/rc.local
*********************************************

********** Setting the Path***********************
echo $PATH
export PATH=$PATH:/sbin:/usr/sbin
echo $PATH
*********************************************

*************Full Details about Partition Group*******
vgdisplay
*********************************************

*****************Linux Version Details************
cat /etc/redhat-release
*********************************************

*****************Extend the memory Example******
vgdisplay
df -h
lvextend -L +50G /dev/VolGroup00/LogVol00
ext2online /dev/VolGroup00/LogVol00
df -h
vgdisplay
*********************************************

********************Deleting the partition*********
lvchange -a n /dev/VolGroup00/lvfpapp
lvremove /dev/VolGroup00/lvfapapp
********************************************

*********************Extension Of Memory Details*
lvextend -L +>>SIZE>>G >>Physical Volume path>>
eg: lvextend -L +10G /dev/VolGroup00/LogVol00
ext2online >>Physical Device path>>
eg: ext2online /dev/VolGroup00/LogVol00
********************************************

********************To see the file flow *********
tail -f/n num of Lines >>filename with path>>
********************************************

********************Open port list**************
netstat -plan
********************************************

********************To find a file in the list *******
find >>source_path>> -name >>filename>>
find >>source_path>> -iname >>filename_pattern>>
**To find files with 777 permission
find >>path>> -perm 777
**To find the files more than specified size
find / -size +1048576k
****Folders only 755 and files only 644
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
********************************************

***** mounting a windows sharing file ****************
mount.cifs //ipaddress/directory /mount_pnt -o user=mid

Example:
mount.cifs //172.22.52.214/Softwares /mnt -o user=mindtree/m1006976
****************************************************

****find content in the files***********
grep -R ">>text>>" >>path>>/*
find . -name "*.jsp" -exec grep -H "/images/" {} \;
********************************

***************Delete the file ******
rm -f >>file_name>>
rm -rf >>Directory_name>>
********************************

****Delete the file from all of the directories**
find >>source_path>> -iname ">>filename_with_pattern>>" -exec rm {} \;
eg: find /opt/IBM/WebSphere/AppServer/profiles/instanceName/installedApps/WC_instanceName_cell/WC_instanceName.ear -iname "*.jsp" -exec rm {} \;
*******************************

********To List the files******
ls -l
*OnlyDirectories
ls -l | grep "^d" (or) ls -d >>path>>
****Find the most recently modified files (e.g. useful for big log directories)
ls -ltr
*****Find files modified on date****
ls -laR / | grep "2008-01-11"
*****************************

******Secure Copy**********
scp -r >>source_files_with_path>> >>remote_user>>@>>destination_serverName>>:>>destination_path>>
scp >>source_files_with_path>> >>remote_user>>@>>destination_serverName>>:>>destination_path>>
Ex:
scp -r /home/oracle/backup/exp_21Jan2009* oracle@172.22.1.21:/home/oracle/backUpFromDev/.
**************************

*****File OwnerShip and Permissions******
chmod -R 755 >>path>>
****It will change all the permission as 755 to all the files and folders in the path
chmod 755 >>filename_with_path>>

chown -R >>user>>:>>user_group>> >>Path>>
****It will change all the ownership to all the files and folders in the path
chown >>user>>:>>user_group>> >>filename_with_Path>>
***********************************

*****USER id and group of present user***
id
**********************************

****ZIP Commands*****
create:
tar -cvf mystuff.tar mystuff/
tar -czvf mystuff.tgz mystuff/

extracting:
tar -xvf mystuff.tar
tar -xzvf mystuff.tgz
zip -r file.zip folder-name/
unzip >>filename>>.zip
*********************

****Finding process id****
ps –elf | grep >>processname>>
eg: ps -elf | grep java
**********************

****X Window accessing from linux gui****
X :1 -query >ipa addrs of other box>
**********************************

*****RPM Commands**************
To install a rpm:
rpm –ivh filename

rpm find:
rpm –qa | grep >rpmname>
********************************

****To Disable Linux Fire Wall********
/etc/init.d/iptables stop
********************************

****To user details **
cat /etc/passwd
**************************

*****NFS Enabling********
Do the following in server machine:
1> Sharing the Directory using NFS
vi /etc/exports
add the following line
/>path-to-be-shared> >ip-address-of-accessing-machine>(ro|rw)
save and exit
2> Start the NFS Service
/etc/init.d/nfs start
3> Confirmation: please run the following command
showmount -e localhost
Do the following in client machine:
1> Check the Directory shared
showmount -e >ip-address-of-shared-machine>
2> create a Directory to be mounted
mount >ip-address-of-shared-machine>:/path-shared /mount-path
3> For Unmount, please run the following command
unmount /mount-path
************************

*****Oracle linux commands******
lsnrctl start
emctl status dbconsole
sqlplus sureshusr/sureshusrs00@//mira:1522/srbolstg.instanceName.com.sg

*Export and Import*
exp userid=sureshusr/sureshusrs00@sureshdb consistent=Y statistics=NONE file=F:\sureshDB\sureshdb11Jun08.dmp log=F:\sureshDB\sureshdb11Jun08.log full=N
exp userid=sureshusr/sureshusrs00@srbolstg FILE="/home/ora10g/backup/XSTRCLSTR_stage_102008.DMP" LOG="/home/ora10g/backup/XSTRCLSTR_stage_102008.log" TABLES=('XSTRCLSTR') COMPRESS=N INDEXES=N TRIGGERS=N CONSTRAINTS=N GRANTS=N
imp sureshusr/sureshusrs00@sureshdb fromuser=sureshusr touser=sureshusr file=D:\suresh\sureshdb06Jun08.dmp log=d:\suresh\impsureshdb06Jun08.log full=n
imp sureshusr/sureshusrs00@sureshdb FILE="F:\ServerMoves\stageMove\fromStage\Oct24\XSTRCLSTR_stage_102008.DMP" LOG="F:\ServerMoves\stageMove\fromStage\Oct24\imp_XSTRCLSTR_stage_102008.log" FROMUSER=sureshusr TOUSER=sureshUSR TABLES=(XSTRCLSTR) GRANTS=N INDEXES=N CONSTRAINTS=N
***Test Server Commands
exp FILE="/home/oracle/04112008_1.DMP" LOG="/home/oracle/exp_04112008_1.log" OWNER=('sureshUSR')

Stage dump query:
exp userid=sureshusr/sureshusrs00@srbolstg FILE="/home/ora10g/19012009_1.DMP" LOG="/home/ora10g/exp_19012009_1.log" OWNER=('sureshUSR')

Dev dump query:
exp userid=sureshusr/sureshusrs00@sureshdb FILE="/home/oracle/backup/exp_21Jan2009.DMP" LOG="/home/oracle/backup/exp_21Jan2009_log.log" OWNER=('sureshUSR')


imp FILE="/home/oracle/04112008_1.DMP" LOG="/home/oracle/imp_04112008_1.log" FROMUSER=sureshUSR TOUSER=sureshUSR IGNORE=Y

Dev dump query:
imp FILE="/home/oracle/backUpFromDev/exp_21Jan2009.DMP" LOG="/home/oracle/imp_21Jan2009_log.log" FROMUSER=sureshUSR TOUSER=sureshUSR IGNORE=Y
*****************************

*******Unlock the account & Changing password******
alter user sureshusr identified by sureshusrs00 account unlock;
**********************************