RSS feed [root] /unix /weblog




login:

password:

title search:




 


Wed Jan 25 00:41:47 HKT 2012

unix



(google search) (amazon search)
second
download zip of files only

Wed Jan 25 00:42:37 HKT 2012 From /weblog/unix/script

xdotool


Simulate user input - http://pratyeka.org/fake-x-input/

(google search) (amazon search)


Wed Jan 25 00:40:32 HKT 2012 From /weblog/unix

ubuntu cheat sheet



(google search) (amazon search)


Mon Jan 16 23:55:27 HKT 2012 From /weblog/unix

filesystem


Basic info of inode - http://www.thegeekstuff.com/2012/01/linux-inodes/

Explanation of /proc filesystem - http://www.redhat.com[..]anual/ref-guide/s1-proc-directories.html

Linux file system structure - http://www.thegeekstuff.com/2010/09/linux-file-system-structure/

File system for archive files - http://linuxtoy.org/archives/avfs.html

BeOS file system, other than discuss about BeOS FS, also discussing about evolution of design of file system - http://arstechnica.com[..]rce/news/2010/06/the-beos-filesystem.ars http://arstechnica.com[..]03/past-present-future-file-systems.ars/

(google search) (amazon search)


Sun Jan 15 20:10:06 HKT 2012 From /weblog/unix

editor


Web base vim as tutorials - http://www.knowvim.com/ http://www.openvim.com/tutorial.html

History of VIM - http://arstechnica.com[..]f-productivity-vims-20th-anniversary.ars

Guide for editing text object, most already familiar with using 'w' for word editing, this blog discuss more about using 'p' for paragrahy and other related stuff. - http://blog.carbonfive.com[..]7/vim-text-objects-the-definitive-guide/

Seven habits of effective text editing , a lot of nice tip of using vim, like hlsearch , omni-completion

http://www.moolenaar.net/habits.pdf
http://video.google.com/videoplay?docid=2538831956647446078

Highlight multiple searches at the same time, each with a different color. - http://www.vim.org/scripts/script.php?script_id=479

C/C++ IDE - http://www.vim.org/scripts/script.php?script_id=213 http://blog.wuwon.id.au[..]10/vim-plugin-for-navigating-c-with.html

vimdiff tips - http://blog.objectmentor.com[..]cles/2008/04/30/vim-as-a-diff-merge-tool http://gcody.blog.ccidnet.com[..]9899-uid-36931-do-showone-type-blog.html

How to regex with line number - http://vim.wikia.com/wiki/Insert_line_numbers_2

cheat sheet of jumping around source code - http://www.faqs.org[..]inux-HOWTO/C-editing-with-VIM-HOWTO.html

Nice analysis of good programming environment - http://www.benrady.com[..]why-i-switched-from-textmate-to-vim.html

Creating macros in vim - http://smartic.us/2010/02/03/creating-macros-in-vim

http://www.markhneedham.com/blog/2010/12/27/vim-learnings-so-far/ <- introduction to Command-T and FuzzyFinder

Some VIM tips:

Essential Vim editor navigation commands
Vim search and replace – 12 powerful find and replace examples.
How To add bookmarks inside the Vim editor
How To record and play inside the Vim editor
Correct spelling mistakes automatically inside the Vim Editor
Automatic word completion using Ctrl-X
Enable thesaurus option in the Vim editor
Vim autocommand magic. Add custom header to your files automatically.
Convert Vim editor to a beautiful source code browser.
Use the Vim editor as a bash IDE, or C/C++ IDE, or Perl IDE.

http://www.thegeekstuff.com/2010/04/vim-editor-tutorial/

ctrl+w, ctrl+w , vimdiff switch folder - hack2live.blogspot.com/2009/02/vimdiff-shortcut-keys.html

tutorial - http://javarevisited.blogspot.com[..]editor-in-unix-example-tutorial-and.html

Compilation plugin - http://www.vim.org/scripts/script.php?script_id=3115#2.9.3

(google search) (amazon search)


Mon Jan 09 21:25:35 HKT 2012 From /weblog/unix

reference


A very nice sectioned list of unix command - http://en.wikipedia.org/wiki/List_of_Unix_programs

