Tag Archives: sysadmin

super crappy script to make a ton of directories and files

needed to create a really quick script to just generate a ton of directories and files to fill them mainly to create something to test backups with.  it’s not quite elegant, but to be honest it’s pretty quick and got the job done, anyway…

 

#!/bin/bash
# a script to create content, creates 1500 directories, a 1MB file and a %K file and copies it into all subdirs
#creates the dummy content files
dd if=/dev/zero of=dummy bs=1024 count=1024
dd if=/dev/zero of=dummysmall bs=1024 count=5
#creates 1500 directories in current directory
mkdir foo{1..1500}
#copies the dummy files
find . -type d -exec cp dummy {}/ \;
find . -type d -exec cp dummysmall {}/ \;
#clean up
rm -r dummmy dummysmall
echo "done!"
Advertisements
Tagged , ,

don’t do the damn symlink yourself

setting up a vhost in apache on an ubuntu machine?  need to symlink it to sites-enabled?  don’t do it manually you big dummy.

following commands let you create/destroy symlinks for vhosts and apache modules:

a2dismod  a2dissite  a2enmod    a2ensite

so blahblah blah i add a new site for supercoolblog.net

create my vhost in /etc/apache2/sites-available/supercoolblog.net

a2ensite supercoolblog.net

Symlink is added, restart apache and you got your cool site.

Tagged ,

get all of your ELB names for some sort of reason

so tony says i need to blog that shit.  so i am blogging that shit.

sometimes when i need to make a large amount of changes to several ELB’s i need a quick way to throw all of the names into a single file.  here’s a fast way to use the AWS API CLI tools to grab all of your ELB names.

prereq:  actual CLI access, your keypair (use dialt0ne’s aks to switch between your IAM accounts), the ELB CLI tools and a few minutes.

Put that shit into a text file:

$ elb-describe-lbs > elbs

cat that shit and pipe into awk printing only the second field which contains the actual ELB names:

$ cat elbs| awk '{print $2}' > elb-names

now look at that shit and confirm you got all your ELBs

$ cat elb-names
that-shit-01
that-shit-02
that-shit-03

now go listen to slayer.

Tagged , , , ,

reflections on my last day

today’s my last day at the current job.  some thoughts on what i took from working here…

was able to gain some knowledge on using xen cli tools.

fussed around with multipath and how you can present luns from a dell san.  this was a neat skill to pick up.

took in some experience on dealing with hardware vendors, navigating quotes and making sure that i was not being overcharged, or sold more equipment than i needed.  this turned into a huge thing and i managed to recoup about $3k in overcharges for my employer.

learned how to install, administrate and maintain symantec’s netbackup.  this was a big undertaking.  no training what so ever, so it was just a matter of reading the documentation and getting some assistance from symatec’s team.

spent some more time around solaris, and i still don’t care for it.

i did way more documenting than i have in the past, which was already a lot.  i guess the less day to day contact you have with other members of a team, the more you have to document things.  so i did my best to document everything i did day to day.

i leave here without making big a mark as i hoped to.  but i am trying to follow a new career path that i hope really changes my future.  i am taking an opportunity that i couldn’t pass up.

more technical stuff to come…

enjoy this song from slapshot that kind of relates to my feelings:

http://www.youtube.com/watch?v=jFCUNIe-o2A

 

Tagged , , ,

MOAR SCREEN!

MOAR SCREEN!

Gotta keep this for later, a neat wrapper to expand on my love for gnu screen.

looks like byobu expands on screen’s functionality by adding toggles and notification.

credit to @jeffreykaplan for the tip.

Tagged , , ,

why i am looking forward to using git more.

today i had to upgrade a wordpress blog with changes from an outside developer.  my current place of employment doesn’t really use much in the way of revision control and automated deployment.

here’s how the changes went today:

outside developer let’s me know that they have completed changes in their development environment via basecamp.

