Jul 202012

As simple and straightforward as they may seem, text files still harbor an opportunity for compatibility problems. Different operating systems have traditionally used different ways to indicate line endings (line breaks). Mac OS has traditionally used the Carriage Return character (ASCII chcracter 13, aka CR or ^M) to indicate line breaks; unix has traditionally used the Line Feed character (ASCII 10, aka LF or ^J). Since Mac OS X derives from both heritages, it winds up using a mix of the two in various contexts. But most command line utilites only understand (and produce) files with unix-style breaks.Just to make things even more fun, there’s actually a third variant: MS-DOS its successors use a carriage return followed by a line feed to indicate a line break. Few Macintosh programs will generate such files, but if you need to deal with a file that came from a PC, you’ll probably want to convert it to a more native format on the Mac.

Fortunately, it’s fairly easy to convert the formats back and forth on the command line. Here are some examples of how to transform files back and forth:

tr '\r' '\n' <macfile.txt >unixfile.txt
convert the Mac-format file macfile.txt to unix format, and save
the result as unixfile.txt. tr is a program that does character
substitution, and in this case it's simply being used to replace
CR (written \r on the command line) with LF (written \n)
throughout the file.

tr '\r' '\n' <macfile.txt | grep fnord
convert the Mac-format file macfile.txt to unix format, then use
grep to search the file for the word "fnord". (Note: grep doesn't
understand Mac-style line breaks.)

tr '\n' '\r' <unixfile.txt >macfile.txt
convert the unix-format file unixfile.txt to Mac format, and save
the result as macfile.txt.

perl -p -e 's/\r/\n/g' macfile.txt >unixfile.txt
convert the Mac-format file macfile.txt to unix format, and save
the result as unixfile.txt. This is functionally identical to the
first example, but since perl is actually a very general
programming language, it can also do some other useful things...
BTW, he -e means the program will be the next thing on the command
line ('s/\r/\n/g' - perlese for replace all \r's with \n's), and
the -p means do this for each line of the file.