Backup a list of directories - http://linuxintegrators.com/acoliver/code/?permalink=x-0272.html

A quick reference - http://www.cs.usfca.edu/~parrt/course/601/lectures/unix.util.html

Tuning cheat sheet - http://www.performancewiki.com/linux-tuning.html

Common and difference between systems - http://www.thegeekstuff.com/2012/01/linux-unix-kernel/

(google search) (amazon search)


Wed Dec 21 21:28:18 HKT 2011 From /weblog/unix

Linux


How to get the system thread version - getconf GNU_LIBPTHREAD_VERSION http://groups.google.com[..]wse_thread/thread/81ff4b5d1ea3372d?hl=en

How to prevent module getting load, by edit /etc/modprobe.d/blacklist.conf : http://www.basshero.org/62/how-to-disable-devices-in-ubuntu/

Standard Linux error code - http://www.thegeekstuff.com/2010/10/linux-error-codes/

http://www.thegeekstuff.com[..]11/03/linux-performance-monitoring-intro

Discussion about why Linux is way faster than Windows for huge number of small file processing - http://stackoverflow.com[..]s-to-go-as-fast-as-linux-for-compiling-c http://games.greggman.com/game/why-is-windows-so-slow/

(google search) (amazon search)


Wed Nov 23 20:46:47 HKT 2011 From /weblog/unix

tracing


If we like to trace process detail flow, system call and file opened - http://www.ussg.iu.edu/UAU/advcomm/truss.html http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?truss+1


-l Includes the id of the responsible lightweight process
(LWP) with each line of trace output. If -f is also
specified, both the process-id and the LWP-id are
included.



If the process hang and we like to check why, can try pstack - http://www.google.com[..]=pstack&sourceid=opera&ie=utf-8&oe=utf-8

Check where is the core dump to - http://groups.google.com[..]s/browse_thread/thread/9f46dfb277c72cc8#

Use gcore to generate coredump for running process - http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=gcore

If we like to check the which process id using which port, we can use lsof or "pfiles /proc/*"
1) save the output of "pfiles /proc/*" to a file
2) grep the file for that port, then find the PID, e.g., say here is the part of the output:

5859: java -Djava.awt.headless=true -DX_R_BRGD -Xms512M -Xmx1024M -Djava.io.
Current rlimit: 1024 file descriptors
0: S_IFCHR mode:0666 dev:85,0 ino:980953 uid:0 gid:3 rdev:13,2
O_RDONLY|O_LARGEFILE

....... ( 125 FD after) ......

125: S_IFSOCK mode:0666 dev:313,0 ino:40404 uid:0 gid:0 size:0
O_RDWR
sockname: AF_INET 10.152.22.22 port: 18075
peername: AF_INET 169.19.21.63 port: 41792

Then PID 5859 is the process working with the port 18075, however, it only work for process which is viewable according to your permission setting

If we like to check the which process id using which file, we can use fuser - http://linuxcommand.org/man_pages/fuser1.html

Check host and port that any process accessing using lsof - http://www.geekology.co.za[..]-are-accessing-internet-on-unix-machine/

How do I monitor or view the thread count of a certain process - ps -o pid,comm,user,thcount -p - http://superuser.com[..]thread-count-of-a-certain-process-on-aix

Examples of using strace, use -e to trace function call is useful - http://www.thegeekstuff.com/2011/11/strace-examples

(google search) (amazon search)


Sun Nov 13 02:40:59 HKT 2011 From /weblog/unix

network


TCP tuning - http://rodrickbrown.com/blog/?p=127

UNIX network performance analysis - http://www.ibm.com[..]works/aix/library/au-networkperfanalysis

Netstat tips - http://www.thegeekstuff.com/2010/03/netstat-command-examples/

Introduction to a lot of difference commands - http://tech.varghees.com[..]work-monitoring-commands-in-linux-part-i

Commandline tools which can do most HTTP message - http://www.thekua.com[..]11/scripting-web-applications-with-curl/

(google search) (amazon search)


Fri Nov 04 23:10:15 HKT 2011 From /weblog/unix

media


