리눅스 (Linux)2015. 12. 24. 23:55

openssh를 centos6.x에 설치시 필요
./configure --prefix=/usr/local/openssh --with-tcp-wrappers --with-pam --with-md5-passwords
gcc
pam-devel
-------------------------------------------------------------------------------------------------------

./configure --prefix=/usr/local/openssh --with-tcp-wrappers --with-pam --with-md5-passwords

성공했다. 이제 make && make install을 진행하자.

[root@localhost openssh-6.6p1]# make


[root@localhost openssh-6.6p1]# make install


--------------------------------------------------------------------------------------------------------
아래 키파일이 다 있는지 확인하여 없으면 find로 찾아 복사해준다
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_rsa_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_dsa_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_ecdsa_key.pub

파일이 없을경우 find로 찾아준다
# find / -name ssh_host_key.pub


openssh 삭제

[root@localhost ~]# rpm -e openssh-clients-5.3p1-104.el6.x86_64
[root@localhost ~]# rpm -e openssh-server-5.3p1-104.el6.x86_64
[root@localhost ~]# rpm -e openssh-5.3p1-104.el6.x86_64


여기부터 설정


설치 스크립트 복사

[root@localhost openssh-6.6p1]# cp /usr/local/src/openssh-7.1p1/contrib/sshd.pam.generic /etc/pam.d/sshd
[root@localhost openssh-6.6p1]# cp /usr/local/src/openssh-7.1p1/contrib/redhat/sshd.init /etc/init.d/sshd
 

[root@localhost openssh-6.6p1]# vim /etc/init.d/sshd

25번줄 - SSHD=/usr/local/openssh/sbin/sshd로 변경
         SSHD=/usr/local/openssh/sbin/sshd

41번줄 - /usr/local/openssh/bin/ssh-keygen -A 로 변경
         /usr/local/openssh/bin/ssh-keygen -A


43번줄
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_rsa_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_dsa_key.pub
               /sbin/restorecon /usr/local/openssh/etc/ssh_host_ecdsa_key.pub



[root@localhost openssh-6.6p1]# export PATH=$PATH:/usr/local/openssh/bin:/usr/local/openssh/sbin
[root@localhost openssh-6.6p1]# ssh -V
OpenSSH_6.6p1, OpenSSL 1.0.1e-fips 11 Feb 2013

sshd start 로 스크립트가 정상인지 테스트
[root@localhost openssh-6.6p1]# /etc/init.d/sshd start
/etc/init.d/sshd: line 41: /usr/local/openssh/ssh-keygen: No such file or directory
/sbin/restorecon:  lstat(/etc/ssh/ssh_host_ecdsa_key.pub) failed:  No such file or directory
Starting sshd:                                             [  OK  ]
[root@localhost openssh-6.6p1]#


스크립트 정상인지 확인되면 재시작
[root@localhost openssh-6.6p1]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]


[root@localhost openssh-6.6p1]# ps -ef | grep sshd
root     23081     1  0 15:41 ?        00:00:00 /usr/local/openssh/sbin/sshd



성공...



Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:54

bit 확인을 하는 방법

내 리눅스가 몇 bit 인가 확인할려면 아래 명령어를 작성해보면 된다.
 

getconf LONG_BIT  // 이거 쓰면 바로 32, 64! 이렇게 뜬다
 
uname -m 

// x86_64은 64비트
 
// i386, i686 나오면 32 bit



Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:53

e2fsck는 리눅스 파일시스템 점검 및 복구 할 수 있는 명령어이고 리눅스에서 사용할 수 있는 거의 모든 파일시스템의 점검과 복구가 가능하다. 서버관리자라면 반드시 알아야 할 중요한 명령어이다!

- e2fsck 작업에서 기본적으로 점검하는 항목 -
1. inodes 점검
2. blocks 점검
3. sizes 점검
4. 디렉토리구조 점검
5. 디렉토리 연결성점검
6. 파일링크 정보
7. 전체파일갯수 점검
8. 전체블록수중 사용중인 블록 점검

- 명령어의 위치 -
[root@omyworld ~]# which e2fsck
/sbin/e2fsck

- 사용법 -

1. 특정 파일시스템의 점검 및 복구
[root@omyworld ~]# e2fsck /dev/hda1
e2fsck 1.35 (28-Feb-2004)
/dev/hda1 is mounted. 

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)?yes

