sed '/s/replace old/replace new/'
스트림이니까, 파이프로 연결해도 당연히(?!) 된다.

[링크 : http://www.grymoire.com/Unix/Sed.html]
Posted by 구차니
awk의 가장 유용한 사용방법은
awk '{print $1}' 가 아닐까 생각이 된다.
일단 1번부터 시작하여 n 번째의 문자열을 출력해주며
문자열은 공백으로 구분한다.

예를 들어
/proc/cmdline의 경우
$ cat /proc/cmdline
ro root=/dev/VolGroup00/LogVol00 rhgb quiet

인데 awk를 사용할 경우
$ cat /proc/cmdline | awk '{print $1}'
ro
$ cat /proc/cmdline | awk '{print $2}'
root=/dev/VolGroup00/LogVol00
$ cat /proc/cmdline | awk '{print $3}'
rhgb
$ cat /proc/cmdline | awk '{print $4}'
quiet
$ cat /proc/cmdline | awk '{print $5}'

이런식으로 구분을 하여 옵션별로 떼어낼 수 있다.


$ cat /proc/cmdline | awk '{print NF}'
4
NF는 내부 변수로 컬럼의 갯수를 알려준다.


[링크 : http://www.grymoire.com/Unix/]
Posted by 구차니
프로그램 사용/busybox2009. 7. 30. 17:24

#!/bin/sh

/bin/run-parts --arg=$1 /etc/udhcpc.d

[링크 : http://www.doit.org/udhcpc/udhcpc.script]

#!/bin/sh
# /etc/init.d/udhcpc: start or stop udhcpc client

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/sbin/udhcpc

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting DHCP client: udhcpc"
    start-stop-daemon --start --quiet --exec $DAEMON \
      -- --script=/etc/udhcpc.script || echo -n " already running"
    echo "."
  ;;

  restart)
    /etc/init.d/udhcpc stop
    /etc/init.d/udhcpc start
  ;;

  reload)
  ;;

  force-reload)
  ;;

  stop)
    echo -n "Stopping DHCP client: udhcpc"
    start-stop-daemon --stop --quiet --exec $DAEMON || echo -n " not running"
    echo "."
  ;;

  renew)
    start-stop-daemon --signal USR1 --stop --quiet --exec $DAEMON || echo -n " not running"
  ;;

  release)
    start-stop-daemon --signal USR2 --stop --quiet --exec $DAEMON || echo -n " not running"
  ;;

  *)
    echo "Usage: /etc/init.d/udhcpc {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0

