From the monthly archives:

November 2007

Q. Accidentally, I had created a file called -foo. Now how do I remove a file with a name starting with ‘-’ under UNIX or Linux operating system?
A. Use standard UNIX rm command, as follows:
rm command
Use rm command to remove files or directories as follows
rm ./-foo
rm ./-filename
rm — -foo
Alternatively, you can also [...]

{ 4 comments }

Q. How do I create a temporary file securely under UNIX Bash shell?
A. There are many ways:
[a] mktemp command – make temporary unique filename
[b] $RANDOM – Use $RANDOM variable
mktemp command
From the man page:
The mktemp utility takes the given filename template and overwrites a portion of it to create a unique filename. The [...]

{ 2 comments }

Q. How do I replace a string with another string in all files? For example, ~/foo directory has 100s of text file and I’d like to find out xyz string and replace with abc. I’d like to use sed or any other tool to replace all occurrence of the word.

A.sed command is designed for this [...]

{ 8 comments }

Q. Can you explain following bash code or bash fork() bomb?
:(){ :|:& };:
A. This is a bash function. It gets called recursively (recursive function). This is most horrible code for any Unix / Linux box. It is often used by sys admin to test user processes limitations (Linux process limits can be configured via [...]

{ 18 comments }

Q. How do I reset a user’s password under any Linux distribution from command prompt?
A. To reset a user’s password, use passwd command. You have to change it to a different password.
Login as the root user
Open terminal or shell prompt
Type the following command:
# passwd username
For example, reset a tom’s password, enter:
# passwd tom
Type a [...]

{ 4 comments }

Q. How do I find out System / Server Memory Utilization under RHEL / CentOS / any other Linux distribution?
A. You need to use free command which, displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.
free command [...]

{ 2 comments }

How do I install Xcache opcode cacher for PHP 5 under RHEL / CentOS version 5.0 server?

{ 13 comments }

nixCraft FAQ PDF Collection Now Available To All