Use GIMP for serverside scripting: http://www.google.com/search?q=gimp+script+fu+server

Call GIMP from java - http://jroller.com[..]anic?entry=calling_gimp_from_within_java

Linux Music workflow - http://createdigitalmusic.com[..]rom-mac-os-x-to-ubuntu-with-kim-cascone/

Write / Create Image from DVD disc - http://www.yolinux.com/TUTORIALS/LinuxTutorialCDBurn.html

(google search) (amazon search)


Fri Nov 04 23:09:22 HKT 2011 From /weblog/unix

operation


An article to share how to organizate files as well as daily task, his approach is difference from me, but still worth to take a look

http://www.onlamp.com/lpt/a/6377

In contrast to the author experience, categories work for me. Spotlight or google desktop doesn't add value, I can just find it.

(google search) (amazon search)


Tue Nov 01 00:57:28 HKT 2011 From /weblog/unix

openoffice


An example of how to do document convertion in batch at shell using openoffice: http://www.xml.com[..]/01/11/from-microsoft-to-openoffice.html

Tip for calc for libreoffice - http://www.thegeekstuff.com/2011/10/openoffice-calc-tips

(google search) (amazon search)


Sat Oct 22 00:34:26 HKT 2011 From /weblog/unix

shell


Sum time in script - http://www.markhneedham.com[..]-summing-the-total-time-from-a-log-file/

Special bash parameters - http://javarevisited.blogspot.com[..]ial-bash-parameters-in-script-linux.html

ls sort by file size - http://www.unix.com[..]ns-answers/6518-sorting-ls-filesize.html

How to use "~" - http://www.thegeekstuff.com/2010/06/bash-tilde-expansion

Few examples of how to use grep - http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators

use rlwrap to enable BASH like editing in SQLplus, and use screen to presist terminal sessions - http://binkley.blogspot.com[..]miracle-utilities-rlwrap-and-screen.html

Ctrl+r searches through history
Use the history command plus !# to run old commands
Shell expansion using {} , e.g. cp foo.sh{,.old} == cp foo.sh foo.sh.old
zsh have good auto complete

http://www.pgrs.net/2007/9/6/useful-unix-tricks

mkdir -p creates nested directories
Use less instead of tail
lsof shows open files
ps will show process trees with the f flag

http://www.pgrs.net/2007/10/8/useful-unix-tricks-part-2

!! is the previous command in the shell history
Use vim -b to show nonprintable characters
** is a recursive wildcard in zsh
cd – will return to the previous folder
Use ctrl+z and kill %1 to kill a process that will not die
pwdx shows the working directory of a process
Use sh -x to debug shell scripts
sysctl replaces /proc on macs

http://pgrs.net/2009/2/20/useful-unix-tricks-part-3

ps -eo pcpu,pid,args | sort -n => check CPU%
grep -sq "" /etc/lsb-release && lsb_release -rd => run command if file exist

More about ps and free - http://www.thegeekstuff.com/2010/07/3-shell-scripts/

HTML tools for commandline - http://www.macdevcenter.com/lpt/a/6343

Bash history - http://www.talug.org/events/20030709/cmdline_history.html

(google search) (amazon search)


Sat Oct 08 19:01:24 HKT 2011 From /weblog/unix/script

sed


http://www.catonmat.net/blog/worlds-best-introduction-to-sed/

(google search) (amazon search)


Thu Oct 06 08:48:34 HKT 2011 From /weblog/unix

monitoring


htop, look much better than top - http://nerds-central.blogspot.com[..]ght-no-i-am-loving-htop-it-is-linux.html http://www.thegeekstuff.com/2011/09/linux-htop-examples

Tutorial of both lsof and pstack - http://myhowto.org[..]ternals-with-lsof-and-strace/#strace_run

Tutorial of SAR - http://www.thegeekstuff.com/2011/03/sar-examples . In Solaris, you can check SAR from previous days using "sar -f /var/adm/sa/sa30 " ( last 30th )

If we like to see the detail from "ps" command:
solaris: /usr/ucb/ps -awwx
linux: ps -aef --cols [XXXX]
prstat - use prstat instead of ps in solaris http://developers.sun.com/solaris/articles/prstat.html
How to check physical memory on solaris? /usr/sbin/prtconf | grep Memory http://www.dbapool.com/faqs/Q_116.html

