Pages

Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Friday, February 17, 2012

IP Aliasing with ifconfig (Mac)

Hi

If you want to bind another IP address to your network card, you need to do IP aliasing. It will give you many IP address for a single nic.

It will help you if you need to start two server that listen on the same ports.

For example, I need to runs two differents systems that runs on 2 differents JBoss. I need to bind each JBoss to a specific IP to prevents port collision.

Here's how to add a new IP to your Mac or Linux.

Here's my IP informations

yannlaviolette@mac:~> ifconfig
lo0: flags=8049 mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
gif0: flags=8010 mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8963 mtu 1500
ether 00:1e:c2:0a:d6:2e
inet6 fe80::21e:c2ff:fe0a:d62e%en0 prefixlen 64 scopeid 0x4
inet 10.19.140.103 netmask 0xffffff00 broadcast 10.19.140.255
media: autoselect (100baseTX )
status: active
en1: flags=8863 mtu 1500
ether 00:1e:c2:a1:91:d1
inet6 fe80::21e:c2ff:fea1:91d1%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.122 netmask 0xffffff00 broadcast 192.168.0.255
media: autoselect
status: active
fw0: flags=8863 mtu 4078
lladdr 00:1e:52:ff:fe:68:49:72
media: autoselect
status: inactive


To add a new IP, run this command: sudo ifconfig en0 alias 10.19.140.222 10.19.140.255 where 10.19.140.222 is the IP that I want to add and 10.19.140.255 is my broadcast address.


sudo ifconfig en0 alias 10.19.140.222 10.19.140.255

After the command I'm getting the following.

yannlaviolette@mac-jeanmat:~> ifconfig
lo0: flags=8049 mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
gif0: flags=8010 mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8963 mtu 1500
ether 00:1e:c2:0a:d6:2e
inet6 fe80::21e:c2ff:fe0a:d62e%en0 prefixlen 64 scopeid 0x4
inet 10.19.140.103 netmask 0xffffff00 broadcast 10.19.140.255
inet 10.19.140.222 netmask 0xff000000 broadcast 10.19.140.255
media: autoselect (100baseTX )
status: active
en1: flags=8863 mtu 1500
ether 00:1e:c2:a1:91:d1
inet6 fe80::21e:c2ff:fea1:91d1%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.122 netmask 0xffffff00 broadcast 192.168.0.255
media: autoselect
status: active
fw0: flags=8863 mtu 4078
lladdr 00:1e:52:ff:fe:68:49:72
media: autoselect
status: inactive

To remove an IP, type the following command: sudo ifconfig en0 -alias 10.19.140.222 10.19.140.255

IMPORTANT!

If you need to ping your machine, you need to add a route to told your kernel that the new address is binded to 120.0.0.1. Type the following command

sudo route add -host 10.19.140.222 127.0.0.1



Thursday, August 18, 2011

Mac -=- Removing dot underscore "._" files...

In some cases involving the Apple Double format, moving a file to a different file system will cause the prefix "._" to appear on a file name. The files "._" are invisible when you're trying to list the file even with "ls -al" but you can see them when you compress a file. 

To remove them, you can go on the root of the directory and type
find . -name '._*' -delete

In order to PERMANENTLY resolve this issue, you can however, add one of the following 2 lines of code to your .bash_profile file in your home directory:
# for Tiger OS 10.4 or earlier
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

# for Leopard OS 10.5 and later
export COPYFILE_DISABLE=true

Wednesday, July 20, 2011

Mac -=- Recursively delete .DS_Store files

Hi!

Mac OS X writes .DS_Store in every folders. If you want to delete theses files, you could use this command:


rm -rf `find . -type f -name .DS_Store`

Monday, June 6, 2011

Mac OS X -=- Disabling Dashboard Function From The Middle Mouse Button


For Dashboard - change the mouse section to either Nothing (-) or add modifier keys to the mouse click (eg. hold any combination of CommandOption, and or Shift when choosing what mouse button to use).
Screenshot of Exposé and Spaces

Monday, April 18, 2011

[RSA] Install Cicso AnyConnect on Mac OS X Snow Leopard

Hi!

There is a bug with the version of Cisco AnyConnect 2.3 that made impossible to install the VPN client on Mac OS X Snow Leopard.

To be able to install it, we must download a newer version (2.4 and later).

