Skip to main content

Posts

Showing posts from 2012

Parse password file and populate variables

#!/bin/bash #ypcat passwd > /tmp/passwd cp /etc/passwd /tmp/passwd while IFS=: read -r user pass uid gid gecos home shell do   echo "ipa-moduser -a -s \"$shell\" -c \"$gecos\" -d \"$home\" $user" done < /tmp/passwd exit 0 Another approach... #!/bin/sh # 1 is the nis domain, 2 is the nis master server ypcat -d $1 -h $2 group > /dev/shm/nis-map.group 2>&1 IFS=$'\n' for line in $(cat /dev/shm/nis-map.group); do   IFS=' '   groupname=$(echo $line|cut -f1 -d:)   # Not collecting encrypted password because we need cleartext password to create kerberos key   gid=$(echo $line|cut -f3 -d:)   members=$(echo $line|cut -f4 -d:)   # Now create this entry   ipa group-add $groupname --desc=NIS_GROUP_$groupname --gid=$gid   if [ -n "$members" ]; then     ipa group-add-member $groupname --users=$members   fi   ipa group-show $groupname done

Change default background fedora 17

Update  /usr/share/backgrounds/beefy-miracle/default/beefy-miracle.xml with the path to the image you would like. cp ~jradtke/Pictures/Wallpapers/DigArt/SpaghettiMontster.jpg /usr/share/backgrounds/beefy-miracle/default/wide/ <background>   <starttime>     <year>2012</year>     <month>01</month>     <day>29</day>     <hour>00</hour>     <minute>00</minute>     <second>00</second>   </starttime> <static> <duration>10000000000.0</duration> <file>         <!-- Wide 16:10 -->         <size width="1680" height="1050">/usr/share/backgrounds/beefy-miracle/default/wide/ SpaghettiMontster.jpg </size>         <!-- Standard 4:3 -->         <size width="2048" height="1536">/usr/share/backgrounds/beefy-miracle/default/standard/beefy-miracle.png</size>         <!-- Normalish 5:4 -->

ksoftirqd consuming high cpu 100%

This happens to be a post from an experience on a Ubuntu machine... although the machine was practically unused, an entire CPU was consumed (by ksoftirqd) Resolution: # date -s "`date`" root@wwwsrv01:~#    uname -a Linux wwwsrv01 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux root@wwwsrv01:~#   lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 10.04.2 LTS Release: 10.04 Codename: lucid root@wwwsrv01:~# top top - 23:02:11 up 491 days, 12:35,  1 user,  load average: 1.45, 1.37, 1.30 Tasks: 206 total,   2 running, 204 sleeping,   0 stopped,   0 zombie Cpu(s):  6.3%us, 12.0%sy,  0.0%ni, 81.6%id,  0.0%wa,  0.0%hi,  0.1%si,  0.0%st Mem:   8253648k total,  7464608k used,   789040k free,   448916k buffers Swap: 19771384k total,     3140k used, 19768244k free,  5471676k cached   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                              

named (bind) consumes over 100% of CPU

I am rebuilding out a lab environment and I installed BIND and attempted to run through everything from memory (instead of running my script or reading my docs...).  BIND was operating "fine", but I noticed that named was consuming around 123% of a CPU. There are a few things that I had not done, and in hindsight, I wish there was a simple how-to on the "correct" way to implement BIND in a best-practices way.  Instead of everyone posting how they did it... (one such example is a person that simply does a chmod 777 to get things rolling...). So -keep in mind that this is for my private lab... Anyhow - in summary: yum -y install bind-chroot chkconfig named on cp /etc/named.conf /etc/named.conf.orig mv /etc/named.conf /var/named/chroot/etc/ echo 'OPTIONS="-4"' >> /etc/sysconfig/named rndc-confgen -a -c /etc/rndc.key chmod 755 /etc/rndc.key cat /etc/rndc.key >> /var/named/chroot/etc/named.conf sed -i -e 's/127.0.0.1/

Cleaning up ZFS

I have a Sun USS 7110 with some issues.  I have had to swap OS drives between machines, at one point the drives were formatted for Linux, etc... At the end of the day, the USS 7110 (basically a Sun x4200) is most useful as it's intended purpose, a Unified Storage Array - imagine that? ;-) Anyhow... once you have the 2 OS drives configured correctly... go to work # echo | format | awk '{ print $2 }' DISKS="c0t5000CCA0002AF4B8d0 c0t5000CCA0002B33A0d0 c0t5000CCA0002CED64d0 c0t5000CCA0002D9A8Cd0 c0t5000CCA0002D9A44d0 c0t5000CCA0007AA6F4d0 c0t5000CCA0007ABB18d0 c0t5000CCA0007ABDBCd0 c0t5000CCA0007B632Cd0 c0t5000CCA0007B3934d0 c0t5000CCA00019B378d0 c0t5000CCA00031D8CCd0 c0t5000CCA000222E5Cd0 c0t5000CCA0002874C4d0" #c0t5000CCA0002CE1C4d0  -- OS Drive #c0t5000CCA00029536Cd0  -- OS Drive for DISK in $DISKS do   echo "dd if=/dev/zero of=/dev/rdsk/${DISK} bs=1024 count=72000"   dd if=/dev/zero of=/dev/rdsk/${DISK} bs=1024 count=72000

