Deleting Users and Data
When users leave a system often the userdel command is used to delete their account. However, the result may be that users have created files and directories outside of their home directory.

The /tmp directory often is used to create programs for users so there may be files left in that directory. If you use this command it will delete all of the user files as well:

# sudo userdel -r tom

Example: The -r takes all associated files and directories in the home directory. It will not delete files owned by the user in another directory besides home and user mail.

If you only wanted to delete the the user account and login you would use:

# sudo userdel tom

When you use userdel to delete a user account the command will not delete files owned by the user outside the user’s home directory.

You will need to search those out:

# find / -user tom -print

This command will search for all files owned by the user mike starting with / and print the filenames to the screen.

Often on systems with different administrator’s you may find that these little issues have been overlooked.

If a user account has been deleted and they left files in locations that were not removed, you will find files that have no owner, as the owner has been deleted.

One way to find these files and folders is to use this command:

# find / \( -nouser \)

Once you find these nouser files you will need to decide if they should be kept or deleted.

You may want to assign a user to those files as they may have significance to the company.

Change File Ownership
There may be a time when you need to delete a user and replace that user with another user who will need access to the former user’s files.

For this you want to change ownership of the needed files. Do a search and change the files.

# find / -user mike -exec chown joe {} \;

Place brackets after joe so that the output can be placed in them. All of the files will be searched out for mike and ownership changed to joe.

First we open /etc/pure-ftpd/pure-ftpd.conf and set CallUploadScript to yes :

# vi /etc/pure-ftpd/pure-ftpd.conf

[...]
# If your pure-ftpd has been compiled with pure-uploadscript support,
# this will make pure-ftpd write info about new uploads to
# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
# spawn a script to handle the upload.
CallUploadScript yes
[...]

Next we create the file /etc/pure-ftpd/clamav_check.sh (which will call /usr/bin/clamdscan whenever a file is uploaded through PureFTPd)...

# vi /etc/pure-ftpd/clamav_check.sh

#!/bin/sh
/usr/bin/clamdscan --remove --quiet --no-summary "$1"

... and make it executable:

# chmod 755 /etc/pure-ftpd/clamav_check.sh

Now we start the pure-uploadscript program as a daemon - it will call our /etc/pure-ftpd/clamav_check.sh script whenever a file is uploaded through PureFTPd:

# pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh

Of course, you don't want to start the daemon manually each time you boot the system - therefore we open /etc/rc.local...

# vi /etc/rc.local

... and add the line /usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh to it - e.g. as follows:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
/usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh
touch /var/lock/subsys/local

Finally we restart PureFTPd:

/etc/init.d/pure-ftpd restart

That's it! Now whenever someone tries to upload malware to your server through PureFTPd, the "bad" file(s) will be silently deleted.

Question: How do I reference perl hash? How do I deference perl hash? Can you explain it with a simple example?

Answer: In our previous article we discussed about Perl array reference. Similar to the array, Perl hash can also be referenced by placing the ‘\’ character in front of the hash. The general form of referencing a hash is shown below.

Question: I would like to know how to install, uninstall, verify depot packages on HP Unix. Can you explain me with an example?

Answer: Use swinstall to install a depot package. Use swremove to remove a depot package as explained below.

Install a DEPOT on HP-UX using swinstall

swinstall command installs software from a software source (a depot or physical media) to your local host. swinstall command invokes GUI, the following steps has to be done to complete the installations.

1. Select the target location

2. Select the source

3. Select the depot file to install as shown in the figure.4. Mark the software for installation.

5. Press ‘m’ to mark the software for installation

6. Install the software. Go to Actions, and select install to install the package.7. Analysis – It will perform the analysis process.

Question: I would like to know how to install, uninstall, verify deb packages on Debian. Can you explain me with an example?

Answer: Use dpkg to install and remove a deb package as explained below.On Debian, dpkg (Debian package system) allows you to install and remove the software packages. dpkg is the simplest way to install and uninstall a package.

