Linux2010. 4. 8. 22:28
FC6 기준으로
/usr/share/doc/MAKEDEV-3.23/devices-2.6+.txt
파일이 존재하며

커널에서 상당부분 정해진 값으로 고정된 것으로 보인다.

type               major,minor

crw-r----- 1 root kmem   1,   1  4월  2 20:04 mem
crw-rw-rw- 1 root root   1,   3  4월  2 20:04 null
crw-r----- 1 root kmem   1,   4  4월  2 20:04 port
crw-rw-rw- 1 root root   1,   5  4월  2 20:04 zero
crw-rw-rw- 1 root root   1,   7  4월  2 20:04 full
crw-rw-rw- 1 root root   1,   8  4월  2 20:04 random
cr--r--r-- 1 root root   1,   9  4월  2 20:04 urandom
crw------- 1 root root   1,  11  4월  2 20:04 kmsg
crw------- 1 root root   1,  12  4월  2 20:04 oldmem

brw-r----- 1 root disk   1,   0  4월  2 20:04 ram0
brw-r----- 1 root disk   1,   1  4월  2 20:04 ram1
brw-r----- 1 root disk   1,   2  4월  2 20:04 ram2
brw-r----- 1 root disk   1,   3  4월  2 20:04 ram3
brw-r----- 1 root disk   1,   4  4월  2 20:04 ram4
brw-r----- 1 root disk   1,   5  4월  2 20:04 ram5
brw-r----- 1 root disk   1,   6  4월  2 20:04 ram6
brw-r----- 1 root disk   1,   7  4월  2 20:04 ram7
brw-r----- 1 root disk   1,   8  4월  2 20:04 ram8
brw-r----- 1 root disk   1,   9  4월  2 20:04 ram9
brw-r----- 1 root disk   1,  10  4월  2 20:04 ram10
brw-r----- 1 root disk   1,  11  4월  2 20:04 ram11
brw-r----- 1 root disk   1,  12  4월  2 20:04 ram12
brw-r----- 1 root disk   1,  13  4월  2 20:04 ram13
brw-r----- 1 root disk   1,  14  4월  2 20:04 ram14
brw-r----- 1 root disk   1,  15  4월  2 20:04 ram15

  1 char    Memory devices
          1 = /dev/mem        Physical memory access
          2 = /dev/kmem        Kernel virtual memory access
          3 = /dev/null        Null device
          4 = /dev/port        I/O port access
          5 = /dev/zero        Null byte source
          6 = /dev/core        OBSOLETE - replaced by /proc/kcore
          7 = /dev/full        Returns ENOSPC on write
          8 = /dev/random    Nondeterministic random number gen.
          9 = /dev/urandom    Faster, less secure random number gen.
         10 = /dev/aio        Asyncronous I/O notification interface
         11 = /dev/kmsg        Writes to this come out as printk's

  1 block    RAM disk
          0 = /dev/ram0        First RAM disk
          1 = /dev/ram1        Second RAM disk
            ...
        250 = /dev/initrd    Initial RAM disk {2.6}

이 파일을 열어보면 major, minor 별로 장치의 설명이 나와있다.