i send a tarball of the docroot along with a dump of the SQL db to basecamp.

they apply their changes to the docroot and db, upload them to basecamp.

download these new files to my local computer, then scp them to the server.  

i backup the old docroot and db, then rsync the changes from the tarballed docroot.  then i drop and reimport the new db.

that’s a lot of steps to be honest, if we used a centralized repository we could have really simplified this to the developer pushing their committed changes along with a db dump.  i could have pulled the changes with git and then imported the database.

i probably should have demanded some form of revision and deployment method earlier in the process, but to be honest i was not part of the contractual discussions between the developer (which also acts as a marketing company) and my employer.  that’s where the third wall sometimes has to be respected.  there are decisions at times that are made that are outside of the scope of what the sysadmin can do simply because project managers cannot think deeply enough about how to easily implement a new piece of code their developers create.

 

Tagged , , , , , ,

wordfence

securing wordpress is getting more and more important lately.  finding a decent plugin that monitors your posts, codex and versions of software is pretty helpful.  i found http://www.wordfence.com around the time i first got heavily involved with wordpress administration.

so today i got an emailed error from wordfence about one of my posts:

* Post contains a suspected malware URL: Blah blah blah I am not saying what the real post is called.

So let’s log in and see what the software says, it’s right there in the wordpress admin dashboard.

This post contains a suspected malware URL listed on Google’s list of malware sites. The URL is: http://blahblahblahnottellin.blah – More info available a Google Safe Browsing Page.

ok so the post itself is fine, but whomever we are linking to probably got something injected, or at the least has a page on the url that google no likey.

i am going to review the google page, then probably reach out to the third party provider and tell them to clean their crap up.

another cool aspect of wordfence is the live traffic scanning.  if you see a remote user being naughty (probably a bot) you can ban it right from the wordfence area in wordpress.

Tagged , ,

screen as a tool for collaboration

gnu screen, http://www.gnu.org/software/screen/, man i love you.  you do so many things for me as a system administrator.

i’ve been working with an international team lately.  one thing i’ve done to be able to do make sure we can work together easily is using screen as a collaborative tool.

let’s say a member of my team in london wants to show me how to work with a specific utility, i’ve always recommended us logging in as the same user on the machine (we have some shared users and of course root) and then i would spawn a screen session.  once done, i’d ask them to log in and throw the following command:

screen -Rx

the -R flag will resume the youngest screen created and the -x flag will share it with any others currently logged in.

you always want to use some form of revision control to handle changes you are making in a file. but at times doing a direct discussion across the globe with someone else and both looking at the file, making comments on what needs to be changed can be helpful in a critical situation.

Tagged , ,

things i do whenever i log in

as soon as i log into a server i have a habit of running two commands.

dmesg and w.

i like to see if there is anyone else logged in and i want to see if there are any obvious hardware errors that have been dumped into dmesg.

 

 

Tagged ,

sed, grep and updating a static website.

so one of the offices at the company recently moved from one city to another. they are in the process of migrating the public website from an old static page to a new page using wordpress. if the new site was online, changing a footer with the office address wouldn’t be a problem.  well the new shiny office doesn’t come with the new shiny website.  had to do some cli kung-fu to get the address changed.

so i figured since line of the address in html was on a separate line the best thing was to grep for the string, then use sed to replace it, it’s not elegant but it worked.

first thing we do, we back up our crap in case i totally screw it up. then once my backups are done i run the first part of the string:

grep -lr -e ‘123 Old Street Location, Floor 3’ * | xargs sed -i ‘s/123 Old Street Location, Floor 3/555 New Street Location Suite 4/g’

then let’s do the new city and zip

grep -lr -e ‘Cambridge, MA 02139 USA’ * | xargs sed -i ‘s/Cambridge, MA 02139 USA/Boston, MA 02111 USA/g’ 

this got the job done and quickly since the problem was sitting around for a little while and no one seemed to notice.

Tagged , , ,
Advertisements