Other forensics tools - http://www.forensicfocus.com[..]om/computer-forensics-software-intro.php

Sun monitoring tools collections - http://blogs.sun.com[..]try/solaris_performance_monitoring_tools http://tech.varghees.com[..]sed-system-monitoring-commands-in-linux/



(google search) (amazon search)


Sat Sep 03 11:37:14 HKT 2011 From /weblog/unix/script

sort


Sort by column - http://javarevisited.blogspot.com[..]/unix-sort-command-example-tutorial.html

(google search) (amazon search)


Thu Aug 25 02:16:44 HKT 2011 From /weblog/unix/script

webserver


Create webserver with nc using bash

http://www.linuxscrew.com[..]07/09/06/web-server-on-bash-in-one-line/
http://paulbuchheit.blogspot.com/2007/04/webserver-in-bash.html

(google search) (amazon search)


Mon Aug 15 00:29:18 HKT 2011 From /weblog/unix

hardware


Power save tool - http://www.ubuntugeek.com[..]er-saving-package-for-linux-systems.html

Disk usage report - http://www.ubuntugeek.com[..]usage-and-availability-report-tools.html

USB info at /var/log/messages

Oct 20 03:56:14 carfield kernel: [ 3568.521099] usb 1-6: configuration #1 chosen from 1 choice
Oct 20 03:56:14 carfield kernel: [ 3568.557038] Initializing USB Mass Storage driver...
Oct 20 03:56:14 carfield kernel: [ 3568.557228] scsi4 : SCSI emulation for USB Mass Storage devices
Oct 20 03:56:14 carfield kernel: [ 3568.557407] usbcore: registered new interface driver usb-storage
Oct 20 03:56:14 carfield kernel: [ 3568.557429] USB Mass Storage support registered.
Oct 20 03:56:19 carfield kernel: [ 3573.557428] scsi 4:0:0:0: Direct-Access BUFFALO USB Flash Disk 4000 PQ: 0 ANSI: 0 CCS
Oct 20 03:56:19 carfield kernel: [ 3573.559904] sd 4:0:0:0: [sdc] 7864320 512-byte hardware sectors: (4.02 GB/3.75 GiB)
Oct 20 03:56:19 carfield kernel: [ 3573.560766] sd 4:0:0:0: [sdc] Write Protect is off
Oct 20 03:56:19 carfield kernel: [ 3573.562913] sd 4:0:0:0: [sdc] 7864320 512-byte hardware sectors: (4.02 GB/3.75 GiB)
Oct 20 03:56:19 carfield kernel: [ 3573.563765] sd 4:0:0:0: [sdc] Write Protect is off
Oct 20 03:56:19 carfield kernel: [ 3573.563772] sdc: sdc1


(google search) (amazon search)


Wed Aug 03 01:15:56 HKT 2011 From /weblog/unix

path


common log files - http://www.thegeekstuff.com/2011/08/linux-var-log-files

(google search) (amazon search)


Tue Jul 12 01:11:20 HKT 2011 From /weblog/unix/script

loop


http://www.thegeekstuff.com/2011/07/bash-for-loop-examples/

(google search) (amazon search)


Thu Jul 07 23:54:28 HKT 2011 From /weblog/unix/script

useful example of shell script


xmlwf, need to know if a XML document is well formed? (A configuration file maybe..)
mkfifo is the coolest one. Sure you know how to create a pipeline piping the output of grep to less or maybe even perl.
nl, add number for every line of a file

http://bashcurescancer.com[..]/10-linux-commands-youve-never-used.html

http://www.thegeekstuff.com/2010/11/50-linux-commands/

