Thursday, January 26, 2012

audit logs reporting on Linux

I just found out about this command today, and it is pretty sweet!

$ aureport --avc


========================================================
# date time comm subj syscall class permission obj event
========================================================
1. 11/02/2011 15:40:55 nacl_helper_boo unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 59 memprotect mmap_zero unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 denied 6001
2. 11/03/2011 11:10:39 nacl_helper_boo unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 59 memprotect mmap_zero unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023 denied 6237

The man pages has more information on the command.

Friday, January 20, 2012

Increment in bash with unary operator ++

Probably a lot of people may know this already, but I didn't... so I might as well share it:

bash-3.2$ c=1
bash-3.2$ echo $c
1
bash-3.2$ ((c++))
bash-3.2$ echo $c
2
The trick here is the ((..)) which is used in bash for arithmetic evaluations like:

echo $((1+1))

Thursday, January 19, 2012

Bypass SSH Host Key Check

Scenario:

You want to loop through a list of hosts that you may never logged in before, and having to type 'yes' for each entry can be a real pain.

for i in `cat SOME_LIST_OF_HOSTS.txt`
do
    print "$i\n"
    ssh -o 'StrictHostKeyChecking=no' $i df -Ph | awk '{print $1 " " $2}'
done 

Monday, January 16, 2012

Ctrl-p and fc in bash

When you write a multi-line shell script directly on your terminal, like:

bash-3.2$ for i in 1 2 3 4
> do
> echo $i
> done
1
2
3
4

Hit Control-p on your keyboard next, and bash will turn your multi-line script into 1 line. i.e.:

bash-3.2$ for i in 1 2 3 4; do echo $i; done
And finally, if you use the command fc afterwards, it will take the script and put it into whatever $EDITOR you have set on your shell.

Wednesday, December 14, 2011

nmap tutorial

http://olex.openlogic.com/wazi/2011/nmap-network-probing-cheatsheet/

Thursday, September 1, 2011

ssh host id changed

Don't you hate when this happens?



$ ssh some.host.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Please contact your system administrator.
Add correct host key in /home/ansilva/.ssh/known_hosts to get rid of this message.
Offending key in /home/ansilva/.ssh/known_hosts:295
RSA host key for some.host.com has changed and you have requested strict checking.
Host key verification failed.


Instead of opening known_hosts, look for line, and delete host, save file... here's what you can do:

$ ssh-keygen -R !$
ssh-keygen -R some.host.com
/home/remote/ansilva/.ssh/known_hosts updated.
Original contents retained as /home/remote/ansilva/.ssh/known_hosts.old
There we go:

$ ssh some.host.com
The authenticity of host ' some.host.com ()' can't be established.
RSA key fingerprint is XXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)?

Wednesday, August 17, 2011

Fedora 15 on Macbook Pro 8,1 (aka 2011, 13")

This is a follow up to my "Fedora 14 on Macbook Air".

First of all, I could not get Fedora 15 installed using the Live CD (32 or 64 bit). Given that I only tried the XFCE spin, as I no longer use GNOME3.

With that said, using the DVD image worked just fine. Here are the steps (recycled from my previous post):

Step 1 - Partition Drive:

On Mac OS X, use Bootcamp (under Applications -> Utilities) to re-partition the drive non-destructively. Once you select how much you want for your 'Windows' partition, tell Bootcamp you will install Windows later.

I used just a 20 Gb partition for Fedora.

Step 2 - rEFIt:

Download and install rEFIt on Mac OS X. This will allow your mac to give you a menu driven boot OS option once Fedora is installed.

Note: If you are running Mac OS X Lion (10.7.x) after you install rEFIt you may have issues booting the system. If you do, just take your Mac OS X dvd install, and use the Start Up disk utility and pick your 'Macintosh HD' as the start up disk.


Step 3 - Booting / Installing Fedora:

Reboot your Mac and hold the 'c' key to tell the computer to boot from the CD.

On your GRUB screen, hit enter to start installation.

Make sure GRUB gets installed on whatever device your /boot is mounting. Mine is /dev/sda4

Note: It seems if you run the Fedora 15 installer with network cable hooked up (and connected to the internet) it will automatically install Fedora 15 with the latest packages automatically, which was kind of cool.

Step 4 - Fixing rEFIt OS Loading:

Once you install Fedora, and reboot your Mac, rEFIt will give you the Linux option for booting, but once you choose it will fail.

Reboot again, and once you get to the rEFIt screen, pick the rEFIt shell, and run:

gptsync

That will fix it.

Step 5 - Install RPMfusion repos:

Install free and nonfree rpmfusion repos. See instructions.

Step 6 - Install ndiswrapper

yum install ndiswrapper

then you can follow these instructions:
https://help.ubuntu.com/community/MacBookPro8-1/Natty#Wireless
Sound, Video, Screen Brightness + Sound shortcuts work out of the box.

I haven't tried to set up the touchpad yet, but basic function does work out of the box as well. I will be trying these settings shortly:
https://help.ubuntu.com/community/MacBookPro8-1/Natty#Touchpad
I don't think there is anything specifically related to 'multitouch' in fedora yet, if there is feel free to leave a comment, but for now, using just the synaptics driver, you can play around with the options described in this document.

https://wiki.archlinux.org/index.php/Touchpad_Synaptics
Note: On Fedora the touchpad configuration is managed by /usr/share/X11/xorg.conf.d/50-synaptics.conf

Adding:
Option "TapButton1" "1"
Option "TapButton2" "2"
Option "TapButton3" "3"
is pretty much all I need.

Update 1:

Modifying fan speed: If your MBP is getting too hot you can update your fan speed. The min speed is set to 2000rpm by default, I run mine around 3000.

Add it to your /etc/rc.local

echo 3000 > /sys/devices/platform/applesmc.768/fan1_min
Update 2:

As requested, here's a screenshot:


Thursday, June 30, 2011

Cycle through all windows on xfce4 using alt-tab

Since I no longer use GNOME as my desktop manager, I found one setting that was bothering me a bit on xfce4. The fact that alt-tab shortcut would only cycle through the available windows of the current virtual desktop. To change this setting, do the following:

Preferences -> System Editor, then pick: xfwm4 -> general -> cycle_workspaces.

Set it to true and you are ready to go.

Friday, April 29, 2011

remove matching end or beginning of value in bash

Thanks again to Matt Woodson:

cd /root; echo ${PWD%oot}; echo ${PWD#/roo}

Friday, April 15, 2011

copy selective files while keeping directory structure

It's silly, but when push comes to shove, sometimes I get stuck on these silly little tasks:

tar -cf t.tar `find /dir -name *.sql`