Automated FTP Script

I’ve been doing some development for some embedded Linux devices which only support ftp and telnet. In order to automate transfer of binaries from my Fedora development host to the target embedded device I’m using this handy ftp script:


# arg1 = dest hostname
# arg2 = local file
# arg3 = dest dir



ftp -inv $HOST<<ENDFTP
chmod 755 $SRCFILE

Then I added something like this to my Makefile after cross-compiling:

        sh ~/bin/ $(TEST_BOX) $(APP_BIN) /usr/local/data

So after I run make all, I run make push. I still need to telnet to the host to test/debug the application, but this makes the process much faster (and less error-prone).

I’m just noting this for myself, hopefully it’s useful to someone else.

Default Xorg Resolution

Recent versions of Linux and the Xorg X-Windows system have been engineered to require very little configuration settings to properly detect graphics options and display resolutions. In most cases graphics should “just work”.

The Xorg system stores all its configuration options in the file: xorg.conf. Many distributions including Fedora and CentOS keep this file in the /etc/X11/ directory. In the past this file would contain a great deal of information that was not easy to setup. However as of recent releases, this file is not required for graphics to work correctly. Both Fedora and CentOS will provide a very minimal xorg.conf file if required.

Typically the proper resolution for your display will be detected at run time. While this is great for most users, it often leads to strange resolutions or blank screens depending on your monitor or LCD screen.

EDIT: If you have NO file at all, on the Fedora wiki is: How to create xorg.conf. This works for both Fedora and CentOS.
There are two solutions if you have no xorg.conf. As ‘root’ run either of the following:

# yum install system-config-display
# system-config-display --noui


# yum install xorg-x11-server-Xorg
# Xorg -configure
# cp /etc/X11/xorg.conf

Whenever I install Fedora or CentOS with the X-server, I typically edit /etc/X11/xorg.conf and add the following Section (or at least the missing parts):

Section "Screen"
        Identifier "Screen0"
        Device     "Videocard0"
        DefaultDepth     24
        Subsection "Display"
                Viewport   0 0
                Depth     24
                Modes     "1024x768"

The Modes line will control the resolution. You should put the proper resolution for your display. You can also add mutiple modes if you monitor supports it. For example:

Modes     "1280x1024" "1024x768" "800x600"

If you have an LCD and Xorg does not properly detect the resolution, set the mode to the maximum resolution your LCD supports. If you have a standard CRT monitor that Xorg detects higher resolutions (with poor refresh rates) set the mode to the resolution you are comfortable. Also, if you have a CRT you can set multiple modes, then using either Gnome or KDE you can pick a resolution you prefer.

Note: This does NOT apply to everyone (most people will find the defaults correct), however many people have reported that setting a fixed resolution is helpful. Especially for some LCD’s which just seem to go blank.

For more information run man xorg.conf

Edit: 11/23/2009

SSH Client Configuration

I have a VPS which is host to many websites. Some of those sites are permitted ssh access for their admins. However I am the admin to several sites myself. Each site has a different username (login/password) for administration. Additionally I have changed the ssh port to a different number (instead of the default 22) to avoid some script/bot attacks.

All of this makes for very inconvenient ssh usage and plenty of typing errors. For example:

# ssh -p33333
# ssh -p33333

Fortunately ssh provides a client configuration file to make “shortcuts” for things like this.
If you start by reading the ssh_config man page:

# man ssh_config

It will reveal 4 useful options:

  • Host – A “shortcut” name which can be used instead of the full hostname address.
  • Hostname – The real host name which is the actual server to log into.
  • Port – Port number on the host server.
  • User – The username used to log in. Typically ssh will use the current unix username if not specified.

So using the above example. I created the the file: ~/.ssh/config:

[mirandam@atlas ~]$ cd .ssh
[mirandam@atlas .ssh]$ touch config

with the following contents:

Host site1
Port 33333
User username_site1

Host site2
Port 33333
User username_site2

Now I can ssh to either site with a simpler command. These do exactly the same as the previous ssh commands:

# ssh site1
# ssh site2

NOTE: Read the man page carefully. If you see the following error:

Bad owner or permissions on /home/mirandam/.ssh/config

This means you did not properly set the permissions on the config file. To fix:

# chmod 600 ~/.ssh/config

There are many other options in the config file for users who might have more specific options (X11 Forwarding, Timeouts, Compression, etc.).
For anyone with multiple ssh accounts on different servers, this is very convenient to implement. Note this also works for scp and sftp.

Command Line DVD Burning

When I built my server, I only used a CD-RW/DVD-ROM combination drive. Whenever I remotely downloaded a ISO using wget or bittorrent, I would have to copy the 2-4GB file(s) from my server to either my desktop or laptop. I finally caved, and bought a DVD-RW drive for my server (even though it will get minimal usage).

(This was all on my CentOS 5 server, I executed these commands entirely remotely. )

After I installed the new drive, I ran dmesg to check how it was detected:

[mirandam@atlas ~]$ dmesg | grep DVD
hda: HP DVD Writer 1140d, ATAPI CD/DVD-ROM drive
hda: ATAPI 12X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache, UDMA(66)

The device is /dev/hda, which will be linked to the DVD device in /dev:

[mirandam@atlas ~]$ ls -l /dev | grep dvd
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvd -> hda
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvd-hda -> hda
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvdrw -> hda
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvdrw-hda -> hda
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvdwriter -> hda
lrwxrwxrwx 1 root root         3 Aug 19 19:44 dvdwriter-hda -> hda