Debian now supplies a tool named Apt (for “A Package Tool”) and aptitude to help the administrators to add or remove software more easily. Refer to our earlier Manage packages using apt-get for more details.

rc stands for ‘removed ok config-files’. The remove action didn’t purge the configuration files. The status of each installed package will be available in /var/lib/dpkg/status. Status of tcl8.4 package looks like,

Friday, June 18, 2010

Creating, assembling and rebuilding small array is fine. But, things started to get nasty when you try to rebuild or resync large size array.

You may get frustrated when you see it is going to take 22 hours to rebuild the array.

You can always increase RAID resync performance using the following technique.

Recently, I build a small NAS server running Linux for one my client with 5 x 2TB disks in RAID 6 configuration for all in one backup server for Mac OS X and Windows XP/Vista clients computers.

Then whey I cat /proc/mdstat it reported that md0 is created and resync is in progress. The resync speed was around 4000K/sec and resync will complete in approximately in 22 hours. I wanted to finish this early.

/proc/sys/dev/raid/{speed_limit_max,speed_limit_min}
The /proc/sys/dev/raid/speed_limit_min is config file that reflects the current "goal" rebuild speed for times when non-rebuild activity is current on an array.

The speed is in Kibibytes per second, and is a per-device rate, not a per-array rate.

The default is 1000.

The /proc/sys/dev/raid/speed_limit_max is config file that reflects the current "goal" rebuild speed for times when no non-rebuild activity is current on an array.

The default is 100,000.

To see current limits, enter:

# sysctl dev.raid.speed_limit_min
# sysctl dev.raid.speed_limit_max

To increase speed, enter:

echo value > /proc/sys/dev/raid/speed_limit_min

OR

sysctl -w dev.raid.speed_limit_min=value

In this example, set it to 50000 K/Sec, enter:

# echo 50000 > /proc/sys/dev/raid/speed_limit_min

OR

# sysctl -w dev.raid.speed_limit_min=50000

If you want to override the defaults you could add these two lines to /etc/sysctl.conf:

dev.raid.speed_limit_min = 50000
dev.raid.speed_limit_max = 200000

Bitmap Option

Bitmaps optimize rebuild time after a crash, or after removing and re-adding a device. Turn it on by typing the following command:

Core dumps are often used to diagnose or debug errors in Linux or UNIX programs.

Core dumps can serve as useful debugging aids for sys admins to find out why Application like Lighttpd, Apache, PHP-CGI or any other program crashed.

Many vendors and open source project author requests a core file to troubleshoot a program. A core file is generated when an application program abnormally terminates due to bug, operating system security protection schema, or program simply try to write beyond the area of memory it has allocated, and so on.

This article explains how to turn on core file support and track down bugs in programs.

Turn On Core File Creation Support

By default most Linux distributions turn off core file creation (at least this is true for RHEL, CentOS, Fedora and Suse Linux).

You need to use the ulimit command to configure core files.

See The Current Core File Limits
Type the following command:

# ulimit -c

Sample outputs:

0

The output 0 (zero) means core file is not created.

Change Core File Limits
In this example, set the size limit of core files to 75000 bytes:

# ulimit -c 75000

HowTo: Enable Core File Dumps For Application Crashes And Segmentation Faults
Edit /etc/profile file and find line that read as follows to make persistent configuration:

fs.suid_dumpable = 2 - Make sure you get core dumps for setuid programs.

kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t - When the application terminates abnormally, a core file should appear in the /tmp. The kernel.core_pattern sysctl controls exact location of core file. You can define the core file name with the following template whih can contain % specifiers which are substituted by the following values when a core file is created:

Reload the settings in /etc/sysctl.conf by running the following command:

# sysctl -p

How Do I Enable Core Dumping For Specific Deamon?
To enable core dumping for specific deamons, add the following line in the /etc/sysconfig/daemon-file file. In this example, edit /etc/init.d/lighttped and add line as follows:

DAEMON_COREFILE_LIMIT='unlimited'

Please note that DAEMON_COREFILE_LIMIT is Redhat specific, for all other distro add configuration as follows:

strace command
System administrators, diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for which the source is not readily available since they do not need to be recompiled in order to trace them.

This is also useful to submit bug reports to open source developers. See how to use the strace command under Linux to debug the problems.

Graphic: Eliza WeeAlthough this port does everything that you expect your smartphone to be able to do, it isn't usable for day-to-day activities just yet--I haven't implemented any power-management functions, so a fully charged iPhone running Android will last only an hour or so.

A few bugs and performance issues remain, too, so while the phone will be usable, it won't be fast. If you do something unexpected (such as forcing the iPhone off), there is a small chance that you may end up restoring your device.

However, it is impossible for any bugs to brick or disable your iPhone permanently.

Finally, media syncing is not working, so loading your media onto your phone is kind of a pain. I'm working as hard as I can, though, and I expect to fix these issues soon.

Required Reading
Start by brushing up on the fundamentals of iPhone maintenance: how to get your iPhone into Recovery Mode, how to put it into DFU Mode, and how to perform a firmware restore from those modes.

The iPhone is a well-engineered device, and it is virtually impossible to brick if you know these techniques. If all else fails, remember that you can always restore using DFU Mode.

You'll also need to be reasonably comfortable working in a command-line interface, and unless you're confident in trying to compile your own binaries, you'll need a PC running Linux (or a Linux virtual machine).

If you already updated your handset to 3.1.3 or to a 4.0 beta, you must use PwnageTool to create a jailbroken 3.1.2 .ipsw file to restore down to.

Note that I am explicitly excluding the iPhone 3GS, all iPod Touch models, and the iPad. This hack will not work with those devices (yet). I am also explicitly excluding iPhone OS 3.1.3 and all of the 4.0 betas. It will not work with the Spirit jailbreak, either.

If you haven't yet jailbroken your iPhone, don't worry--it's a simple process that consists mainly of pressing buttons on the device when prompted and clicking the next button in a wizard.

I humbly recommend Redsn0w, since I wrote much of the code for that program.

15. Using the SFTP client or scp, create a folder called firmware in the /private/var folder on the iPhone; afterward, upload all the files from the 'firmware' folder you created earlier to it.

If the 'firmware' folder you created earlier is inside your home directory, you can use the following command:

scp -r ~/firmware/ root@[ip address of iPhone]:/private/var/firmware

16. Reboot your iPhone. As a safety precaution, check to make sure that the files are still present after the reboot and that they all have the right sizes.

An incorrect file size is one that does not exactly match the source file size (for example, system.img is not 71327744 bytes, android.img.gz is not 2161556 bytes, or zImage is not 2364280 bytes on the 3G or not 2356044 bytes on the older iPhone).

Many people have trouble with this process because not all of the files reached their iPhone in one piece.

18. Shut down the iPhone and place it into Recovery Mode: With the iPhone powered off and plugged into the computer via USB, push Hold and Home simultaneously, and then let go of Hold after the backlight turns on.

Continue holding Home until the 'Connect to iTunes' image appears on the screen.

19. Run the following commands in Terminal (you'll need to install libusb-0.1-4 with Synaptics or 'apt-get' if you haven't already):

cd ~/idroid sudo ./loadibec openiboot.img3

If all goes well, the 'openiboot' boot menu should now appear!

20. Use either the volume-control buttons or the Hold button to select the second menu option, Console. Tap the Home button to launch it.

A text-mode console should start running on your screen, ending with a 'Welcome to openiboot' message.

21. Type sudo ./oibc in Terminal.
The same messages that appeared on the iPhone screen should now appear in Terminal.

You should next make a backup of the NOR (the device on which the iPhone's bootloader is stored) in case something goes wrong, so you don't brick your iPhone.

22. Type nor_read 0x09000000 0x0 1048576 in Terminal/oibc. This will read the entire NOR into main memory.

23. Type ~norbackup.bin@0x09000000:1048576 in Terminal/oibc. A file will appear in the 'idroid' folder called norbackup.bin. Keep this somewhere safe.

The command uploads the NOR to the computer. After you make this backup, you are now free to modify the NOR.