rename your "root" VG - Linux LVM

I will be updating this later...  I believe what I have here is accurate.  However, I have not tested it. NOTE: These specific steps will not work with Grub2. # vgs [root@neo ~]# vgs   VG     #PV #LV #SN Attr   VSize   VFree   vg_neo   1   5   0 wz--n- 451.66g 152.66g [root@neo ~]# vgrename vg_neo vg_noob [root@neo ~]# cp /etc/fstab /etc/fstab.bak [root@neo ~]# sed -i -e 's/vg_neo/vg_noob/g' /etc/fstab [root@neo ~]# sed -i -e 's/vg_neo/vg_noob/g' /boot/grub/grub.conf [root@neo ~]# sync [root@neo ~]# vgscan [root@neo ~]# shutdown now -r

Install Fedora Core 17 on Vmware Fusion 5.0.1

Something is amiss when attempting to install Fedora Core 17 x86_64 via VMware Fusion 5.0.1. It's as though you have a 1280x768 pallet for a desktop that is hard coded at 1280x800, except Fusion will not allow you to "scroll" around on the desktop.  So, basically you can't see the Back and Next buttons. Until I figure out what boot flag to use, just remember that Alt-N is next ;-)

Using Keyspan USA-19HS with RHEL (minicom)

Using the keyspan is fairly simple - however, I do occasionally run into issues using it in Linux so I thought it would be good to document a working configuration $ sudo tail -f /var/log/messages Oct 19 09:05:07 neo kernel: usb 1-1.1: new full speed USB device number 9 using ehci_hcd Oct 19 09:05:07 neo kernel: usb 1-1.1: New USB device found, idVendor=06cd, idProduct=0121 Oct 19 09:05:07 neo kernel: usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Oct 19 09:05:07 neo kernel: usb 1-1.1: Product: Keyspan USA-19H Oct 19 09:05:07 neo kernel: usb 1-1.1: Manufacturer: Keyspan, a division of InnoSys Inc. Oct 19 09:05:07 neo kernel: usb 1-1.1: configuration #1 chosen from 2 choices Oct 19 09:05:07 neo kernel: usbcore: registered new interface driver usbserial Oct 19 09:05:07 neo kernel: USB Serial support registered for generic Oct 19 09:05:07 neo kernel: usbcore: registered new interface driver usbserial_generic Oct 19 09:05:07 neo kernel: usbserial: USB Ser

Install/Configure Mac OS X in a Linux kind of way...

NOTE:   I have abandoned this approach to user management on my machine...  Changing the UID, when done properly, should be a non-event.  It is, after all, just a bunch of files ;-)  However, after now doing a clean install and NOT changing my UID from 501, my machine is behaving quite well.  Possibly unrelated, but I have work to get done... This post is most likely trivial and borderline useless to most... but... I have run into an issue which is quite perplexing and until now I have written it off as coincidence. My goal - allow myself the ability to easily use my Mac Mini Server (OS Snow Leopard Server), Mac Book Pro (OS X Mountain Lion), Lenovo T520 (RHEL 6.3 and Windows 7) and my whitebox file server (RHEL 6.3) all function with each other.  My primary focus is to be able to pick up either my Lenovo or my MBP and head out the door and have the stuff I need (without any cloud integration). Now - sadly... this whole episode actually hinges on my Mac's misbehaving.  Which

Installing OS X Mountain Lion from DVD

This is sort of a repost, since I have done a bare-metal install of OS X previously.  I thought I would update my thread based on the new release - as Apple has introduced... more changes?  Ugg... NOTE: I would NOT recommend going to Mountain Lion Server.  It is actually fairly cheesy and a disappointment.  I say it is cheesy as it now seems like having a "Server" is just an application - that is due to the fact that you now install the "Workstation" release and then purchase/install Server.app.  Fair enough - I guess a Server is simply a few more daemons and configuration files and startup scripts.  Either way this presentation of what a *nix server is, deflated my ego a bit.  But, here is the primary reason I do not recommend moving "forward" to the new release.  The management interface.  I think it is horrible.  I suppose I don't like change (for the sake of change) and this new release certainly seems as though that is exactly what Mountain Lio

Migrating Volume between Volume Groups (RHEL)

