Forward outgoing mails of particular user to another account using sender_bbc_maps in Postfix

To forward outgoing mails of particular user to another account using sender_bbc_maps in Postfix:

To main.cf add the following entry:

sender_bcc_maps = hash:/etc/postfix/sender_bcc

and then create a file in /etc/postfix called: sender_bcc and then add the following entry to sender_bcc:

user1@domain.com anotheruser@domain.com

And then type the following command:

postmap /etc/postfix/sender_bcc

and restart Postfix. Now on, emails sent from user1@domain.com will be a blind carbon copy to anotheruser@domian.com

Removing volume group and logical volume after physical drive has been removed

root:/ # lvs
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 1073676288: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 1073733632: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 0: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 4096: Input/output error
/dev/sdc: read failed after 0 of 4096 at 0: Input/output error
/dev/sdc: read failed after 0 of 4096 at 10737352704: Input/output error
/dev/sdc: read failed after 0 of 4096 at 10737410048: Input/output error
/dev/sdc: read failed after 0 of 4096 at 4096: Input/output error
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
home sp3tosp4 -wi-ao--- 4.00g
var sp3tosp4 -wi-ao--- 8.00g
root:/ #

When the disk was physically removed, the /dev/sdc and this device nodes wasn’t automatically removed. The above errors are clearly indicating that /dev/sdc and /dev/myvg/mylv can no longer be read due to the removal of the disk.
Remove the stale /dev/sdc device node and clean up the stale device-mapper nodes. In the above example, this would be accomplished by either a simple reboot, or by running the following:

root:/ # dmsetup remove –force /dev/5gbdisk_vg/5gbdisk
root:/ # echo 1 > /sys/block/sdc/device/delete

root:/ # pvs
PV VG Fmt Attr PSize PFree
/dev/sdb sp3tosp4 lvm2 a-- 16.00g 4.00g
root:/ # lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
home sp3tosp4 -wi-ao--- 4.00g
var sp3tosp4 -wi-ao--- 8.00g
root:/ #

How to remove an unwanted channel from SUSE Manager

At first you need to identify what channels you want to delete. Use the “mgr-sync list channels” command.

root # mgr-sync list channels
Available Channels:

Status:
- [I] - channel is installed
- [ ] - channel is not installed, but is available
- [U] - channel is unavailable

