Dear Sadhiq Gr8 work of sending Daily Tips . can you pl send some tips for DNS & Sendmail.
Regards Vijay Agarwal On Mon, Feb 9, 2009 at 1:25 PM, b.sadhiq <[email protected]> wrote: > cpio works like tar, only better. > > Daily Tips > Message-ID: <[email protected] <gmonif%2Bcegk%40eGroups.com>> > User-Agent: eGroups-EW/0.82 > MIME-Version: 1.0 > Content-Type: multipart/alternative; boundary="8-1229220142-1180365921=:4" > X-Mailer: Yahoo Groups Message Poster > X-Yahoo-Post-IP: 123.252.172.84 > X-Yahoo-Newman-Property: groups-compose > Sender: [email protected] <notify%40yahoogroups.com> > X-Yahoo-GPoster: I85c9jU3AGfSgPTV > > --8-1229220142-1180365921=:4 > Content-Type: text/plain; charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > TIP 1: > > cpio works like tar, only better. > > STEP 1 (Create two directories with data ../dir1 an ../dir2) > > mkdir -p ../dir1 > mkdir -p ../dir2 > cp /etc/*.conf ../dir1/. > cp /etc/*.cnf ../dir2/. > > Which will backup all your cnf and conf files. > > STEP 2 (Piping the files to tar) > > cpio works like tar but can take input > from the "find" command. > > $ find ../dir1/ | cpio -o --format=3Dtar > test.tar > or > $ find ../dir1/ | cpio -o -H tar > test2.tar > > Same command without the ">" > > $ find ../dir1/ | cpio -o --format=3Dtar -F test.tar > or > $ find ../dir1/ | cpio -o -H tar -F test2.tar > > Using append > > $ find ../dir1/ | cpio -o --format=3Dtar -F test.tar > or > $ find ../dir2/ | cpio -o --format=3Dtar --append -F test.tar > > STEP 3 (List contents of the tar file) > > $ cpio -it < test.tar > or > $ cpio -it -F test.tar > > STEP 4 (Extract the contents) > > $ cpio -i -F test.tar > > TIP 2: > > Working with tar. The basics with encryption. > > STEP 1 (Using the tar command on the directory /stuff) > > Suppose you have a directory /stuff > To tar everything in stuff to create a ".tar" file. > > $ tar -cvf stuff.tar stuff > > Which will create "stuff.tar". > > STEP 2 (Using the tar command to create a ".tar.gz" of /stuff) > > $ tar -czf stuff.tar.gz stuff > > STEP 3 (List the files in the archive) > > $ tar -tzf stuff.tar.gz > or > $ tar -tf stuff.tar > > STEP 4 (A way to list specific files) > > Note, pipe the results to a file and edit > > $ tar -tzf stuff.tar.gz > mout > > Then, edit mout to only include the files you want > > $ tar -T mout -xzf stuff.tar.gz > > The above command will only get the files in mout. > Of couse, if you want them all > > $ tar -xzf stuff.tar.gz > > STEP 5 (ENCRYPTION) > > $ tar -zcvf - stuff|openssl des3 -salt -k secretpassword | dd > of=3Dstuff.des3 > > This will create stuff.des3...don't forget the password you > put in place of secretpassword. This can be done interactively as > well. > > $ dd if=3Dstuff.des3 |openssl des3 -d -k secretpassword|tar zxf - > > NOTE: above there is a "-" at the end... this will > extract everything. > > TIP 3: > > Creating a Virtual File System and Mounting it with a Loopback Device. > > STEP 1 (Construct a 10MB file) > > $ dd if=3D/dev/zero of=3D/tmp/disk-image count=3D20480 > > By default dd uses block of 512 so the size will be 20480*512 > > STEP 2 (Make an ext2 or ext3 file system) -- ext2 shown here. > > $ mke2fs -q > > or if you want ext3 > > $ mkfs -t ext3 -q /tmp/disk-image > > yes, you can even use reiser, but you'll need to create a bigger > disk image. Something like "dd if=3D/dev/zero of=3D/tmp/disk-image > count=3D50480". > > $ mkfs -t reiserfs -q /tmp/disk-image > > Hit yes for confirmation. It only asks this because it's a file > > STEP 3 (Create a directory "virtual-fs" and mount. This has to be done > as root) > > $ mkdir /virtual-fs > $ mount -o loop=3D/dev/loop0 /tmp/disk-image /virtual-fs > > SPECIAL NOTE: if you mount a second device you will have to increase the > loop count: loop=3D/dev/loop1, loop=3D/dev/loop2, ... loop=3D/dev/loopn > > Now it operates just like a disk. This virtual filesystem can be mounted > when the system boots by adding the following to the "/etc/fstab" file. > Then, > to mount, just type "mount /virtual-fs". > > /tmp/disk-image /virtual-fs ext2 rw,loop=3D/dev/loop0 0 0 > > STEP 4 (When done, umount it) > > $ umount /virtual-fs > > SPECIAL NOTE: If you are using Fedora core 2, in the /etc/fstab you can > take > advantage of acl properties for this mount. Note the acl next to the > rw entry. This is shown here with ext3. > > /tmp/disk-image /virtual-fs ext3 rw,acl,loop=3D/dev/loop1 0 0 > > Also, if you are using Fedora core 2 and above, you can mount the file > on a cryptoloop. > > $ dd if=3D/dev/urandom of=3Ddisk-aes count=3D20480 > > $ modprobe loop > $ modprobe cryptoloop > $ modprobe aes > > $ losetup -e aes /dev/loop0 disk-aes > $ mkfs -t ext2 /dev/loop0 > $ mount -o loop,encryption=3Daes disk-aes <mount point> > > If you do not have Fedora core 2, then, you can build the kernel from > source > with some of the following options (not complete, yet) > reference: > http://cvs.sourceforge.net/viewcvs.py/cpearls/cpearls/src/posted_on_sf/a\ > cl/ehd.pdf?rev=3D1.1&view=3Dlog<http://cvs.sourceforge.net/viewcvs.py/cpearls/cpearls/src/posted_on_sf/acl/ehd.pdf?rev=3D1.1&view=3Dlog> > > Cryptographic API Support (CONFIG_CRYPTO) > generic loop cryptographic (CONFIG_CRYPTOLOOP) > Cryptographic ciphers (CONFIG_CIPHERS) > Enable one or more ciphers (CONFIG CIPHER .*) such as AES. > > HELPFUL INFORMATION: It is possible to bind mount partitions, or > associate the > mounted partition to a directory name. > > # mount --bind /virtual-fs /home/mchirico/vfs > > Also, if you want to see what filesystems are currently mounted, "cat" > the > file "/etc/mtab" > > $ cat /etc/mtab > > Also see TIP 91. > > TIP 4: > > Setting up 2 IP address on "One" NIC. This example is on ethernet. > > STEP 1 (The settings for the initial IP address) > > $ cat /etc/sysconfig/network-scripts/ifcfg-eth0 > > DEVICE=3Deth0 > BOOTPROTO=3Dstatic > BROADCAST=3D192.168.99.255 > IPADDR=3D192.168.1.155 > NETMASK=3D255.255.252.0 > NETWORK=3D192.168.1.0 > ONBOOT=3Dyes > > STEP 2 (2nd IP address: ) > > $ cat /etc/sysconfig/network-scripts/ifcfg-eth0:1 > > DEVICE=3Deth0:1 > BOOTPROTO=3Dstatic > BROADCAST=3D192.168.99.255 > IPADDR=3D192.168.1.182 > NETMASK=3D255.255.252.0 > NETWORK=3D192.168.1.0 > ONBOOT=3Dyes > > SUMMARY Note, in STEP 1 the filename is "ifcfg-eth0", whereas in > STEP 2 it's "ifcfg-eth0:1" and also not the matching > entries for "DEVICE=3D...". Also, obviously, the > "IPADDR" is different as well. > > TIP 5: > > Sharing Directories Among Several Users. > > Several people are working on a project in "/home/share" > and they need to create documents and programs so that > others in the group can edit and execute these documents > as needed. Also see (TIP 186) for adding existing users > to groups. > > $ /usr/sbin/groupadd share > $ chown -R root.share /home/share > $ /usr/bin/gpasswd -a <username> share > $ chmod 2775 /home/share > > $ ls -ld /home/share > drwxrwsr-x 2 root share 4096 Nov 8 16:19 /home/share > ^---------- Note the s bit, which was set with the chmod 2775 > > $ cat /etc/group > ... > share:x:502:chirico,donkey,zoe > ... ^------- users are added to this group. > > The user may need to login again to get access. Or, if the user is > currently > logged in, they can run the following command: > > $ su - <username> > > Note, the above step is recommended over "newgrp - share" since > currently > newgrp in FC2,FC3, and FC4 gets access to the group but the umask is not > correctly formed. > > As root you can test their account. > > $ su - <username> "You need to '-' to pickup thier environment '$ su > - chirico' " > > Note: SUID, SGID, Sticky bit. Only the left most octet is examined, and > "chmod 755" is used > as an example of the full command. But, anything else could be used as > well. Normally > you'd want executable permissions. > > Octal digit Binary value Meaning Example > usage > 0 000 all cleared $ chmod > 0755 or chmod 755 > 1 001 sticky $ chmod > 1755 > 2 010 setgid $ chmod > 2755 > 3 011 setgid, sticky $ chmod > 3755 > 4 100 setuid $ chmod > 4755 > 5 101 setuid, sticky $ chmod > 5755 > 6 110 setuid, setgid $ chmod > 6755 > 7 111 setuid, setgid, sticky $ chmod > 7755 > > A few examples applied to a directory below. In the first example all > users in the group can > add files to directory "dirA" and they can delete their own files. Users > cannot delete other > user's files. > > Sticky bit: > $ chmod 1770 dirA > > Below files created within the directory have the group ID of the > directory, rather than that > of the default group setting for the user who created the file. > > Set group ID bit: > $ chmod 2755 dirB > > Regards. > B.Sadhiq > > --8-1229220142-1180365921=:4 > Content-Type: text/html; charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > <pre><font size=3D"3"><u><b>TIP 1:</b></u></font><br><br> cpio works li= > ke tar, only better.<br><br> STEP 1 (Create two directories with data .= > ./dir1 an ../dir2)<br><br> mkdir -p ../dir1<br> mkdir -p = > ../dir2<br> cp /etc/*.conf ../dir1/.<br> cp /etc/*.cnf ..= > /dir2/.<br><br> Which will backup all your cnf and conf files.<br>= > <br> STEP 2 (Piping the files to tar)<br><br> cpio works like = > tar but can take input<br> from the "find" command.<br><br> = > $ find ../dir1/ | cpio -o --format=3Dtar > test.tar<br> = > or<br> $ find ../dir1/ | cpio -o -H tar > test2.tar<br><br> = > Same command without the ">"<br><br> $ find ../dir1/ = > | cpio -o --format=3Dtar -F test.tar<br> or<br> $ fi= > nd ../dir1/ | cpio -o -H tar -F test2.tar<br><br> Using append<br>= > <br> $ find ../dir1/ | cpio -o --format=3Dtar -F test.tar<br> = > or<br> $ find ../dir2/ | cpio -o --format=3Dtar --append= > -F test.tar<br><br> STEP 3 (List contents of the tar file)<br><br> = > $ cpio -it < test.tar<br> or<br> $ cpio -i= > t -F test.tar<br><br> STEP 4 (Extract the contents)<br><br> $ = > cpio -i -F test.tar<br><br><br><font size=3D"3"><br><u><b>TIP > 2</b></u>:</f= > ont><br><br> Working with tar. The basics with encryption.<br><br> = > STEP 1 (Using the tar command on the directory /stuff)<br><br> Sup= > pose you have a directory /stuff<br> To tar everything in stuff to= > create a ".tar" file.<br><br> $ tar -cvf stuff.tar stuff<br><br> = > Which will create "stuff.tar".<br><br> STEP 2 (Using the tar c= > ommand to create a ".tar.gz" of /stuff)<br><br> $ tar -czf stuff.t= > ar.gz stuff<br><br> STEP 3 (List the files in the archive)<br><br> = > $ tar -tzf stuff.tar.gz<br> or<br> $ tar -tf st= > uff.tar<br><br> STEP 4 (A way to list specific files)<br><br> = > Note, pipe the results to a file and edit<br><br> $ tar -tzf stuf= > f.tar.gz > mout<br><br> Then, edit mout to only include the fil= > es you want<br><br> $ tar -T mout -xzf stuff.tar.gz<br><br> = > The above command will only get the files in mout.<br> Of cous= > e, if you want them all<br><br> $ tar -xzf stuff.tar.gz<br><br> = > STEP 5 (ENCRYPTION)<br><br> $ tar -zcvf - stuff|openssl des3 -= > salt -k secretpassword | dd of=3Dstuff.des3<br><br> This will crea= > te stuff.des3...don't forget the password you<br> put in place of = > secretpassword. This can be done interactively as<br> well.<br><b= > r> $ dd if=3Dstuff.des3 |openssl des3 -d -k secretpassword|tar z= > xf -<br><br> NOTE: above there is a "-" at the end... this will<br> = > extract everything.<br><br><br><br><font size=3D"3"><u><b>TIP 3:</= > b></u></font><br><br> Creating a Virtual File System and Mounting it wi= > th a Loopback Device.<br><br> STEP 1 (Construct a 10MB file)<br><br> = > $ dd if=3D/dev/zero of=3D/tmp/disk-image count=3D20480<br><br> = > By default dd uses block of 512 so the size will be 20480*512<br><br> = > STEP 2 (Make an ext2 or ext3 file system) -- ext2 shown here.<br><br> = > $ mke2fs -q<br><br> or if you want ext3<br><br> = > $ mkfs -t ext3 -q /tmp/disk-image<br><br> yes, you can even use r= > eiser, but you'll need to create a bigger<br> disk image. Somethin= > g like "dd if=3D/dev/zero of=3D/tmp/disk-image count=3D50480".<br><br> = > $ mkfs -t reiserfs -q /tmp/disk-image<br><br> Hit yes for co= > nfirmation. It only asks this because it's a file<br><br><br> STEP 3 (= > Create a directory "virtual-fs" and mount. This has to be done as > root)<br>= > <br> $ mkdir /virtual-fs<br> $ mount -o loop=3D/dev/loo= > p0 /tmp/disk-image /virtual-fs<br><br> SPECIAL NOTE: if you mount a= > second device you will have to increase the<br> loop= > count: loop=3D/dev/loop1, loop=3D/dev/loop2, ... loop=3D/dev/loopn<br><br>= > Now it operates just like a disk. This virtual filesystem can be = > mounted<br> when the system boots by adding the following to the "= > /etc/fstab" file. Then,<br> to mount, just type "mount /virtual-fs= > ".<br><br> /tmp/disk-image /virtual-fs ext2 r= > w,loop=3D/dev/loop0 0 0<br><br> STEP 4 (When done, umount it)<br><br> = > $ umount /virtual-fs<br><br><br> SPECIAL NOTE: If you are usin= > g Fedora core 2, in the /etc/fstab you can take<br> advantage = > of acl properties for this mount. Note the acl next to the<br> = > rw entry. This is shown here with ext3.<br><br> /tmp/disk-= > image /virtual-fs ext3 rw,acl,loop=3D/dev/loop1 0 0<br><br> = > Also, if you are using Fedora core 2 and above, you can mount the file= > <br> on a cryptoloop.<br><br> $ dd if=3D/dev/ur= > andom of=3Ddisk-aes count=3D20480<br><br><br> $ modprobe loo= > p<br> $ modprobe cryptoloop<br> $ modprobe ae= > s<br><br> $ losetup -e aes /dev/loop0 disk-aes<br> = > $ mkfs -t ext2 /dev/loop0<br> $ mount -o loop,encrypti= > on=3Daes disk-aes <mount point><br><br><br> If you do no= > t have Fedora core 2, then, you can build the kernel from source<br> = > with some of the following options (not complete, yet)<br> = > reference:<br> http://cvs.sourceforge.net/viewcvs.py/cpearls/cpear= > ls/src/posted_on_sf/acl/ehd.pdf?rev=3D1.1&view=3Dlog<br><br> = > Cryptographic API Support (CONFIG_CRYPTO)<br> = > generic loop cryptographic (CONFIG_CRYPTOLOOP)<br> = > Cryptographic ciphers (CONFIG_CIPHERS)<br> Enable one = > or more ciphers (CONFIG CIPHER .*) such as AES.<br><br><br> HELPFUL I= > NFORMATION: It is possible to bind mount partitions, or associate the<br> = > mounted partition to a directory name.<br><br> = > # mount --bind /virtual-fs /home/mchirico/vfs<br><br> = > Also, if you want to see what filesystems are currently mounted, "cat"= > the<br> file "/etc/mtab"<br><br> $ cat /etc/m= > tab<br><br> Also see TIP 91.<br><br><br><br><font size=3D"3"><u><b>TIP = > 4:</b></u></font><br><br> Setting up 2 IP address on "One" NIC. This ex= > ample is on ethernet.<br><br> STEP 1 (The settings for the initial IP a= > ddress)<br><br> $ cat /etc/sysconfig/network-scripts/ifcfg-eth0<b= > r><br> DEVICE=3Deth0<br> BOOTPROTO=3Dstatic<br> = > BROADCAST=3D192.168.99.255<br> IPADDR=3D192.168.1.155<br> = > NETMASK=3D255.255.252.0<br> NETWORK=3D192.168.1.0<br>= > ONBOOT=3Dyes<br><br> STEP 2 (2nd IP address: )<br><br> = > $ cat /etc/sysconfig/network-scripts/ifcfg-eth0:1<br><br> = > DEVICE=3Deth0:1<br> BOOTPROTO=3Dstatic<br> BROADCAST= > =3D192.168.99.255<br> IPADDR=3D192.168.1.182<br> NETM= > ASK=3D255.255.252.0<br> NETWORK=3D192.168.1.0<br> ONB= > OOT=3Dyes<br><br> SUMMARY Note, in STEP 1 the filename is "ifcfg-eth0"= > , whereas in<br> STEP 2 it's "ifcfg-eth0:1" and also not the m= > atching<br> entries for "DEVICE=3D...". Also, obviously, the<= > br> "IPADDR" is different as well.<br><br><br><br><font size= > =3D"3"><u><b>TIP 5:</b></u></font><br><br> Sharing Directories Among Se= > veral Users.<br><br> Several people are working on a project in "/home/= > share"<br> and they need to create documents and programs so that<br> = > others in the group can edit and execute these documents<br> as need= > ed. Also see (TIP 186) for adding existing users<br> to groups.<br><br>= > $ /usr/sbin/groupadd share<br> $ chown -R root.share /home/s= > hare<br> $ /usr/bin/gpasswd -a <username> share<br> $ c= > hmod 2775 /home/share<br><br> $ ls -ld /home/share<br> d= > rwxrwsr-x 2 root share 4096 Nov 8 16:19 /home/share<br> = > ^---------- Note the s bit, which was set with the chmod 2775= > <br><br> $ cat /etc/group<br> ...<br> share:x:502= > :chirico,donkey,zoe<br> ... ^------- users are added to t= > his group.<br><br> The user may need to login again to get access. Or, = > if the user is currently<br> logged in, they can run the following comm= > and:<br><br> $ su - <username><br><br> Note, the above step= > is recommended over "newgrp - share" since currently<br> newgrp in FC= > 2,FC3, and FC4 gets access to the group but the umask is not<br> correc= > tly formed.<br><br> As root you can test their account.<br><br> = > $ su - <username> "You need to '-' to pickup thier environment '$ = > su - chirico' "<br><br> Note: SUID, SGID, Sticky bit. Only the left mos= > t octet is examined, and "chmod 755" is used<br> as an example of = > the full command. But, anything else could be used as well. Normally<br> = > you'd want executable permissions.<br><br> Octal digit Binar= > y value Meaning Example usage<br> = > 0 000 all cleared $ chmod 0755= > or chmod 755<br> 1 001 sticky = > $ chmod 1755<br> 2 010 setgid = > $ chmod 2755<br> 3 011 = > setgid, sticky $ chmod 3755<br> 4= > 100 setuid $ chmod 4755<b= > r> 5 101 setuid, sticky = > $ chmod 5755<br> 6 110 setuid, setgid = > $ chmod 6755<br> 7 111 setuid, s= > etgid, sticky $ chmod 7755<br><br> A few examples appl= > ied to a directory below. In the first example all users in the group > can<b= > r> add files to directory "dirA" and they can delete their own files. U= > sers cannot delete other<br> user's files.<br><br> Sticky bit:<b= > r> $ chmod 1770 dirA<br><br> Below files created within the = > directory have the group ID of the directory, rather than that<br> of t= > he default group setting for the user who created the file.<br><br> = > Set group ID bit:<br> $ chmod 2755 dirB<br><br><br>Regards.<br>B= > .Sadhiq<br><br><br><br><br></pre> > > --8-1229220142-1180365921=:4-- > > > [Non-text portions of this message have been removed]

