I'm getting better with sed all the time but today was a challenging little booger. I wanted to change /etc/pam.d/su from
cat /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth include system-auth
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so
to
cat /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
auth required pam_wheel.so use_uid
auth include system-auth
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so
Notice the absense of the comment on line 6? If you used sed -i 's/\#auth/auth/' <file> it would only look at the first line and then quit. If you used sed -i 's/\#auth/auth/g' it'd change all of them. I wanted to change just ONE out of the whole file. The trick? To specify a LINE for sed to work on.
sed -i '6s/\#auth/auth/' /etc/pam.d/su
Finally! Looked for a while to find the answer. The key is using the line number at the beginning of the search string here. This link helped me get going in the right direction, http://www.linuxquestions.org/questions/linux-software-2/sed-display-text-on-specific-line-of-text-file-397405/. but it didn't give me EXACTLY what I wanted. However it helped me figure out how to specify a line. I knew I could do it after I was able to print the line I wanted to work on. SUCCESS!!
Saturday, November 24, 2012
Thursday, November 22, 2012
Need to make a Linux Kickstart iso?
I work with Linux on a daily basis. I'm also fortunate to have a good grasp on how to build servers and most of my co-workers, aside from a few, have trusted me to make most of the servers. It's a pain having to use a windows server just to mount the ISO to get the process started. Also if you're working from a longer distance away the size of that ISO burdens your connection. Behold the necessary steps to make a tiny ISO of just what you need to get the process started!
http://mikent.wordpress.com/2012/04/12/how-to-create-a-kickstart-iso-boot-disk-for-redhat/
1) logon as root
2) create a directory name bootdisk/RHEL
mkdir -p bootdisk/RHEL
3) copy the directory isolinux from your RedHat DVD or other location containing RedHat binaries in bootdisk/RHEL
example: cp -R /mnt/isolinux/* ~/bootdisk/RHEL/
4) change direcotry to ~/bootdisk/RHEL/
cd ~/bootdisk/RHEL/
5) create (or copy) your ks.cfg (it will be discussed later in another post how to create a kickstart file) in ~/bootdisk/RHEL/
example: cp ks.cfg ~/bootdisk/RHEL/
6) Now, you can create the ISO boot disk as follow (make sure you run the command from ~/bootdisk/RHEL/) :
mkisofs -r -T -J -V “RedHat KSBoot” -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v -o linuxboot.iso .
7) Burn your iso linuxboot.iso into a blank cd-rom or mount it as it is on a Virtual Machine for example
8) At linux boot prompt, type the following command:
linux ks=cdrom:/ks.cfg
if you need to install using a specific IP address using a specific Ks boot device, type the following:
linux ks=cdrom:/ks.cfg append ip=<IPaddress> netmask=<netmask> ksdevice=<NICx>
example: linux ks=cdrom:/ks.cfg append ip=10.10.10.10 netmask=255.255.255.0 ksdevice=eth0
9) your are done!
http://mikent.wordpress.com/2012/04/12/how-to-create-a-kickstart-iso-boot-disk-for-redhat/
How to create a kickstart ISO boot disk for RedHat
2) create a directory name bootdisk/RHEL
mkdir -p bootdisk/RHEL
3) copy the directory isolinux from your RedHat DVD or other location containing RedHat binaries in bootdisk/RHEL
example: cp -R /mnt/isolinux/* ~/bootdisk/RHEL/
4) change direcotry to ~/bootdisk/RHEL/
cd ~/bootdisk/RHEL/
5) create (or copy) your ks.cfg (it will be discussed later in another post how to create a kickstart file) in ~/bootdisk/RHEL/
example: cp ks.cfg ~/bootdisk/RHEL/
6) Now, you can create the ISO boot disk as follow (make sure you run the command from ~/bootdisk/RHEL/) :
mkisofs -r -T -J -V “RedHat KSBoot” -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v -o linuxboot.iso .
7) Burn your iso linuxboot.iso into a blank cd-rom or mount it as it is on a Virtual Machine for example
8) At linux boot prompt, type the following command:
linux ks=cdrom:/ks.cfg
if you need to install using a specific IP address using a specific Ks boot device, type the following:
linux ks=cdrom:/ks.cfg append ip=<IPaddress> netmask=<netmask> ksdevice=<NICx>
example: linux ks=cdrom:/ks.cfg append ip=10.10.10.10 netmask=255.255.255.0 ksdevice=eth0
9) your are done!
Subscribe to:
Posts (Atom)