Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, January 21, 2014

Generating Mock Userdata

I often find myself needing to generate dummy data when doing software projects. The rig command-line utility makes it easy to do so.
# apt-get install rig

$ rig
Maureen Cummings
614 Spring County Blvd
Phoenix, AZ  85026
(602) xxx-xxxx

Tuesday, March 31, 2009

Survival Hacks

Many years back when I was first starting to get savvy with Linux, a co-worker approached me with a problem. He had yanked the harddrive out of his old Linux router and placed it in a different machine. The old machine had on-board ethernet and used a different driver than the new machine's PCI ethernet card. His only other computer was a laptop, which was currently offline due to the router issue. Thinking it would be an easy job, I downloaded a binary copy of the PCI driver and copied it onto a floppy at work. When I got to his house, I realized there was a bigger issue. My friend didn't have a monitor of any sort for the machine we'd be working on. We could have just given up and borrowed one from work the next day, but we decided to see how far we could get without one. We hooked up a keyboard and booted the machine waiting a few extra minutes to be sure we had a login prompt. From there, we very carefully logged in as root and mounted the floppy. The light on the floppy drive gave us a good indication that we were good so far. Not being able to remember the name of the driver forced me to do a glob copy based on the file extension to the /tmp directory, but again, the light on the floppy drive showed things were working. From there, we had another problem. We weren't sure if modprobe, the command to load a kernel module, would accept wildcards, so the globbing was no good this time. Still totally blind, I typed the following into the command line:

for I in *.ko; do modprobe ./$I; done

Fingers crossed, I hoped for the best and typed:

ifconfig eth0 192.168.0.1 netmask 255.255.255.0

From there, we plugged in his laptop, and tried to ping the machine. Much to our surprise, it was up and responding. Feeling accomplished, we did an ssh login from there, and got everything setup as it should be. Now, I'm not saying this was totally elite or anything, but it does go to show that a little creative thinking can get you pretty far. Feel free to share your own survival hacks in the comments if you have a similar story.

Monday, September 8, 2008

Determining Linux Version

Linux distributions don't tend to standardize where they store information about what release is installed. Going further, there's not even a standard way to detect what distribution is installed. If a system is running a popular distro, this information can usually be found in one of the following files:


Debian /etc/debian_release, /etc/debian_version,
Fedora /etc/fedora-release
Gentoo /etc/gentoo-release
Mandrake /etc/mandrake-release
Novell SUSE /etc/SUSE-release
Red Hat /etc/redhat-release, /etc/redhat_version
Slackware /etc/slackware-release, /etc/slackware-version
Solaris/Sparc /etc/release
Sun JDS /etc/sun-release
Ubuntu /etc/lsb-release
UnitedLinux /etc/UnitedLinux-release
Yellow dog /etc/yellowdog-release


You can find more information on this problem as well as a shell script to assist with OS detection here. An even larger master list can be found here.

Tuesday, August 19, 2008

Interactive Linux Kernel Map

Thanks to Nate for sending in this awesome map of the Linux kernel. To make it even more fun, you can scroll your mouse wheel to zoom in and out of the different components of the system.

Interactive Kernel Map

Wednesday, April 2, 2008

SSHFS via Fuse

This is relatively new to me and pretty damn cool. FUSE (Filesysten in Userspace) is a software package which allows you to mount various types of filesystems from inside userspace. It also includes an API for integrating such functionality into your own software and all sorts of other goodies, but that's beyond the scope of this post. I'm constantly hopping between the Grooveshark dev server and my local machine. Thinking it would be really convenient to have the remote filesystem available from inside my home directory, I decided to give Fuse a try. On my local Ubuntu workstation the sequence went something like this:

desktop:~$ apt-get install fuse-utils sshfs
desktop:~# usermod -a -G fuse travis # add my user to the fuse group
... logout ... log back in ...
desktop:~$ mkdir devmnt
desktop:~$ sshfs -p someport -oIdentityFile=/path/to/id/file user@host:/ devmnt
desktop:~$ cd devmnt
desktop:~/devmnt$ ls
... files !...

If you don't use an identity file or alternative port to ssh, you can omit those options from the sshfs command-line. Also, the filesystem is mounted with the same privileges as if you were logged onto the box as the user specified... so you can read and write files at will so long as the filesystem permissions allow.

Oh, one important little piece of information that was surprisingly absent from the sshfs manpage, you can unmount the filesystem as follows:

fusermount -u mountpoint