Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, July 23, 2016

mancinglog.sh

berguna untuk mencari korelasi antara ip address / file di access.log
------------------------------------------------------------------------------------
start script
------------------------------------------------------------------------------------

#!/bin/bash
logpath=/var/log/nginx/access.log
ARRAY=()
getip=()
getfile=()

function getfiles {
        echo "getfiles param " ${getip[@]}
        pat=$(echo ${getip[@]}|tr " " "|")
        getfile+=($(grep -Ew $pat $logpath| cut -f 7 -d " " | sort | uniq))
        uniqf=($(printf "%s\n" "${getfile[@]}" | sort | uniq -c | sort -rnk1 | awk '{ print $2 }'))
        unset getfile
        getfile=("${uniqf[@]}")
        printf "%s\n" "${getfile[@]}" > files.txt
        echo "getfiles result " ${getfile[@]}
        getips
}



function getips {
        echo "getips param " ${getfile[@]}
        pat=$(echo ${getfile[@]}|tr " " "|")
        getip+=($(grep -Ew $pat $logpath| cut -f 1 -d " " | sort | uniq))
        uniqi=($(printf "%s\n" "${getip[@]}" | sort | uniq -c | sort -rnk1 | awk '{ print $2 }'))
        unset getip
        getip=("${uniqi[@]}")
        printf "%s\n" "${getip[@]}" > ips.txt
        echo "getips result "${getip[@]}
        getfiles
}

getfile=( `cat "files.txt"` )
getip=( `cat "ips.txt"` )
#getips $1
getfile+=($1)
getips

Tuesday, June 23, 2015

fix locale

fix locale on some python or another script that locale-sensitive
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
 taken from:
http://askubuntu.com/questions/205378/unsupported-locale-setting-fault-by-command-not-found

Saturday, January 31, 2015

sha512sum