[링크 : http://unix.co.kr/bbs/board.php?bo_table=LSN_qa&wr_id=185207&page=]
Posted by 구차니
Linux2010. 4. 5. 18:23
by 하나 차이지만, 큰 차이가 있는 녀석이다.

gethostname()은 자기 자신의 이름을 얻는 함수이고
gethostbyname()은 다른 녀석의 ip를 얻는 함수이다.

#include <unistd.h>
int gethostname(char *name, size_t len);
int sethostname(const char *name, size_t len);

#include <netdb.h>
struct hostent *gethostbyname(const char *name);

#include <sys/socket.h>       /* for AF_INET */
struct hostent *gethostbyaddr(const void *addr, int len, int type);

# cat /usr/include/netdb.h
/* Description of data base entry for a single host.  */
struct hostent
{
  char *h_name;                 /* Official name of host.  */
  char **h_aliases;             /* Alias list.  */
  int h_addrtype;               /* Host address type.  */
  int h_length;                 /* Length of address.  */
  char **h_addr_list;           /* List of addresses from name server.  */
#define h_addr  h_addr_list[0]  /* Address, for backward compatibility.  */
};

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

'Linux' 카테고리의 다른 글

wget  (4) 2010.04.10
/dev의 major minor에 대하여  (0) 2010.04.08
chown 사용방법(사용자와 그룹 바꾸기)  (0) 2010.04.03
터미널을 통한 데이터 통신에서 0x11이 사라졌어요  (0) 2010.04.02
ls 용량별로 정렬하기  (0) 2010.04.01
Posted by 구차니
Linux2010. 4. 3. 21:37
chown 은 원래 이름만 보자면 파일이나 디렉토리의 소유자를 변경하는 유틸리티인데
사용용법에 따라서는 chgrp를 통괄하는 유틸리티이다.

SYNOPSIS
       chown [OPTION]... [OWNER][:[GROUP]] FILE...
       chown [OPTION]... --reference=RFILE FILE...

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

SYNOPSIS
       chgrp [OPTION]... GROUP FILE...
       chgrp [OPTION]... --reference=RFILE FILE...

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

chown -R user dir
chgrp -R group dir

명령을
chown -R user:group dir
로 한번에 끝낼수 있다.
Posted by 구차니
Linux/Ubuntu2010. 4. 3. 21:31
우분투에서 아파치를 설치하면 아래와 같은 기본설정 파일이 생성된다.
htdocs는 /var/www 이고 root:root 권한을 가진다.
drwxr-xr-x  7 root root  4096 2010-04-03 21:18 www

하지만 apache2는 www-data:www-data 권한으로 서버가 실행되고
웹서버는 /var/www에 대하여 other 권한으로 파일을 access 하게된다.
/var/www를 www-data:www-data 로 변경하는게 무난한 방법이 될 듯하다.

# cat /etc/apache2/apache2.conf
144 # These need to be set in /etc/apache2/envvars
145 User ${APACHE_RUN_USER}
146 Group ${APACHE_RUN_GROUP}

# cat /etc/apache2/envvars
  1 # envvars - default environment variables for apache2ctl
  2
  3 # Since there is no sane way to get the parsed apache2 config in scripts, some
  4 # settings are defined via environment variables and then used in apache2ctl,
  5 # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
  6 export APACHE_RUN_USER=www-data
  7 export APACHE_RUN_GROUP=www-data

Posted by 구차니
Linux/Ubuntu2010. 4. 2. 23:16
설치 패키지
apache2
mysql-client-5.1
php5

위에 세가지를 선택하면 아래와 같이 줄줄이 엮여서 설치된다.



아파치 설정
/etc/apache2/apache2.conf (환경설정파일 경로)
/var/www (기본 설치시 htdocs 경로)

Mysql
기본암호는 설치시에 물어봄
/etc/mysql/my.cnf (환경설정파일 경로)
/var/lib/mysql (데이터경로)

PHP
$ cat index.php
<?
    phpinfo();
?>

[링크 : http://coffeenix.net/board_view.php?bd_code=1684]
[링크 : http://www.yamuzin.com/zbxe/758]
[링크 : http://www.sitepoint.com/forums/showthread.php?t=658149]
[링크 : https://help.ubuntu.com/community/ApacheMySQLPHP]

'Linux > Ubuntu' 카테고리의 다른 글

Ubuntu 10.04 LTS!  (0) 2010.05.07
apache2 환경설정  (0) 2010.04.03
fprintf man page가 왜 없지?!  (0) 2010.03.26
apt 명령어 정ㅋ벅ㅋ  (0) 2010.03.04
우분투에서 /etc/sysconfig/network 에 대응하는 파일  (0) 2010.02.16
Posted by 구차니
Linux2010. 4. 2. 16:18
console로 열린 터미널에서 일부의 속성만을 변경해서 사용중이었는데
다른건 전송이 되는데 0x11 데이터가 제대로 받아지지 않는 문제가 발생했다.

일단 엔터 치기 전에는 입력이 받아지지 않는건
'캐노니컬 모드(canonical mode)'로 인한 것이기 때문에 ~ICANON 으로 해결을 했지만

0x11 은 DC1(Data Control 1 - XON) 으로 캐노니컬과는 별개이기 때문에 0x11 데이터가 손실되었다.
터미널은 워낙 내용이 방대해서.. 간단하게 해결책만 제시하자면

ffmpeg의 소스중 일부를 인용
 712                 new_set.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
 713                                       |INLCR|IGNCR|ICRNL|IXON);
 714                 new_set.c_oflag |= OPOST;
 715                 new_set.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
 716                 new_set.c_cflag &= ~(CSIZE|PARENB);
 717                 new_set.c_cflag |= CS8;
 718                 new_set.c_cc[VMIN] = 1;
 719                 new_set.c_cc[VTIME] = 0;


       IXON   Enable XON/XOFF flow control on output.
       IXOFF  Enable XON/XOFF flow control on input.

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

결론 : 아마도 이랬을 것입니다
Posted by 구차니
Linux2010. 4. 1. 14:12
ls 자체적으로 정렬기능을 제공한다.
하지만, 디렉토리별이라서, 전체에 대해서 정렬을 하지는 못한다.

       -S     sort by file size

       --sort=WORD
              extension -X, none -U, size -S, time -t, version -v, status -c, time -t, atime -u, access -u, use -u

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

[링크 : http://thedaneshproject.com/posts/sort-files-by-size/]
Posted by 구차니
Linux2010. 3. 31. 11:38
fileno() 는 fp를 fd로 변환해주고
fdopen()은 fd를 fp로 변환해준다.

int fileno(FILE *stream);
FILE *fdopen(int fildes, const char *mode);

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

아무튼 원하는 파일이나, stdin/out/err에 대한 fd를 얻어온뒤
fcntl() 함수를 이용하여 변경하면 된다.

fctnl(fd, F_SETFL, O_NONBLOCK);
(테스트 안해봣음!)

int fcntl(int fd, int cmd, long arg);

F_SETFL
    Set the file status flags to the value specified by arg. File access mode (O_RDONLY, O_WRONLY, O_RDWR) and file creation flags (i.e., O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC) in arg are ignored. On Linux this command can only change the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME, and O_NONBLOCK flags.

[링크 : http://linux.die.net/man/2/fcntl]
[링 크 : http://www.falinux.com/win/study/06/devicedriver11.html]

Posted by 구차니
Linux/Ubuntu2010. 3. 26. 22:02
build-essencial을 깔았다고 해서 각종 man page들이 설치되는 것은 아니다.
각종 개발관련 man page는 manpages-dev 패키지에 존재한다.

$ sudo apt-get install manpages-dev

[링크 : https://lists.ubuntu.com/archives/ubuntu-users/2009-May/182747.html]
Posted by 구차니
Linux2010. 3. 26. 17:12
putty로 두개의 창을 ssh를 통해 열었는데,
ps -ef | grep sshd로 하니 아래와 같이 4개의 ssh 데몬이 검색되었다.
root      2050     1  0 Mar24 ?        00:00:00 /usr/sbin/sshd
root     25402  2050  0 10:23 ?        00:00:00 sshd: morpheuz [priv]

morpheuz 25404 25402  0 10:23 ?        00:00:00 sshd: morpheuz@pts/1
root     26343  2050  0 16:53 ?        00:00:00 sshd: morpheuz [priv]
morpheuz 26345 26343  0 16:53 ?        00:00:00 sshd: morpheuz@pts/4
morpheuz 26394 25405  0 17:00 pts/1    00:00:00 grep --color=auto sshd

priv는 previleged의 약자로, 보안을 강화하기 위해
접속은 소켓을 열수 있는 root로 열고
root의 sshd가 chile process를 만들어, 권한을 제한하여 서비스를 해준다.

위의 ps -ef 에서 보이듯,
[root] /usr/sbin/sshd
[root]           + sshd : morpheuz [priv]
[user]                    + sshd : morpheuz@pts/1
[root]           + sshd : morpheuz [priv]
[user]                    + sshd : morpheuz@pts/4
계층구조로 실행되며, 실질적인 권한은 사용자 권한으로 한정시켜, 시스템에 손상을 입히는 행위를 예방한다.

LOGIN PROCESS
     When a user successfully logs in, sshd does the following:

           1.   If the login is on a tty, and no command has been specified, prints last
                login time and /etc/motd (unless prevented in the configuration file or by
                ~/.hushlogin; see the FILES section).
           2.   If the login is on a tty, records login time.
           3.   Checks /etc/nologin; if it exists, prints contents and quits (unless root).
           4.   Changes to run with normal user privileges.
           5.   Sets up basic environment.
           6.   Reads the file ~/.ssh/environment, if it exists, and users are allowed to
                change their environment.  See the PermitUserEnvironment option in
                sshd_config(5).
           7.   Changes to user’s home directory.
           8.   If ~/.ssh/rc exists, runs it; else if /etc/ssh/sshrc exists, runs it; other-
                wise runs xauth.  The “rc” files are given the X11 authentication protocol
                and cookie in standard input.
           9.   Runs user’s shell or command.

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

[링크 : http://www.citi.umich.edu/u/provos/ssh/privsep.html]
[링크 : http://www.citi.umich.edu/u/provos/ssh/privsep-faq.html]



Posted by 구차니