perl -pi -e 's/\r/\n/g' textfile.txt
convert the file textfile.txt from Mac-style (CR) line breaks to
unix-style (LF), and replace the original file with the converted
version (that's what the -i means).

perl -pi -e 's/\r\n?/\n/g' textfile.txt
convert the file textfile.txt from Mac-style (CR) or PC-style
(CRLF) line breaks to unix-style (LF), and replace the original

perl -pi -e 's/\r\n?/\n/g' *.txt
convert all text files (or rather, files with .txt extensions)
in the current directory to unix-style breaks. Note that any that
were already in unix format will not be changed.

perl -pi -e 's/\n/\r/g' textfile.txt
convert the file textfile.txt from unix-style (LF) line breaks to
Mac-style (CR), and replace the original file. Source

Jul 202012
To read the information about a group type:

dseditgroup -o read ladmins

Or the following has the same output:

dseditgroup read ladmins

In the case of a namespace collision between two ladmins in two directory services
then the one listed highest in the Search Policy would be displayed. The

dseditgroup create -n /Local/Default -r “Local Admins2″ ladmins2

Now read the group you just created and you’ll notice that it has a GeneratedUID
and a PrimaryGroupID even though one was not specified. Let’s say you wanted to
manually assign the PrimaryGroupID so you could hide a group; you could do so with
a -i parameter and not that many want to you could also use the -g option to
manually provide a GeneratedUID. Other parameters include -u and -P for placing the
username and password into the command (ie – if you’re creating groups in LDAP), -a
if you want to use the group name as a parameter rather than just trail the command
with it, -n to define the Directory Domain node (ie – /LDAPv3/MYDOMAIN vs.
/Local/Default vs. /var/Hidden), if you wanted to place keywords or comments then
use the -k or -c respectively and encase them in doublequotes (“).

Editing group memberships:

dseditgroup -o edit -n /Local/Default -a cedge -t user ladmins

In the above command we defined the node we were editing with the -n followed by the
user we were adding to the group with the -a and then the -t for the type of object
we’re adding into the group, which is listed last. The reason that you have to put
the -t with user in there is because we could just as easily have said:

dseditgroup -o edit -n /Local/Default -a staff -t group ladmins

Which would have put a group called staff into the ladmins group (noted by the
NestedGroups attribute).

To verify membership, use the checkmember verb (insert witty Beavis and Butthead
remark here;). If su’d the following command is likely to report back with the fact
that no, root has not been added to the group; otherwise it will look at your
currently logged in account:

dseditgroup -o checkmember ladmins

But you can check and see whether my account is a member of your ladmins group with
the -m parameter on the command:
dseditgroup -o checkmember -m cedge ladmins
Now finally, since no one likes a messy Marvin, to delete our test group:

dseditgroup -o delete -n /LDAPv3/ldap.company.com -u myusername -Pmypassword extragroupdseditgroup -o delete -n /Local/Default ladmins2

Jul 192012
EXIF and GPS data on a Mac
OSX supports and reports EXIF data including GPS location data.
  Step 1. Open your image in Preview mode (default when double-clicking the image).
  Step 2. Press the "command" key and the letter "i" to Open Inspector.
  Step 3. Click the 'i' tab and select EXIF or GPS button.

You can use the 'Locate' button to view the location in Google maps.
You can copy and paste the data into a text editor.
Apr 132010
ifconfig eth0 down
ifconfig eth0 hw ether 00:1E:37:D9:31:9F
If you want to be able to do these commands with a normal user not root you will need to edit have in your /etc/sysconfig/network-scripts/ifcfg-eth0 the following line



of course it eth0 is just an example. You can do it with any other interface you need. For example with wlan0.You could add this shell script in /etc/init.d/mac_change.sh if you wish to have this MAC permanently changed with startup. To manage this on boot you need to run this command

chkconfig –add mac_change.sh


# chkconfig: 2345 99 99

ifconfig eth0 down
ifconfig eth0 hw ether 00:1E:37:D9:31:9F 

1. View Network Settings of an Ethernet Adapter

Ifconfig, when invoked with no arguments will display all the details of currently 
active interfaces. If you give the interface name as an argument, the details of 
that specific interface will be displayed.

# ifconfig eth0

eth0   Link encap:Ethernet  HWaddr 00:2D:32:3E:39:3B
inet addr:  Bcast:  Mask:
inet6 addr: fe80::21d:92ff:fede:499b/64 Scope:Link
RX packets:977839669 errors:0 dropped:1990 overruns:0 frame:0
TX packets:1116825094 errors:8 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2694625909 (2.5 GiB)  TX bytes:4106931617 (3.8 GiB)
Interrupt:185 Base address:0xdc00
2. Display Details of All interfaces Including Disabled Interfaces

# ifconfig -a
3. Disable an Interface

# ifconfig eth0 down
4. Enable an Interface

# ifconfig eth0 up
5. Assign ip-address to an Interface

Assign as the IP address for the interface eth0.

# ifconfig eth0

Change Subnet mask of the interface eth0.

# ifconfig eth0 netmask

Change Broadcast address of the interface eth0.

# ifconfig eth0 broadcast

Assign ip-address, netmask and broadcast at the same time to interface eht0.

# ifconfig eth0 netmask broadcast
6. Change MTU

This will change the Maximum transmission unit (MTU) to XX. MTU is the maximum 
number of octets the interface is able to handle in one transaction. For Ethernet 
the Maximum transmission unit by default is 1500.

# ifconfig eth0 mtu XX

7. Promiscuous mode

By default when a network card receives a packet, it checks whether the packet 
belongs to itself. If not, the interface card normally drops the packet. But in 
promiscuous mode, the card doesn’t drop the packet. Instead, it will accept all the 
packets which flows through the network card.

Superuser privilege is required to set an interface in promiscuous mode. Most 
network monitor tools use the promiscuous mode to capture the packets and to 
analyze the network traffic.

Following will put the interface in promiscuous mode.

# ifconfig eth0 promisc

Following will put the interface in normal mode.

# ifconfig eth0 -promisc