where
adapter Connection name
(wildcard characters * and ? allowed, see examples)
Options:
/? Display this help message
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
/flushdns Purges the DNS Resolver cache.
/registerdns Refreshes all DHCP leases and re-registers DNS names
/displaydns Display the contents of the DNS Resolver Cache.
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id.
The default is to display only the IP address, subnet mask and
default gateway for each adapter bound to TCP/IP.
For Release and Renew, if no adapter name is specified, then the IP address
leases for all adapters bound to TCP/IP will be released or renewed.
For Setclassid, if no ClassId is specified, then the ClassId is removed.
Examples:
> ipconfig ... Show information.
> ipconfig /all ... Show detailed information
> ipconfig /renew ... renew all adapters
> ipconfig /renew EL* ... renew any connection that has its
name starting with EL
> ipconfig /release *Con* ... release all matching connections,
eg. "Local Area Connection 1" or
"Local Area Connection 2"
iwconfig - configure a wireless network interface
iwspy - Get wireless statistics from specific nodes
iwlist - Get more detailed wireless information from a wireless interface
DESCRIPTION
ldd prints the shared libraries required by each
program or shared library specified on the command line.
OPTIONS
--version
Print the version number of
ldd.
-v --verbose
Print all information, including e.g.
symbol versioning information.
-u --unused
Print unused direct dependencies.
-d --data-relocs
Perform relocations and report any
missing objects (ELF only).
-r --function-relocs
Perform relocations for both
data objects and functions, and report any missing objects or
functions
(ELF only).
--help Usage information.
NOTES
The standard version of ldd comes with glibc2. Libc5 came
with an older version, still present on some sys-
tems. The long
options are not supported by the libc5 version. On the other hand, the glibc2
version does not
support -V and only has the equivalent --version.
The libc5 version of this program will use the name of a library given
on the command line as-is when it con-
tains a ’/’; otherwise it
searches for the library in the standard locations. To run it on a shared
library in
the current directory, prefix the name with "./".
BUGS
ldd does not work on a.out shared libraries.
ldd does not work with some extremely old a.out programs which were
built before ldd support was added to the
compiler releases. If you
use ldd on one of these programs, the program will attempt to run with argc = 0
and
the results will be unpredictable.
SEE ALSO
ld.so(8), ldconfig(8)
Linux Programmer’s Manual 30 October 2000
LDD(1)
man ar
AR(1) GNU Development Tools
AR(1)
NAME
ar - create, modify, and extract from archives
SYNOPSIS
ar [-X32_64] [-]p[mod [relpos] [count]] archive
[member...]
DESCRIPTION
The GNU ar program creates, modifies, and extracts
from archives. An archive is a single file holding a col-
lection of
other files in a structure that makes it possible to retrieve the original
individual files (called
members of the archive).
The original files’ contents, mode (permissions), timestamp, owner,
and group are preserved in the archive,
and can be restored on
extraction.
GNU ar can maintain archives whose members have names of any length;
however, depending on how ar is config-
ured on your system, a limit
on member-name length may be imposed for compatibility with archive formats
main-
tained with other tools. If it exists, the limit is often 15
characters (typical of formats related to a.out)
or 16 characters
(typical of formats related to coff).
ar is considered a binary utility because archives of this sort are
most often used as libraries holding com-
monly needed
subroutines.
ar creates an index to the symbols defined in relocatable object
modules in the archive when you specify the
modifier s. Once
created, this index is updated in the archive whenever ar makes a change to its
contents
(save for the q update operation). An archive with such an
index speeds up linking to the library, and allows
routines in the
library to call each other without regard to their placement in the archive.
You may use nm -s or nm --print-armap to list this index table. If
an archive lacks the table, another form
of ar called ranlib can be
used to add just the table.
GNU ar is designed to be compatible with two different facilities.
You can control its activity using com-
mand-line options, like
the different varieties of ar on Unix systems; or, if you specify the single
command-
line option -M, you can control it with a script supplied via
standard input, like the MRI "librarian" pro-
gram.
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
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
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] 을 실행해도 된다.
ERRORS EACCES The requested access to the file is not allowed, or search permission is denied for one of the directories
in the path prefix of pathname, or the file did not exist yet and write access to the parent directory is
not allowed. (See also path_resolution(2).)
EEXIST pathname already exists and O_CREAT and O_EXCL were used.
EFAULT pathname points outside your accessible address space.
EISDIR pathname refers to a directory and the access requested involved writing (that is, O_WRONLY or O_RDWR is
set).
ELOOP Too many symbolic links were encountered in resolving pathname, or O_NOFOLLOW was specified but pathname was
a symbolic link.
EMFILE The process already has the maximum number of files open.
ENAMETOOLONG
pathname was too long.
ENFILE The system limit on the total number of open files has been reached.
ENODEV pathname refers to a device special file and no corresponding device exists. (This is a Linux kernel bug;
in this situation ENXIO must be returned.)
ENOENT O_CREAT is not set and the named file does not exist. Or, a directory component in pathname does not exist
or is a dangling symbolic link.
ENOMEM Insufficient kernel memory was available.
ENOSPC pathname was to be created but the device containing pathname has no room for the new file.
ENOTDIR
A component used as a directory in pathname is not, in fact, a directory, or O_DIRECTORY was specified and
pathname was not a directory.
ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO and no process has the file open for reading. Or,
the file is a device special file and no corresponding device exists.
EOVERFLOW
pathname refers to a regular file, too large to be opened; see O_LARGEFILE above.
EPERM The O_NOATIME flag was specified, but the effective user ID of the caller did not match the owner of the
file and the caller was not privileged (CAP_FOWNER).
EROFS pathname refers to a file on a read-only filesystem and write access was requested.
ETXTBSY
pathname refers to an executable image which is currently being executed and write access was requested.
EWOULDBLOCK
The O_NONBLOCK flag was specified, and an incompatible lease was held on the file (see fcntl(2)).
access()
DESCRIPTION
mode is a mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
R_OK, W_OK and X_OK request checking whether the file exists and has read, write and execute permissions,
respectively. F_OK just requests checking for the existence of the file.
ERRORS
access() shall fail if:
EACCES The requested access would be denied to the file or search permission is denied for one of the directories in
the path prefix of pathname. (See also path_resolution(2).)
ELOOP Too many symbolic links were encountered in resolving pathname.
ENAMETOOLONG
pathname is too long.
ENOENT A directory component in pathname would have been accessible but does not exist or was a dangling symbolic
link.
ENOTDIR
A component used as a directory in pathname is not, in fact, a directory.
EROFS Write permission was requested for a file on a read-only filesystem.
access() may fail if:
EFAULT pathname points outside your accessible address space.
EINVAL mode was incorrectly specified.
EIO An I/O error occurred.
ENOMEM Insufficient kernel memory was available.
ETXTBSY
Write access was requested to an executable which is being executed.
fstat()
ERRORS EACCES Search permission is denied for one of the directories in the path prefix of path. (See also path_resolu-
tion(2).)
EBADF filedes is bad.
EFAULT Bad address.
ELOOP Too many symbolic links encountered while traversing the path.
ENAMETOOLONG
File name too long.
ENOENT A component of the path path does not exist, or the path is an empty string.
ENOMEM Out of memory (i.e. kernel memory).
ENOTDIR
A component of the path is not a directory.
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] 부터는 인자를 넘겨 주면 된다.
리눅스에서 프로그램을 실행 시키는 방법은
fork() / exec() 로 하는 방법과 system() 으로 하는 방법이 있다고 한다.
(내가 직접해본게 아니니 발뺌하기 모드 -.-v)
아무튼 fork()의 경우 parent 의 메모리를 복사해서(COW - Copy On Write) 사용하므로 메모리의 낭비가 생기는데,
이런 이유로 메모리가 넉넉해 보임에도
"fork 시에 ENOMEM 을 뱉어 내고 실행을 못한다"면 fork 대신에 vfork를 사용하면 된다.
어플리케이션 서브프로세스를 생성할때 메모리 사용량 최대로 줄이기
Greg Nakhimovsky, 2006년 5월
Fork의 퍼포먼스 ... fork() 가 exec() 에 뒤따라 바로 살행되는 fork/exec 모델의 단점을 다루기 위해 버클리 버젼의 유닉스(BDS)는 1980년대 초반에 vfork() 시스템 콜을 내놓았습니다. vfork(2) 는 부모 프로세스를 자식 프로세스에 카피하지 않습니다. 두 프로세스가 모두 부모의 가상 주소 공간을 공유 합니다; 부모 프로세스는 자식 프로세스가 종료 되거나 exec() 를 호출할때 까지정지 상태로 들어 갑니다.
...
오랜 시간이 지난후에 멀티쓰레딩(MT)이 가능해 지고 많이 사용되면서 vfork() 가 어플리케이션이 여러개의 쓰레드를 가지고 있을때 새로운 문제를 일으킬 수 있음이 밝혀 졌습니다: 데드락.
몇몇 운영체제 (리눅스, IBM AIX, HP-UX 같은) 들은
memory overcommit 이라는 기능을 가지고 있습니다.( lazy swap allocation 이라고도 불림) memory
overcommit 모드에서 malloc() 은 스왑스페이스를 예약하지 않고 시스템에 충분한 VM이 있든 없든 항상NULL 이 아닌 포인터를 리턴 합니다.
...
리눅스 커널 버젼 2.6과 그후에 버젼에서는 이론적으로 커널의 동작을 수정할 수 있는 방법이 존재 합니다. 그러므로 overcommit memory 가 발생하지 않을 것입니다. 이것은 strict overcommit mode 을 sysctl을 통해 조정함으로써 가능합니다:
sysctl -w vm.overcommit_memory=2
혹은 동일한 의미를 가지고 있는 vm.overcommit_memory=2 을 /etc/sysctl.conf 에 삽입합니다.
Memory overcommit is a Linux kernel feature that lets
applications allocate more memory than is actually
available. The idea behind this feature is that some
applications allocate large amounts of memory "just in
case", but never actually use it. Thus, memory overcommit
allows you to run more applications than actually fit in
your memory, provided the applications don't actually use
the memory they've allocated. If they do, then the kernel
terminates the application.
일단 mkfs는 DOS로 치자면 format 명령인데
linux에서는 ext2는 이제 잘 안쓰고 ext3를 주로 쓴다.
흥미롭게도 mkfs 과정중에 mkfs.ext2 와 mkfs.ext3 의 결과의 차이가 한줄 뿐이라는 사실을 발견했다.
그리고 부가적으로는 자동으로 체크하는 mount 횟수의 차이도 있다.
[root@localhost mnt]# mkfs.ext2 /dev/sda2
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3842720 inodes, 7679070 blocks
383953 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
235 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost mnt]# mkfs.ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2093056 inodes, 4178908 blocks
208945 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4282384384
128 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000