Linux2009. 1. 22. 21:45
Fedora Core 9 기준입니다.

linux 로그인 계정 관련
/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow

ID/PW는 passwd 와 shadow에 분산저장되며
그룹은 group와 gshadow에 저장이 됩니다.

NFS 관련
/etc/exports

NFS 경로의 저장은 exports 파일에 저장이 됩니다.

2010.02.02 추가

SAMBA 관련
/etc/samba

삼바의 설정과 계정은 /etc/samba 아래에 저장되어 있습니다.

사용자 계정정보 관련
/home

/home 아래의 디렉토리 별로 사용자 디렉토리가 존재함.


Posted by 구차니
Linux/Fedora Core2009. 1. 21. 13:55
예전에 KLDP 문서에서 그냥 패키지만 추가 하면 별다른 설정없이 FC6에서는 AIGLX를 사용할 수 있다고 봤지만,
실제로 해보지는 못했었다. 서버 설치 하면서 겸사겸사 딴짓을 조금 해봤는데 의외로 너무 쉽게 깔려서 허탈해졌다 OTL

설치된 패키지는 다음과 같다.
Gnome의 패키지 관리자에서 aiglx로 검색된 내용들 이다. beryl 관련 패키지들인데 전부 설치해 본다.


아래는 스카이돔, 큐브 투명 적용 화면
마우스 휠 클릭하고 prtsc 누르니 캡쳐가 된다.

Posted by 구차니
Linux2009. 1. 20. 23:45
윈도우에서는 ipconfig 라는 녀석으로 유선랜의 경우에는 dhcp까지 설정이 가능하다.
ipconfig /all <- 모든 어댑터 리스트 보기
ipconfig /renew <- dhcp 갱신



리눅스에서는 조금은 분화가 되어있다.(윈도우에 익숙해서인지 불편하다)
ifconfig - configure a network interface
dhclient - Dynamic Host Configuration Protocol Client

iwconfig - configure a wireless network interface

iwspy - Get wireless statistics from specific nodes
iwlist - Get more detailed wireless information from a wireless interface

굳이 윈도우와 비교를 하자면
 windows  linux
 ipconfig  ifconig, iwconfig
 ipconfig /renew
 dhclient, dhcpcd

