≡ Menu


Bash: Get The Last Argument Passed to a Shell Script

I'm writing a bash wrapper script that will pass arguments to the command. I need to find out the last argument if I call the wrapper as follows:

./wrapper -a -b --longarg=foo thisfilename.txt
./wrapper -a -b thisfilename.txt
./wrapper -a --next=true thisfilename.txt

=> $@ is all of them.
=> $0 is script name.
=> $1 is first arg.

I want thisfilename.txt stored in a shell variable called $last. How do I find the last argument passed to a shell script written in bash or ksh under Unix like operating systems?
[click to continue…]

HowTo: Open a Tar.gz File In Linux / Unix

I've received a file called date.tar.gz. How do I open/extract/unpack a tar.gz file on Linux or Unix like operating systems using shell prompt?
[click to continue…]

Linux: HowTo Check User Password Expiration Date and Time

/etc/shadow files stores actual password in encrypted format for user’s account. How do I check users password expiry information under Linux operating systems?
[click to continue…]

HowTo: Find Out DNS Server IP Address Used By My Router?

My router configured by ISP tech and it is set to get DNS server address automatically from upstream. Is there is a way to find out the IP address of the dns server used by my router which is located at Is there Linux, Unix, Apple OS X, or MS-Windows command that I can use get the same information?
[click to continue…]

Where Is The Xorg.conf File Located under Unix / Linux / BSD?

I want to find and edit my xorg.conf file for tweaking and configure it for new settings. The problem is that I'm unable to find the file. According to my research, xorg.conf should in /etc/X11 or /usr/X11R6/lib/X11/ directory. I found directories but not the file in directories. How do I find the xorg.conf under Unix or Linux like operating systems?
[click to continue…]

Linux Download Password Protected Large ISO Images [ Authentication Credentials ]

I'm trying to download an ISO image for Enterprise Linux from RHN or Novell Suse. Both providers have placed ISO images behind paywall. I need to provide authentication credentials before downloading all files. How do I download ISO files using the wget command with user name and password?
[click to continue…]

UNIX / Linux: Rsnapshot Restore Backups

I've created the backup server using this tutorial under Redhat and Debian Linux systems. How do I restore files (such as /var/www/html) with rsnapshot backup tool? How do I restore MySQL database dumps with rsnapshot under UNIX or Linux operating systems?
[click to continue…]

Linux / UNIX: PHP mail() Error Log File

How do I view PHP mail() errors? How do I see php mail() error log file under UNIX or Linux?
[click to continue…]

RHEL6 Beta: HowTo Use yum Command To Install Packages Without RHN

I'm testing Redhat Enterprise Linux 6 for our apps. However, RHN do not support beta RHEL 6 software. How do I use yum command to install additional software without using DVD ROM?
[click to continue…]

Linux Iptables: Add / Delete An IP Address Remotely Using A Shell Script

I've root ssh access and need to add / delete a few IP address on fly using the IPtables command via local shell script. How do I add or delete an IP address remotely over the SSH session under CentOS / Redhat / RHEL / Debian / Ubuntu Linux?
[click to continue…]