[ ] RHEL i386 Server 5 RES 5 [rhel-i386-server-5]
[ ] RHEL i386 Server 6 Red Hat Expanded Support for RHEL 6 [rhel-i386-server-6]
[ ] RHEL x86_64 Server 5 RES 5 [rhel-x86_64-server-5]
[ ] RHEL x86_64 Server 6 Red Hat Expanded Support for RHEL 6 [rhel-x86_64-server-6]
[ ] RHEL x86_64 Server 7 Red Hat Expanded Support for RHEL 7 [rhel-x86_64-server-7]
[ ] SLES10-SP3-Pool for i586 SUSE Linux Enterprise Server 10 SP3 i686 [sles10-sp3-pool-i586]
[ ] SLES10-SP3-Pool for x86_64 SUSE Linux Enterprise Server 10 SP3 x86_64 [sles10-sp3-pool-x86_64]
[ ] SLES10-SP4-Pool for i586 SUSE Linux Enterprise Server 10 SP4 i486 [sles10-sp4-pool-i586]
[ ] SLES10-SP4-Pool for x86_64 SUSE Linux Enterprise Server 10 SP4 x86_64 [sles10-sp4-pool-x86_64]
[ ] SLES11-SP1-Pool for i586 SUSE Linux Enterprise Server 11 SP1 i586 [sles11-sp1-pool-i586]
[ ] SLES11-SP1-Pool for x86_64 SUSE Linux Enterprise Server 11 SP1 x86_64 [sles11-sp1-pool-x86_64]
[ ] SLES11-SP3-Pool for i586 SUSE Linux Enterprise Server 11 SP3 i686 [sles11-sp3-pool-i586]
[ ] SLES11-SP3-Pool for x86_64 SUSE Linux Enterprise Server 11 SP3 x86_64 [sles11-sp3-pool-x86_64]
[ ] SLES11-SP4-Pool for i586 SUSE Linux Enterprise Server 11 SP4 i686 [sles11-sp4-pool-i586]
[I] SLES11-SP4-Pool for x86_64 SUSE Linux Enterprise Server 11 SP4 x86_64 [sles11-sp4-pool-x86_64]
[ ] SLE11-Public-Cloud-Module for x86_64 SLES-SP4 SUSE Linux Enterprise Server 11 SP3 x86_64 [sle11-public-cloud-module-x86_64-sles-sp4]
[I] SLE11-SDK-SP4-Pool for x86_64 SUSE Linux Enterprise Software Development Kit 11 SP4 [sle11-sdk-sp4-pool-x86_64]
[I] SLE11-SDK-SP4-Updates for x86_64 SUSE Linux Enterprise Software Development Kit 11 SP4 [sle11-sdk-sp4-updates-x86_64]
[ ] SLE11-Security-Module for x86_64 SLES-SP4 SUSE Linux Enterprise Server 11 SP3 x86_64 [sle11-security-module-x86_64-sles-sp4]
[ ] SLE11-SMT-SP3-Pool for x86_64 SP4 SUSE Linux Enterprise Subscription Management Tool 11 SP3 [sle11-smt-sp3-pool-x86_64-sp4]
[ ] SLE11-SMT-SP3-Updates for x86_64 SP4 SUSE Linux Enterprise Subscription Management Tool 11 SP3 [sle11-smt-sp3-updates-x86_64-sp4]
[ ] SLE11-SP4-Debuginfo-Pool for x86_64 SUSE Linux Enterprise Server 11 SP4 x86_64 [sle11-sp4-debuginfo-pool-x86_64]
[ ] SLE11-SP4-Debuginfo-Updates for x86_64 SUSE Linux Enterprise Server 11 SP4 x86_64 [sle11-sp4-debuginfo-updates-x86_64]
[ ] SLES11-Extras for x86_64 SLES-SP4 SUSE Linux Enterprise Server 11 SP1 x86_64 [sles11-extras-x86_64-sles-sp4]
[I] SLES11-SP4-Updates for x86_64 SUSE Linux Enterprise Server 11 SP4 x86_64 [sles11-sp4-updates-x86_64]
[I] SLES12-Pool for x86_64 SUSE Linux Enterprise Server 12 x86_64 [sles12-pool-x86_64]

For example you want to delete the following channel:
[I] SLE11-SDK-SP4-Updates for x86_64 SUSE Linux Enterprise Software Development Kit 11 SP4 [sle11-sdk-sp4-updates-x86_64]

To do that, use the following command: “spacewalk-remove-channel -c

root # spacewalk-remove-channel -c sle11-sdk-sp4-updates-x86_64

Linux force the rereading of the disk geometry.

Assuming you know the device name of the disc you have expanded /dev/sdg then you can simply issue the following command to force the rereading of the disk geometry.

debian02:~ # echo 1 > /sys/class/scsi_device/0:0:6:0/device/rescan

To determine the SCSI ID from device names enter: ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'

For example:
debian02:~ # ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'
sda - SCSI 0:0:0:0
sdb - SCSI 0:0:1:0
sdc - SCSI 0:0:2:0
sdd - SCSI 0:0:3:0
sde - SCSI 0:0:4:0
sdf - SCSI 0:0:5:0
sdg - SCSI 0:0:6:0
sdh - SCSI 0:0:8:0
sdi - SCSI 0:0:9:0
sdj - SCSI 0:0:10:0
sdk - SCSI 0:0:11:0
sdl - SCSI 0:0:12:0
sdm - SCSI 0:0:13:0
sdn - SCSI 0:0:14:0
sdo - SCSI 0:0:15:0
debian02:~ #