Necessary Software

In order to work with DVD writing, you should have the dvd+rw-tools package installed. This will most likely be installed if you have Gnome or a CD/DVD app such as K3b. If not install via yum:

# yum install dvd+rw-tools

I wanted to erase a DVD+RW.

I had a junk DVD+RW (Memorex) laying around that I wanted quickly deleted. I used the dvd+rw-format command (it took less than 30 seconds):

[mirandam@atlas ~]$ sudo dvd+rw-format -force /dev/dvd
* BD/DVD+RW/-RAM format utility by <appro>, version 7.0.
* 4.7GB DVD+RW media detected.
* formatting 92.3\

I wanted to burn a downloaded ISO file onto the DVD+RW.

I used the growisofs command. I tried using sudo but it refused, so logged in directly as root.

[mirandam@atlas ISO]$ su -
[root@atlas ~]# cd ~mirandam/ISO/

[root@atlas ISO]# growisofs -dvd-compat -Z /dev/dvd=DVD_Image.iso -speed 2
Executing 'builtin_dd if=DVD_Image.iso of=/dev/dvd obs=32k seek=0'
/dev/dvd: restarting DVD+RW format...
/dev/dvd: "Current Write Speed" is 4.1x1352KBps.
   31490048/2530975744 ( 1.2%) @4.0x, remaining 7:56 RBU 100.0% UBU   2.4%
 2512584704/2530975744 (99.3%) @4.0x, remaining 0:03 RBU 100.0% UBU  99.8%
builtin_dd: 1235840*2KB out @ average 4.0x1352KBps
/dev/dvd: flushing cache
/dev/dvd: writing lead-out

As you can see, it took about 8 minutes (fast!) for this to finish. After it finished, I mounted the new DVD to test it (my image was udf, most linux CD/DVD images are iso9660):

[mirandam@atlas ~]$ sudo mount /dev/dvd /mnt/dvd -t udf

When I got back to the server, my DVD+RW was ready for me.

I plan to always leave a DVD+RW media in the drive so it can serve as an means for backup. Automating the process may also be a good idea.

More Info

NetworkManager and YUM Update Issue

As been noted, the NetworkManager update in Fedora 9 and Fedora 10 prevents YUM from performing a regular update. Apparently due to a bug in the Fedora Update system. The following error may be seen:

Public key for NetworkManager- is not installed

The solution is coming soon, but for a temporary workaround YUM supports an exclude option:

yum --exclude=NetworkManager\* update

This should ignore NetworkManager related packages and continue on in the update process.

For more tips on YUM usage, run: yum --help.

Various Linux and Fedora News

A great deal of the following is all old news.

Adobe has has Flash Plugin for x86_64 Linux architecture in Beta since Oct 2008. The only thing, is that since it is provided in a tarball (.tar.gz), you are better off builing an RPM (spec file). Note that the 32bit i386 version still works perfectly with nspluginwrapper.

Similarily Sun has released the Java JRE web plugin for x86_64 archictecture. Installation is the very identical to 32bit. Just make sure you are using Version 6 Update 12 or newer. It only took 5 yrs? Keep in mind openjdk works well for most scenarios in 64bit linux.

A few weeks ago, KDE 4.2 was released. I’m sure its better than the problematic 4.0 and marginally improved 4.1. For some information for KDE 4.2 on Fedora follow Rex.

I was pleased to see Knoppix 6.0 released. Once upon a time Knoppix was THE Live CD everyone used. Now with Ubuntu, Fedora, OpenSuSE and many other distro’s releasing Live CD’s anyone can really take their pick on what suits them best. Even so, I will download 6.0 and finally replace the Knoppix 5.0 CD that has been travelling with me for the past few years.

Unrelated to any software release, apparently many people have been having issues with the System Bell. For a quick tip on disabling the Fedora 10 system bell. Yeah, that beep is annoying.

Livna troubles: Most Fedora tutorials depend on the Livna repository for software installation. However due to DNS problems Livna has been unavailable. People should wait a few days. Of course it should be noted that Livna was only critical for libdvdcss rpm which is needed to watch DVD’s in Fedora.

Meanwhile on the Fedora mailing list, another whacky thread has errupted. This time: WHY I WANT TO STOP USING FEDORA!!! (yes, it is all in CAPS!). That obviously spawned a bunch of new related threads. While I do read a lot there, that mailing list is getting less useful each day (especially for newbies).

As for me, I’m still quite behind in my email (I apologize if you contacted me). I have not fixed my computer hardware. I know I need to get some updates on some of my Fedora Guides. (Thanks to all the people mailing me hints and tips – I really appreciate it).

Network Connections and Applications

A fairly common question is: How do I determine which applications are making network connections?

While there are different ways to do this, a quick solution is with netstat. To see which applications are connecting to which network addresses, run the following as root (if you are not root certain output is limited):

# netstat -tuap

This will produce several columns of output the last column is PID/Program name. If you do not recognize the application name, use the PID number and use the ps command to find more information. For example (replace PID with the actual number):

# ps -p PID -F

For more information on the many other functions of either of these commands use the man utility:

# man netstat
# man ps

Copy with a Progress Bar

This is something I’ve always thought about looking up myself. Great tip for using pv command for seeing copy progress.


$ cat source/file.img | pv -s 100g -p -e -r > destination/file.img
[ 25MB/s] [==========> ] 13% ETA 0:54:35

Only problem: what package in CentOS includes pv?