'Linux'에 해당되는 글 4건

  1. 2020.01.12 find 사용방법
  2. 2020.01.01 yum exclude
  3. 2019.12.30 LVM 용량 확장 (온라인중)
  4. 2019.12.30 패스워드 알고리즘 변경방법

find 사용방법

Linux 2020. 1. 12. 22:34

대상 디렉토리 : 찾기를 시작할 디렉토리를 지정한다.


검색 조건 : 찾을 조건을 지정한다.

-name filename 파일 이름으로 찾는다.

-atime +n access time 이 n일 이전인 파일을 찾는다.

-atime -n access time이 n일 이내인 파일을 찾는다.

-mtime +n n일 이전에 변경된 파일을 찾는다.

-mtime -n n일 이내에 변경된 파일을 찾는다.

-perm nnn 파일 권한이 nnn인 파일을 찾는다.

-type x 파일 타입이 x인 파일들을 찾는다.

-size n 사이즈가 n이상인 파일들을 찾는다.

-links n 링크된 개수가 n인 파일들을 찾는다.

-user username user이름으로 찾는다.

-group groupname group 이름으로 찾는다.

-inum [Num] : [Num] 숫자의 inode파일을 찾는다



처리방법 : 찾은 파일을 어떻게 할 것인지를 지정한다.

-print 찾은 파일의 절대 경로명을 화면에 출력한다.

-exec cmd {}\; 찾은 파일들에 대해 cmd 명령어를 실행한다.


예를 들어보자.

$ find /user4 -name test* -print

/user4 아래에서 파일이름이 test로 시작하는 모든 파일을 찾아서 화면에 보여준다.


$ cd /

$ find . -name ping -print

root 디렉토리 밑에서 파일이름이 ping인 파일을 찾아 절대 경로명을 화면에 출력한다.


$ cd /

$ find /usr -name *.c -print

/usr 밑에 이름이 .c로 끝나는 모든 파일들을 찾아 경로명을 보여준다.


$ cd /

$ find $home -name who.txt -print

home 디렉토리 아래에 who.txt라는 파일을 찾아 경로명을 보여준다.


$ cd /

$ find . -type d -print

파일 타입이 d인 파일을 찾아 경로명을 화면에 출력한다.


$ cd /

$ find /dev -type c -print

/dev디렉토리 아래에서 파일 타입이 c인 파일을 찾아 경로명을 보여 준다.


$ cd /

$ find . -perm 700 -print

파일 권한이 700인 파일을 찾아준다.


$ cd /

$ find . \ ( -perm 400 -o -perm 200 ) -print

파일 권한이 400인 파일과 200인 파일을 찾아준다.

(주의 : “\”의 앞뒤에 space 가 반드시 있어야 한다.)


$ cd /

$ find . -size +1024 -print

파일의 블럭 크기가 1024 이상인 파일을 찾아준다.


$ cd /

$ find . -name core -size +2048 -print

파일 이름이 core이고 크기가 2048블럭 이상인 파일을 찾아준다.


$ cd /

$ find . -user unix01 -print

파일 소유자가 unix01인 파일을 찾아준다.


$ cd /

$ find . -group unix -print

사용자그룹이 unix인 파일을 찾아준다.


$ cd /

$ find . -atime +30 -print

30일 이전에 억세스되었던 파일을 찾는다.


$ cd /

$ find . -mtime -7 -print

7일 이내에 수정된 적이 있는 파일을 찾는다.


$ cd /

$ find . -name core -exec ls -l {} ₩;

이름이 core인 파일을 찾아서 ls -l 한다.


$ cd /

$ find . -name \*.c -atime +30 -exec ls -l {} ₩;

30일 이전에 억세스된 파일 중 *.c를 찾아 ls -l 한다.


$ cd /

$ find . -name core -exec rm -i {} ₩;

현재 디렉토리 밑에서 이름이 core인 파일을 찾아 지운다(지우기 전에 정말 지울 지를 물어본다.)