[링크 : http://www.doit.org/udhcpc/udhcpc]

[링크 : http://www.doit.org/udhcpc/]
Posted by 구차니
프로그램 사용/busybox2009. 7. 30. 13:16
menu 'Build Options'

config CONFIG_STATIC
    bool "Build BusyBox as a static binary (no shared libs)"
    default n
    help
      If you want to build a static BusyBox binary, which does not
      use or require any shared libraries, then enable this option.
      This can cause BusyBox to be considerably larger, so you should
      leave this option false unless you have a good reason (i.e.
      your target platform does not support shared libraries, or
      you are building an initrd which doesn't need anything but
      BusyBox, etc).

      Most people will leave this set to 'N'.

[링크 : http://stablebox.googlecode.com/svn/trunk/Config.in]

비지박스를 컴파일 하면, 용량이 생각보다 크다.
이 경우에는 위의 옵션을 꺼주면 컴팩트해진다.

1.10.4 기준으로 1.6M에서 600K 정도로 용량이 줄어드는데,
확신할 수는 없지만, 이 옵션을 사용했기 때문에 DNS resolv를 하지 못하는 것 같다.
busybox에서 ping이나 telnet 이 resolv 실패가 뜨면

libresolv.so
libdns.so

를 복사 해주면 되는데, 이 옵션의 영향이 아닐까 생각이된다.
Posted by 구차니
프로그램 사용/busybox2009. 7. 29. 15:13
$ ls /bin/udhcpc*
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpc -> busybox
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpd -> busybox

요즘 busybox는 udhcp 라는 dhcp 서버/클라이언트가 내장되어있다.
물론 기본값으로 busybox에 포함되긴 하지만, 확인 후 사용해야 한다.

아무튼, 옵션은 설정되어 있었음에도 불구하고
심볼릭 링크와, 스크립트가 생성되어 있지 않았다.


/sbin/udhcpc - udhcp Client
/sbin/udhcpd - udhcp Daemon
/usr/share/udhcpc/default.script - 기본 dhcp 스크립트




Posted by 구차니
sftp는 ssh를 이용한 ftp이다.
별다르게 설정하지 않았다면, 기본값으로 ssh를 통해 sftp로 전송이 가능하다.

SYNOPSIS
     sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
          [-o ssh_option] [-P sftp_server_path] [-R num_requests] [-S program]
          [-s subsystem | sftp_server] host
     sftp [[user@]host[:file [file]]]
     sftp [[user@]host[:dir[/]]]
     sftp -b batchfile [user@]host

사용방법은 위와 같은데 간단하게 예를 들자면,

# sftp root@192.168.10.10:/home.tar home.tar
Connecting to 192.168.10.10...
root@192.168.10.10's password:
Fetching /home.tar to home.tar
/home.tar                                       8% 1811MB   6.3MB/s   49:58 ETA

처럼 사용하면 된다. 머랄까.. 저 형식은 cvs나 svn 포맷같기도 하고..
Posted by 구차니
프로그램 사용/busybox2009. 7. 23. 14:45
busy 박스의 문제라기 보다는 라이브러리의 문제인 듯 하다.

ld-linux.so.2
libc.so.6
libdl.so.2
libnss_dns.so.2
libnss_files.so.2
libpthread.so.0
libresolv.so.2

이번 경우에는 libresolv.so 가 없어서 dns resolv가 되지 않았었다.

[링크 : http://kelp.or.kr/korweblog/stories.php?story=05/04/03/4168817]
Posted by 구차니
프로그램 사용/VNC2009. 7. 22. 14:42
서버설정은 크게 6단계로 나뉜다.

1. rpm이나 소스로 vnc를 설치한다.(자세한 내용은 생략)
2. /etc/sysconfig/vncserver의 내용을 수정한다.
# The VNCSERVERS variable is a list of display:user pairs.
 #
 # Uncomment the lines below to start a VNC server on display :2
 # as my 'myusername' (adjust this to your own).  You will also
 # need to set a VNC password; run 'man vncpasswd' to see how
 # to do that.
 #
 # DO NOT RUN THIS SERVICE if your local area network is
 # untrusted!  For a secure way of using VNC, see
 # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
 
 # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
 
 # Use "-nohttpd" to prevent web-based VNC clients connecting.
 
 # Use "-localhost" to prevent remote VNC clients connecting except when
 # doing so through a secure tunnel.  See the "-via" option in the
 # `man vncviewer' manual page.
 
 # VNCSERVERS="2:myusername"
 # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

FC6에서는 localhost:0.0 은 gdm에서 사용하고 있으므로, 1번 이후로 설정을 해준다.
예를들어 testuser 라는 아이디로 1번 디스플레이 1024x768 해상도로 접속을 하도록 하려면 아래와 같이 추가를 해준다.
VNCSERVERS="1:testuser"
VNCSERVERARGS[1]="-geometry 1024x768 -nohttpd"

3. vncpasswd로 사용자 비밀번호를 설정한다. 물론 확인을 위해 두번 입력 해야 한다.
   이 부분을 하지 않고 vncserver를 구동시키면, 아무런 에러 없이 FAILED 만 출력된다.
$ vncpasswd
Password:
Verify:

4. 기본으로 설정되는 윈도우 매니저는 twm으로, gdm에 익숙해진 일반유저로서는 교체해주는 것이 좋다.
   위의 설정에 해준 아이디의 홈디렉토리에서 .vnc/ 디렉토리에 xstartup이라는 스크립트를 교체 해준다.
   xstatup 파일은 /etc/X11/xinit/xinitrc을 xstartup으로 이름 바꾸어 복사해주면 된다.


# more xstartup
#!/bin/sh
# Copyright (C) 1999 - 2005 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Authors:
#       Mike A. Harris <mharris@redhat.com>

# Mandatorily source xinitrc-common, which is common code shared between the
# Xsession and xinitrc scripts which has been factored out to avoid duplication
. /etc/X11/xinit/xinitrc-common

# The user may have their own clients they want to run.  If they don't,
# fall back to system defaults.
if [ -f $HOME/.Xclients ]; then
    exec $SSH_AGENT $DBUS_LAUNCH $HOME/.Xclients || \
    exec $SSH_AGENT $HOME/.Xclients
elif [ -f /etc/X11/xinit/Xclients ]; then
    exec $SSH_AGENT $DBUS_LAUNCH /etc/X11/xinit/Xclients || \
    exec $SSH_AGENT /etc/X11/xinit/Xclients
else
    # Failsafe settings.  Although we should never get here
    # (we provide fallbacks in Xclients as well) it can't hurt.
    [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45'
    [ -x /usr/bin/xclock ] && /usr/bin/xclock -geometry 100x100-5+5 &
    [ -x /usr/bin/xterm ] && xterm -geometry 80x50-50+150 &
    [ -x /usr/bin/twm ] && /usr/bin/twm
fi

5. 방화벽을 해제하거나, 포트를 풀어준다.(자세한 내용은 생략)
    포트는 5900번이 기본으로 디스플레이 포트를 더해준다.
    예를들어 3번 display 번호를 사용하면 5900 + 3 = 5903 번의 포트를 열어주어야 한다.

6. vnc 서버를 구동한다.(자세한 내용은 생략)
    service vncserver start
    service vncserver restart

'프로그램 사용 > VNC' 카테고리의 다른 글

tsclient에 VNC 추가하기  (0) 2011.12.31
UVNC - Ultra VNC  (2) 2010.11.26
우분투 9.10 원격설정하기(vino server on Ubuntu 9.10)  (0) 2009.12.30
tightVNC 서버사용기  (0) 2009.04.02
tightVNC / realVNC  (0) 2009.03.13
Posted by 구차니
프로그램 사용/vi2009. 7. 21. 13:06
ctags는 c언어를 파싱하여 token 별로 추출해주는 녀석이다.
아무튼 vi에서 사용하기 위해서는
가장 간단한 방법으로


/src/ctags -R 을 실행후
/src/vi src.c 를 실행한다.

네비게이션은
ctrl - ] 는 추적하기(여러개 있을 경우 숫자로 선택)
ctrl - t 는 이전 위치로 돌아오기이다.
:tag tagname 은 그 태그로 이동하기 이다.(함수 이름, 변수 전부 이동가능)

[링크 : http://www.buggymind.com/90]
[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/ctags]

문서불러오기
:e [파일명]
새 문서(새 창열기)
:new
새 문서(이름으로)
:new [파일명]
[링크 : http://mwultong.blogspot.com/2006/06/vim-gvim.html]


ctrl+w f 하면 #include "" 나 #include <>의 파일 따라가기
[링크 : http://kldp.org/node/72478]


2010.01.28 추가
[링크 : http://www.viper.pe.kr/cgi-bin/moin.cgi/ctags_와_vi_사용하기]
Posted by 구차니
프로그램 사용/u-boot2009. 7. 18. 13:09
u-boot/tools/env 에 있는 README 파일 번역입니다.

이것은 U-boot의 환경 변수를 읽어오는 리눅스 명령행 프로그램의 적용예제 입니다.

run-time 유틸리티 설정을 위해서 다음의 줄을 주석처리 합니다.
fw_env.h 파일의
    #define CONFIG_FILE  "/etc/fw_env.config"

특정 타겟 보드를 위한 define들은 fw_env.confg 파일의 주석을  보시기 바랍니다.

화경설정은 fw_env.h 파일의 #define들을 통해 할 수 있습니다.
아래의 내용을 수정하시면 됩니다.

    #define HAVE_REDUND     /* 환경변수 영역이 2개일 경우 */
    #define DEVICE1_NAME    "/dev/mtd1"
    #define DEVICE2_NAME    "/dev/mtd2"
    #define DEVICE1_OFFSET    0x0000
    #define ENV1_SIZE         0x4000
    #define DEVICE1_ESIZE     0x4000
    #define DEVICE2_OFFSET    0x0000
    #define ENV2_SIZE         0x4000
    #define DEVICE2_ESIZE     0x4000

현재의 설정은 TRAB 보드에 맞추어져 있습니다.

백업용 환경변수 영역을 사용하지 않는다면 HAVE_REFUND를 주석처리합니다.
HAVE_REDUND 가 주석처리 되면 DEVICE2_NAME, ENV2_SIZE, DEVICE2_ESIZE 를 무시합니다.

DEVICEx_NAME 에는 환경변수가 저장되어 있는 MTD 캐릭터 디바이스를 지정합니다.
DEVICEx_OFFSET 에는 MTD 캐릭터 디바이스 범위 안의 환경변수의 offset을 지정합니다.
ENVx_SIZE 에는 (만약에 환경변수가 하나의 섹터크기 보다 적다면 플래시 섹터보다 작은 값을 지닐) 환경변수에 의해 사용되는 크기를 지정합니다.
DEVICEx_ESIZE 환경변수가 위치하는 플래시 파티션의 첫 섹터의 크기를 지정합니다.


Posted by 구차니