Posts

Showing posts from 2010

WaterRoof : Easy to use free IPFW firewall configuration tool for Mac OS X

WaterRoof is  easy to use free IPFW firewall configuration tool for Mac OS X if you do not like the command line mode to set your firewall rules. The tool can be downloaded from here

How to set host/computer name permanently in Mac OS X

To set host/computer name permanently or temporarily in Mac OS X , mac os provides a command line utility "scutil". This tool helps in setting the host name of your mac permanently.

Ex1:

sudo scutil --set HostName  MyNewMachintoshHostname

This will set your mac host name to 'MyNewMachintoshHostname' permanently

Ex2 :

sudo scutil --set ComputerName  MyNewMachintoshComputerName

This will set your mac computer name to 'MyNewMachintoshComputerName' permanently.

How to open terminal man page in Preview application in Mac OS X

The terminal man help for particular command can be in Preview application on Mac OS X . To do this run the below command in terminal 

man -t mount | open -f -a /Applications/Preview.app



How to find what all files are accessed by an application or vice versa

"Opensnoop" command helps in file system monitoring activities ex if we want to know what all files are accessed by an application or which all processes access a particular file then opensnoop will help you in that activity.

Ex 1:

Let us say if we want to know what all files are accessed by firefox in its operation time on mac os x then run opensnoop in sudo or root mode as below

sudo opensnoop -n firefox 


Note : We can even supply the process id (PID) of an application in place of the application name above by using the -p switch as "sudo opensnoop -p "

Ex 2 :

Let us say if we want to know what all process/applications are accessing a particular file then run the opensnoop command as

sudo opensnoop -f  /Users/user/Documents/Test.txt

Command Line Music player in mac os x

The Mac OS X provides a command line music player if you do not want to use iTunes or any other music player, which is very easy to use. Just supply the music file (such as mp3,wma , etc) located in a directory "afplay" command as below.

afplay  /Users/user/Music/yourmusic.mp3


afplay -h    will give you all the other options available with the command.

Installing Mac OS X updates from command line

Mac OS X provides a command "softwareupdate" to update your mac from terminal. The command is very easy to use and can be used as below.


To install all the mac os x updates:


sudo softwareupdate -i -a 


To install only recommended os updates:


sudo softwareupdate -i -r

How to disable Mac OS X spotlight search in snow leopard 10.6.x

We might some time require to disable the spotlight(search indexing) for some time in mac os x operating system. This can be done as below
sudo mdiutil -a -i off
The above command will stop indexing on all the volumes mounted in mac os x.
To enable back again, run
sudo mdiutil -a -i on

Visible Light Communication - Data transfer through LED lights !!!

Visible Light Communication is new type of data communication technology which uses LED lights to transfer the data between communicating devices. Introductory video can be seen here

Effective Data File Recovery Tool from Auslogics

Auslogics Disk Defrag : A very useful utility to schedule and organize disk de-fragmentation in windows

Auslogics Disk Defrag : A very useful utility to schedule and organize disk de-fragmentation in windows . The software provides multiple preferences or settings to schedule or organize the regular or much needed disk de-fragmentation on windows operated disks. The tool is freeware for home users and can be downloaded from here

How to fix the drive not getting opened upon double click in windows when infected with autorun.inf virus

We often see the disk drives such as USB's / Harddisk partitions do not get opened in windows when we double click on the disk icon in explorer after machine is infected with autorun.inf virus. This is due to hidden autorun.inf presence in the root directory of the drive ex: C:\autorun.inf or I:\autorun.inf where I:\ refers to a USB disk. The below said steps will help you in fixing this problem very easily