'Linux' 카테고리의 다른 글

yum exclude  (0) 2020.01.01
LVM 용량 확장 (온라인중)  (0) 2019.12.30
패스워드 알고리즘 변경방법  (0) 2019.12.30
Posted by minjunc
,

yum exclude

Linux 2020. 1. 1. 23:48

yum --exclude=kernel*,crmsh*,upstart update


exclude 옵션을 사용하여 특정 패키지를 제외시키고 update 할 수 있다


'Linux' 카테고리의 다른 글

find 사용방법  (0) 2020.01.12
LVM 용량 확장 (온라인중)  (0) 2019.12.30
패스워드 알고리즘 변경방법  (0) 2019.12.30
Posted by minjunc
,

아래 내용은 LV 확장을 테스트 한 내용으로
ext2 파일시스템을 사용중인경우,
온라인중 증설이 불가합니다
ext3,ext4,xfs 는 온라인중에 용량의 증설이 가능
(서비스중에 그냥 작업이 가능함)

 
실제 작업시 e2fsck 는 해본적이없습니다
여러번 작업해보았으나 e2fsck 불필요했음

 

주의사항은
용량을 증설하는것은 가능하지만
줄이는것은 데이타의 손실이 발생할 확률이 굉장히 높기때문에 특히나 운영중이던 시스템에는 권장하지않는다
용량을 줄이기를 원한다면 서비스를 내리고
해당 파티션에 존재하는 필요 데이터를 모두 백업받은 후
새롭게 파일시스템을 생성해야 안전하다(첨부터 새로 만들어야 안전)

 

확장 방법은 아래와 같습니다
1. 파티셔닝을 한다.
2. pv생성을 한다.
3. vg확장을 한다.
4. lv확장을 한다.
5. 파일시스템에 따라 파티션에 적용을 시킨다.

 

(조금자세히)

1. 파티셔닝을 하는것은 fdisk 나 parted 등
편한것으로 파티셔닝을 해주면 되는데
2. 생성한 파티션을 pvcreate 하고
3. 생성한 pv를 그대로 vg에 추가시킨다음
4. vgs 를 보면 free가 추가되어있는것이 확인된다.
5. 용량을 증설할 lv에 lvextend를 하면
lvs 에는 용량이 증가한것이 확인이 되지만
df에는 변함이 없다
6. 파일시스템이 ext3/ext4 면
resize2fs /dev/mapper/VG-LVNAME
하면 df에도 용량이 증설된것을 확인 할 수 있고
추가로 필요한 작업은 없다.
파일시스템이 xfs 면 resize2fs 가 안되고
xfs_growfs /dev/mapper/VG-LVNAME
하면 된다.
마찬가지로 추가작업은 필요없다.

※ resize2fs, xfs_growfs 명령어를 수행했을 때
프롬프트가 안떨어지고 한참 있는 경우가 있으나
겁먹지 말고 느긋하게 기다려주시면 됩니다
경험상 15분정도 기다려본적이 있는데 아무문제없이
잘 된적이 있음(증설하는 용량이 클수록 오래걸릴 수 있습니다)

[방법(테스트로그 포함)]

fdisk로 파티셔닝후에 진행한다

pvcreate /dev/sdb1
(pvdisplay나 pvs로 확인할 수 있다.)
vgcreate VG01 /dev/sdb1 /dev/sdc1 /dev/sdd1 .........(이하 그룹에 포함시킬 물리볼륨을 추가로 써준다.)

lvcreate -l 100%FREE VG01 -n LV_Name /dev/sdb1 /dev/sdc1 /dev/sdd1 ...
lvcreate -L 100G VG01 -n LV_Name
-l 옵션은 백분율과 함께 어디에서 할당해주는건지 플래그를 붙여준다.(FREE/PVS/VG/LV/ORIGIN)
-L 옵션은 실제 사용하는 용량을 적어준다.
-n 옵션으로 논리볼륨에 이름을 수동으로 설정 한다.
(lvdisplay나 lvs로 확인 할 수 있다.)