Issue:  I have 2 x 2 Disk Software RAID arrays in my host running a number of Virtual Machines.  Initially I had created all of the VMs on the same disks as the OS (2 x 500GB RAID 1) and I would like to spread them out. This is not elegant, but in my initial investigation, I was unable to find a way to migrate Volumes.  I found numerous way to mirror devices, or to manipulate whole devices. [root@llrh6kvm01 ~]# lvdisplay /dev/vg_llrh6kvm01/VM_LLRHEVM01   --- Logical volume ---   LV Path                /dev/vg_llrh6kvm01/VM_LLRHEVM01   LV Name                VM_LLRHEVM01   VG Name                vg_llrh6kvm01   LV UUID                K8kpKm-H4WR-GwKS-EXM8-kJDx-FPFs-yrlOGW   LV Write Access        read/write   LV Creation host, time llrh6kvm01.ncell.lab, 2012-09-04 08:48:45 -0500   LV Status              NOT available   LV Size                36.00 GiB   Current LE             9216   Segments               1   Allocation             inherit   Read ahead sectors     auto

Autostart Application in Gnome 2 on RHEL

Resolution : #1 - you can create a file in ~/.config/autostart/ #2 - you can use the GUI #1 - ~/.config/autostart/conky.desktop [jradtke@neo ~]$ cat .config/autostart/conky.desktop [Desktop Entry] Type=Application Exec=/usr/bin/conky ~/.conkyrc & Hidden=false X-GNOME-Autostart-enabled=true Name[en_US]=Conky Name=Conky Comment[en_US]=Conky Desktop App Comment=Conky Desktop App #2 - Click on System | Preferences | Startup Applications Click Add Provide a Name, Command and Comment. In the Name field, enter /usr/bin/conky ~/.conkyrc & What does a conkyrc look like on RHEL? I had a difficult time finding a configuration that would do anything useful, other than no custom config whatsoever.  I found this one online - and I wish I could remember where so I could give credit. [jradtke@neo ~]$ cat .conkyrc # Conky sample configuration # # the list of variables has been removed from this file in favour # of keeping the documentation more maintainable.

Convert iTunes Playlist to Rhythmbox

Solution : get perl script from http://dwelle.org/eg/transferratingsperl.zip - written by Bowen Dwelle (apparently).  YOU... need to test this if you place any importance on your Rhythmbox setup.  I... do not.  If wreck my playlists and/or library, I'm OK with resyncing the media and starting over.  I don't anticipate any issues/problems, but I did not write the script. Situation : I have multiple machines at home, each with a different purpose. MacBook Pro: Music, Pictures, Netflix, etc... Valve/Steam games IBM T520:  Mostly work type stuff. iTunes 10.6.3 rhythmbox-0.12.8-1.el6.x86_64 On the Mac I use iTunes to manage my music library, currently around 12,000 songs.  I think it is a very decent solution and meets all of my needs.  On my "PC", I run RHEL 6.3 and Rhythmbox.  (Rhythmbox is the only audio app I have managed to get working using RHEL with the standard repos.) Issue :  Since my Lenovo is basically just a mirror of my Mac, I don't want to spe

desktop lock up on RHEL

Issue : my desktop would lock up and become unresponsive while the machine still had a normally functioning  OS. Resolution : attempt #1:  disable the Lenovo fingerprint reader.  This didn't fix it. attempt #2:  stop using Google Chrome.  Wasn't Google Chrome... attempt #3:  stay away from flash...  perhaps I'll try uninstalling flash. attempt #4:  this seems to have fixed it... update the boot string with  i8042.noloop SOLVED : --FOR RHEL update your /boot/grub/grub.conf title Red Hat Enterprise Linux Workstation (2.6.32-279.2.1.el6.x86_64)         root (hd0,2)         kernel /vmlinuz-2.6.32-279.2.1.el6.x86_64 ro root=/dev/mapper/vg_neo-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto rd_LVM_LV=vg_neo/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_neo/lv_root rd_NO_DM i8042.noloop         initrd /initramfs-2.6.32-279.2.1.el6.x86_64.img -- Fedora 17 (fc16 and greater, actually) root@neo ~ # cat /etc/defa

Install an old kernel

Issue : My laptop has been acting up since my latest kernel update (at least that is what I am hoping it is).  I had run a clean-up on my machine to remove the older kernels.  I would like to re-install the most recent kernel. Resolution : [root@neo ~]# yum list --showduplicates | grep kernel.x86_64 | tail -2 | head -1 | awk '{ print "kernel-"$2 }' | xargs yum install [root@neo ~]# grep 2.6.32-279.1.1.el6 /boot/grub/grub.conf  title Red Hat Enterprise Linux Workstation (2.6.32-279.1.1.el6.x86_64) kernel /vmlinuz-2.6.32-279.1.1.el6.x86_64 ro root=/dev/mapper/vg_neo-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto rd_LVM_LV=vg_neo/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_neo/lv_root rd_NO_DM irqpoll initrd /initramfs-2.6.32-279.1.1.el6.x86_64.img Alternate ending: [root@neo ~]# yum list --showduplicates | grep kernel.x86_64 | tail -2 Unable to read consumer identity kernel.x86_6

