How to Use the alias Command
Let us say you execute the command ‘ls –alh’ every time you need a long listing of files and directories. Now you want a shortcut to do this. Fortunately, you can do so by using the command alias.
The alias command is useful for creating shortcuts for long commands or for correcting typing mistakes.
To create a shortcut for ls, you can do this:
$ alias ls=”ls -alh”
Now, everytime you execute ls command, it will be run as if you are executing the whole ls –alh command. Be reminded that this will replace the existing ls command. You may use a different name for the new shortcut like so:
$ alias ll=”ls -alh”
However, once you exit the current terminal, the alias will not be saved. To make the alias permanent, you may edit the .bashrc file in user’s home directory:
$ vi ~rai/.bashrc
Then insert the alias command after the line that says #system wide functions and aliases. Save and exit.
That should do it!
How to Fix PECL PHP Error: /bin/sh: bad interpreter: Permission denied
I recently tried installing xdebug on a RHEL 4 machine, and somehow, the server decided that it should refuse having xdebug installed. As if running a heavy Java app is not enough, I decided to add more processes for the server to run. And it looks like the server has got me:
[root@server src]# pecl install xdebug
downloading xdebug-2.0.5.tgz ...
Starting to download xdebug-2.0.5.tgz (287,621 bytes)
.............done: 287,621 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
/usr/local/bin/phpize: /tmp/pear/temp/xdebug/build/shtool: /bin/sh: bad interpreter: Permission denied
So, like I always do, I tackle the problem with my handy tool: Google. I found out that this error occurs when /tmp is mounted as read-only (ro). You can check this by looking at the /etc/fstab file and check the /tmp partition.
Okay, now I know what the problem is. How do I get over this?
Lazy that I am, I moved the /tmp/pear directory, and create a symlink to the root directory.
[root@server src]# mv /tmp/pear /tmp/pear-ori
[root@server src]# mkdir /root
[root@server src]# ln -s /tmp/pear /root/tmp/pear
Now that the directory from where the PECL scripts are running is in /root, the installation should go smoothly.
Another way to go around this is to remount the /tmp:
[root@server src]# mount -oremount,exec /tmp
I have not tried the above command because I thought that creating symlink is a safer approach rather than messing with the mounts.
If there are other ways to fix this, let me know using the comment box below.
Tips: SSL Certificate Checker
If you have one too many SSL certificates to manage, there is one nifty program made with Bash that can determine a certificate’s validity.
SSL Certificate Expiration Check can do that for you and send the results to email. The program’s “send to email” feature allows the user to simply add it to cron to check the certificates and send an alert to the administrator if any certificate (from file or website) falls below the set expiration date.
Tip: Detect Network Connectivity in Bash
There are times that we are required to check hundreds of servers for network connectivity, and what command comes first in mind when testing network – ping. To help out other system and network administrators out there, here is a quick bash script to ping servers.
#!/bin/bash
SERVERS=server.txt
for i in $(cat $SERVERS)
do
ping -c2 $i > /dev/null
if [ $? -ne 0 ]
then
echo "$i is DOWN"
else
echo "$i is UP"
fi
sleep 3
done
Tip: How to Place Pause in Bash Scripts
There some scripts that need human interaction from time to time from confirming certain actions or to warn users that they are about to do something stupid ( “ rm -rf / “, perhaps?). In any case, putting a pause break in a Bash script is a very nifty trick to learn.
This is an example of how to use the Bash built-in command read to put pauses in scripts:
#!/bin/bash
find /home -type f -name "*.txt"
read -p "Press [enter] key to delete *.txt files in /home or CTRL+C to exit"
find /home -type f -name "*.txt" | xargs rm -v
This example script will run the find command and display the results. If user presses the Enter key, the script will remove all files that were found, while pressing CTRL+C will terminate the script.
Here is another variation of the the script:
#!/bin/bash
find /home -type f -name "*.txt"
echo "Press [enter] key to delete *.txt files in /home or CTRL+C to exit"
read contscr
find /home -type f -name "*.txt" | xargs rm -v
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- Anidich1 on Tip: Add User and Generate Password Script
- Tom S on Cebu Pacific Sucks
- kadersardar on PinoyTux Spreads Some CommentLuv
- Steve on Creative Labs Threatens Third Party Driver Modder
- Barry on Free Laptops with Broadband Connection