예시> 50GB 디스크 2개(sdb,sdc)를 LVM으로 묶어 /data에 마운트 시킨다.

파티션은 일반 LINUX 타입으로 생성했다. 50G 두개 디스크로 100G의 파티션을 사용하는 중에 50G 디스크 한개를 추가 시켰다가 다시 하나를 제거하고 있다.

[root@localhost /]# pvcreate /dev/sdb1
  Labels on physical volume "/dev/sdb1" successfully wiped
[root@localhost /]# pvcreate /dev/sdc1
  Labels on physical volume "/dev/sdc1" successfully wiped
[root@localhost /]# pvs
  PV              VG       Fmt        Attr        PSize           PFree
/dev/sdb1               lvm2     ---     50.00g     50.00g
/dev/sdc1               lvm2     ---     50.00g     50.00g
[root@localhost /]# vgcreate VG01 /dev/sdb1 /dev/sdc1
 Volume group "VG01" successfully created
[root@localhost /]# vgs
  VG          #PV          #LV          #SN          Attr          VSize          VFree
  VG01         2                0              0            wz--n-     99.9g          99.9g
[root@localhost /]# lvcreate -l 100%FREE -n LV_Name
  Logical volume "LV_Name" created
[root@localhost /]# lvs
   LV              VG          Attr               LSize          Pool          Origin          Data%          Meta%          Move          Log     Cpy%Sync          Convert
LV_Name   VG01      -wi-a-----      99.9g
[root@localhost /]# pvcreate /dev/sdd1
  Labels on physical volume "/dev/sdd1" successfully wiped
[root@localhost /]# pvs
  PV              VG       Fmt        Attr        PSize           PFree
/dev/sdb1   VG01  lvm2         ---        50.00g                   0
/dev/sdc1   VG01   lvm2         ---        50.00g                   0
/dev/sdd1               lvm2         ---        50.00g        50.00g
[root@localhost /]# vgextend VG01 /dev/sdd1
 Volume group "VG01" successfully extended
[root@localhost /]# vgs
  VG          #PV          #LV          #SN          Attr          VSize          VFree
  VG01         3                1              0            wz--n-     149.99g          50.00g
[root@localhost /]# lvextend /dev/VG01/LV_Name -l 100%VG /dev/sdd1
 Size of Logical volume VG01/LV_Name changed from 99.99 GiB (25598 extents) to 149.99 GiB (38397 extents).
 Logical volume data successfully resized
[root@localhost /]# lvs
   LV              VG          Attr               LSize          Pool          Origin          Data%          Meta%          Move          Log     Cpy%Sync          Convert
LV_Name   VG01      -wi-a-----      149.99g
[root@localhost /]# e2fsck -f /dev/VG01/LV_Name
[root@localhost /]# resize2fs /dev/VG01/LV_Name
-------------------------------------------------------------
lvextend
:
ext2 일때만 umount/mount 수행하고
ext3, ext4 일때는 umount/mount 안해도 됨
100GB -> 110GB
# umount
# lvextend -L +10G /dev/VG01/LV_Name
# e2fsck -f /dev/VG01/LV_Name
# resize2fs /dev/VG01/LV_Name 110G
# resize2fs /dev/VG01/LV_Name
# mount
-------------------------------------------------------------

'Linux' 카테고리의 다른 글

find 사용방법  (0) 2020.01.12
yum exclude  (0) 2020.01.01
패스워드 알고리즘 변경방법  (0) 2019.12.30
Posted by minjunc
,

: 5.0버전, 5.1버전에서는 안됩니다
authconfig 명령어에 패스워드 알고리즘 변경하는
옵션이 없기때문입니다
이것은 authconfig 패키지를 5.2껄로 업데이트 해주면
되는데 의존성 패키지때문에 패키지 하나만 업데이트
할 수는 없습니다

