192.168.10.1/24

192.168.10.1/25

 

서브넷 마스크를 보면 보통 255.255.255.0 이런식으로 표시된다.

255를 2진수로 변화시키면 11111111 이 된다.

그래서 255.255.255.255.0 를 2진수로 표시하면

11111111.11111111.11111111.0 이렇게 된다.

따라서 1의 개수가 총 24개가 되고 마지막 자리에서 0~255까지의 아이피를 모두 사용할 수 잇게 된다.

이럴때 IP뒤에 /24 라고 표시한다.

즉 /24 라고 되어 있으면 IP 255개 모두를 사용할 수 있는 것이다.

 

만약 255개의 IP를 두개로 나누게 되면

255.255.255.128 은

11111111.11111111.11111111.10000000 이 된다.

이렇게 되면 아이피를 255개의 반밖에 사용할 수 없게 된다. (128까지)

/25 라고 되어 있으면 128개의 아이피를 사용할 수 있다고 보면 된다.

 

/26 이면 아이피를 1/4로 나눈것이다. 즉 64개가 사용가능하다.

Posted by 옥탑방람보
,

<CentOS 5 에서 jailkit 설치 방법>

 

1. jailkit 다운로드 - http://olivier.sessink.nl   

2. jailkit 설치 (root 계정)

    $> yum install jailkit.x86_64

    또는

    $> tar jxvf jailkit-2.11.tar.bz2

    $> cd jailkit

    $> ./configure

    $> make

    $> su -

    $> make install

3. jailkit init 파일 수정

    $> vi /etc/jailkit/jk_init.ini

    paths=/usr/libexec/openssh/sftp-server  #CentOS5 에서의 sftp-server 위치임.

4. chroot jail 생성

5. 계정 생성

    $> adduser juser

    $> passwd juser

6. jail 로 계정 정보 이동

    $> jk_cp -j /var/jail /usr/sbin/jk_lsh

    $> jk_jailuser -m -j /var/jail/ juser

7. sftp/scp only (기타사항 허용시 paths, executables에서 관련 실행파일을 , 단위로 나열하면 된다. *테스트필요)

    $> mkdir -p /jail/etc/jailkit

    $> vi /var/jail/etc/jailkit/jk_lsh.ini

    [juser]

    paths = /usr/libexec/openssh/

    executables = /usr/libexec/openssh/sftp-server

    allow_word_expansion = 0

8. 확인

    $> cat /etc/passwd

    juser:x:505:506::/var/jail/./home/juser:/usr/sbin/jk_chrootsh

    $> sftp juser@localhost

    sftp> 라고 나타나면 성공

    이후 juser 계정으로 sftp를 접속하면 juser의 / 는 서버상의 /var/jail 이 되므로 상위 디렉토리를 볼 수 없게 된다.

 

<rocks clusters>

계정생성시 /export/home 과 같은 심볼릭링크로 걸면 되지 않는다.

그렇기 때문에,

adduser -d /state/partition1/home/juser juser

로 계정을 생성해야 하고,

$> cat /etc/passwd 시

juser:x:505:506::/var/jail/./state/partition1/home/juser:/usr/sbin/jk_chrootsh

으로 구성되어야 한다.

jail로 묶인 계정은 cluster 분석 계정으로 사용할 수 없다. (automount 문제)

'TA > Common' 카테고리의 다른 글

IP 주소  (0) 2012.12.28
ip주소 표시할때 뒤에 쓰는 /24 /25 /26  (0) 2012.12.28
[linux] working multiple files on vi editor  (0) 2012.12.24
[linux] vi regular expression  (0) 2012.12.24
[ssh] start SSH server on Ubuntu  (0) 2012.12.24
Posted by 옥탑방람보
,
How do I work with multiple files at the same time?