You can get the client by connecting to the Cisco Web Site (http://www.cisco.com/cisco/software/navigator.html) and download it. You need a username / password.

If you do not have an account on the Cisco's Web Site, you can download a copy of the software here:
at  http://unf.net/snowleopard/anyconnect-macosx-i386-2.4.0154-k9-BETA.zip


Download and install the client. After that, connect yourself to the RSA servers. The AnyConnect client will be automatically updated.

You must be ready to use AnyConnect Client with Snow Leopard.

Monday, April 11, 2011

Mac OS X -=- Installing Java 1.4 on Snow Leopard

By default, Snow Leopard does not include Java 1.4 anymore. All the Java 1.4 softlinks points to the Java 1.6 library. If you want to install Java 1.4, you must install it manually.


In the terminal: 


Get the java 1.4.2 that was included in 10.5 "leopard" and unpack

cd /tmp/
curl -o java.1.4.2-leopard.tar.gz http://icebergsofts.com/static_content/java.1.4.2-leopard.tar.gz
tar -xvzf java.1.4.2-leopard.tar.gz

Move it to your System java folder (password needed)
sudo mv 1.4.2 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2-leopard

Tell OS X that java 1.4.2 actually is java 1.4.2
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo ln -s 1.4.2-leopard 1.4.2
sudo ln -s 1.4.2 1.4

Open Java Preferences
open "/Applications/Utilities/Java Preferences.app"

Change the properties to use Java 1.4.2 32-bit by default:



Credits goes to http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard

Mac OS X -=- Installing Java 1.5 on Snow Leopard

By default, Snow Leopard does not include Java 1.5 anymore. All the Java 1.5 softlinks points to the Java 1.6 library. If you want to install Java 1.5, you must install it manually.


In the terminal: 


Get the java 5 that was included in 10.5 "leopard" and unpack

cd /tmp/
curl -o java.1.5.0-leopard.tar.gz http://icebergsofts.com/static_content/java.1.5.0-leopard.tar.gz
tar -xvzf java.1.5.0-leopard.tar.gz

Move it to your System java folder (password needed)
sudo mv 1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard

Tell OS X that java 5 actually is java 5
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo rm 1.5.0
sudo ln -s 1.5.0-leopard 1.5.0
sudo rm 1.5
sudo ln -s 1.5.0 1.5

Open Java Preferences
open "/Applications/Utilities/Java Preferences.app"

Change the properties to use Java 5 32-bit by default:



Credits goes to http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard

Friday, April 8, 2011

Mac OS X -=- Prevent Writing .DS_Store on Network Drives

If you want to prevent Mac OS X to write .DS_Store on network drives, simply write this command in a terminal.

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

After restart, OS X won't create these files anymore on shared drives.

Friday, March 25, 2011

Prevent Mac OS X to write .DS_Store on network drives

Simply enter
defaults write com.apple.desktopservices DSDontWriteNetworkStores true

in a terminal

Friday, October 29, 2010

MacOS X -=- Getting the RGB Hex value of a color

Hi!

Mac OS X have a nice tool to get the RGB value of a specific color in the screen.

To launch the application, just type the following command in Spotlight
Digital Color Meter

Wednesday, August 25, 2010

Hex viewer in console

Hi!

If you want to view the hex content of a file under Mac OS X or Linux system, you can type in a console
hexdump -C file.xml

 It will show the hex content with the corresponding characters like this

00000000  3c 3f 78 6d 6c 20 76 65  72 73 69 6f 6e 3d 22 31  |00000010  2e 30 22 20 65 6e 63 6f  64 69 6e 67 3d 22 55 54  |.0" encoding="UT|

Sunday, March 14, 2010

Mac OS X recover lost root password

If you have the password to an account that is an administrator on the system, then it is easy to recover the password using the sudo command. Open a terminal window and type:

sudo passwd root
and you will be prompted for your password (the user account that you do remember). Then you will be prompted for the new root password twice. That’s it!

The sudo command is a wonderful way to control who can do what on a system. In this case, since the user account is considered an administrator, the sudo command allows you (after confirming that you are who you say you are with the user password) to run a command as if you were root. The command we are running is passwd root which is the command to change the password for the root user.

If you do not have an administrator password, either, you can still reset the root password. Boot the system from the Mac OS X installation CD and select the Reset password option from the installer screen and follow the directions.

Source: http://www.tech-recipes.com/rx/712/mac-os-x-recover-lost-root-password/

Wednesday, February 24, 2010

BSDTar I/O redirection bug with Mac OS X Snow Leopard

Hi!

Mac OS X Snow Leopard changed the version of the "tar" utility. Instead of using GNU tar (http://www.gnu.org/software/tar/), they start to use BSDTar which have a bug. BSDTar doesn't send the standard output to the STDOUT but it sends the STDOUT output to the STDERR channel.

Snow Leopard is using BSDTar because it is faster than GNUTar see http://lists.freebsd.org/pipermail/freebsd-current/2007-March/069860.html

If you have scripts or programs that looks at STDERR, you must pay attention to this!

Tuesday, February 9, 2010

Mac OS X -=- Hex Editor

Hi!

Need an hexadecimal editor for Mac OS X? Try  HexFiend, it's free!

Yann

Monday, February 8, 2010

Mac OS X -=- Text Editor

Hi!


If you want a good software for text editing in Mac OS X, TextWrangler is your best friend! This software is stable, easy to use, and FREE!

Try it!

Yann

Friday, February 5, 2010

Enable Web Inspector in Safari

Hi!

Web Inspector is a great tool to inspect HTML components with Safari on Mac OS X. To activate it, open a terminal and type:

defaults write com.apple.Safari WebKitDeveloperExtras -bool true

To deactivate it, set the boolean flag to false.

Tuesday, January 26, 2010

MacOS X -=- Show / Hide Hidden Files

Hi!

By default, Mac OS X hides hidden files in Finder. To show hidden files in Finder, open a terminal and types.

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder


If you want to hide hidden file, replace the TRUE for FALSE in the preceding command.

MacOS X - French Canadian Keyboard Layout

Hi!

For those like me who need the French Canadian keyboard layout for your Mac, you should have noticed that Apple's French Canadian keyboard layout is not like the keyboard layout that we use in Québec. If you want this keyboard layout, you can download it here:

MacOSX_ClavierCanadienFrancais.zip

Saturday, January 23, 2010

Flushing DNS cache in Mac OS X

DNS request are usually cache, that’s good as it speeds up the lookups within the same host but sometimes we will want to clear the cache so it don’t hold the values that are no longer valid. To do that in Mac (OS Tiger and below) we used the following command:
lookupd -flushcache


However a Mac OSX 10.5 Leopard user will tell you this command did not work on their terminal. In Leopard a new command has been used to replace flushcache, so to clear DNS cache in Leopard, just type this in your Terminal and hit enter.
dscacheutil -flushcache