<authconfig 패키지 패치시 필요한 패키지 목록>
authconfig-5.3.21-3.el5.x86_64.rpm
authconfig-gtk-5.3.21-3.el5.x86_64.rpm
glibc-2.5-24.i686.rpm
glibc-2.5-24.x86_64.rpm
glibc-common-2.5-24.x86_64.rpm
glibc-devel-2.5-24.i386.rpm
glibc-devel-2.5-24.x86_64.rpm
glibc-headers-2.5-24.x86_64.rpm
pam-0.99.6.2-3.27.el5.i386.rpm
pam-0.99.6.2-3.27.el5.x86_64.rpm
pam-devel-0.99.6.2-3.27.el5.x86_64.rpm
shadow-utils-4.0.17-13.el5.x86_64.rpm

아래 패스워드알고리즘 변경 방법 이후에
테스트 로그가 있으니 참고바랍니다

패스워드 알고리즘 변경 후
/etc/pam.d/system-auth 내에 기존 보안조치 내용의 재설정이 필요합니다.

1. 패스워드 알고리즘 확인 및 변경
[확인]
# authconfig --test | grep hashing
password hashing algorithm is sha512

# cat /etc/sysconfig/authconfig | grep ALGORITHM
PASSWDALGORITHM=sha512

[변경]
# authconfig --passalgo=sha512 --update
RHEL5.2 버전 이후로는 위 방법으로 테스트 시 정상 동작 확인

2. RHEL 5.0 초기 버전 시
</etc/pam.d/system-auth>
# cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so sha256 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so

</etc/login.defs>
cat /etc/login.defs  | grep ENCRY
ENCRYPT_METHOD SHA256

</etc/libuser.conf>
# cat /etc/libuser.conf | grep crypt_style
crypt_style = sha256

[shadow 파일 내 인자 값]
$1 = MD5 hashing algorithm.
$2 =Blowfish Algorithm is in use.
$2a=eksblowfish Algorithm
$5 =SHA-256 Algorithm
$6 =SHA-512 Algorithm

(예시)
suser:$5$p.WE79DA$1i6qZM01up1Kembati3e04oqGa1yhy4UpCoE3oGtbMC:16722:0:99999:7:::


[변경 시 수정되는 파일 목록]
/etc/pam.d/system-auth
/etc/pam.d/password-auth
/etc/login.defs
/etc/libuser.conf
/etc/sysconfig/authconfig

</etc/pam.d/system-auth>
# cat /etc/pam.d/system-auth
...(skip)...
auth        required      pam_env.so
auth        required      pam_tally.so onerr=fail deny=10 unlock_time=3600 magic_root
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so

account     required      pam_unix.so
account     required      pam_tally.so
...(skip)...

