Linux Shell Insights: Volume 2

My last volume Linux Shell Insights: Volume 1 had some talk on the social plane about it so here’s Volume 2. Enjoy.

Here are a few more one-liners. I also call for the assistance of our audience; if anyone has more reliable or efficient methods to accomplish the ends in this article, get involved and comment!

  1. Obtain your internet IP
    There are two ways to do this (both below.) This can be useful in bash scripts that require your IP address. It’s useful in a dynamic IP environment when handling dynamic DNS in some fashion; though can be useful in a variety of scripts in which NAT may exist making eth0 unreliable for this information.

    shell# wget -O – -q checkip.dyndns.org | grep -o “[[:digit:].]+”

    You can also use curl if it’s your tool-of-choice.

    shell# curl -s http://checkip.dydns.org/ | grep -o “[[:digit:].]+”

    If you’ve got a static IP that is directly connected to the internet; it’s best to just scrape the information out of ifconfig.

    shell# /sbin/ifconfig eth0 | grep inet | grep -o “[[:digit:].]+” | head -n 1
  2. Get Distribution Information/Version
    From time to time we get support tickets or calls asking “What distribution of Linux am I running?”. Here’s a way to ascertain this under most modern Linux distributions we offer.

    Most Linux distributions follow the “Linux Standard Base” and have a file in /etc matching *release. You can take a look by running:

    shell# cat /etc/*release

    This does the same thing if you find it easier to remember.

    shell# lsb_release –all

    NOTE: You may have to cat the file /etc/debian_version on some Debian releases.

  3. Shortcut to list all system users
    I stumbled upon this one by a typo once where you can get a peek of system users. This shouldn’t be considered authoritative, as /etc/passwd is your daddy; but it’s quick to verify the spelling of that strange developer who insists on the username supercalifragilistic_expialidocious.
    Tested on: Debian, Redhat

    shell# ~(HIT TAB TWICE HERE)
  4. Lost Plesk Password
    Here’s one of those gems that we keep close to our chest, but I’m willing to reveal it to you. If you misplace your Plesk Admin password, on UNIX it stores it in /etc/psa/.psa.shadow. This is a read-only file, changing the password here does not change it for Plesk. It’s a good way to jot your memory if you forget though.

    shell# cat /etc/psa/.psa.shadow

Continue to keep an eye out for my next list!

Related Posts

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

Tags: , , , , , ,

Leave a Reply

You must be logged in to post a comment.