PeopleSoft – Redhat (RHEL5.7) – sysctl parameters

Just to drive the system administrator nuts, for some reason Redhat sysctl parameters by default are not robust enough to handle starting up even a small application server. There are several cases on My Oracle Support that explain how to set the variables but at a minimum I found this to a good starting point:

fs.file-max = 65536
kernel.msgmni = 512
kernel.msgmax = 1048576
kernel.msgmnb = 1048576
kernel.shmmni = 4096
kernel.shmmax = 33554432
kernel.sem = 250 256000 64 1024

You can add/modify these entries in the sysctl.conf file (/etc/sysctl.conf). Once they are modified you can put them into effect by issuing sysctl -p. If you want to do a change temporarily you can issue: sysctl -w parameter=value.

Converting dos to unix ascii files

There is just nothing in this world that is universal and that even includes straight up text files. When carriage returns are stored in windows they are stored as Carriage Return & Line Feed, however, in unix they are stoed as just Carriage Return.

So when you ftp a file from windows to unix sometimes you will see ^M characters at the end of each line. This is because the files has been transferred as a binary file versus an ascii file. Most ftp (sftp, ftps, etc..) programs will convert the carriage returns correctly if the file is set to transfer in ascii mode based on the operating system it is going to.

However, if by chance you end up with a “dos” based file on your unix system and you want to convert it. A quick simple trick is to use the vi editor using the the :set ff command.

Simply open the text file in the vi editor, and type
:set ff=unix

This will change the file format from dos to unix based and the carriage return problem should be solved!

Linux: Remove Files older then x days

The other night I had to cleanup a mess in a couple of directories and doing it by date seemed to be the easiest way. I found this command and it worked like a charm:

find /path/to/files* -mtime +5 -exec rm {} \;

Basically use the find command to the files in question, the -mtime function in this example will find files older then 5 days, the last part executes the remove command on file it finds.

Note: Before running this command with the remove code, just run the find part of the command to validate that the files being found are the ones you want to remove (Measure twice cut once!).

Unix SCP – Remote Copy

The SCP command in unix is extremely useful for move files/directories from one server to another. If you log into the machine you want to transfer the files to and navigate to the directory where you want the file or directory, you can issue the following command:

To move a file: scp username@remoteserver:/home/username/example .

To move a directory: scp -r username@remoteserver:/home/username/exampledirectory .

The -r flag is to move all files/directories within the example directory. username is the remote servers user name, this can be eliminated if you want to login with the same user as you are currently logged in to the local machine with. remoteserver is the server that houses the file(s)/directory(s) you want to copy, and the “.” signifies to copy to the current location.

Unix VI – search & replace reference

?When using the VI editor on most unix systems a common command you will use is the search and replace.  The % indicates that you want to search the entire file, you can also use 1,$ to indicate from line 1 to the end.  If you just say :s it will only search the current line. If you want to search from the current line to end of a file you can type :.,$s the “.” Indicates the current line. Lastly the g at the end of the command indicates “global” so all occurances will be changed.  If you omit the g it will only change the first occurrence of search_string.

 :%s/{search_string}/{replacement_string}/g

 If you are searching for a string or replace a string the has a “/” in it, you can have to prefix the “/” with a “\” it can get somewhat messy but it works!

For example

:%s/\/etc/\/opt/g

This will search the entire file for /etc and change it to /opt