<script language="JavaScript">
<!--
function reSizePopup(){
window.resizeTo(512, document.body.scrollHeight+30);
}
//-->
</script>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" bgcolor="#EBE3D7" onload="reSizePopup()">
<script language="JavaScript">
<!--
function reSizePopup(){
window.resizeTo(512, document.body.scrollHeight+30);
}
//-->
</script>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" bgcolor="#EBE3D7" onload="reSizePopup()">
Some examples follow how to send cookies:
Example #1 setcookie()>$2 send example
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1);
?> Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() instead if you are using PHP 5. To see the contents of our test cookie in a script, simply use one of the following examples:
<?php
// Print an individual cookie
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
// Another way to debug/test is to view all cookies
print_r($_COOKIE);
?> Example #2 setcookie()>$2 delete example
When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example:
<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1);
?> Example #3 setcookie()>$2 and arrays
You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name:
<?php
// set the cookies
setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
?> The above example will output:
three : cookiethree two : cookietwo one : cookieone
usermod
사용자 계정정보를 수정하는 명령어이다.
기존에 생성되어 있는 계정사용자의 다음과 같은 계정정보들을 수정할 수 있다.
사용형식
usermod [-c comment] [-d home_dir [ -m]]
[-e expire_date] [-f inactive_time]
[-g initial_group] [-G group[,...]]
[-l login_name] [-p passwd]
[-s shell] [-u uid [ -o]] [-L|-U] login
사용예 #1
다음은 sspark5라는 계정사용자의 /etc/passwd, /etc/shadow, /etc/group내에 설정된 기본 설정내용이다.
[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508::/home/sspark5:/bin/bash
[root@host3 root]#
[root@host3 root]# grep sspark5 /etc/shadow
sspark5:$1$/H.bOlGk$jeEdF1g7naK9vVe4v5i/s/:12314:0:99999:7:::
[root@host3 root]#
[root@host3 root]# grep sspark5 /etc/group
sspark5:x:508:
[root@host3 root]#
위의 초기 설정값을 간단히 보면 UID는 506, GID는 508, 코멘트는 현재 없으며, 홈디렉토리는 /home/sspark5이며, 사용하는 기본쉘은 bash쉘임을 알 수 있다.
이제 이 값들을 usermod로 바꾸어 보도록 하자.
먼저, sspark5사용자의 코멘트를 입력해 보자.
[root@host3 root]# usermod -c 박성수 sspark5
[root@host3 root]#
위의 예와 같이 코멘트를 수정하는 usermod의 옵션은 -c이다.
다음은 /etc/passwd내에 sspark5의 변경된 코멘트를 확인한 것이다.
[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/home/sspark5:/bin/bash
[root@host3 root]#
사용예 #2
이번에는 sspark5사용자의 홈디렉토리를 변경해보자.
usermod에서 홈디렉토리를 변경하는 옵션은 -d이다.
[root@host3 root]# usermod -d /usr/sspark5 sspark5
[root@host3 root]#
위와 같이 홈디렉토리를 변경하였다.
다음은 변경된 값을 확인한 것이다.
[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/usr/sspark5:/bin/bash
[root@host3 root]#
한가지 주의할 것은 홈디렉토리의 위치가 변경되었지만 원래 있던 홈디렉토리파일들이 삭제되거나 이동되는 것은 아니다.
원래의 홈디렉토리내에 존재하는 파일들은 모두 그대로 존재한다.
사용예 #3
이번에는 -e옵션을 사용하여 sspark5의 계정 종료일을 설정해보자.
[root@host3 root]# usermod -e 2006-12-31 sspark5
[root@host3 root]#
위와 같이 설정한 후에 /etc/shadow파일을 확인한 것이다.
계정 종료일의 설정은 위에서 보았던 /etc/shadow파일의 내용과는 달리 '13513"이 설정되어 있는 거을 알 수가 있다.
[root@host3 root]# grep sspark5 /etc/shadow
sspark5:$1$/H.bOlGk$jeEdF1g7naK9vVe4v5i/s/:12314:0:99999:7::13513:
[root@host3 root]#
사용예 #4
이번에는 sspark5의 기본사용쉘을 변경해 보자.
sspark5의 원래 사용했던 기본사용쉘은 /bin/bash(Bash Shell)이였다.
이것을 usermod로 다음과 같이 /bin/csh(C Shell)로 변경한 것이다.
[root@host3 root]# usermod -s /bin/csh sspark5
[root@host3 root]#
이를 확인하기 위하여 /etc/passwd의 내용을 확인하였다.
[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/usr/sspark5:/bin/csh
[root@host3 root]#
사용예 #5
이번에는 sspark5의 UID를 변경해 보자.
UID를 변경하기 위해서는 -u옵션을 사용하면 된다.
[root@host3 root]# usermod -u 508 sspark5
[root@host3 root]#
원래 sspark5의 UID는 506이였던 것을 508로 변경한 것이다.
다음은 변경된 UID값을 확인한 것이다.
[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:508:508:박성수:/usr/sspark5:/bin/csh
[root@host3 root]#
이상과 같이 usermod에 대해서 살펴보았다.
usermod명령어는 useradd, useradd -D, userdel과 함께 익혀두는 것이 바람직한다.
여러분들의 건투를 빈다.
useradd 옵션
-d /user/id --> 홈디렉토리 위치를 /user/id 로 지정함
-u 2000 --> UID 를 2000 으로 지정함
-s /bin/sh --> id 사용자가 기본으로 사용할 쉘 종류를 C쉘로 지정함
-c I'm a man --> 계정사용자의 간단한 코멘트
-e 2009-09-03 --> id의 계정사용기간
-p 1234 --> id의 기본 패스워드
siidc --> 생성할 계정명
1번) useradd -d /home/xnote -u 2000 -s /bin/sh -c NOTEBOOK -e 2007-11-11 -p 1 siidc
ex) useradd -u 1000 -g web -d /user/web -s /bin/sh
2번) useradd에 관한 사용자 생성 및 관리 를 하는 (3개의 파일 _ 디렉토리)
cat /etc/default/useradd--->해당 추가유져 에 대하여 세부적으로 설정가능
cat /etc/login.defs--->메일디렉토리/패스워드기간및알림/UID/GID설정
cat /etc/skel--->계정생성시 자동복사 되는 원본 디렉토리
# useradd defaults file
GROUP=100---> 소속될 그룹의 GID
HOME=/home/web---> 사용자의 홈디렉토리위치
INACTIVE=-1---> 사용자의 패스워드 종료일수 이후의 유효기간
EXPIRE=---> 앞으로 추가 되는 계정들의 종료일수 “2010-10-30” 라고 함
SHELL=/bin/bash---> 기본쉘로 사용할 쉘의 종류이다.
SKEL=/etc/skel---> 새로 생성되는 사용자의 홈디렉토리로 복사될 초기환경파일들이 저장된 디렉토리 지정하는곳
※ 리눅스 는 2번 예제로 설정하는 것보다 1번 예제로 설정하였는것 을 우선으로 함! ※
\