Skip to main content

Posts

display the line number in a file (vi / vim)

When writing scripts,I often like to insert text into a file at a very specific location/line. The following lines of code, will enable rsync comment out the line starting with default_password_crypted insert a new line with  default_password_crypted in it's place [root@rhnsat01 ~]# sed -i -e 's/\=\ yes/\=\ no/g' /etc/xinetd.d/rsync [root@rhnsat01 ~]# sed -i -e 's/default_password_crypted:/#default_password_crypted:/g' /etc/cobbler/settings [root@rhnsat01 ~]# MYPASS=`openssl passwd -1 -salt 'Passw0rd' 'Passw0rd'` [root@rhnsat01 ~]# sed -i -e '84i'${MYPASS}'' /etc/cobbler/settings  In vi, to see the line you are on (I don't know how to turn the numbers back off though ;-) : set number

Locking down ssh (keys only)

# cp /etc/ssh/sshd_config /etc/ssh/sshd_config-20120522 # sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config # service sshd restart I guess when I set out to document this I thought the task was more challenging.  ;-) I went this route as I am sick of worrying about the script kiddies pounding on my system all day long.  I also scan the secure log every minute for random connection attempts and then shun them at my firewall.  I'll save that for another post.

GPT and Software RAID on Linux (RHEL)

I was rebuilding one of my lab boxes which has 4 x SATA drives (2 x 500GB and 2 x 1TB).  During the install I configured the Software RAID on the 2 x 500's for the OS, etc.. afterwards I wanted to use Software RAID to mirror the 2 x 1TB. 2 x 500GB - OS, swap, Virtual Machines 2 x 1TB - iSCSI and NFS share to be used by my RHEV 3 lab I acknowledged (just today) that GPT is the future... so I decided to use GPT to accomplish all of this. parted -s /dev/sdc -- mklabel gpt mkpart primary ext4 1 -1 set 1 raid on parted -s /dev/sdd -- mklabel gpt mkpart primary ext4 1 -1 set 1 raid on mdadm --create /dev/md127 --level=mirror --raid-devices=2 /dev/sdc1 /dev/sdd1 Conversely, if you are still using the MSDOS partition scheme (which is perfectly fine/normal for drives under 2TB), then the following would work also echo -e "o\nn\np\n1\n\n\nt\nfd\nw\n" | fdisk /dev/sdc echo -e "o\nn\np\n1\n\n\nt\nfd\nw\n" | fdisk /dev/sdd mdadm --create /dev/md127 --le...

iSCSI target RHEL 6

I'm currently attempting to become more familiar with the iSCSI targets on Linux... so, I anticipate that I will be adding to this post - but what I have documented here should get a person by... # NOTE: I discovered this will not work on a VXFS mount if SELinux is enabled # :-( yum install iscsi-initiator-utils scsi-target-utils perl-Config-General mkdir -p /var/lib/tgtd/ lvcreate -L500g -nlv_tgtd vg_blackmesa mkfs.ext4 /dev/mapper/vg_blackmesa-lv_tgtd echo "/dev/mapper/vg_blackmesa-lv_tgtd   /var/lib/tgtd  ext4 defaults 0 0" >> /etc/fstab dd if=/dev/zero of=/var/lib/tgtd/iscsi-tgt-01.img bs=1m seek=100000 count=0 dd if=/dev/zero of=/var/lib/tgtd/iscsi-tgt-02.img bs=1m seek=100000 count=0 dd if=/dev/zero of=/var/lib/tgtd/iscsi-tgt-03.img bs=1m seek=100000 count=0 dd if=/dev/zero of=/var/lib/tgtd/iscsi-tgt-04.img bs=1m seek=100000 count=0 dd if=/dev/zero of=/var/lib/tgtd/iscsi-tgt-05.img bs=1m seek=100000 count=0 restorecon -RFvv /var/...

RHEL 6.2 Server vs Workstation

I have wondered what the difference, at a cursory level, was between the Workstation and Server version of the Red Hat flagship product. As you may have guessed, the Server product has a number of additional Server-based packages, and the same goes for the Workstation product. I did the following (I inserted the appropriate media in my machine) # ls /media/RHEL_6.2\ x86_64\ Disc\ 1/Packages/ > /tmp/RHEL_6.2-Workstation # ls /media/RHEL_6.2\ x86_64\ Disc\ 1/Packages/ > /tmp/RHEL_6.2-Server # sdiff /tmp/RHEL_6.2-Server /tmp/RHEL_6.2-Workstation | egrep '<|>' # sdiff /tmp/RHEL_6.2-Server /tmp/RHEL_6.2-Workstation | egrep '<|>' | wc -l 333 The "big 3" differences appears to be that Workstation includes OpenOffice, hyphen and Evolution.  Server includes cluster, and misc infrastructure type products.

Nvidia drivers on Lenovo T520

Update : Unless you are playing games or something, I see no reason to use the Nvidia drivers.  After I installed the Nvidia drivers the external display was not auto-detected and required a restart of Gnome-shell to recognize the updated config.  Once I did that, it started in Gnome-fallback mode?  Bummer...  So - nouveau is the better option... IMO. I had decided to put Fedora 16 back on my rig.  I know this install won't be on this machine long as it has some quirky issues (sudden desktop lockups, WLAN occasionally flakes out, etc... I digress...)  I also decided to try the Nvidia proprietary driver, along with using the discrete Nvidia graphics chipset. So - the process was fairly straight-forward. # yum -y update # rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm # rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm # yum install akmod-nvidia xorg-x...

convert banshee "favorites" to xmms playlist

Issue :  Xmms is the only media player that I am currently able to configure to play mp3s.  So.. what I have done, is to install a Fedora 16 VM and run banshee with my RHEL ~/Music directory NFS mounted in my VM.  Banshee is where I manage my playlists, etc..  My logout script then copies the banshee.db to my ~/Music directory (as opposed to .config/banshee-1/banshee.db) I then run the following script to create a "default" Xmms playlist. I replace the default XMMS .m3u file, then I create a ~/Music/xmms.pls file (optional to use). Resolution : [jradtke@neo bin]$ cat banshee-to-xmms.sh  #!/bin/bash BANSHEEMINRATING=3 BANSHEEDBFILE=~/Music/banshee.db TMPSYNC=/tmp/banshee2xmms.tmp PLSOUT=~/Music/xmms.pls echo "select Uri from CoreTracks where rating > ${BANSHEEMINRATING};" | sqlite3 $BANSHEEDBFILE > ${TMPSYNC} sed -i -e 's/file:\/\///g' ${TMPSYNC} # MORE GENERIC FILE CLEANUP TYPE STUFF # THEN... REPLACE/REMOVE SOME OF ...