to generate recursively:
find . -type f -exec sha512sum {} \; > sha512sum-${PWD##*/}

to check:
sha512sum -c sha512sum-${PWD##*/} | grep -i fail

ps.: "${PWD##*/}" is only the directory name, like: "pwd | rev | cut -d / -f1 | rev"

from:
http://www.shell-fu.org/lister.php?id=850

Tuesday, June 17, 2014

InnoDB: Completed initialization of buffer pool InnoDB: Error: checksum mismatch in data file ./ibdata1

untuk menangani:
131104 11:17:16 InnoDB: Completed initialization of buffer pool InnoDB: Error: checksum mismatch in data file ./ibdata1 131104 11:17:16 InnoDB: Could not open or create data files
maka dilakukan
mysqld_safe  --innodb_force_recovery 4
diambil dari 
http://lifeandshell.com/mysql-innodb-error-checksum-mismatch/

Saturday, January 18, 2014

Finding out largest tables on MySQL Server

mysql> SELECT CONCAT(table_schema, '.', table_name),
    ->        CONCAT(ROUND(table_rows / 1000000, 2), 'M')                                    rows,
    ->        CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G')                    DATA,
    ->        CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G')                   idx,
    ->        CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
    ->        ROUND(index_length / data_length, 2)                                           idxfrac
    -> FROM   information_schema.TABLES
    -> ORDER  BY data_length + index_length DESC

    -> LIMIT  10;

taken from: http://www.mysqlperformanceblog.com/2008/02/04/finding-out-largest-tables-on-mysql-server/

Sunday, January 05, 2014

rapalan mysql akbar :D

mysqlcheck --all-databases -r #repair
mysqlcheck --all-databases -a #analyze
mysqlcheck --all-databases -o #optimize

Friday, January 25, 2013

serba serbi perintah find

touch -t "20121120" /tmp/start
touch --date "2012-12-15" /tmp/end
find -type f -newer /tmp/start -not -newer /tmp/end

Monday, September 10, 2012

Tuesday, July 03, 2012

Mounting partitions from full-disk 'dd' images

Forensics: Mounting partitions from full-disk 'dd' images

Published: 2009-08-18,
Last Updated: 2009-08-19 00:26:36 UTC
by Daniel Wesemann (Version: 1)
3 comment(s)
If you are, as I am, a GCFA who attended Rob Lee's famous training in the not-so-recent past, you probably still are "carving out" partitions from within an acquired full disk "dd" image by running it through another "dd". Given how quickly the disk sizes are increasing, this is highly inefficient both in terms of disk space and analyst time used.
But there's a better way. You already know how to use "loopback mount" on Linux to mount an image? Well, loopback mount supports an "offset" parameter that lets you mount a partition directly from within a larger full-disk image. Thusly:

root@ubuntu:/media/disk-1# ls -al
total 39082701
drwxrwxrwx 1 root root 4096 2009-07-12 13:33 .
drwxr-xr-x 4 root root 4096 2009-08-18 19:04 ..
-rwxrwxrwx 1 root root 878 2009-07-07 11:46 fdisk
-rwxrwxrwx 1 root root 701 2009-07-07 11:47 hdparm
-rwxrwxrwx 2 root root 40020664320 2009-07-07 14:34 image-sda
-rwxrwxrwx 1 root root 43 2009-07-07 12:02 md5sum
-rwxrwxrwx 1 root root 43 2009-06-29 13:13 md5sum-sda
drwxrwxrwx 1 root root 0 2009-07-11 19:03 $RECYCLE.BIN
root@ubuntu:/media/disk-1# fdisk -ul image-sda
You must set cylinders.
You can do this from the extra functions menu.

Disk image-sda: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x9c879c87

Device     Boot Start End      Blocks    Id System
image-sda1 *    63    78140159 39070048+ 7  HPFS/NTFS
Partition 1 has different physical/logical endings:
phys=(1023, 254, 63) logical=(4863, 254, 63)

root@ubuntu:/media/disk-1# mount -o ro,loop,offset=32256 -t auto image-sda /media/image
root@ubuntu:/media/disk-1# cd ..
root@ubuntu:/media# cd image
root@ubuntu:/media/image# ls
AUTOEXEC.BAT favorites ntldr Start Menu blp INFCACHE.1 pagefile.sys System Volume Information boot.ini IO.SYS Program Files temp

CONFIG.SYS MSDOS.SYS RECYCLER WINDOWS Documents and Settings NTDETECT.COM spoolerlogs
root@ubuntu:/media/image#


The magic "32256" offset passed to "mount" is easily explained as the start of the partition you are interested in (63 in this case) multiplied by the unit size (512 in this case).  If you have more than one partition, just repeat the above steps for the other slices.
There you go. This easily saves several hours and untold gigabytes of disk space compared to the GCFA "carving out" method.

taken from: https://isc.sans.edu/diary.html?storyid=6991

Sunday, March 18, 2012

BADSIG Cure

Try deleting the key
sudo apt-key del 16126D3A3E5C1192
then updating the repository
sudo apt-get update
You should get a NO_PUBKEY error instead of a BADSIG error and
sudo apt-key finger
should not find the key (called "Ubuntu Extras Archive Automatic Signing Key")
Now add the key
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16126D3A3E5C1192
The result of apt-key finger should have
pub   1024D/3E5C1192 2010-09-20
      Key fingerprint = C474 15DF F48C 0964 5B78  6094 1612 6D3A 3E5C 1192
uid                  Ubuntu Extras Archive Automatic Signing Key 

If that does not work, try
apt-get clean            # Remove cached packages
cd /var/lib/apt
mv lists lists.old       # Backup mirror info
mkdir -p lists/partial   # Recreate directory structure
apt-get clean
apt-get update           # Fetch mirror info
Source: this ubuntu forums thread
linkimprove this answer

Wednesday, March 07, 2012

search and replace n occurrence with awk

awk '/Jack/{c++;if(c==2){sub("Jack","Rob");c=0}}1' file

Friday, February 24, 2012

Convert and resize picture with imagemagick

for img in *.jpg; do
base=`basename $img .jpg`
echo $base;
convert -resize 640x480 "$img" "$base.png"
done

Wednesday, December 21, 2011

love in mathematic with gnuplot

yusuf81@yusuf81-desktop:~$ gnuplot

    G N U P L O T
    Version 4.4 patchlevel 2
    last modified Wed Sep 22 12:10:34 PDT 2010
    System: Linux 2.6.38-13-generic

    Copyright (C) 1986-1993, 1998, 2004, 2007-2010
    Thomas Williams, Colin Kelley and many others

    gnuplot home:     http://www.gnuplot.info
    faq, bugs, etc:   type "help seeking-assistance"
    immediate help:   type "help"
    plot window:      hit 'h'

Terminal type set to 'wxt'
gnuplot> set xrange [-2:2]
gnuplot> set yrange [-2:2]
gnuplot> set samples 10000
gnuplot> set title "Love in MATH"
gnuplot> plot (sqrt (cos (x)) * cos (200 * x) + sqrt (abs (x)) -0.7) * (4-x * x) ** 0.01
gnuplot>


Enhanced by Zemanta

Monday, December 05, 2011

Andjoeran Pengoeasa, "GIATLAH MEMBATJA"

In linux, comprehensive manual always exist, in example just simply type "man find", then you will enlighted how to find your pr0n file that had size twenty megs or more. 

Before you play and mess the code/installation and anything, please put your eyes to at least 5 tutorial. Don't stick only with 1 tutorial. Why more tutorial is better?, because more tutorial will give you different angle of perspective.

And remember all error message always explain why and where you did something wrong. The place for error sometimes buried in dmesg, /var/log/syslog or /var/log/messages. When you got those messages, simply copy paste it to google will yield the answer.

You will get more bright information with that way, than you asking the questions to the old man with rusty brain and dirty mouth like me :P. This isn't because  me and those old bags down here is lazy nor feel 3l33t, but this is not how the good discussion flow. It's already said, one of the old bags (@Bino Oetomo) tell that he crawl google through 20 pages, when he got some error or problem. I and I not crazy as that old bags, I just crawl first 5 pages, then redefine the keyword with proper keywords.

And after you do that ways, but still had no enlightenment, then you can floor it to this playground. Tell the action that you already did, and the proper documentation that you already read. I or maybe another guys will happily discuss it, and good discussion will flow. This is what we call "sama-sama belajar, belajar bersama-sama" (I'm not translate this, because this idiom seems moronic when it's said with another langs). 

Almost forgot something, you must had the vision and clearly know what are you doing. Sometimes the tutorial is does in different environment and different purpose, you must adjust it manually.

And last one, please understand this fucking language. No exception for this, because this moronic things (I mean this poor operating system, yes I talking about this damn OS), build in the western world, not from magelang, situbondo, kendal payak or another place in this island. This fact that we must admitted. So goods articles or howtos will came from their language.  

PS: If you cannot understand this article, please get your ass to bookshop and buy some oxford dicts, burn it, put it on a glass of water, and drink it with single shots, after that, we will meet in another side :)).