Match Linux SCSI Devices (sdX) to Virtual Disks in VMware

To determine the SCSI ID from device names enter ls -d /sys/block/sd*/device/scsi_device/*

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/*
/sys/block/sda/device/scsi_device/0:0:0:0 /sys/block/sde/device/scsi_device/0:0:4:0 /s
/sys/block/sdb/device/scsi_device/0:0:1:0 /sys/block/sdf/device/scsi_device/0:0:5:0 /s
/sys/block/sdc/device/scsi_device/0:0:2:0 /sys/block/sdg/device/scsi_device/0:0:6:0 /s
/sys/block/sdd/device/scsi_device/0:0:3:0 /sys/block/sdh/device/scsi_device/0:0:8:0 /s
debian02:~ #

You can see the the device name, and 4 numbers a:b:c:d

a = Hostadapter ID
b = SCSI channel
c = Device ID
d = LUN

The Device ID is always c. At the controller, it depends whether you are using the Paravirtual (b) controller, or the LSI Logic (a) controller.

On the VMware it looks like that:

debian02
/dev/sda has the SCSI ID 0:0:0:0 which is the equivalent to 0:0 and is Hard Disk 1 on VMware.
/dev/sde has the SCSI ID 0:0:4:0 which is the equivalent to 0:4 and is Hard Disk 5 on VMware.
/dev/sdo has the SCSI ID 0:0:15:0 which is the equivalent to 0:15 and is Hard Disk 16 on VMware.

When you remove and add disks, the order might change so always double check if you want to remove disks from a Virtual Machine.

Also you can use the following command if you want an output that is better to read:

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'
sda - SCSI 0:0:0:0
sdb - SCSI 0:0:1:0
sdc - SCSI 0:0:2:0
sdd - SCSI 0:0:3:0
sde - SCSI 0:0:4:0
sdf - SCSI 0:0:5:0
sdg - SCSI 0:0:6:0
sdh - SCSI 0:0:8:0
sdi - SCSI 0:0:9:0
sdj - SCSI 0:0:10:0
sdk - SCSI 0:0:11:0
sdl - SCSI 0:0:12:0
sdm - SCSI 0:0:13:0
sdn - SCSI 0:0:14:0
sdo - SCSI 0:0:15:0
debian02:~ #

Boot Single User Mode – Resetting forgotten root user account password in RHEL/CentOS 6

While booting hit an arrow key, and it will take you to the GRUB menu. Again, use an arrow key to select the entry that you want to modify.
And hit “e” key to edit this. Find line which starts with “kernel“, and almost at the end of this line find “rhgb quiet“, and add “1” after “quiet“, so it will look like this: “rhgb quiet 1“. Once this is done hit enter. Now, it will take you to the kernel setting prompt. Just press “b” to boot from the kernel, and it takes you to the single user mode.

Now, you are in a single user mode, and you will be able to reset a root password, but before you do that check whether the SELinux is enabled or disabled.
Just type: “getenforce“. It has three contents: Enforcing – no permission to reset a root password. Permissive – permission to rest a root password, and Disabled – No policies are loaded. If you have Enforcing enabled you can disable it by using the following command: “setenforce 0“.
Once this is done, you can change a root password 🙂

Extract specific file(s) from tar.gz

To list the contents of an archive called tarball.tar.gz use this command:

tar -tzf tarball.tar.gz

example:
tarball/file1.txt
tarball/.bash_logout
tarball/file2.txt
tarball/bash.txt
tarball/.bash_history

Then you extract whatever you wish using this command:

tar -zxvf tarball.tar.gz tarball/bash.txt

example:
find . -type f
./tarball/bash.txt
./tarball.tar.gz

To extract a few files use this:

tar -zxvf tarball.tar.gz tarball/bash.txt tarball/file1.txt

find . -type f
./tarball/bash.txt
./tarball/file1.txt
./tarball.tar.gz