Scan and Clean the drives with a good antivirus and make sure all the disks are free from virus.Now open Command Prompt (i.e. cmd.exe) by typing cmd, in Run ( To open it go to Start -> Run, enter cmd and press enterGoto USB disk drive such as F: in your command promptNow run the command DIR /w /a to see all hidden files and folders.Now run the command attrib to remove all special attributes associated with files and folders as attrib -R -S -H /S /D  *.*Now delete the autorun.inf with command del autorun.infRemove your usb disk and plug it againNow you can open the drive by d…

Mac OS X Hibernate / Sleep mode modifications

When Mac goes to sleep mode (i.e, when we close the lid of the laptop, or power saving kicks in, etc.) it saves a hibernate file (/var/vm/sleepimage) first, and then goes to standy mode (thus the computer is on, it just stops running all programs and puts itself into a low powered mode).  If you want your mac always to go to hibernate mode then execute the below commands with sudo privileges

       sudo pmset -a hibernatemode 1 (This effects when your mac is in all modes such as  battery and UPS and AC)

       sudo pmset -b hibernatemode 1 (This effects only when your mac is on battery mode)

Thats it! Now put the machine to sleep or just close the lid of your mac to put your mac directly to hibenate.



If you want to reset back to default settings use following commands

For Portable Macs( mac book etc)

       sudo pmset -a hibernatemode 3

       sudo pmset -b hibernatemode 3

For Desktops ( iMac )

      sudo pmset -a hibernatemode 0 


      sudo pmset -b hibernatemode 0


If you do no…

Startupmanager - A very usefull tool for grub configuration on debian flavors of linux

Startup-manager is a GUI tool to configure settings for Grub, Grub 2, Usplash and Splashy. It provides a menu interface which allows you to set boot menu options such as the default operating system, Which kernel you want to boot into always, menu timeouts and displays  etc. Startup-manager accomplishes this by translating your GUI inputs into bootloader settings without the need to manually edit the bootloader file (in Ubuntu, normally /boot/grub/menu.lst).

To install the startup-manager application on your ubuntu.


#>apt-get install  startupmanager

Note : Just to ensure the safety, keep a backup of original menu.lst file


#> sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.orig

How to find and resolve dependencies of linux rpm file.

When ever we try to install the rpm file in Linux, the rpm often throws dependency errors . RPM dependencies can be resolved with some handy rpm commands. The below commands will be helpful when your are trying to install a rpm file on Linux. 

#> rpm -qpR <.rpm file >       --- > This command will list all the other dependent files for this rpm to get installed.


#>rpm -qf < absolute path to the file>   --->  This command will tell what package this  file belongs to or find which  package owns this file

Booting Linux in single user mode

Restart the system , wait till grub appears.Select the kernel you want to boot into and press e to enter into edit mode.Edit the line which starts with kernel , some thing like this          kernel /boot/vmlinuz-X.X.X.X.X. ro root=LABEL=/ rhgb quiet
     4. Add keyword 'single' at the end of the line and press enter to exit edit mode.
     5. Now select the kernel and press b to boot into single usermode.

Mounting the root partition in rw mode during single user mode in linux

We may some time required to boot in single user mode in linux to fix some issues with the linux. Some times when we boot into single user mode in linux we might see the root volume(/)  as read only and we can edit the config files inside root volume due to this. Solution to this is mounting the root volume (/) in read/write mode using the following command in single user mode.

# mount -L / / -t ext3 -o remount,rw

How to find what system calls are triggered by a command

Do you want to find what system calls are being called when you execute a command , then run the strace command as below

$strace -c /bin/ls


This command will list all the system calls made by "ls" command with cpu time spent on each system calls.

Adding users to sudoers file in linux operating systems

Let us say we need to add the users to the sudoers file in linux to run some commands with special root privileges to avoid seeing error such as "user is not in sudoers file. The incident will be reported " . We need to follow below steps:
Login as root.Run visudo command , this opens /etc/sudoers file. Search for the line  # % wheel  ALL=(ALL)  ALL.Uncomment the line by deleting #.Save the file.Now run command as a root, "usermod -aG wheel logout from root session.Now if the user 'xyz' belongs to the group 'wheel' then the user "xyz" can run privileged commands with sudo access.

If you want to give sudo access to specific user then add the following line in /etc/sudoers file by using visudo command

xyz   ALL=(ALL)  ALL

finding the glibc version on your linux computer

1. Run command " ldd --version " will display the version of glibc that came with ldd.

2. Or run the below program

#include
#include
int main ( )
{
puts (gnu_get_libc_version ());
return 0;
}

3. Or just run the libc binary as

#/lib/libc.so.6

Mounting nfs share on Mac

Mounting nfs share on Mac

Through The Finder

Accessing an NFS share with the Mac OS X Finder is simple. Select Go -> Connect to Server... in the Finder. In the Address box, enter the location of the NFS share as follows nfs:// servername /path/to/share. So if your server's name is taco and the share is /exports/media, you would use the address nfs://taco/exports/media. The Finder will then access the share and mount it on your desktop. An important note here is that the Finder uses an unprivileged port to do this, which may not work with some NFS server configurations.

Through The Mount Command

To use the mount command to mount a share, open the Terminal application. Enter the command sudo /bin/mount_nfs servername: /path/to/share _/private/mnt/point_, replacing the italicized sections with the necessary values. This command will also use an unprivileged port by default, but you can force a privileged port with the -P switch.



Using the automount Daemon

For more permanent mounts…

Converting .DMG or .CDR to .ISO on Mac OS X

To convert .DMG to . iso

hdiutil convert /Users/alpa/Desktop/winxp-sp2.DMG -format UDTO -o /Users/alpa/Desktop/winxp-sp2.iso

To convert .cdr to .iso

hdiutil makehybrid -iso -joliet -o /Users/alpa/Desktop/winxp-sp2.iso /Users/alpa/Desktop/winxp-sp2.cdr

What process is using your CD or DVD on *nix

Tried to eject a CD or DVD and you were told that the disk was in use and couldn't figure out what was using the disk? Use the below shell script is to findout.



#!/bin/bash

PATH=${PATH}:/sbin:/usr/sbin

dr=($(drutil status | grep -i 'type:'))
devtype=${dr[1]}
device=($(mount | grep ${dr[3]}))
if [ $devtype = "No" ]
then echo No disk found. Sorry! >&2
exit 1;
fi
echo A $devtype is mounted on the device named $device
pids=($(sudo -p 'Please enter the administrator password:' lsof -t $device))
echo \nList of programs that may be preventing the disk to eject
ps -o pid,user,comm=COMMAND -www -p $(echo ${pids[*]} | sed 's/ /,/g')

The output is a list of the processes that lsof says is using the CD or DVD.

Mount NFS Volumes in Snow leopard with Disk Utility

NFS mounts are now added using Disk Utility. To add a Linux-hosted NFS share on my network,

1. Start Disk Utility
2. Select NFS Mounts from the File menu
3. Click the plus sign in the lower left corner
4. Enter in your remote NFS URL info as described
5. Enter the mount point. If you add it to /Network, then it will show up in the Shared section of Finder, in an entry called All.
6. If you're using secure ports on your server, then click the Advanced option and enter -P
7. Click Verify
8. Save your settings

The NFS mount is now available.

How to pass an init level to kernel in linux

Pass a init level to the kernel assuming you have grub open up /boot/grub/menu.1st and add 'init=3' to the options in the config like:

example:

kernel (hd0,0)/boot/linux-2.6.8 root=/dev/hda1 idebus=66 init=3

Enabling Kernel Cores in Linux permanently

Enabling Kernel Cores in Linux permanently

1. Open /root/.bashrc file and append the following strings

sysctl -w kernel.core_uses_pid=1

ulimit -c unlimited

Displaying user related information on mac in Terminal

Displaying user related information on Mac in Terminal

$ dscl . -read /Users/user

Formatting an external disk or usb disk of size more than 32 GB as FAT32

Formatting an external disk or usb disk of size more than 32 GB is a problem ? Then use the this tool available at below link. with this tool you can format the disk of size 2TB as fat32

A GUI BASED TOOL - http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm

OR

A COMMAND LINE BASED TOOL - http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm

Resetting PRAM and NVRAM on mac

Resetting PRAM and NVRAM

1. Shut down the computer.
2. Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
3. Turn on the computer.
4. Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
5. Hold the keys down until the computer restarts and you hear the startup sound for the second time.
6. Release the keys.

Setting up kernel boot architecure in mac osx permanently without worrying about holding 32 or 64 keys during the mac system bootiing

Now you are not required to hold 32 or 64 keys on keyboard to boot the snow leopard into respective OS mode. Run the below command to set the kernel boot parameter.

sudo systemsetup -setkernelbootarchitecture i386 | x86_64

Snow leopard will boot in respective os mode from next reboot onwards.

how to set up webDAV on Mac OS X

The following is how to set up webDAV on Mac OS X

1. Start Apache Server ( Go to System Preferences > Sharing, and turn on the box labeled Web Sharing.)

2. Enable WebDAV support in Apache. Edit the file /etc/apache2/httpd.conf, (remember to use sudo to edit it) and locate this line:

LoadModule dav_module libexec/apache2/mod_dav.so
Make sure it is not commented. Then locate this line (towards the bottom of the file):
Include /private/etc/apache2/extra/httpd-dav.conf
Again, make sure it is not commented out. It is disabled by default, so you need to remove the "#" from this line.

3. Configure WebDAV.

Edit the file /etc/apache2/extra/httpd-dav.conf. Add a section as below in it to create our new WebDAV share.


Alias /webdav "/Library/WebServer/WebDAV"



Dav On
Order Allow,Deny
Allow from all
AuthType Basic
AuthName WebDAV-Realm
AuthUserFile "/usr/webdav.passwd"


require user a…

Mounting temporary filesystem in linux

The below command will mount temporary file system on your linux computer

$ mount tmpfs /mnt/tmpfs -t tmpfs

Clearing kernel cache in linux

This is about the drop_caches tunability. It's available in kernel 2.6.16 and above, and exists in /proc/sys/vm.

If you echo various values to it, various kernel cache data structures are dropped. This is a non-destructive operation, so if you still see stuff hanging out after it, it's likely that it was dirty cache. Anyhow, on to the values:

1 - drop the pagecache
2 - drop the dentry and inode caches
3 - drop both the dentry and inode caches, as well as the pagecache.


echo 3 > /proc/sys/vm/drop_caches as a root or admin user

Linux Run Levels

Runlevel Scripts Directory State
0 /etc/rc.d/rc0.d/ shutdown
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services
3 /etc/rc.d/rc3.d/ Full Multiuser with no init 5 level services
4 /etc/rc.d/rc4.d/ Reserved for local use
5 /etc/rc.d/rc5.d/ GUI
6 /etc/rc.d/rc6.d/ Reboot
s or S Single user/Maintenance mode

Linux init Process

The init process is the last step in the boot procedure and identified by process id "1". Init is responsible for starting system processes as defined in the /etc/inittab file. Init typically will start multiple instances of "getty" which waits for console logins which spawn one's user shell process. Upon shutdown, init controls the sequence and processes for shutdown. The init process is never shut down. It is a user process and not a kernel system process although it does run as root.

System Processes:

Process ID Description
0 The Scheduler
1 The init process
2 kflushd
3 kupdate
4 kpiod
5 kswapd
6 mdrecoveryd