Archive for the ‘Linux’ Category

Retrieve Your Public IP Address From The Command Line.

There are many reasons that you want to know your public IP address and getting that is easy by visiting some of the sites that allow you to view that information, but what if you wanted to do it from the command line? What if you wanted to script that? To upload the result to a web page? Or to email it?

There is a quick and easy way of doing it from the command line.

In Linux or any other UNIX based system, open terminal window or ssh to your server and type the following at the command prompt.

wget -qO - http://www.whatismyip.org

In Windows, if you haven’t done already, download and wget from this location, extract it to your c:\Windows or C:\Windows\system32 folder and then open a command line box and type the same command in the above in the command box.

On Linux/UNIX systems, curl http://www.whatismyip.org has the same result for the wget command above.

  • Share/Bookmark

Comments (17)

Convert And Download Youtube Videos Online.

While it is not new that Youtube videos can be downloaded to a local drive, now you can convert the format to a Windows or Mac friendly formats even before downloading the videos to your local drive.

This has been done using expensive software in the past, but now it is done online, and for free.

To do this, you can visit http://www.vixy.net/ provide the link to the Youtube video that you want to download, choose the format that you want to download that video in, which currently supports AVI for Windows (Divx+MP3), MOV Windows and Mac (MPEG4+MP3), MP4 for iPod (MPEG4+AAC), 3GP for mobile devices (MPEG4+AAC), or MP3 (Audio only), which means that you can even rip sounds, sound effects, and songs from the posted youtube videos.

Please note that on Windows, in order to play the AVI files you must have a DIVX or XVID codec installed.

I recommend installing XVID codec package for Windows from this location.

  • Share/Bookmark

Comments (5)

How To Find Files And Folders In Linux.

This is “find” command tutorial.

The command find will search location you specify for files that match the supplied search criteria.

The search is recursive which means that find will search the location that you specify and all the subdirectories that it find in there.

If you type

# find –help

You’ll see the help text which starts by listing:

Usage: find [path...] [expression]

Default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions.

To simplify it, look at it like this.

find path criteria action

Examples:

# find / -name httpd

Will located any file or folder named httpd searching recursivley from the root path and downwards.

Depending on your configuration, that might take a while since you are searching the whole OS installation.

On my Cent OS server the output looks like.

/var/log/httpd
/var/lock/subsys/httpd
/usr/include/httpd
/usr/lib/httpd
/usr/sbin/httpd
/etc/logrotate.d/httpd
/etc/rc.d/init.d/httpd
/etc/sysconfig/httpd
/etc/httpd

Please note that if find doesn’t locate any matching files, there will be no output.
You also will see an error message on each directory that you don’t have access permissions to.

You can specify as many places as you want to search in, for example:

# find /var $HOME /bin -name history

This will search /var, your home directory and /bin for files name history.

You can use wildcards in the file name argument.

# find / -name mail\*log

This will search the whole system for any file with a name that begins with mail and ends with log.

Another way of specifying wildcards in your search is

# find / -name ‘*.log’

This will find all the files in your system that have the .log extension.

If you want to find more than one type of files, use the following:

# find / -name ‘*.log’ -o -name ‘*.pid’

This will find all the log and pid files on your system.

To find a list of the directories, use the -type specifier. Here’s an example:

# find . -type d

This is a basic tutorial, as find is very customizable and powerful command.

Please refer to the full usage of find by typing.

# man find

In your shell.

  • Share/Bookmark

Comments (12)

Installing Yum On Redhat Enterprise Linux 4.

I have one server hosted by a third party which runs Red Hat Enterprise Linux 4 and it doesn’t have yum installed.

To install yum on Red Hat Enterprise Linux 4 you need to install the dependencies first.

Here is a quick and dirty way of doing it.

First download all the required packages.

Download the main yum rpm.

# wget http://dag.wieers.com/rpm/packages/yum/yum-2.4.2-0.4.el4.rf.noarch.rpm

Now download the dependencies…

# wget ftp://fr2.rpmfind.net/linux/PLD/dists/ac/ready/i386/libsqlite-2.8.15-1.i386.rpm

# wget ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/python-elementtree-1.2.6-7.el4.rf.i386.rpm

# wget ftp://rpmfind.net/linux/dag/redhat/el4/en/i386/dag/RPMS/python-sqlite-0.5.0-1.2.el4.rf.i386.rpm

# wget ftp://rpmfind.net/linux/dag/redhat/el4/en/x86_64/dag/RPMS/python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm

Note: Each one of the above should be on ONE line.

Now we need to install the packages.

First we install the dependencies.

# rpm -ivh libsqlite-2.8.15-1.i386.rpm

# rpm -ivh python-elementtree-1.2.6-7.el4.rf.i386.rpm

# rpm -ivh python-sqlite-0.5.0-1.2.el4.rf.i386.rpm

# rpm -ivh python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm

Now we are ready to install yum.

# rpm -ivh yum-2.4.2-0.4.el4.rf.noarch.rpm

Add a repository to the current ones that are installed by default.

# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm

# rpm -ivh rpmforge-release-0.3.6-1.el4.rf.i386.rpm

Now run the following commands to update and upgrade all packages.

# yum update

# yum upgrade

If you would like to add more repositories to your Yum installation, please look here for instructions.

  • Share/Bookmark

Comments (2)

How to Manually Add A Repository To Yum.

Some 3rd part repositories have their own rpm that you can use.

Here is how to do it manually in Cent OS.

For example if you have a repository that exists at subdomain.domain.com.
Note: Replace subdomain, domain, and com with your link.

# cd /etc/yum.repos.d

Add a file that points to the repository name and location.

# nano subdomain

Now type the following in the new file (or copy/paste the following changing the names and locations to the correct repository):

[subdomain]
name=Subdomain for RHEL/ CentOS $releasever – $basearch
baseurl=http://subdomain.domain.com/centos/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://subdomain.domain.com/RPM-GPG-KEY.txt

Save the changes and then exit out of nano.

Now import the PGP keys for the repository.

# rpm –import http://subdomain.domain.com/RPM-GPG-KEY.txt

Now run your update and upgrade processes.

# yum update

# yum upgrade

And you are now ready to install packages from the new repository.

  • Share/Bookmark

Comments (5)