Tuesday, November 22, 2011

USB modem, networkmanager dan native networking stack

Gini lho ceritanya, orang2 itu kadang pada bingung menggunakan modem usb bawaannya provider gsm dan evdo di ubuntu, dan solusi nya selalu menggunakan wvdial yang dalam hal ini helper untuk setting native stack networking, padahal saya menggunakan networkmanager  bawaannya gnome/ubuntu selalu berhasil. Yang jadi pertanyaan, apanya yang salah? kukur2.

Native stack networking/tcp-ip.
Ini adalah mekanisme inisialisasi network paling kuno. Di setiap distro utama (redhat,slackware,debian) tempatnya berbeda-beda.
Kalo di slackware kalo gak salah ada di /etc/rc.network (kalo gak salah), soalnya slackware ngambil model konfigurasi ala bsd.
Kalo di redhat ada di /etc/sysconfig/network-scripts/ifcfg-device dan di /etc/sysconfig/network
Kalo di debian ada di /etc/network/interfaces
Setting dns ada di /etc/resolv.conf baik untuk debian, redhat maupun slackware (ini gara2 semua menggunakan libc/glibc).

Sunday, October 09, 2011

fix GPG key missing

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com [key-fingerprint]

lightweight ubuntu versi network_pirates

  1. Install ubuntu dengan cd alternate dan jangan pilih package apapun.
  2. install xorg lxde lxdm openoffice network-manager libasound2-plugins "pulseaudio-*" paman padevchooser paprefs pavucontrol pavumeter pidgin openntpd iptraf iptables iproute ifstat
  3. edit /etc/xdg/ untuk menampilkan network manager applet
  4. selesai :P

Monday, September 26, 2011

Bug direct3d / opengl pada wine

jika sampeyan main DotA pake wine, terus menggunakan wine versi ini:

yusuf81@yusuf81-desktop:/opt/DotA$ wine --version

wine-1.3.28

terus mengalami warning message seperti ini:

err:d3d:swapchain_blit >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from Swapchain present blit(EXT_framebuffer_blit)

 @ swapchain.c / 334

err:d3d:swapchain_blit >>>>>>>>>>>>>>>>> GL_INVALID_OPERATION (0x502) from Swapchain present blit(EXT_framebuffer_blit)

 @ swapchain.c / 334

fixme:d3d:resource_check_usage Unhandled usage flags 0x8.

fixme:d3d:resource_check_usage Unhandled usage flags 0x8.

fixme:d3d:resource_check_usage Unhandled usage flags 0x8.

dan game hanya berjalan di mode windowed (wine w3l.exe -window) dan/atau harus berjalan pada resolusi yang sama dengan xwindows. 
Terus pas ngegame jalannya game nggembot dan setelah di cek, kelihatannya seluruh proses dilakukan di prosesor, dan prosesor vga, kelihatannya nganggur.
Jika sampeyan mengalami hal-hal tersebut, maka sampeyan semua apes. 
Tunggu saja update wine yang anyar, atau downgrade ke versi yang lama. 
Yang jelas wine versi sebelum ini lancar jaya dan aman. Saya saja yang sok gaya pake repository wine dilaunchpad, terus jadinya keblusuk seperti ini.

NB: Untuk langganan versi wine yang lucu ini (lebih cepet dari standard repository ubuntu, namun dengan resiko gak stabil), silahkan ikuti jejak saya dengan mengetik:
sudo echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu natty main" >> /etc/apt/source.list

sudo apt-get update && apt-get upgrade

Namun ingat, segala resiko silahkan ditanggung sendiri

Sekian, Wassalam

[mangkel gara2 gak bisa main dota]

Sunday, September 11, 2011

perintah tunnel ssh

ssh -p 443 -D 1080 -N -f

Saturday, September 03, 2011

wodim dan geniso bento

poro hadlirin penikmat linux yang berbahagia, jangan pakai geniso dan wodim bawaannya debian. Itu package yang bento, pakailah mkisofs dan cdrecord aseli dari brandonsnider di ppa:brandonsnider/cdrtools. Hal ini pernah diulas oleh saudara walecha99 tapi baru hari ini saya melihat bukti dari ke bento an itu.
Sekian