======================================create real player song list
#!/bin/sh
win_path=C:/tools
linux_path=/mnt/disk/winapp
for file in `find $1 -type f`;
do
if(`/bin/cat $file | grep $win_path`); then echo $file;fi;
done;
/usr/bin/find $MUSIC_SRC -type f -exec /bin/echo file://{} \; > $TMPDIR/tmp.rm
while read i ; do /bin/echo "$RANDOM $i" ; done < $TMPDIR/tmp.rm | /bin/sort -n | /bin/sed 's/^[0-9]* //' > $TMPDIR/tmp1.rm
/bin/cat $TMPDIR/tmp1.rm |/bin/sed -e 's/file:\/\///' >$HOME/mplayer.list
/bin/cat $TMPDIR/tmp1.rm |/bin/grep -vi wma >$HOME/real.rm
/bin/cat $TMPDIR/tmp1.rm |/bin/sed -e 's/file:\/\/\/var\/www\/html/http:\/\/www.carfield.com.hk/'>/var/www/html/.secure/media/music/live.rm

======================================remove log
for file in `find -type f|grep website.|grep -v lck`;do rm -f $file;done
======================================for loop
for((a = 1; a <10; a++)); do wget -b "http://www.thai.net/ferrari545/bbs_series/ku_bbs_000$a.jpg";done
======================================resize photo
for i in *.jpg; do convert -geometry 1024x768 $i newdir/$i ; done
======================================basic calculation
i=1;find|grep -v zng|grep -v avi|while read file;do mv "$file" $i.jpg;i=$((i+1));done
======================================# Make 3 a copy of 1 (stdout)
exec 3>&1
result="$(command to generate stream \
| tee /dev/fd/3 \
| command to process stream)"
# Now work with $result
# The original stream also went to the console

http://binkley.blogspot.com[..]5/getting-more-from-streams-in-bash.html


(google search) (amazon search)


Sun May 29 01:36:21 HKT 2011 From /weblog/unix

ssh


Using SSh tunneling at RMI - http://blogs.sun.com[..]alventosa?entry=using_the_ssl_tls_based1

Use sshd as proxy - http://rudygems.com/post/569787317/ssh-d-is-your-friend

http://www.thegeekstuff.com/2011/05/openssh-options

(google search) (amazon search)


Sun May 29 01:25:49 HKT 2011 From /weblog/unix

performance


Few config suggestions - http://blog.monitis.com[..]20-linux-server-performance-tips-part-2/

(google search) (amazon search)


Mon Mar 21 10:57:59 HKT 2011 From /weblog/unix/script

find example


An question about how to remove unused package from MacOSX turn out to be an example of "find" command:

http://forums.osxfaq.com/viewtopic.php?p=57887#57887
http://www.osxfaq.com/tips/unix-tricks/week98/tuesday.ws
http://javarevisited.blogspot.com[..]find-command-in-unix-examples-basic.html

File Search tips in Linux - http://discuss.joelonsoftware.com[..]iscussTopicParent=18272&ixDiscussGroup=3

Another search tip, example of find base on time and size, and how to compare with other files - http://viralpatel.net[..]e-useful-unix-file-finding-commands.html

(google search) (amazon search)


Wed Mar 16 21:22:12 HKT 2011 From /weblog/unix

backup


Reference of rsync - http://www.thegeekstuff.com/2010/09/rsync-command-examples

Backup the package list - http://radio.javaranch.com/davo/2011/03/09/1299682981215.html

(google search) (amazon search)


Tue Feb 08 00:47:36 HKT 2011 From /weblog/unix

boot


Linux Boot Process - http://www.thegeekstuff.com/2011/02/linux-boot-process

if you want to boot into something you can edit the boot parameters in grub:

"e" to edit
replace the boot parameters from ro xxxx xxxx to "rw init=/bin/bash"

and you'll be able to access a limited shell (no job control), then can run

ifconfig eth0 up
dhclient

to bring up network.

https://bugs.launchpad.net/ubuntu/+bug/430272/comments/24

If there is really disaster situation that grub fail, can try this to reinstall grub:


sudo mount /dev/sdXx /mnt
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /sys /mnt/sys
sudo mount -o bind /proc /mnt/proc
sudo chroot /mnt

Once at the prompt I reinstall grub:

Code:
grub-install /dev/sda
and then updated grub

Code:
update-grub
then Ctrl-D twice to exit, and reboot. http://ubuntuforums.org/showthread.php?t=1677888

(google search) (amazon search)