Echo is your friend: So for my first post let me tell you a quick little lesson I learned the other day. One of my responsibilities at work is to create FTP accounts (which I have created a pretty awesome python script – “well yes I am a legend in my own mind, thanks for asking”), but learned a quick but valuable lesson the other day. We got an urgent request in a ticket about some users being unable to access a dir, so I went in and checked the dir and it seems as though the name has some funky (yet invisible) character at the end. So trying to do this before I had to leave for a Dr’s appt, was probably not the best idea. So I, out of habit, chdir’d into the dir and typed mv _dirname “tab for auto-completion” /* _newdirname/ “enter”. I’m not sure what the character was, or my own failing, but instead of _dirname/* it tried moving _dirname /* (yes that is /* as in root and everything under it) into the new dir. I quickly killed it when I realized what was happening (I noticed it was failing on /dev/ files), but unfortunately the /dev, /etc, and /bin dirs had been moved.
Ok, here comes the panic, so I go and talk to the Staff SysAdmin (where we work staff > senior, gotta love job titles), and he’s like ok, no biggie. cd /disk_location/ftp/account_dir, then here is where the magic comes in, as /bin was gone so was ls (or /bin/ls for you purists), so he typed echo * (which formatting wise is completely ugly, but the key is, it worked). Long and short, we were able to move the directories back out into the root (/) and everything was hunky dory. So two lessons, 1. when moving files, if you have the space either do it from inside the dir, or try cp first, 2. echo * can save the day if ls is gone.