/boot1: recovering journal
/boot1: clean, 34/26104 files, 11778/104388 blocks

2. 특정 파일 시스템 강제 점검 및 복구
*** 강제점검및 복구는 불가피한 상황이 아니면 사용하지 않습니다. ***
[root@omyworld ~]# e2fsck -f /dev/hda1
e2fsck 1.35 (28-Feb-2004)
/dev/hda1 is mounted. 

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)? yes

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/boot1: 34/26104 files (2.9% non-contiguous), 11778/104388 blocks

3. ext3(저널링)파일시스템의 점검 및 복구
"-j ext3" 옵션을 주면 됩니다.
[root@omyworld ~]# e2fsck -j ext3 /dev/hda1 --> 요론식으로 하면 되겠죠? *^^*

4. 특정 파일시스템 강제 점검 및 상세 작업내용보기
[root@omyworld ~]# e2fsck -fv /dev/hda1
e2fsck 1.35 (28-Feb-2004)
/dev/hda1 is mounted. 

WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.

Do you really want to continue (y/n)? yes

Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

    34 inodes used (0%)
      1 non-contiguous inode (2.9%)
        # of inodes with ind/dind/tind blocks: 5/3/0
  11778 blocks used (11%)
      0 bad blocks
      0 large files

    21 regular files
      3 directories
      0 character device files
      0 block device files
      0 fifos
      0 links
      1 symbolic link (1 fast symbolic link)
      0 sockets
--------
    25 files
5. 디스크의 배드블럭 마크하기
e2fsck의 옵션중 badblocks를 실행하여 배드블록을 찾은 후에 디스크의 배드블록 inode에 추가하여 마크함으로써 마킹된 배드블록을 사용하지 못하도록 하는 방법
-c 옵션을 사용하세요~
[root@omyworld ~]# e2fsck -cv /dev/hda1

6. 오류 자동수정
-p 옵션 : 복구하는 과정에서 많은 질문이 발생할 수 있는데 이런 질문을 계속해서 답해주는것도 참 힘든일이겠죠? 이런 과정을 자동으로하도록 하는 옵션입니다.

7. 모든 질문항목에 yes라고 대답하기
-y 옵션

8. 모든 질문 항목에 no라고 대답하기
-n 옵션

 


[ 발생 원인 및 기타 ]

  파일 시스템의 손상은 갑작스런 정전이나 비 정상적인 시스템 종료시 흔히 발행한다.
  이런 경우 시스템은 부팅되면서 자동으로 파일시스템을 check 하게끔 etc/fstab 에 설
  정되어있다.

  부팅과정을 지켜보면 해당 파티션에대한 check 작업을 하는 과정을 볼수가있다.
  이때 아무런 문제없이 파일 시스템의 check 가 끝나게되면 OK 라는 싸인이 떨어지게된다.
  그렇지 못할경우 PASSED 하는 사인이 뜰어진다. PASSED 라는 메시지가뜰어지면 정상적으 
  로 부팅후 파일시스템을 check 해주는게 좋을듯 싶다.

  하지만, 위의 내용처럼 간단한 파일시스템 손상의 경우는 문제가 되지않지만, 심각한 
  손상이있을경우 파일시스템을 마운드하지못하고 root 패스워드를 입력하라는 화면에서 
  멈출때가 종종있다.
  이때는 root 패스워드를 입력하고 파일시스템을 check 한후 재부팅을 하게되면 그런 문제 
  는 해결할수가있다. 
  하지만 이미 손상이된 파일시스템은 차후에 동일한 결과를 가져올수있기 때문에 심각한
  오류가 발행한 시스템은 새로이 설치하는게 차후의 서비스에대한 대비책이라고 생각된다.

[ 파일시스템의 손상형태 - 복구쉬움 ]

  1. 참조되지않은 inode
  2. 납득할수없이 큰 링크의 갯수
  3. 블록멥에 기록되지않은 사용되지않는 데이터 블럭
  4. 파일에서 사용하고있지만 비어있다고 기록된 데이터 블럭
  5. 슈퍼블럭의 부정확한 요약정보
 
  위의 5가지 내용은 부팅되면서 자동으로 fsck로 고쳐진다. - 단 fstab 에 부팅되면서 파일
  시스템을 check 하라고 지정되어있을시.....