"finish" script for RHEL 6.3 x86_64

Issue: As powerful and inclusive as RHEL is for a server, it still needs a few tweaks to make it functional as a desktop.  I end up rebuilding my primary machine often enough that I decided I needed a finish script. #!/bin/sh PWD=`pwd` DATE=`date +%Y%m%d` ARCH=`uname -p` # ****************************** # Setup local user(s) # Add the admin/redacted Groups and redacted User - if not already there. # ****************************** if [ -d /home/redacted ] then   echo "mv /home/redacted /home/redacted.${DATE} "   exit 9   mv /home/redacted /home/redacted.${DATE} fi getent group admin >/dev/null || groupadd -g 6969 admin getent group redacted >/dev/null || groupadd -g 2025 redacted getent passwd redacted >/dev/null || useradd -g 2025 -u 2025 -G admin -s /bin/bash -c "Redacted" -d /home/redacted -p '$6$KumYpty4aMKx8Jp/$<ENCRYPTED PASSPHRASE HERE>.' redacted # UPDATE THE SUDOERS FILE cat << EOF >> /etc/sudoers

backup Satellite (embedded) database

A simple script to backup the embedded Oracle database included with Satellite 5.4.1 [root@rhnsat01 Satellite]# cat db_backup.sh  #!/bin/bash PRETTY_DATE=`date +%Y%m%d` BACKUP_DIR=/rhnsat-backup/${PRETTY_DATE} OUTPUT_LOG=/var/log/rhnsat-backup.log mkdir ${BACKUP_DIR} if [ ! -d ${BACKUP_DIR} ] then   echo "ERROR: unable to create Backup Dir: ${BACKUP_DIR}"   exit 9 fi # MESSAGE TO USER ON CONSOLE echo "NOTE: you can find output at: ${OUTPUT_LOG}" # BEGIN LOGGING OF THE SCRIPT OUTPUT echo "Script ran at: `date +%Y%m%d-%H%M`" > ${OUTPUT_LOG} echo "start: `date +%Y%m%d-%H%M`" >> ${OUTPUT_LOG} # UPDATE PERMISSIONS OF THE BACKUP DIRECTORY TO ALLOW ORACLE # TO WRITE echo "chown -R oracle:dba /rhnsat-backup/*" >> ${OUTPUT_LOG} chown -R oracle:dba /rhnsat-backup/* >> ${OUTPUT_LOG} # CREATE A REPORT OF THE CURRENT ORACLE DB USAGE echo "su - oracle -c \"/usr/

Red Hat Training Review

The following is my perspective of the Red Hat classes I have taken.  I am very happy with training I have received from Red Hat.  If your goal is to become certified, I highly recommend taking advantage of the courses.  Currently (July 2012) I have successfully completed the RHCSA, RHCE and RHCVA exams. The most important step is to take advantage of the self-assessment online Red Hat skills assessment tool RH300 -  RHCE Rapid Track Course with RHCSA and RHCE Exams RH300 - Course Description RH300 is a  fast-paced   review   over 4 days to prep for the exam. I felt as though quite a few people who attended this class at the same time as myself did not understand the goal of this particular class.  RH300 is not for the squeamish.  You should NOT hope to learn a lot from this class.   If you are a proficient Linux (read: Red Hat) Administrator and simply need some guidance on what to expect and what to study for, this class is for you.  The RHCE is no joke.  I highly recommend

Clone an LVM based KVM based Virtual Machine ;-)

I recently opted to use a volume for my VM (instead of creating a file). RHEVM01 is the "source" and RHUTIL01 is the destination.  I am also cloning from my vg_blackmesa to vg_apps.  One thing I would like to figure out is how to monitor the progress. root@blackmesa ~]# lvdisplay /dev/mapper/vg_blackmesa-VM_RHEVM01   --- Logical volume ---   LV Path                /dev/vg_blackmesa/VM_RHEVM01   LV Name                VM_RHEVM01   VG Name                vg_blackmesa   LV UUID                zx4BLV-Athf-Ymcd-ox4h-965J-uo30-Aey9dJ   LV Write Access        read/write   LV Creation host, time blackmesa.area51.private, 2012-06-22 00:12:02 -0500   LV Status              available   # open                 1   LV Size                20.00 GiB   Current LE             5120   Segments               1   Allocation             inherit   Read ahead sectors     auto   - currently set to     256   Block device           253:6 [root@blackmesa ~]# vgs   VG           #P