vi allows for multiple files to be open at the same time. Unlike many editors, you only see one file at a time. If you start vi with multiple files on the command line they'll all be opened up.
You'll start out in the first file, and you can move to the next file by typing :n.
If you've made changes to the current file that you don't want to keep, you can go on by using :n!. Note that this will discard any changes that you've made.
If you want to save, you need to use :w first.

 

Posted by 옥탑방람보
,
Regular expressions appear to be rapidly gaining in popularity among VIM users as they discover the sheer programming power that regular expressions can provide. Historically, regular expressions have been associated with the UNIX platform and scripting languages like Perl (Practical Extraction and Report Language).

The syntax in VIM is slightly different then in Perl, but is pretty close. This makes Perl regular expression examples relevant to VIM users.

Softpanorama RegEx page contain basic information about regular expressions. I would like to stress that Vim's regexp implementation is reasonably close to Perl's and skills are transferable. Among the differences between Perl and Vim we can note:

Some meta characters are different (in yellow)

# Matching # Matching
. any character except new line
\s whitespace character \S non-whitespace character
\d digit \D non-digit
\x hex digit \X non-hex digit
\o octal digit \O non-octal digit
\h head of word character (a,b,c...z,A,B,C...Z and _) \H non-head of word character
\p printable character \P like \p, but excluding digits
\w word character \W non-word character
\a alphabetic character \A non-alphabetic character
\l lowercase character \L non-lowercase character
\u uppercase character \U non-uppercase character

Many special characters need to be escaped. For example:
\+ matches 1 or more of the preceding characters...
\{n,m} matches from n to m of the preceding characters...
\= is used instead of \? (matches 0 or 1 more of the preceding characters)

Quantifier Description

* matches 0 or more of the preceding characters, ranges or metacharacters .* matches everything including empty line
\+ matches 1 or more of the preceding characters...
\= matches 0 or 1 more of the preceding characters...
\{n,m} matches from n to m of the preceding characters...
\{n} matches exactly n times of the preceding characters...
\{,m} matches at most m (from 0 to m) of the preceding characters...
\{n,} matches at least n of of the preceding characters...


Alternatives (OR) need to be escaped

Using "\
" you can combine several expressions into one which matches any of its components. The first one matched will be used.

\(Date:\
Subject:\
From:\)\(\s.*\)

will parse various mail headings and their contents into \1 and \2, respectively. The thing to remember about VIM alternation that it is not greedy. It won't search for the longest possible match, it will use the first that matched. That means that the order of the items in the alternation is important!

Tip 3: Quick mapping to put \(\) in your pattern string
cmap ;\ \(\)

Non-greed modifiers are different and more obscure then in Perl. Perl allows you to convert any quantifier into a non-greedy version by adding an extra ? after it. So *? is a non-greedy version of a special character *


Quantifier Description
\{-} matches 0 or more of the preceding atom, as few as possible
\{-n,m} matches 1 or more of the preceding characters...
\{-n,} matches at lease or more of the preceding characters...
\{-,m} matches 1 or more of the preceding characters...

Replacement rules are different

You can group parts of the pattern expression enclosing them with "\(" and "\)" and refer to them inside the replacement pattern by their special number \1, \2 ... \9. Typical example is swapping first two words of the line:

s:\(\w\+\)\(\s\+\)\(\w\+\):\3\2\1:


where \1 holds the first word, \2 - any number of spaces or tabs in between and \3 - the second word. How to decide what number holds what pair of \(\) ? - count opening "\(" from the left.

Replacement part of the S&R has its own special characters which we are going to use to fix grammar:



# Meaning # Meaning
& the whole matched pattern \L the following characters are made lowercase
\0 the whole matched pattern \U the following characters are made uppercase
\1 the matched pattern in the first pair of \(\) \E end of \U and \L
\2 the matched pattern in the second pair of \(\) \e end of \U and \L
... ... \r split line in two at this point
\9 the matched pattern in the ninth pair of \(\) \l next character made lowercase
~ the previous substitute string \u next character made uppercase


