Boneheaded Linux Tip of the day
I’m starting to get my Linux legs back. So today I’m building a custom Tomcat bundle and it absolutely MUST HAVE symbolic links in it. (For the non-techies [Aunt Sharon] reading, Linux is the free version of Windows XP, Tomcat is a web server and a symbolic link is kinda like a Windows shortcut… well let me expound further… a web server is one of those computer programs that give you the internet while Windows shortcuts are like a quick way to go to a file or a folder somewhere hidden on your computer. Actually I love my auntie dearly but what would she be doing reading up on a Linux tip? Let’s continue, shall we?) So I got this GAnt build that HAS TO run on Windows because the mobile development community forgot there are operating systems that don’t actually start with the letter “W”. The build updates a tarball. (My family and next door neighbor can stop reading at this point because I don’t even want to try to go into detail on what a tarball is. No, it’s nothing like a spitball or loogey, it’s more like a zip file for Linux and Unix computers.) The tarball, created originally on a Linux box, has the symbolic links. The build scp’s (secure copy) the tarball to a remote Linux server. Ya’ with me so far? If not then goto 1 else break.
when the file gets to the Linux box I try to use it (there’s some other magic that goes on here) and it doesn’t work. I finally figure out that my symbolic links are gone! I’m not sure where they went. Maybe they got lost in the build. Maybe they were dropped when the tarball was first copied over to Windows, maybe scp running under GAnt has something to do with it. The point is that they’re gone!
Now I’m running further iterations to get the tarball built correctly and for now I manually unwrap the tarball on Linux and replace the symbolic links. I then manually tar everything back up and that’s where today’s tip comes in. It’s really nothing spectacular and if you’ve read this far then I pity you. Feel free to navigate away to someplace more educational. I’m just tickled pink that I finally have something Linuxy to talk about. So if you’re still there, are you ready for this? Today’s boneheaded Linux tip:
Instead of manually unpackaging your tar file to check for symbolic links you can list the contents of the tar file by passing the “-t” option on the command line. Also including the “-v” option will show the true path of all symbolic links. Cool, right? But that’s not it! I found out that because the output, especially with verbosity (-v) fills the screen so much you can hone in on just the symbolic links by… get this… by piping the output to grep!!! Isn’t that fantastic! So in the end you have a neat little query that asks if the tar file includes any symbolic links:
tar -tzvf my-file.tar.gz | grep -e ‘->’
The z flag handles any GZipped tar file and the resulting output lists only the symbolic links in the file!
That’s all for now. Come back later when I figure out how to move a console process to the background, eg. Ctrl-Z bg %1!!! Woah! I feel like such a Linux newbie nowadays… Hit me up people.
- Posted in: Programming