============================================
<테스트 로그>
============================================
[skroot@rhel5 patch]$ ll
total 35544
-rw-r--r-- 1 skroot skroot   463549  4월  4  2008 authconfig-5.3.21-3.el5.x86_64.rpm
-rw-r--r-- 1 skroot skroot    46977  4월  4  2008 authconfig-gtk-5.3.21-3.el5.x86_64.rpm
-rw-r--r-- 1 skroot skroot  5415445  4월 26  2008 glibc-2.5-24.i686.rpm
-rw-r--r-- 1 skroot skroot  4906472  4월 26  2008 glibc-2.5-24.x86_64.rpm
-rw-r--r-- 1 skroot skroot 16909197  4월 26  2008 glibc-common-2.5-24.x86_64.rpm
-rw-r--r-- 1 skroot skroot  2105018  4월 26  2008 glibc-devel-2.5-24.i386.rpm
-rw-r--r-- 1 skroot skroot  2535427  4월 26  2008 glibc-devel-2.5-24.x86_64.rpm
-rw-r--r-- 1 skroot skroot   615626  4월 26  2008 glibc-headers-2.5-24.x86_64.rpm
-rw-r--r-- 1 skroot skroot   996610  2월 14  2008 pam-0.99.6.2-3.27.el5.i386.rpm
-rw-r--r-- 1 skroot skroot   993065  2월 14  2008 pam-0.99.6.2-3.27.el5.x86_64.rpm
-rw-r--r-- 1 skroot skroot   192964  2월 14  2008 pam-devel-0.99.6.2-3.27.el5.x86_64.rpm
-rw-r--r-- 1 skroot skroot  1103288  1월 19  2008 shadow-utils-4.0.17-13.el5.x86_64.rpm
[skroot@rhel5 patch]$ sudo rpm -Uvh ./*.rpm
warning: ./authconfig-5.3.21-3.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:glibc-common           ########################################### [  8%]
   2:glibc                  ########################################### [ 17%]
   3:glibc                  warning: /etc/ld.so.conf created as /etc/ld.so.conf.rpmnew
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
########################################### [ 25%]
   4:pam                    warning: /etc/pam.d/system-auth created as /etc/pam.d/system-auth.rpmnew
########################################### [ 33%]
   5:glibc-headers          ########################################### [ 42%]
   6:pam                    warning: /etc/pam.d/config-util created as /etc/pam.d/config-util.rpmnew
warning: /etc/pam.d/other created as /etc/pam.d/other.rpmnew
warning: /etc/pam.d/system-auth created as /etc/pam.d/system-auth.rpmnew
warning: /etc/security/access.conf created as /etc/security/access.conf.rpmnew
warning: /etc/security/chroot.conf created as /etc/security/chroot.conf.rpmnew
warning: /etc/security/console.handlers created as /etc/security/console.handlers.rpmnew
warning: /etc/security/group.conf created as /etc/security/group.conf.rpmnew
warning: /etc/security/limits.conf created as /etc/security/limits.conf.rpmnew
warning: /etc/security/namespace.conf created as /etc/security/namespace.conf.rpmnew
warning: /etc/security/namespace.init created as /etc/security/namespace.init.rpmnew
warning: /etc/security/opasswd created as /etc/security/opasswd.rpmnew
warning: /etc/security/pam_env.conf created as /etc/security/pam_env.conf.rpmnew
warning: /etc/security/time.conf created as /etc/security/time.conf.rpmnew
########################################### [ 50%]
   7:shadow-utils           ########################################### [ 58%]
   8:authconfig             ########################################### [ 67%]
   9:authconfig-gtk         ########################################### [ 75%]
  10:glibc-devel            ########################################### [ 83%]
  11:glibc-devel            ########################################### [ 92%]
  12:pam-devel              ########################################### [100%]
[skroot@rhel5 patch]$ sudo authconfig --test | grep hash
 password hashing algorithm is md5
[skroot@rhel5 authconfig_patch]$ sudo authconfig --passalgo=sha256 --update
[skroot@rhel5 authconfig_patch]$ sudo authconfig --test | grep hash
 password hashing algorithm is sha256
[skroot@rhel5 ~]$ sudo cat /etc/shadow | tail 
...(skip)...
skroot:$1$SFq0aHFH$O1pmlitoqMweoT4.My0sx0:18228:0:99999:7:::
...(skip)...
[skroot@rhel5 ~]$ passwd
Changing password for user skroot.
Changing password for skroot
(current) UNIX password: 
New UNIX password: 
Retype new UNIX password: 
passwd: all authentication tokens updated successfully.
[skroot@rhel5 ~]$ sudo cat /etc/shadow | tail 
...(skip)...
skroot:$5$VeJqH.cH$5Ua1byXXYNTJ8Osi.FJLyp9KnN2pYxJ99vW5govqMIA:18228:0:99999:7:::
...(skip)...
============================================

'Linux' 카테고리의 다른 글

find 사용방법  (0) 2020.01.12
yum exclude  (0) 2020.01.01
LVM 용량 확장 (온라인중)  (0) 2019.12.30
Posted by minjunc
,