Posts

Showing posts with the label linux

My New Favorite Phone Game: termux

 A lot of people when bored pull out their phone and play games.  Games just don't do it for me for some reason.  I mean, I played chess for a while, and recently I tried Shoot Bubble and 5 Dice (generic Yahtzee), but for some reason I always forget I even have them available and I end up just scrolling Twitter :-/  My feed is pretty good, if someone gets overly political or negative (usually its a combination of the two) I block them, but stuff still leaks in.  Usually if Twitter is holding my attention for a long time it's because it's making me angry.  I don't like that.  I think I've found a better solution for when I'm bored and pull out my phone: termux . Termux is a linux command-line environment for Android.  It's a kinda like wsl (or cygwin if you are old like me) or Terminal.app, but for your phone.  It's almost linux but not quite.  Normally I find that very frustrating, especially if I'm trying to get real work done (you may ...

Zmodem File Transfer With GNU Screen

I've been using screen as my serial terminal (as opposed to minicom or picocom) for a long time now.  Today I had the need to transfer a file from my PC to the embedded device I was connected to with screen.  Networking was not working, and a co-worker reminded me that zmodem was a way to transfer a file over the serial port.  I googled for instructions on exactly how to use zmodem and I found stack overflow answers and blog entries all mentioning GNU screen for doing so, but none of them really explained it right.  Here's what worked for me today. To transfer a file from my PC to the embedded device: in screen hit ctrl-a : zmodem catch in screen, at the linux command-line on your device type: rz screen will prompt with an sz command, just append the filename to that command and hit enter Note that this works best if the file is in the same directory as you ran screen from.   To send a file from the embedded device to your PC: in screen hit ctrl-a : zmodem catc...

Linux Environment Management: direnv does it all

  Linux Environment Management: direnv does it all A few years back I wrote about different options for linux environment management .  I recently learned about another option, direnv.  I think I'm convinced that it is the only tool you need.  Read this as if it's another section added to that previous post. Use direnv Straight from  the direnv website : "direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.  Before each prompt, direnv checks for the existence of a .envrc file in the current and parent directories. If the file exists (and is authorized), it is loaded" This happens automatically, so it solves the problem of the "Explicit Environment Files" solution above in a way that is much more convenient than the "Per-command Environment Files" solution. The .envrc files are in standard shell syntax and it properly unloads environme...

MSD: A Red Hat-like business for Open Source EDA (Verilog, VHDL, etc.)

I have been working with commercial EDA tools (Verilog, VHDL, etc.) for years and always found them to be quite overpriced and frustrating.  Whenever I bring up the idea of using open source tools I get responses just like I got when first brining up Linux in the workplace back in 2001.  Things like, "you get what you pay for" and "it's only free if you don't value your time."  Red Hat (and SUSE/Novell) addressed those concerns for business people and made Linux mainstream (and put UNIX out of business and made a lot money for themselves in the process).  Maybe a similar business could do the same for open source EDA. To that end, I have quit my job and I've spent the past few week putting this business together.  What do you think? https://millenniumsoftwaredesign.com (AKA, https://msd.llc/ )

The Dark Cockpit Theory

A co-worker who is annoyed with the verbosity of our verilog simulations just asked me if I subscribed to the Dark Cockpit Theory. I immediately replied, "no." I've had this argument a number of times with other engineers and I have already decided that more information is better than less. I had to google "dark cockpit theory" later because I'd never heard of it referred to that. For me it has always been the UNIX "Rule of Silence" . Same idea, I think. Just to be clear, I do like the Rule of Silence when it's software that I trust isn't going to do weird things or silently hang. There isn't a lot of code that I trust that much, though, and if it's software I don't trust, I want to know what it's doing, or at least that it's doing something . As I thought about this more, it's the same with people. When a person you trust is doing something for you, they can go do it without giving you any intermediat...

A UNIX/Linux Environment Manager

I have written A UNIX/Linux environment manager that allows on-the-fly configuration of your shell environment. It's called, albion . Using albion, environment variables, aliases, functions, and so forth can be changed without requiring you to do the tedious log-out-and-log-back-in-again routine. Simply type 'albion load ' and your shell environment will be reconfigured according to the specification in your environment file. It should work with any POSIXy shell (bash, ksh, zsh, etc.) Albion is similar to the Environment Modules Project , however, environment configuration files (configs) are written in standard shell language, not tcl. Another improvement over modules is that when unloaded, the effect of the configs is correctly undone, even if the configs have changed or been deleted after loading. The main albion tool is written in Python, with some supporting pieces written in POSIX shell code. albion is currently alpha quality. The core functionality seems to be ...

How to Disable Ubuntu command-not-found