Now the full S&R to correct non-capital words at the beginning of the sentences looks like

s:\([.!?]\)\s\+\([a-z]\):\1 \u\2:g

We have corrected our grammar and as an extra job we replaced variable number of spaces between punctuation and the first letter of the next sentence with exactly two spaces.

Perl supports a more options that can be appended to the regexp, or even embedded in it.

You can also embed variable names in a Perl regular expression. Perl replaces the name with its value; this is called "variable interpolation".

The most common task is to make replacements in a text following some certain rules using VIM search and replace command (S&R) :s(substitute). For example here is how globally replace all occurrences of vi with VIM.


%s/1999/2003/g

This is a very common idiom in vi/vim. Like in Perl you can also use several modifiers

c Confirm each substitution
g Replace all occurrences in the line (without g - only first).
i Ignore case for the pattern.
I Don't ignore case for the pattern

 

Posted by 옥탑방람보
,
sudo apt-get install ssh
sudo apt-get install openssh-server
sudo update-rc ssh defaults

 

'TA > Common' 카테고리의 다른 글

[linux] working multiple files on vi editor  (0) 2012.12.24
[linux] vi regular expression  (0) 2012.12.24
[ssh] Keeping SSH session from Firewall  (0) 2012.12.24
[linux] Adding a samba user on Ubuntu  (0) 2012.12.24
[linux] umout: device is busy  (0) 2012.12.24
Posted by 옥탑방람보
,
> vi /etc/ssh/ssh_config    (or  ~/.ssh/config)

Host *
    ServerAliveInterval 60

On Client machine,
The 'ServerAliveInterval 60' indicates that it should send a little bit of data over the connection every 60 seconds. You can avoid disconnection by many firewalls. Available on SSH protocol 2 version only.



Possible on server machine as an another solution,

> vi /etc/ssh/ssh_config

ClientAliveInterval 600
ClientAliveCountMax 3

 

'TA > Common' 카테고리의 다른 글

[linux] vi regular expression  (0) 2012.12.24
[ssh] start SSH server on Ubuntu  (0) 2012.12.24
[linux] Adding a samba user on Ubuntu  (0) 2012.12.24
[linux] umout: device is busy  (0) 2012.12.24
[ssh] Very slow login of SSH on Ubuntu  (0) 2012.12.24
Posted by 옥탑방람보
,

> sudo adduser user01  (if need)
> sudo passwd user01  (if need)
> sudo smbpasswd -a user01
> sudo vi /etc/samba/smb.conf

[user01]
command = user01's smb
path = /home/user01
read -nly = no
writable = yes
printable = yes
public = yes
browsable = yes
guest ok = no

> sudo /etc/init.d/smbd restart  (or   service smbd restart)

Posted by 옥탑방람보
,

> umount /mnt/imsi
umount: /mnt/imsi: device is busy


==>
> fuser -cu /mnt/imsi/     #check users holding this directory
> fuser -ck /mnt/imsi      #remove users holding this directory forcely

(주의, fuser 하면 로그인되어 있는 유저들이 로그아웃됨)

Posted by 옥탑방람보
,
> vi /etc/nsswith.conf
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 
==>
hosts:          files mdns4_minimal [NOTFOUND=return] dns #mdns4 

 

Posted by 옥탑방람보
,
Type the following command to install plugin, enter:

# yum install yum-downloadonly


# yum update httpd -y --downloadonly --downloaddir=/opt
==> update or install or reinstall

 

'TA > Common' 카테고리의 다른 글

[linux] umout: device is busy  (0) 2012.12.24
[ssh] Very slow login of SSH on Ubuntu  (0) 2012.12.24
[linux] write error in swap file  (0) 2012.12.24
[ssh] sync ssh key between two different machines or accounts  (0) 2012.12.24
[ssh] slow SSH login  (0) 2012.12.24
Posted by 옥탑방람보
,