[ 위험한 손상형태 ]

  1. 하나이상의 파일이 요구되는 블럭
  2. 파일시스템의 범위밖에서 요구하는 블럭
  3. 너무 작은 링크 갯수
  4. 셀수없는 블럭
  5. 할당되지않은 inode를 가리키를 디렉토리
  6. 다양한 포맷 에러

[ e2fsck 사용하기 - man 페이지를 참고로 했습니다 ]

1. e2fsck 는 ?

  e2fsck - 리눅스 파일시스템을 check & repair 하기위해서 사용되는 명령어이다.
            e2fsck 는 ext2 파일시스템을 지원한다.

2. 사용 방법

  e2fsck [옵션] [디바이스명] 

3. 사용 옵션

  -p : 파일시스템을 검사하면서 자동으로 복구해준다.
  -n : 파일 시스템을 바꾼다.
  -y : 모든 질문에대한 응답을 yes 로 취급한다.
  -c : BAD BLOCK 을 CHECK 한다.
  -f : 깨끗한 파일시스템까지 강제적으로 check 한다.

'리눅스 (Linux)' 카테고리의 다른 글

openssh를 centos6.x에 설치하기  (0) 2015.12.24
리눅스 비트 확인 방법  (0) 2015.12.24
[linux] fsck, e2fsck 활용하여 filesystem check 하기  (0) 2015.12.24
배드블럭 검사  (0) 2015.12.24
리눅스 기본 명령어  (0) 2015.12.24
Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:53

리눅스 파일시스템 점검및 복구를 할 수 있는 명령어입니다.

리눅스 시스템이 부팅되는 과정에서 /etc/rc.d/rc.sysinit 스크립트가 자동으로 실행이 됩니다.
/etc/rc.d/rc.sysinit 스크립트를 확인해 보시면 파일시스템을 점검하는 명령어가 실행되는 단계가 있습니다. 따라서 시스템부팅시마다 파일시스템점검명령어가 실행됩니다.

e2fsck 의 종료코드
0 - 에러없이 정상적인 종료를 의미함.
1 - 파일시스템을 복구하였음을 의미함.
2 - 파일시스템이 복구되어 시스템이 재부팅되어야함을 의미함.
4 - 작업대상 파일시스템에 문제가 있으나 복구하지않고 그대로 두었음을 의미함.
8 - 실행에러를 의미함.
16 - 사용법(Usage)또는 문법(Syntax)에러를 의미함.
32 - e2fsck 작업이 사용자에 의해서 취소(Cancel)되었음을 의미함.
128 - 공유 라이브러리(Shared library) 에러를 의미함.

[주의사항]
e2fsck 명령어로 파일시스템을 점검하고 복구할 때에는 대상 파일시스템이 마운트되어있지않은 상태에서 실행하시기 바랍니다. 만약 마운트되어있는 상태에서 이 명령어를 사용하신다면 원하지않은 오류를 발생할 수도 있습니다.
마운트된 파일시스템을 e2fsck 로 점검 할때는 "WARNING!!!" 메세지가 나온다~

