Tag Archives: for Command

Useful Linux Commands

This documentation covers Linux commands that are useful as they pertain to Oracle Applications.

1. To change prompt to display the time:

PS1='[u@h W] t $ ‘

alias settime=’PS1=”'[u@h W] t $ ””

alias settime=”PS1='[u@h W] t $ ‘”

Modify the /etc/bashrc file as root to add alias for all terminal windows.

2. To list the free disk space on all drives:

df -h

3. To display the disk space used by a directory:

du oracle -csh

4. To display lines in files with the word ‘oracle’:

for i in `ls -a`; do grep -Hnr oracle $i; done;

-H, –with-filename

Print the filename for each match.

-n, –line-number

Prefix each line of output with the line number within its

inputfile.

-R, -r, –recursive

Read all files under each directory, recursively; this is

equivalent to the -d recurse option.

5. To create a symbolic link to another directory:

ln -s stage11i10/ stage11510

For example: [root@appslinux u1]# ln -s stage11i10/ stage11510

ln [OPTION]… TARGET… DIRECTORY

Note that this command may need to be executed as the root user.

6. To delete directories one at a time while noting the time started:

for i in `ls`; do echo –n ‘Deleting ‘ $i ‘: Started ‘ ; date ; rm -r $i /u4/oracle/; done

7. To copy directories one at a time while noting the time started:

for i in `ls`; do echo –n ‘Copying ‘ $i ‘: Started ‘ ; date ; cp -r $i /u4/oracle/; done

8. How to Set the Date:

date -s “09/03/2006 14:09:00”

This sets the date to 03-SEP-2006, time 13:17. Note: this command is executed as root. Note: format is “mm/dd/yyyy”

9. To test all zip files in a directory:

for i in `ls *.zip`; do unzip -qt $i; done;

10. To get the size of directories one at a time:

for i in `ls`; do echo -n ‘Size of ‘ $i ‘: ‘ ; du $i -sh ; done ; du -sh

11. To get the total size of a directory:

du -sh

12. To search all files with AP_ACCOUNTING_MAIN_PKG:

for i in `find . -type f`; do grep -Hin AP_ACCOUNTING_MAIN_PKG $i; done;