Ubuntu, in all its helpfulness, has a feature that tries to guess what you mean when you type commands at the bash prompt. If you type a command that's found, it runs it, of course. If you type a command that it can't find, it takes a moment to search available packages for install and suggest what you might do to make that command available. It sometimes looks like this: $ foo No command 'foo' found, did you mean: Command 'xoo' from package 'xoo' (universe) Command 'fop' from package 'fop' (universe) Command 'fox' from package 'objcryst-fox' (universe) Command 'zoo' from package 'zoo' (universe) Command 'goo' from package 'goo' (universe) foo: command not found It's great when you have a new system and you haven't yet installed everything you need. Type emacs before emacs has been installed, and it will helpfully tell you the exact command to use to install it. After a...

Email with Thunderbird, Compose with Emacs

My Mac let's me use emacs keyboard shortcuts everywhere. I'm really sad that I don't get that in Linux. How the universe ever got into this state is beyond my comprehension. Mail.App has gotten me hooked on emacs keybindings when typing emails especially. The solution in Linux, it turns out, is to just use emacs. I already have It's All Text for Firefox, with emacsclient as the editor. I just found External Editor for Thunderbird, with emacsclient as the editor and tbemail-mode for extra goodness. I think that'll do.

ls colors on Ubuntu

I ls -ed some files today and noticed a few listed with blue backgrounds and white text. I use the --color option to ls because it's pretty, and because the colors provide information that's not always blindingly obvious from regular ls output. Case in point, what did this blue background with white text mean? It turns out that, at least for Ubuntu 9.10 an 10.04 (the two I tried), you can see a list of the colors that ls uses for various things by typing: dircolors --print-database Now, I had a hunch that these files were hardlinks, and sure enough, I saw this line: HARDLINK 44;37 # regular file with more than one link And looked up a few lines to see that, yes, 44 is blue and 37 is white. Cool. Just to be extra sure I passed the file names to the stat command and saw the, links: 2 for those files.

How not to mount a particular server with autofs

There are a couple servers that I use the fancy new (to me at least) autofs scripts to mount on my Ubuntu 9.10 client machine. You know, the ones that let you just cd /net/servername/exportname and it automagically turns that into the command to mount that export from that server at that mountpoint (so cool). To test something out though, I wanted to make sure one of the servers was not auto-mounted by autofs. The simple way to tell autofs to ignore that server (let's call it, foobarbaz) is to edit /etc/auto.net and put this snippet right after the key="$1" line: # don't mount foobarbaz, for now: if [ $key = "foobarbaz" ]; then exit fi Then restart autofs: sudo /etc/init.d/autofs restart And autofs automagically mounts any nfs server except foobarbaz.

Mac nfs client, Linux nfs server

I have a Mac laptop at work and it's been interesting to play with. We have nfs mounted home directories for our Linux workstations and I thought, hey, my Mac is a UNIX machine, it should be able to mount that nfs export too! Turns out, no, not by default. You get a nice "Operation not permitted" error message. The problem is that Mac nfs clients insist on using high numbered TCP ports, and Linux nfs servers by default insist on rejecting clients that use high numbered TCP ports. You can tell the Linux server to stop rejecting clients using high numbered ports with the insecure option in /etc/exports , or you can tell your Mac client to stop using high ports with the resvport option to your mount command. Most websites I found while googling for this just listed the Linux nfs server solution, which works fine if you have control over the server. Most people have a lot more control over their client. For autofs on the Mac, put ,resvport at the end of the /net ...

Convert putty key to openssh on linux

I had a putty generated ssh key that I wanted to use on my linux box (long story). Turns out it's simple to convert it using linux tools. Here are the steps: sudo aptitude install putty-tools Then, to convert a private putty key named id_dsa.ppk to an openssh key named id_dsa: puttygen id_dsa.ppk -O private-openssh -o id_dsa Then just type in the key's passphrase and you're done. You can type puttygen --help to see similar options for public keys.

New Job, New Focus

I have a new job! I am now a verification engineer at a relatively new hardware company in Utah. I worked on digital design and verification stuff back during internships in college and then for the first few years that I worked full-time. Then about five years ago I switched over to embedded software. It's fun to be back in the hardware design world. Better verification and system modelling was a hot topic five years ago, and it looks like a lot of progress has been made in the intervening years. It's really cool to see. Another big win with the new job is, no more windoze! ASIC designers know a good development environment runs on Linux ;-) I mostly use this blog to write down helpful reminders for myself, and as a start, here's my first verilog tip. Code browsing with ctags works for verilog too! I used find to get a list of all our verilog files and put that in a file called, file-list.txt. Then I generated tags like so: ctags -e --verbose --language-for...

.bash_profile vs. .bashrc