사용하기전에 파일시스템 정보부터 확인한다.
-----------------------------------------------------------------------------------
[root@dg69 /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2              4957220   2726600   1978804  58% /
/dev/sdb1             17654736   2672588  14085324  16% /backup
/dev/sda1               101086     17979     77888  19% /boot
none                    517292         0    517292   0% /dev/shm
/dev/sda5             11084636    178904  10342656   2% /home
------------------------------------------------------------------------------------
[root@dg69 /]# mount
/dev/sda2 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sdb1 on /backup type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda5 on /home type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/proc on /var/named/chroot/proc type none (rw,bind)
------------------------------------------------------------------------------------
[root@dg69 /]# fdisk /dev/sdb
The number of cylinders for this disk is set to 2233.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 18.3 GB, 18373206016 bytes
255 heads, 63 sectors/track, 2233 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        2233    17936541   83  Linux
Command (m for help): q
------------------------------------------------------------------------------------
[root@dg69 /]# fdisk /dev/sda
The number of cylinders for this disk is set to 2233.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 18.3 GB, 18373206016 bytes
255 heads, 63 sectors/track, 2233 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         640     5036377+  83  Linux
/dev/sda3             641         831     1534207+  82  Linux swap
/dev/sda4             832        2233    11261565    5  Extended
/dev/sda5             832        2233    11261533+  83  Linux
Command (m for help): q
[root@dg69 /]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/backup1          /backup                 ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
LABEL=/home1            /home                   ext3    defaults        1 2
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/hda                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0
[root@dg69 /]#
------------------------------------------------------------------------------------
e2fsck 사용법
------------------------------------------------------------------------------------
[root@dg69 /]# e2fsck /dev/sdb1              <-----일반적인 특정시스템 점검복구
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 is mounted. 
WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/backup1: clean, 62/2244608 files, 738598/4484135 blocks
------------------------------------------------------------------------------------
[root@dg69 /]# e2fsck -f /dev/sdb1                   <-----강제적인 특정시스템 점검복구
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 is mounted. 
WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/backup1: 62/2244608 files (16.1% non-contiguous), 738598/4484135 blocks
------------------------------------------------------------------------------------
[root@dg69 /]# e2fsck -j ext3 /dev/sdb1      <-----ext3(저널링)파일시스템 점검복구
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 is mounted. 
WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/backup1: clean, 62/2244608 files, 738598/4484135 blocks
--------------------------------------------------------------------------------------
[root@dg69 /]# e2fsck -fv /dev/sdb1     <-----강제적인 특정시스템 점검복구및 상세정보출력
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 is mounted. 
WARNING!!!  Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
      62 inodes used (0%)
      10 non-contiguous inodes (16.1%)
         # of inodes with ind/dind/tind blocks: 27/17/0
  738598 blocks used (16%)
       0 bad blocks
       1 large file
      43 regular files
      10 directories
       0 character device files
       0 block device files
       0 fifos
       0 links
       0 symbolic links (0 fast symbolic links)
       0 sockets
--------
      53 files
-----------------------------------------------------------------------------------------

*점검 복구 자동 : e2fsck -p /dev/sdb1

*점검,복구시 묻는질문에 무조건 yes : e2fsck -y /dev/sdb1

*점검,복구시 묻는질문에 무조건 no : e2fsck -n /dev/sdb1

*버퍼캐쉬의 내용을 디스크에 저장하기 : e2fsck -F /dev/sdb1


파일시스템의 수퍼블록을 이용한 파일시스템 복구방법

리눅스의 파일시스템은 블록그룹(Block Group)이라는 것으로 기본구조를 이루고 있으며 모든 블록그룹의 맨 앞에는 수퍼블록이라는 것이 존재합니다. 블록그룹에 존재하는 모든 수퍼블록들은 동일한 정보를 가지고 있으며 파일시스템이 파괴되었을 경우에 이 정보를 이용하여 복구를 할 수 있도록 준비하고 있습니다.

- 첫번째 수퍼블록 : 1 번블록에 위치함.
- 두번째 수퍼블록 : 1 번블록 + 8192 번블록*1 = 8193 번째 블록에 위치함.
- 세번째 수퍼블록 : 1 번블록 + 8192 번블록*2 = 16385 번째 블록에 위치함.
- n 번째 수퍼블록 : 1 번블록 + 8192 번블록*n 번째블록에 위치함.

ex)  첫번째 수퍼블록이 깨졌기 때문에 일반적인 방법으로 복구가 불가능하게 된 경우로서 두번째 수퍼블록으로 복구를 하는 예
----------------------------------------------------------------------------------------
[root@file root]# e2fsck -b 8193 /dev/sda1
e2fsck 1.32 (09-Nov-2002)
/dev/sda1 is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? yes
/boot was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/boot: ***** FILE SYSTEM WAS MODIFIED *****
-------------------------------------------------------------------------------------------
세번째 수퍼블록을 이용한 복구작업 : # e2fsck -b 16385 /dev/sda1
네번째 수퍼블록을 이용한 복구작업 : # e2fsck -b 24577 /dev/sda1

'리눅스 (Linux)' 카테고리의 다른 글

리눅스 비트 확인 방법  (0) 2015.12.24
e2fsck 리눅스 파일시스템 점검 및 복구  (0) 2015.12.24
배드블럭 검사  (0) 2015.12.24
리눅스 기본 명령어  (0) 2015.12.24
openssl_1.0.2d 적용하기  (0) 2015.12.24
Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:52

