Wednesday, January 13, 2010

SETUID to bypass sudo everytime....

To avoid using sudo every time, you can just enable the setuid bit on the application. Do this carefully though, because it means anybody who runs the program is running it with root permissions.

Okay, here's what you do: (most of it from the Terminal)

1. First, set the owner of the program to root. With the setuid bit enabled, the program is run with the permissions of the owner.
2. Set the group to admin (assuming you're an user under admin group in mac). This way we can set it so only admin users have access to the program.
3. chmod 4750 programfilename

The chmod command alters the permission bits. In this case, here's what they represent.
4 - setuid bit enabled
7 - read, write, execute enabled for owner (root)
5 - read, execute enabled for group (admin)
0 - all other users have no access

I practically used this for WireShark which uses libpcap and /dev/bpf* (bpf : Berkley Packet Filter). To capture data user must have read and write permission to /dev/bpf*

so what I did is

# ls -l /dev/bpf*
#chmod 4750 /dev/bpf*
#chgrp admin /dev/bpf* (unfortunately there is not usermod command in MAC)

Sunday, December 27, 2009

Print Screen in Mac Book

There are few ways to do screen capture in Mac OS X.
Follow the steps below and you will be able to do a screen capture in Mac OS X.

* Switch to the screen that you wan to to do screen capture
* Hold down Apple key(aka. Command Key) + Shift + 3 and release all
* then use your mouse to click on the screen
* Done. You will see a picture file in at your desktop. That’s the screen capture picture.

You can also do a screen capture for a portion of your screen.

* Switch to the screen that you wan to to do screen capture
* Hold down Apple key (aka. Command Key) + Shift + 4 and release all key
* Now, You will see the mouse cursor will change to +
* You can start to drag your mouse to select the portion you wish to capture.
* Once finish, you will see a picture file in at your desktop. That’s the screen capture picture!

If you want to do a screen capture for a particular application window, you can follow this:-

* Switch to the screen that you wan to to do screen capture
* Hold down Apple key (aka. Command Key) + Shift + 4 and release all key
* Now, You will see the mouse cursor will change to +
* Press the space bar once
* You will see the mouse cursor change to a camera
* Now you can use the camera to select which application window to screen capture
* Once finish, you will see a picture file in at your desktop. That’s the screen capture picture!

Friday, April 17, 2009

X11 forwarding using SSH

First of all open MAC terminal and try:
MAC#ssh -X -l login-name hostname/ip-add

This command will enable X login in the remote system. If you are logged in the remote system, you can run graphical tool in the remote system. For example, say we logged in the RHEL system,

RHEL#system-config-network-gui will run the graphical network config tool over the network.

RHEL#xclock will run the graphical clock of the system remotely.


(for more info: do #man ssh )

Saturday, March 21, 2009

Is there HOME and END button on the MAC?

Of course not... but don't be panic
There are hotkeys to do the same

FUNCTION KEY + (Arrow Keys)

COMMAND KEY + (Arrow Keys)

HOME is equivalent to COMMAND + Left Arrow Key
END is equivalent to COMMAND + Right Arrow Key

Try yourself and figure out the difference...

Friday, March 13, 2009

Password protect my MAC BOOK

Because Mac OS X is based on Unix, the operating system has native support for a password-protected multiple-user environment. By default, you are required to set a single user with a password. If you have only one user created, your computer will not prompt for a user password when your computer starts. However, you may secure your computer with a password as follows:

  • From the Apple menu, select System Preferences... .
  • From the View menu, select Accounts.
  • In Mac OS X 10.5.x, at the bottom of the left panel, click Login Options. In the right panel next to "Automatic login:", select Disabled from the pull-down menu. If the Login Options are grayed out, click the padlock icon in the bottom of the preference window and authenticate to your account.
  • In Mac OS X 10.3.x and 10.4.x, at the bottom of the left panel, click Login Options, and in the right panel, uncheck Automatically log in as: . If the Login Options are grayed out, click the padlock icon in the bottom of the preference window and authenticate to your account.
  • When starting your computer, you will have to authenticate to access your account. You may also log out of your computer without restarting. From the Apple menu, select Log out... .

Saturday, March 7, 2009

Activate the ROOT USER in MAC

The root user, or superuser, is a special user account in Mac OS X that has read and write privileges throughout the file system. By default the root account is not active.

IMPORTANT: The root user can edit and delete important system files not available to normal users. To prevent damaging the system by moving or deleting important files, use extreme caution while working in the root account.

To enable the root user:
  • Open Directory Utility, located in the Utilities folder in the Applications folder.
  • Click the lock to make changes. You will need to enter an administrator name and password.
  • Choose Edit > Enable Root User.
  • Enter a secure password for the root user, then enter it again in the Verify field, and click OK.
The root user should be used only for specific administration or monitoring tasks. After completing a task as the root user, log out of Mac OS X and log back in using a normal user account.

To ensure the security and stability of your system, disable the root user when you are not using it.

For more information: Click on FINDER--> go to HELP--->type ROOT ---> it will guide you how to enable the root user

inbuilt isight camera not responding

The very first day of my MacBook.. I tried to use the webcam of my MacBook.. it wasn't working..
Finally i found the way:
Reset the PRAM

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.