[dhcpcd : http://www.phystech.com/download/dhcpcd_man.html]
Posted by 구차니
Linux2009. 1. 14. 13:20

 $ldd ps
        linux-gate.so.1 =>  (0x00110000)
        libproc-3.2.7.so => /lib/libproc-3.2.7.so (0x00b23000)
        libdl.so.2 => /lib/libdl.so.2 (0x00b4c000)
        libc.so.6 => /lib/libc.so.6 (0x009e1000)
        /lib/ld-linux.so.2 (0x009c4000)


$ar -t libdevmapper.a
bitset.o
hash.o
libdm-common.o
libdm-file.o
libdm-deptree.o
libdm-string.o
dbg_malloc.o
pool.o
libdm-iface.o


ldd 라는 녀석은 실행파일이 동적으로 사용하고 있는 라이브러리의 목록을 보여주고

ar 이라는 녀석은 라이브러리에 포함되어 있는 목록을 보여준다.


[참조 : http://www.misofruit.co.kr/seojewoo/embedded/linuxschedule/030312study.htm]


man page for ldd & ar


Posted by 구차니
Linux2008. 12. 26. 16:18
find 라는 명령어는 -exec 라는 옵션을 사용하여 파이프라인을 통해 검색된 결과를 넘겨 줄 수 있다.

윈도우/리눅스를 혼합하여 사용할 경우 의미 없이 용량만 늘리는 Thumbs.db 라는 넘을 삭제 하고 싶은데
일일이 찾아 지우기는 귀찮으니 조금 더 귀차니즘을 발휘하여 find에게 떠밀어 보자

 find [start path] -name Thumbs.db -exec rm {} \;

{} 는 검색된 결과가 넘어 가는 것이고
\; 는 명령어의 끝을 나타낸다. {}는 붙여 써야 하고(치환자)
\;역시 붙여 써야 하되, {} \;는 띄워서 써야 한다.


[참고 : http://kin.naver.com/detail/detail.php?d1id=1&dir_id=10202&eid=uOUzGMEfvG/Z2+VmcTxiS3R/sb6P15T+&qb=ZmluZCBleGVj&pid=fSfZswoi5URssbZwiR4sss--173216&sid=SVSD7S1zVEkAACzVjnk]
Posted by 구차니
Linux2008. 12. 22. 12:02
-rwxr-xr-x 1 root root   76400 Jul  5  2007 libresolv-2.5.so
lrwxrwxrwx 1 root root      16 Apr 11  2008 libresolv.so.2 -> libresolv-2.5.so
-rwxr-xr-x 1 root root   44060 Jul  5  2007 librt-2.5.so
lrwxrwxrwx 1 root root      12 Apr 11  2008 librt.so.1 -> librt-2.5.so

심볼릭 링크를 보는데 의구심이 생겼다.

1. 어떻게 심볼릭 링크는 저장이 되는지
2. libresolv-2.5.so면 16글자인데, 그럼 null 포함하면 17byte인데 왜 파일 사이즈가 16인가?

/usr/share/file/magic 파일을 보면
 9280 # lnk files windows symlinks
 9281 0       string  \114\000\000\000\001\024\002\000\000\000\000\000\300\000\000\000\000\000\000\106        MS Windows shortcut
 라는 내용이 있는데, file 하면 나오는

lrwxrwxrwx  1 morpheuz dev      7 Dec 22 11:47 tt -> err.log
[morpheuz@dev stbmw]$ file tt
tt: symbolic link to `err.log'

file 결과에서 나온 "symbolic link t"o 라는 메시지는 magic 파일에서 검색되지 않는다.

그리고 readlink() / readlink 라는 녀석도 존재 하는데
이녀석이 심볼릭 링크의 실제 내용을 읽어 주는 녀석이라고 한다.
READLINK(1)                      User Commands                     READLINK(1)

NAME
       readlink - display value of a symbolic link

SYNOPSIS
       readlink [OPTION]... FILE

DESCRIPTION
       Display value of a symbolic link on standard output.

       -f, --canonicalize
              canonicalize  by  following every symlink in every component of the given name recursively; all but the
              last component must exist

       -e, --canonicalize-existing
              canonicalize by following every symlink in every component of the given name  recursively,  all  compo-
              nents must exist

       -m, --canonicalize-missing
              canonicalize  by  following  every  symlink  in  every component of the given name recursively, without
              requirements on components existence

       -n, --no-newline
              do not output the trailing newline

       -q, --quiet,

       -s, --silent
              suppress most error messages

       -v, --verbose
              report error messages

       --help display this help and exit

       --version
              output version information and exit
근데.. 해보니 머.. ls -l 이랑 별 차이도 없는데 -ㅁ-!
Posted by 구차니
Linux2008. 12. 19. 20:05
man find

       -type c
              File is of type c:

              b      block (buffered) special

              c      character (unbuffered) special

              d      directory

              p      named pipe (FIFO)

              f      regular file

              l      symbolic link; this is never true if the -L option or the -follow option is in effect,
                     unless  the symbolic link is broken.  If you want to search for symbolic links when -L
                     is in effect, use -xtype.

              s      socket

              D      door (Solaris)


'ls -l'을  실행하면
$ ll
total 1922
drwxr-xr-x   2 root root    4096 Nov 15 04:17 bin
drwxr-xr-x   4 root root    1024 Apr 11  2008 boot
drwxr-xr-x  12 root root    3900 Nov 14 13:07 dev
drwxr-xr-x 101 root root   12288 Dec 15 04:15 etc
drwxr-xr-x  10 root root    4096 Aug 19 13:59 home
drwxr-xr-x  14 root root    4096 Apr 11  2008 lib
drwx------   2 root root   16384 Apr 10  2008 lost+found
drwxr-xr-x   2 root root    4096 Nov 14 13:07 media
drwxr-xr-x   2 root root       0 Nov 14 13:07 misc
drwxr-xr-x   2 root root       0 Nov 14 13:07 mnt
drwxr-xr-x   2 root root       0 Nov 14 13:07 net
drwxr-xr-x   2 root root    4096 Jun 19  2008 nfsroot
drwxr-xr-x   3 root root    4096 May 29  2008 opt
dr-xr-xr-x 195 root root       0 Nov 14 13:06 proc
drwxr-x---  29 root root    4096 Dec 17 11:00 root
drwxr-xr-x   2 root root   12288 Apr 11  2008 sbin
drwxr-xr-x   2 root root    4096 Apr 10  2008 selinux
drwxr-xr-x   2 root root    4096 Oct 11  2006 srv
drwxr-xr-x  12 root root       0 Nov 14 13:06 sys
drwxr-xr-x   2 root root    4096 Dec 17 13:30 tftpboot
drwxrwxrwt  16 root dev    90112 Dec 19 20:01 tmp
drwxr-xr-x  15 root root    4096 May 30  2008 usr
drwxr-xr-x  24 root root    4096 Apr 10  2008 var

이런식으로 퍼미션과 파일의 종류가 출력이 된다.
아무튼 일반적으로 보이는 녀석들은

- 일반 파일
b Block device
c Character device
d Directory
l symbolic Link

인데 드물게 보이는 녀석들이 존재 한다.
prw------- 1 morpheuz dev        0 Jul 15 13:21 initctl
crw-rw---- 1 morpheuz dev  61,   0 May 30  2008 lirc
srwxr-xr-x 1 morpheuz dev        0 Oct 20 19:57 lircd
brw-rw---- 1 morpheuz dev   7,   0 May 30  2008 loop0

이 녀석들의 의미는 역설적이게도.. find에서 찾아 냈다.

p name Pipe
s Socket


Posted by 구차니
Linux2008. 12. 18. 11:24
CALL source or . (dot operator) "include" another script

[출처 : http://tldp.org/LDP/abs/html/dosbatch.html]



In the last syntax ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell, The syntax for . (dot) command is as follows
Syntax:
. command-name
[출처 : http://www.freeos.com/guides/lsst/ch02sec01.html]




간단하게 환경변수를 쓰기 위해 만든 스크립트를 단순하게
실행하면, 별도의 쉘이 생성이 되어 실행되므로 현재 쉘에 적용이 되지 않는다.

그런 이유로 일반적으로 환경 변수로 사용하기 위한 스크립트를 실행 할때는 반드시
source [script.file] 로 실행을 한다.

source [script.file]와 동일하게
. [script.file] 을 실행해도 된다.
Posted by 구차니
Linux2008. 12. 16. 17:35
굳이 파일이 존재 하는지 확인을 하려면

1. fopen()의 리턴값을 확인한다.
FILE *fopen(const char *path, const char *mode);
FILE 포인터로 리턴을 하는데 open 실패시 NULL을 리턴하며, errno에 에러를 기록함.

2. access()로 확인한다.
int access(const char *pathname, int mode);
리턴값을 바로 확인하면 됨.

3. fstat()의 리턴값을 확인한다
int fstat(int filedes, struct stat *buf);
리턴값을 바로 확인하면 됨.

구차니즘을 털고 2008.01.06일 테스트
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <time.h>
int main()
{
        int ret = 0;
        clock_t before;
        clock_t after;
        double res;
        FILE *fp;
        struct stat st;

        before = clock();
        fp = fopen("test.txt","rb");
        after = clock();
        printf("%d - %d = %d tick\n",after, before,after - before);

        before = clock();
        ret = access("test2.txt",F_OK);
        after = clock();
        printf("%d - %d = %d tick\n",after, before,after - before);

        before = clock();
        ret = stat("test3.txt",&st);
        after = clock();
        printf("%d - %d = %d tick\n",after, before,after - before);

        return 0;
}

로 테스트 하는데, 전부 0 tick이 나온다 ㄱ-
결론은 어느걸 쓰던지 현존 시스템에서는 지장이 없다는 의미인데, 임베디드에서 쓰기 위해서는
조금 더 자세히 조사를 해봐야 할 듯 하다.

dmesg | grep CPU
CPU0: Intel(R) Pentium(R) 4 CPU 3.40GHz stepping 0a

$ time ./a.out
0 - 0 = 0 tick
0 - 0 = 0 tick
0 - 0 = 0 tick

real    0m0.001s
user    0m0.000s
sys     0m0.001s

이래저래 측정이 안되는건 마찬가지 ㄱ-




fopen(open) / access / fstat 에러 모음은 아래 클릭!


'Linux' 카테고리의 다른 글

ls 명령어의 file type  (0) 2008.12.19
쉘 스크립트 명령어 . (meaning of dot in sheel script)  (0) 2008.12.18
execl() - excute a file  (0) 2008.12.08
fork : Not Enough Memory  (2) 2008.12.08
mkfs - ext2 & ext3  (4) 2008.11.21
Posted by 구차니
Linux2008. 12. 8. 16:20

#include <unistd.h>

int execl(const char *path, const char *arg, ...);
int execlp(const char *file, const char *arg, ...);
int execle(const char *path, const char *arg,  ..., char * const envp[]);
int execv(const char *path, char *const argv[]);
int execvp(const char *file, char *const argv[]);


The  functions  execlp()  and execvp() will duplicate the actions of the shell in searching for an executable file if
the specified filename does not contain a slash (/) character.  The search path is the path specified in the environ-
ment  by the PATH variable.  If this variable isn’t specified, the default path ‘‘:/bin:/usr/bin’’ is used.  In addi-
tion, certain errors are treated specially.

[출처 : man page]

execl의 경우에는 path가 들어 가는데 arg에서 문제가 생긴다.




execl은 잠시 잊고 잠시 C언어로 돌아가서 main()의 프로토 타입을 생각해보자
 int void(int argc, char **argv)
그리고 argv[0] argv[1]의 내용을 떠올려 보자
argv[0]은 실행한 파일의 이름이 argv[1] 부터 인자가 넘어 오지 않았던가!




다시 execl로 돌아와서
int execl(const char *path, const char *arg, ...);
path에서는 파일 이름이 포함 된 경로를 적어주고, arg[0]에는 파일 이름 arg[1] 부터는 인자를 넘겨 주면 된다.


간단한 예를 들자면
 execl("/bin/ls","ls","-al",0);
로 실행을 하면된다.

마지막의 0은 '\0' == NULL 이다.


[참고 : http://kldp.org/node/1548]
Posted by 구차니