sudo badblocks -v /dev/sdx (/dev/sda, /dev/sdb, ... /dev/sdx)


이 명령어는 하드디스크와 플로피디스크의 배드블럭(bad block)을 검사하는 명령어이다.

배드블럭이 존재하는 하드디스크를 사용하게 되면 정상적인 운용중에도 갑자기 서버가 다운되는 등의 심각한 장애를 초래할 수 있다.

따라서 배드블럭은 서버설치시 또는 설치직후에 반드시 점검을 해야하며 배드블럭이 존재할 경우에는 깨끗한 디스크로 반드시 교체해야한다.

아래는 실제 배드블럭을 검사하는 예이다.

[root@www named]# badblocks -v /dev/sda5
Checking for bad blocks in read-only mode
From block 0 to 15615148

Pass completed, 0 bad blocks found.
[root@www named]#

위의 예는 배드블럭이 존재하지 않았을 경우의 예이다. 이상이 없는 깨끗한 디스크이므로 정상적인 사용이 가능하다고 할 수 있다.


[root@www root]# badblocks -v -o badblock.txt /dev/sda3
Checking for bad blocks in read-only mode
From block 0 to 16755795
Pass completed, 3 bad blocks found.
[root@www root]#
[root@www root]#
[root@www root]#
[root@www root]# ll
total 8
-rw-r--r--    1 root     root         1199 Jun 30  2002 anaconda-ks.cfg
-rw-r--r--    1 root     root           27 Jan 17 22:34 badblock.txt
[root@www root]#
[root@www root]# cat badblock.txt
16755792
16755793
16755794
[root@www root]#

위의 경우에는 3개의 배드블럭이 존재하는 경우이다. 배드블럭이 존재할 경우에는 몇개의 배드블럭이 존재하는지 결과에서 알려준다.

이 경우처럼 -o옵션을 주게 되면 지정된 파일(badblock.txt)에 결과를 저장하며 그 파일을 확인(cat badblock.txt)함으로서 배드블럭의 번호를 확인할 수 있다.

Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:52

디렉토리
# pwd(현재위치한 디렉토리 경로나타남)
# cd(change directory 이동할 디렉토리명)

# cd /   n.(루트디렉토리로 이동)
# cd ~sample1   n.(sample1사용자 홈디렉토리로 이동한다)
# cd ..  n.(그 부모(홈) 디렉토리로 이동)
# cd ../sample2 (그 부모 홈으로가서 다시 sample2로 이동한다)
# ls   n.(파일목록 보여줌)
# ls -l   n.(파일의 목록과 상세정보 보여줌)
------------------------------------
-l(엘)파일의 긴정보 상세정보 보여줌
-a    숨김파일을 보여줌
-t    가장 최근에 변경된 파일을 최근순서대로 보여줌
-u    최근에 엑세스했던 파일목록 보여줌
-f    파일의 특성 보여줌
-R    하위디렉토리 파일도 모두 보여줌
---------------------------------------

디렉토리/파일생성(mkdir-make directory)
----------------------
-m 디렉토리권한을 지정
-p 상의 경로까지 생성
---------------------
# mkdir test1 n.(test1 디렉토리/파일생성)
# ls -l  n.(만든 디렉토리 확인-리스트)

디렉토리삭제(rmdir)
# rmdir test1  n.(test1 디렉토리 삭제)
# ls -l  n.(리스트 확인)
# cd test1  n.(test1 안으로 들어가서 보기)
# ls -l n.(상세보기 없는파일)
# ls -al  n.(히든파일이 보인다)
# cd ..   n.(이곳에서 위로 나가기)

사용자추가
# grounpadd susergroup n. (그룹만들기)
# cat /etc/group:grep susergroup n.  (그룹이름 susergroup 으로 만든다/grep-조건)
505:그룹숫자나타남/그룹내부 소속만들기
# useradd -g susergroup user1 n.
# cat /etc/passwd n.  (만든 소그룹 user1 확인)
# useradd -g susergroup user2 n. (내부그룹 또하나 만든다)
# cat /etc/passwd n. (만들어진 소그룹 user2 확인하기)

