GoogleSearchBox

Custom Search

Friday, May 24, 2013

Frequently Used Linux Unix Commands while working with Java Web Projects

To Display the current directory path:# pwdTo List out the directories and Files under the current directory:# ls To list out vertically only:# ls -lTo list out vertically with sort by timestamp:# ls -ltTo list out vertically and files having all kind of attributes:# ls -laSet JAVA_HOME and PATH Environment variables for a single user:
Login to your account and edit .bash_profile file using vi editor as below:
# vi ~/.bash_profile

Set JAVA_HOME and PATH Environment variables for all users:
Edit the global config file located at /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile

type below in the .bash_profile or /etc/profile file towards the end of the file using the vi editor as above:

export JAVA_HOME=/usr/java/jdk1.7.0_07/
PATH=$PATH:$JAVA_HOME/bin
export PATHwhere "/usr/java/jdk1.7.0_07/" is the JDK installation path.
Save and close the file. Just logout and login back to see new changes.

To test JAVA_HOME set correctly or not:
# echo $JAVA_HOME

To verify if Java is setup correctly on your PATH or not:

# java -version

-Should return the JRE version.To verify if Java Compiler (JDK) is setup correctly on your PATH or not:
# javac -version
-Should return the version of the JDK compiler.

To View Log Files / Any files :
User head or tail command as below :
$ head -30 mylogfile.log
Is used to see first 30 lines of the file from beginning.

$ tail +30 mylogfile.log
To view records in the log file starting from line 30 till the end of the file.

$ tail -20f mylogfile.log
To view the log records on realtime on console starting from -20 records from end of file at that point and fetch the records of log file as it generates in realtime and displays on console.

To Check Which Directory our Opnessl conf is located:
$ openssl version -d

Result is something like this:

Finding a File containing a particular String.
We have to navigate to the suspected directory first or its parent directory.
It starts searching for the file containing the text from the current directory and then in its sub-directories.