Linux2010. 2. 1. 15:30

메모장이나 각종 텍스트 에디터에서 지원하는
"완전히 일치하는 단어" 검색은 grep 에서 -w 옵션을 사용하면 된다.

-w, --word-regexp
    Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.

[링크 : http://linux.die.net/man/1/grep]

[링크 : http://www.unix.com/unix-dummies-questions-answers/42144-find-exactly-word-grep-command.html]
Posted by 구차니
Linux/Ubuntu2010. 1. 29. 15:26
rpm 을 막상 설치하려니 에러가 발생한다.

morpheuz@ubuntu:/media/iso/host$ rpm -ivh --nodeps --ignorearch stlinux22-host-*.rpm
rpm: please use alien to install rpm packages on Debian, if you are really sure use --force-debian switch. See README.Debian for more details.

Fedora쪽 도움말에는 이러한 옵션이 안나오고, --help 에도 나오지 않는다.
[링크 : http://linux.die.net/man/8/rpm]

Ubuntu에 rpm 설치후 --help를 해보니
$ rpm --help
설치/업그레이드/삭제 옵션:
      --aid                         add suggested packages to transaction
      --allfiles                    특정 파일을 생략하기 위한 설정이 적용된 경우에도, 패키지 안의 모든 파일을
                                    설치합니다
      --allmatches                  <패키지> 이름과 일치하는 패키지는 모두 제거합니다 (<패키지>에 여러개의
                                    패키지를 동시에 지정할 경우에는 오류가 발생합니다)
      --badreloc                    relocate files in non-relocatable package
  -e, --erase=<패키지>+                패키지를 (제거) 삭제합니다
      --excludedocs                 패키지에 포함된 문서 파일을 설치하지 않습니다
      --excludepath=<경로>            <경로>로 시작되는 파일은 설치하지 않습니다
      --fileconflicts               detect file conflicts between packages
      --force                       --replacepkgs 와 --replacefiles 옵션을 동시에 사용합니다
      --force-debian                force installation of rpm on Debian system
아마도, 데비안용으로 추가된듯한 느낌이다.

2009/08/31 - [Linux/Ubuntu] - 우분투에서 rpm 설치하기 - install rpm package on ubuntu
Posted by 구차니
Linux2010. 1. 28. 19:43
ar은 *.a 파일에 들어있는 함수들의 목록을 얻어내고
ldd는 단순하게 실행파일이 링킹(linking)하고 있는 so들의 목록을 얻어내고
nm은 *.so 파일에 들어있는 함수들의 목록을 얻어낸다.

nm - list symbols from object files

Synopsis
nm [-a|--debug-syms] [-g|--extern-only] [-B] [-C|--demangle[=style]] [-D|--dynamic] [-S|--print-size] [-s|--print-armap] [-A|-o|--print-file-name][--special-syms] [-n|-v|--numeric-sort] [-p|--no-sort] [-r|--reverse-sort] [--size-sort] [-u|--undefined-only] [-t radix|--radix=radix] [-P|--portability] [--target=bfdname] [-fformat|--format=format] [--defined-only] [-l|--line-numbers] [--no-demangle] [-V|--version] [-X 32_64] [--help] [objfile...]

[링크 : http://linux.die.net/man/1/nm]

You can use
nm -Ca /lib/mylib.so.1
man nm for full

[링크 : http://www.linuxquestions.org/questions/linux-general-1/list-library-function-of-a-shared-library-.so-438693/]

+
2016.06.13

For the shared libs:
Code:
nm -D /lib/mylib.so.1


Posted by 구차니
Linux2010. 1. 27. 11:09
patch -p0 < filename 이라고 스크립트가 되어있었는데 귀차니즘으로
patch -p0 filename 라고 했더니 끝나지 않아서 man page에서 확인하니


SYNOPSIS
       patch [options] [originalfile [patchfile]]

       but usually just

       patch -pnum < patchfile

[링크 : http://linux.die.net/man/1/patch]

엄훠 히밤~
착한 아이는 스크립트 대로 하세요~ ㅋㅋ
Posted by 구차니
Linux2010. 1. 26. 15:54
How seperate directory and filename from path.

getfilename()
getdirectorypath()

이런식으로 좀 구현해주면 덧나나 싶을 정도로
은근히 검색해도 안나오는 녀석이었는데, 은근히 용도가 많은 녀석이다.

#include <libgen.h>
char *dirname(char *path);
char *basename(char *path);

path          dirname        basename
"/usr/lib"     "/usr"        "lib"
"/usr/"        "/"           "usr"
"usr"          "."           "usr"
"/"            "/"           "/"
"."            "."           "."
".."           "."           ".."


[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/3/basename]

path가 절대경로이든, 상대경로이든 dirname()과 basename()은 알아서 분리해준다.

[링크 : http://linux.die.net/man/3/basename]
[링크 : http://linux.die.net/man/3/dirname]

#include <string.h>
char *strdup(const char *s);
#define _GNU_SOURCE
#include <string.h>
char *strndup(const char *s, size_t n);
char *strdupa(const char *s);
char *strndupa(const char *s, size_t n);

The strdup() function returns a pointer to a new string which is a duplicate of the string s. Memory for the new string is obtained with malloc(3), and can be freed with free(3).

[링크 : http://linux.die.net/man/3/strdup]

[링크 : http://www.unix.com/unix-dummies-questions-answers/100617-how-get-directory-name-its-path.html]

오늘의 교훈 : 쉘에서 되면 당연히 API로도 존재한다!


Posted by 구차니
Linux/Ubuntu2010. 1. 25. 12:28
FC6 참.. 오래된 녀석인데.. 아무튼 이녀석 OS를 깔았떤 하드를 우분투에 연결하니 인식이 안된다.
/boot 만 인식해서 마운트를 할 수 있는데
그 아래의 것들은 LVM(Logical Volume Manager)로 되어있기 때문이다.


아무튼 필요한 패키지는
$ sudo apt-get install lvm2
로 설치하고

$ sudo vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
$ sudo vgchange -a y
  2 logical volume(s) in volume group "VolGroup00" now active
로 LVM을 검색후 활성화 해준다.

그리고 마운트는 별다른 옵션없이 붙었다.
$ sudo mount /dev/VolGroup00/LogVol00 /mnt/lvm

modprobe 하라는데 없다고 에러나지만 별다른 문제 없이 작동한다.

$ mount
...
/dev/mapper/VolGroup00-LogVol00 on /media/sdb type ext3 (rw)
ext3로 rw 하게 붙었다!
Posted by 구차니
Linux/Ubuntu2010. 1. 15. 13:55
집에서는 잘되던넘이.. 회사오니 배를 짼다.
죽일수도 없는 노릇이고, 2일째 틈틈히 검색을 해보니 조금의 실마리가 잡힌다.

원인은 저번글에 적었듯 EDID이고
Nvidia 에서 지원하는 option으로 IgnoreEDID 라는 것이 존재한다.
[링크 : http://baudizm.blogsome.com/2005/09/27/ignoring-edid-to-impose-higher-resolution/]

내가 사용하는 카드는 Geforce2 MX, 드라이버는 96.43.13 이다.
아무튼 IgnoreEDID는 아래와 같은 오류가 난다.

$ vi /var/log/Xorg.0.log
202 (**) NVIDIA(0): Option "IgnoreEDID" "True"
203 (**) NVIDIA(0): Option "AddARGBGLXVisuals" "True"
204 (**) NVIDIA(0): Enabling RENDER acceleration
205 (WW) NVIDIA(0):
206 (WW) NVIDIA(0): The IgnoreEDID and NoDDC options have been deprecated.  The
207 (WW) NVIDIA(0):     NVIDIA X driver makes use of a display device's EDID
208 (WW) NVIDIA(0):     during construction of its modePool.  It is recommended
209 (WW) NVIDIA(0):     that you allow the X driver to make use of any available
210 (WW) NVIDIA(0):     EDID.  If, however, you know what you are doing and have
211 (WW) NVIDIA(0):     good reason to do so, you can disable the X driver's use
212 (WW) NVIDIA(0):     of EDIDs by setting the "UseEDID" X configuration option
213 (WW) NVIDIA(0):     to FALSE; e.g.,
214 (WW) NVIDIA(0):
215 (WW) NVIDIA(0):   Option "UseEDID" "FALSE"
216 (WW) NVIDIA(0):
217 (WW) NVIDIA(0): Note that, rather than globally disable all uses of the EDID,
218 (WW) NVIDIA(0):     you can individually disable each particular use of the
219 (WW) NVIDIA(0):     EDID; e.g.,
220 (WW) NVIDIA(0):
221 (WW) NVIDIA(0):   Option "UseEDIDFreqs" "FALSE"
222 (WW) NVIDIA(0):   Option "UseEDIDDpi" "FALSE"
223 (WW) NVIDIA(0):   Option "ModeValidation" "NoEdidModes"
224 (WW) NVIDIA(0):
225 (WW) NVIDIA(0): See Appendix D: X Config Options in the README for details on
226 (WW) NVIDIA(0):     each of these options.
간단하게 말하자면, IgnoreEDID 대신에 UseEDID를 쓰라는 이야기이다.

아무튼, 이런식의 오류가 나면서 640x480으로 강제 설정된다.
209 (II) NVIDIA(0): NVIDIA GPU GeForce2 MX 100/200 at PCI:1:0:0 (GPU-0)
210 (--) NVIDIA(0): Memory: 32768 kBytes
211 (--) NVIDIA(0): VideoBIOS: 03.11.01.26.31
212 (II) NVIDIA(0): Detected AGP rate: 4X
213 (--) NVIDIA(0): Interlaced video modes are not supported on this GPU
214 (--) NVIDIA(0): Connected display device(s) on GeForce2 MX 100/200 at
215 (--) NVIDIA(0):     PCI:1:0:0:
216 (--) NVIDIA(0):     CRT-0
217 (--) NVIDIA(0): CRT-0: 350.0 MHz maximum pixel clock
218 (II) NVIDIA(0): Assigned Display Device: CRT-0
219 (WW) NVIDIA(0): No valid modes for "1024x768"; removing.
220 (WW) NVIDIA(0): No valid modes for "800x600"; removing.
221 (II) NVIDIA(0): Validated modes:
222 (II) NVIDIA(0):     "640x480"
223 (II) NVIDIA(0): Virtual screen size determined to be 640 x 480
224 (WW) NVIDIA(0): Unable to get display device CRT-0's EDID; cannot compute DPI
225 (WW) NVIDIA(0):     from CRT-0's EDID.
226 (==) NVIDIA(0): DPI set to (75, 75); computed from built-in default



640x480 에서 처참하게 잘린 X Server Setting (드라이버 버전 96.43.13)


해결방법 : 나의 경우에는 어처구니 없게도.. 모니터 케이블 교체하니 EDID를 제대로 받아왔다.
               케이블이 회사에 없어서 20m 짜리 케이블을 사용했는데 커넥터 하나가 비어있었다.
               아무튼 이녀석이야 Green GND 쪽이라 상관은 없겠지만.. 아무튼 케이블 문제라니 ㄱ-
               (아래 기준으로 7번 핀이 빠져있었지만, 상관없어 보이고, 아마 단가를 낮추기 위해서
               가장 아래쪽에 13,14번 핀을 제외한 나머지 핀이 연결되어 있지 않았었나보다)


Pin 1 RED Red video
Pin 2 GREEN Green video
Pin 3 BLUE Blue video
Pin 4 ID2/RES formerly Monitor ID bit 2, reserved since E-DDC
Pin 5 GND Ground (HSync)
Pin 6 RED_RTN Red return
Pin 7 GREEN_RTN Green return
Pin 8 BLUE_RTN Blue return
Pin 9 KEY/PWR formerly key, now +5V DC
Pin 10 GND Ground (VSync, DDC)
Pin 11 ID0/RES formerly Monitor ID bit 0, reserved since E-DDC
Pin 12 ID1/SDA formerly Monitor ID bit 1, I²C data since DDC2
Pin 13 HSync Horizontal sync
Pin 14 VSync Vertical sync
Pin 15 ID3/SCL formerly Monitor ID bit 3, I²C clock since DDC2

[링크 : http://en.wikipedia.org/wiki/VGA_connector]
Posted by 구차니
Linux2010. 1. 14. 14:14
우분투에는 /etc/ld.so.conf.d 로 존재한다.
다른 배포판에서는 /etc/ld.so.conf 로 존재하는듯 하다.

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variableduring execution
   - add LIBDIR to the `LD_RUN_PATH' environment variableduring linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

autoconf 에서 출력되는 ld 관련 메시지



3.3. 환경 변수들

여러가지 환경변수는 이 과정을 제어할 수 있다. 그리고 이 과정을 오버라이드하는 환경변수들이 존재한다.
3.3.1. LD_LIBRARY_PATH

이 특별한 실행을 위해 당신은 일시적으로 다른 라이브러리를 대체할 수 있다. 리눅스에서, 환경변수 LD_LIBRARY_PATH는 표준의 디렉토리들을 찾기전에 찾아보게되는 라이브러리의 디렉토리들의 콜론으로 구분되는 셋이다; 이것은 새 라이브러리나 특별히 제작한 표준이 아닌 라이브러리를 디버깅할때 유용하다. 환경변수 LD_PRELOAD는 /etc/ld.so.preload가 하는 것처럼 표준 셋을 오버라이드하는 공유 라이브러리를 함수와 함께 나열한다. 이것들은 /lib/ld-linux.so라는 로더에 의해 구현된다. LD_LIBRARY_PATH가 많은 유닉스 시스템에서 작동하는 반면 모든 시스템에서 작동하지 않는다는 것을 말하고 싶다; 예를들어, HU-UX에서는 이 기능이 환경변수 SHLIB_PATH에 의해서 가능하고, AIX에서는 LIBPATH에 의해 가능하다(같은 문법과, 콜론으로 구분되는 리스트로 가능하다).

LD_LIBRARY_PATH는 개발과 검사를 위해 편리하다. 그러나 보통의 유저의 보통의 사용을 위해서 설치 과정에서 변경되면 안된다; 왜 그런지는 http://www.visi.com/~barr/ldpath.html의 ``Why LD_LIBRARY_PATH is Bad''에서 찾아보라. 하지만, 이 기능은 여전히 개발과 검사를 위해 유용하고, 다른방식으로 해결하지 못하는 것을 해결하는데 유용하다. 만약 당신이 환경변수 LD_LIBRARY_PATH를 설정하고 싶지 않다면, 리눅스에서 당신은 프로그램 로더를 직접 불러서 인자를 넘겨줄수도 있다. 예를들어, 다음은 환경변수 LD_LIBRARY_PATH의 경로 이외의 주어진 PATH를 사용할 것이고, 실행가능 프로그램을 돌릴 것이다.

  /lib/ld-linux.so.2 --library-path PATH EXECUTABLE

인자없이 ld-linux.so를 돌리는 것은 당신이 이렇게 사용하는데에 도움을 줄 것이다. 하지만, 이것을 보통의 용도로 사용하지 마라. 이것들은 디버깅용이다.

[링크 : http://wiki.kldp.org/HOWTO/html/Program-Library-HOWTO/shared-libraries.html]

/sbin/ldconfig - configure dynamic linker run time bindings

Files
/lib/ld.so                run-time linker/loader
/etc/ld.so.conf        File containing a list of colon, space, tab, newline, or comma-separated directories in which to search for libraries.
/etc/ld.so.cache    File containing an ordered list of libraries found in the directories specified in /etc/ld.so.conf.

[링크 : http://linux.die.net/man/8/ldconfig]

pkg-config - Return metainformation about installed libraries

PKG_CONFIG_PATH
    A colon-separated (on Windows, semicolon-separated) list of directories to search for .pc files. The default directory will always be searched after searching the path; the default is libdir/pkgconfig:datadir/pkgconfig where libdir is the libdir where pkg-config and datadir is the datadir where pkg-config was installed.
[링크 : http://linux.die.net/man/1/pkg-config]

[링크 : http://kldp.org/node/71409]
[링크 : http://kldp.org/node/64845]
Posted by 구차니
Linux/Ubuntu2010. 1. 13. 22:49
우분투에서 우연히 보게된 기능인데.. 기존에도 있었던가?



오른쪽 클릭하고 탭 열기 하면 탭으로 생긴다.
나만 몰랐나 -ㅁ-?
Posted by 구차니
Linux2010. 1. 11. 11:42
/proc/diskstats 파일은 linux kernel 2.6 부터 지원하는 것으로
hdd의 파일 입출력 속도를 볼 수 있다.

음.. FC6에서는 해보니, 1초 간격으로 갱신되는것 같은데
$ cat /proc/diskstats
   1    0 ram0 0 0 0 0 0 0 0 0 0 0 0
   1    1 ram1 0 0 0 0 0 0 0 0 0 0 0
   1    2 ram2 0 0 0 0 0 0 0 0 0 0 0
   1    3 ram3 0 0 0 0 0 0 0 0 0 0 0
   1    4 ram4 0 0 0 0 0 0 0 0 0 0 0
   1    5 ram5 0 0 0 0 0 0 0 0 0 0 0
   1    6 ram6 0 0 0 0 0 0 0 0 0 0 0
   1    7 ram7 0 0 0 0 0 0 0 0 0 0 0
   1    8 ram8 0 0 0 0 0 0 0 0 0 0 0
   1    9 ram9 0 0 0 0 0 0 0 0 0 0 0
   1   10 ram10 0 0 0 0 0 0 0 0 0 0 0
   1   11 ram11 0 0 0 0 0 0 0 0 0 0 0
   1   12 ram12 0 0 0 0 0 0 0 0 0 0 0
   1   13 ram13 0 0 0 0 0 0 0 0 0 0 0
   1   14 ram14 0 0 0 0 0 0 0 0 0 0 0
   1   15 ram15 0 0 0 0 0 0 0 0 0 0 0
   3    0 hda 108013 40509 5794964 3417656 108015 779595 7103102 61420792 0 2737052 64843120
   3    1 hda1 1076 2158 19 38
   3    2 hda2 147415 5792382 887883 7103064
 253    0 dm-0 147169 0 5791122 5857704 887853 0 7102824 1796618756 0 2736044 1802476620
 253    1 dm-1 70 0 560 1432 30 0 240 38624 0 6188 40056
   2    0 fd0 0 0 0 0 0 0 0 0 0 0 0
   9    0 md0 0 0 0 0 0 0 0 0 0 0 0

이런식으로 숫자만 잔뜩 나온다.

/proc/diskstats, giving some information (including device numbers) for each of the logical disk devices
[링크 : http://en.wikipedia.org/wiki/Procfs]

sysstat 패키지의 iostat 유틸리티
[링크 : http://elenoa.tistory.com/52]

3.2 /proc/diskstat => disk utilization, throughput (only 2.6 kernels)
[링크 : http://duo830210.tistory.com/45]

Field  1 -- # of reads completed
    This is the total number of reads completed successfully.

Field  2 -- # of reads merged, field 6 -- # of writes merged
    Reads and writes which are adjacent to each other may be merged for
    efficiency.  Thus two 4K reads may become one 8K read before it is
    ultimately handed to the disk, and so it will be counted (and queued)
    as only one I/O.  This field lets you know how often this was done.

Field  3 -- # of sectors read
    This is the total number of sectors read successfully.

Field  4 -- # of milliseconds spent reading
    This is the total number of milliseconds spent by all reads (as
    measured from __make_request() to end_that_request_last()).

Field  5 -- # of writes completed
    This is the total number of writes completed successfully.

Field  7 -- # of sectors written
    This is the total number of sectors written successfully.

Field  8 -- # of milliseconds spent writing
    This is the total number of milliseconds spent by all writes (as
    measured from __make_request() to end_that_request_last()).

Field  9 -- # of I/Os currently in progress
    The only field that should go to zero. Incremented as requests are
    given to appropriate struct request_queue and decremented as they finish.

Field 10 -- # of milliseconds spent doing I/Os
    This field is increases so long as field 9 is nonzero.

Field 11 -- weighted # of milliseconds spent doing I/Os
    This field is incremented at each I/O start, I/O completion, I/O
    merge, or read of these stats by the number of I/Os in progress
    (field 9) times the number of milliseconds spent doing I/O since the
    last update of this field.  This can provide an easy measure of both
    I/O completion time and the backlog that may be accumulating.

[링크 : http://www.mjmwired.net/kernel/Documentation/iostats.txt]


Posted by 구차니