비밀번호 설정
# passwd user1 n.(비밀번호 설정하기)
Changing password for user user1. 질문이 나타나면 암호를 입력한후 엔터/안보임)
# cat /etc/shadow n.(암호화된 비밀번호 보기/!!는 비밀번호 설정 안된것)
# cd ~user1 n.(user1 의 홈디렉토리로가기)
# cd ..   n.  (상위로 가기)
# cd /   n. (다시 루트로 돌아가기)
# groupdel susergroup (susergroup 삭제하기-소그룹이 있으면 그것먼저 삭제한다)
# userdel -r user1   n.(소그룹 user1 삭제하기 -r을 써야 홈디렉도 삭제된다)
# cd ~user1  n.  (삭제됐는지 확인후 그룹삭제한다)
# groupdel susergroup n. (그룹삭제하기)
# cat /etc/group  n.(그룹확인하기)

권한부여(퍼미션)-chmod(명령어)
---------------------------------------
u-사용자 
g-그룹 
o-다른사용자
d-디렉토리             예:drwx----
-(빼기표시)-파일의미   예:-rw-r--r--
|-링크표시
r-읽기.보는권한(4으로표기)
w-쓰기 변경 삭제,추가 권한(2으로표기)
x-실행권한(1으로표기)
권한없음(0으로표기)
r w x ---     ---  는 7 0 0 (즉 700이라고 표기함)
4 2 1  0소그룹0그룹
-c :변경파일만 보여줌
-f :변경안된 파일에서 오류메시지를 보여주지 않음
-/ :작업상태를 자세히 보여줌
--------------------------------------------
# chmod 700 hello2 (hello2 파일에 대하여 rwx------ 으로 변경하라)

소유자변경-chown(명령어)
# chown user1 hello1 (hello1 파일의 소유자를 user1으로 변경하라)

파일만들기
# touch sample n.(sample파일만들기)
# ls -al(목록보기-만든파일 확인하기)

파일수정하기 (-rw-r--r-- 상태를 수정하기)
# chmod 766 sample n.  (-rwxr--r--)
# ls -l(목록보기-변경파일 확인하기)
# groupadd susergroup n.
# useradd -g susergroup u1 n.(u1 은 사용자이름등록)
# useradd -g susergroup u2 n.(u2 은 사용자이름등록)
# chown u1 sample (sample 파일의 소유자를 u1 로변경하기)
# ls -l n.(확인)
# chown u2.susergroup sample  n. (그룹명수정하고 u2사용자명도 변경)

파일관련(파일만들기)
-------------------------
-a 최근파일사용 시간만변경
-d 현재시간대신 지정한 시간을 사용
-m 최근파일변경시간만 바꿈
--------------------------
# touch sample  n. (sample 파일을 당장 만들어라)
# ls -al  n.(모든파일 보기-히든파일도 보기)

파일복사(cp-copy)
-------------------------------------------------------
-a 원본파일의 속성,링크 정보를 그대로 유지하면서 복사
-l 복사장소에 같은 파일있으면 덮어쓸것인지..
-r 디렉토리를 복사할때 하위디렉토리까지 포함해서 복사
-f i와 반대로 같은이름의 파일이 있으면 자동 덮어쓰기 실행
--------------------------------------------------------
# cp samplegroup sample1(samplegroup 파일 sample1 이름 복사)

파일변경(mv-move)
# mv test t1  n.(test 파일을 te1 이름으로 변경)

파일이동
# mv test* /room/  n.(test이름으로 시작된 모든 파일을 room폴더로 이동한다)

파일삭제(rm-remove)
# rm sample1  n. (sample1 파일 삭제)
# rm -r sample1  n. (sample1 파일삭제시및디렉토리도 삭제하는지 묻고 삭제한다)

파일내용을 화면에 출력(cat)
# cat -n(-b) sample (sample 파일내용중 -b 공백제외)

파일내용 분할(more=less)
# more sample (-d / -p 는 옵션)
# ls -al : more   n.(페이지마다 잘라 보여줌 space바 누르면 다음 보여줌)