There are many subtleties in the way shells start up and what they automatically source when they do. At one point I had to have this down pat for my job, for both Red Hat Linux systems and HP-UX systems. It has gotten a little fuzzy since then, but I rediscovered this basic point today: profile files are sourced once when you log in, your rc file is sourced every time you start a shell. But what does that mean? If you put something like this in your .bashrc: export PATH=$PATH:/home/username/bin And start up, say, a gnome-terminal, your PATH will have /home/username/bin appended to it. To see it type this: echo $PATH Good enough. Now, in that gnome-terminal, if you execute something that causes another sub shell to be spawned (like, you execute a script), your .bashrc will be sourced again, and that export statement will execute again. Try typing this in your gnome-terminal: bash # starts a subshell echo $PATH See /home/username/bin repeated twice? That’...

Large Hidden Files

I'm working on another backup script. I admit it had been over a year since I had backed up my home hard drive. In that time, the stuff my old script had been backing up from my home directory got a lot bigger. Why? I found a couple obvious culprits that I should have seen right away, but then it was less obvious. Running du | sort -rn is always insightful when this problem comes up, and I found that I had a .local directory that was 2.3 GB in size and a .cache that was almost 1 GB. Ouch. Looks related to tracker . The other biggie that I had totally missed was that I had played around with VirtualBox , and it stores its hard drive images in the hidden .VirtualBox directory. What is with these programs stashing huge amounts of data in hidden directories? In the case of VirtalBox, it could be very important data. Is that smart to hide it from the users like that? I don't like it.

Playing With Dar

I'm playing with backups again. Most recently, I'm looking at dar . Some quick notes: To backup just /etc , become root, make sure your pwd is / , and type this: dar -v -c /path/to/etc-backup -g etc This will create a file named etc-backup1.dar at the path you specified. The -v is optional. To do the same but encrypt the archive do this: dar -K passphrase -v -c /path/to/etc-backup -g etc Where "passphrase" is your sneaky passphrase. To list the contents of the archive: dar -K passphrase -l /path/to/etc-backup Of course, you leave out the -K passphrase if you didn't encrypt it in the first place. Notice that you don't give it the full filename, ever. Getting more advance, to write the backup to a file on a remote machine over ssh, do this: dar -c - -g etc | ssh user@host dd of=/path/to/etc-backup.1.dar You tell dar that the backup file is stdout, pipe that to ssh, and use dd on the remote side to put the backup into the file. Note that yo...

Ubuntu 9.04 + X11 forwarding + Windows XP + Putty + XMing

Wow, I sure thought this was a longshot when I went searching for an obscure problem I was having. Strangely enough, someone else using putty and Xming to run X11 applications from a Jaunty machine also got the error message: PuTTY X11 proxy: wrong authentication protocol attemptedError: Can't open display: localhost:10.0 And their fix worked for me too. Thanks, timkoop on the Ubuntu Forums!

Upgrade from 8.10 to 9.04

Pretty much just like the upgrade from 8.04 to 8.10 , minus the xorg problem. The /etc/apache2/sites-available/default didn't even change this time, but I still had to kick apache to get it to serve my virtual host. Not sure what's going on there. One thing I noticed that I forgot to write down about the last upgrade, that is still weird with Jaunty, is the network manager applet has a red X on it, as if I'm not connected to a network, even though networking is configured how I like and working just fine. I'll have to google that one someday.

Upgrade from 8.04 to 8.10

I'm a little behind on my version of Ubuntu at home. Last night I finally upgraded to 8.10. Very smooth compared to past experiences. Video didn't work at first. I just deleted my xorg.conf entirely and then X started up just fine. My apache virtual host was not being served. Everything caused the default junk in /var/www to be served up. Here's what I believe the relevant diff off /etc/apache2/sites-available/default was: bryan@brzo:/etc/apache2/sites-available$ diff -urNp default.dpkg-old default.dpkg-new --- default.dpkg-old 2007-10-31 21:38:12.000000000 -0700 +++ default.dpkg-new 2008-09-19 06:41:53.000000000 -0700 @@ -1,5 +1,4 @@ -NameVirtualHost * -<VirtualHost *> +<VirtualHost *:80> Restoring NameVirtualHost * and <VirtualHost *> statments seemed to fix the problem. I have not taken the time to understand why, and if anyone wants to comment and enlighten me I'll greatly appreciate it. Look for another post soon on how the u...

Packet Protector

A friend recently purchased an ASUS WL-500g Premium V2 wifi router and installed PacketProtector on it for his mom. She wanted some filtering for the household internet connection, and my buddy thought that this would be a nice self-contained, stand-alone, hard-to-bypass solution for her and the fam. So far it seems to be all of that. I got to thinking about my own curious boys and wondering if I might want some DansGuardian filtering on my own internet connection. I've been pretty anti web filter ever since I discovered the web, mainly because I've been successful at avoiding and ignoring bad stuff on my own, and have only been annoyed by filters that always seem to block useful pages right when you need them. I've realized lately, though, that without even thinking about it very much, I really don't let my kids online at all. I think it's because I know that they won't be able to avoid all the bad stuff, and I fear they won't ignore and quickly m...