파일찾기(find)
# (find /(슬러쉬는 시작디렉토리의미) 검색조건)
------------------------------------------------
-name "문자열" 파일이름이 문자열과 일치하는 파일 검색
-user "사용자이름" 특정 사용자의 소유권인 파일을 찾을때사용
-perm "퍼임션" 명시된 퍼미션으로 된 파일을 찾을때 사용
--------------------------------------------------------
# fine -name test  n. (test가 붙은 파일을 찾아라)
# find / -name test  n. ((/는모두중에서 test가 붙은 파일을 모두 찾아라)
# fine /home -perm 700  n. (home 디렉토리에 대하여 파일권한이 700 인것 찾아라)
                예) -rwx --- ---
                     421  0   0   = 700

파일내 입력값부터 특정패턴을 검색(grep)
---------------------------------------
-c 검색조건과 일치하는 행의 개수
-l 검색조건과 일치하는 파일의 이름만 표시
-n 검색조건과 일치하는 내용있는 파일이름과 행번호 표시
-------------------------------------------------------
# grep -n "rc.d" /etc/ini   n.(ini파일내용중에서 rc.d 내용을 표시)
# cat /etc/passwd | grep "sam*"   n.(etc/passwd 에서 sam로 시작하는 결과만 보여줌)

파이프명령(|)-(명령1값을|명령2가 받는다)
# cat /etc/passwd | grep "sample*" (etc/passwd 에서 sample로시작하는 결과만 보여줌)

Vi명령어Vi편집기(vi에디터/Vi에디터-메모장역활)
---------------------------------
I 커서가 위치한곳 앞에 내용 삽입
A 커서가 위치한곳 바로뒤에 내용 추가
O 커서가 위치한 다음줄에 내용 삽입
----------------------------------
# vi test (test 파일이 생성된다)
# :w  (저장)
# :w sample (sample 이름으로 저장)
# :wq (저장후 종료 꼭 esc 누른후)
# :q  (저장하지않고 종료)
# :q! (강제저장후 종료)
# x (delete역할)
# 10 dd (현재커서위치한곳부터 10줄삭제)
# dw (단어단위 삭제)
# :20  (20번째 라인으로 커서이동)
# 2yy (2라인복사)
# yw (단어단위 복사)
# p  (현재커서 아래쪽으로 붙여넣기-소문자p)
# P  (현재커서 위쪽에 붙여넣기-대문자P)
# /init  (init 단어가 있는곳으로 찾아감)
# :s/형식/바꿀형식/g (치환작업)
# :1,10 s/an/bw/g  (1~10줄까지 an을찾아 bw로 모두(g) 변경하라)
# :1,$ s/an/bw/g  (1부터$(끝까지) an을찾아 bw로 모두(g) 변경하라)
# !bash  (명령prompt상태로 변환)
# #edit   (다시 에디터로 돌아옴)

파일시스템
# fdisk -l (현재시스템의 파티션 목록)
# fdisk -v (버전정보)
# fdisk -s (장치명/입력된장치의 크기출력)
# p (설정된 파티션을 확인)
# n (새로운 파티션 설정)
# 2 (주 파티션과 파티션번호 설정)

파일시스템설정-mkfs
# mkfs -t ext3 /dev/hda5
# mount -t ext3 /dev/hda5 /wkarea (hda5와 wkarea 마운트한다)
# umount /dev/hda5 (dev/hda5 마운트작업 해제)
 


# diff 파일명1, 파일명2 ( 파일명1, 파일명2 비교하여 틀린 행 출력)
 

<< linux 2013 >>

리눅스유선네트워크연결 : 상단 오른쪽 네트워크해제표시 -> System ethO클릭(네트워크연결)

# ifconfig (ip주소검색)

# uname -i -> 시스템이키택출력 -하드,소프트구조

# uname -a -> 시스템 모든정보 출력

# man -> 메뉴얼 man [command]

# --help

Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:52

basic:root:/root># find / -name *crypto*.so -ls
1581959    0 lrwxrwxrwx   1 root     root           30 11월  5 23:18 /usr/lib64/libk5crypto.so -> ../../lib64/libk5crypto.so.3.1
2367822   96 -rwxr-xr-x   1 root     root        94496  7월 24 07:52 /usr/lib64/python2.6/site-packages/OpenSSL/crypto.so
1584362    0 lrwxrwxrwx   1 root     root           19 11월  5 23:18 /usr/lib64/libcrypto.so -> libcrypto.so.1.0.1e

 

basic:root:/usr/lib64># ls -al libcrypto*
lrwxrwxrwx. 1 root root      19 2015-11-05 23:18 libcrypto.so -> libcrypto.so.1.0.1e
-rwxr-xr-x. 1 root root 1965856 2015-07-24 04:09 libcrypto.so.1.0.1e
lrwxrwxrwx. 1 root root      19 2015-11-05 23:18 libcrypto.so.10 -> libcrypto.so.1.0.1e
basic:root:/usr/lib64>#



---------------------------------------------------------------------------------------

# cd /usr/local/src

# wget http://openssl.org/source/openssl-1.0.2d.tar.gz

# tar -xvf openssl-1.0.2d.tar.gz

# cd openssl-1.0.2d

# ./config shared

# make

# make test

# make install

# openssl version

// 구 버젼으로 나올때는 아래 ln 관련 문장들을 실행하고, 1.0.2d로 나오면 so파일 적용으로 넘어간다.


# mv /usr/bin/openssl openssl.20151028

# chmod ugo-x openssl.20151028

# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

# openssl version

?

---------------------------------------------------------------------------------------

so파일들 변경 적용 (shared lib)

/usr/local/ssl/lib
에 다음의 파일이 생긴다
libcrypto.so -> libcrypto.so.1.0.0
libcrypto.so.1.0.0

libssl.so -> libssl.so.1.0.0
libssl.so.1.0.0


이걸

/usr/lib64

libcrypto.so -> libcrypto.so.1.0.2d
libssl.so -> libssl.so.1.0.2d

로 적용시킨다



-------------------------------------------
기타
다음의 옵션으로 할 수도 있다
./config --prefix=/usr/local --openssldir=/usr/local/openssl shared 라고 컴파일하면

/usr/local/bin

openssl

파일이 생긴다
---------------------------------------------------

v6_web:root:/usr/lib64># ls -al libcrypto*
v6_web:root:/usr/lib64># ls -al libssl*



Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:51

▣ tar

tar 파일은 여러 디렉토리를 하나의 파일로 묶을 때 주로 사용 합니다.

묶인 파일은 xxxx.tar 와 같이 .tar의 확장자명을 가지며 풀었을 때 여러 파일과 디렉토리 구조로 묶임이 풀리게 됩니다.

 
 압축 : tar -cvf test.tar

 해제 : tar -xvf test.tar


 특정 디렉토리만을 압축하고 싶은 경우

 tar -cvf test.tar [디렉토리명] [디렉토리명]


 
▣ gzip

.gz 또는 .tar.gz 으로 확장자명이 되어있는 파일은 gzip으로 압축 된 파일입니다.

 
 압축 : gzip test.tar

          gzip -v test.tar

 해제 : gzip -d test.tar.gz


 

'리눅스 (Linux)' 카테고리의 다른 글

리눅스 기본 명령어  (0) 2015.12.24
openssl_1.0.2d 적용하기  (0) 2015.12.24
리눅스 파일갯수 확인  (0) 2015.12.24
서비스 동시접속 인원알기  (0) 2015.12.24
프롬프트 절대경로 표시  (0) 2015.12.24
Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:51

# ls -l | grep ^d | wc -l (디렉토리 갯수 확인)

# ls -l | grep ^- | wc -l (파일 갯수 확인)

# ls -lR | grep ^- | wc -l  (하위디렉토리 파일 갯수 확인)


# ls -lR R130 | grep ^- | wc -l (R130 디렉토리 하위디렉토리 안에 갯수 확인)
       (디렉토리)


Posted by 랩퍼우
리눅스 (Linux)2015. 12. 24. 23:50

서비스 동시접속 인원알기


#netstat -l 또는 netstat -nap | grep LISTEN (LISTEN 되는 모든 포트)
#netstat -nap | grep ESTABLISHED | wc -l ( 모든 서비스 동시 접속자 수)
#netstat -nap | grep :80 | grep ESTABLISHED | wc -l ( 웹 동시 접속자 수)
#netstat -n|grep -F :80|egrep '(ESTAB|SYN)'|awk '{print $5}'|sed 's/:[0-9]*//'|sort -u|wc -l  (웹서버 커넥션수 체크)

Posted by 랩퍼우