가끔 yum을 사용하는데 다운로드 속도가 너무 안나와서 구글링을 하던 도중 fastest mirror라는 플러그인을 발견 하였다.

이 플러그인은 자동으로 속도가 빠른 미러를 찾아 적용해 준다. 설치 방법은

yum install yum-plugin-fastestmirror 또는

yum install yum-fastestmirror

설치가 되었다면 아래와 같이

 # yum update

Loading "fastestmirror" plugin

Setting up Update Process

Setting up repositories

yum이 동작 할 때 fastest mirror가 동작한다.

[출처] http://whorya.tistory.com/14



CentOS 7 은 많은 변화가 있었지만 그중 하나가 네트워크 인터페이스 이름 입니다.

지금까지 네트워크 인터페이스 이름은 eth0, eth1 식으로 고정되어 있었습니다. 하지만 CentOS 7 부터는 바이오스 장치 이름을 조합해서 생성됩니다. 다시 말해서 각 서버마다 네트워크 인터페이스 카드가 모두 동일하다고 할지라도 CentOS 7 에서의 네트워크 인터페이스 이름은 모두 다를 수가 있다는 겁니다.

이 문서는 CentOS 7 에서 네트워크 인터페이스 이름 바꾸기 에 대한 것입니다.

1. 상태확인

CentOS 7 에서의 네트워크 인터페이스 이름은 다음과 같습니다.

[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.55  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5def:d7b6:b644:3343  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:f5:93:8e  txqueuelen 1000  (Ethernet)
        RX packets 76  bytes 11976 (11.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 11460 (11.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 72  bytes 6248 (6.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 72  bytes 6248 (6.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3 으로 나옵니다. 네트워크 인터페이스 설정 파일도 이름과 동일하게 생성 됩니다.

[root@localhost ~]# ls -al /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. 1 root root 312  3월 28 09:31 /etc/sysconfig/network-scripts/ifcfg-enp0s3


2. eth0 로 바꾸기

바꾸는 방법은 grub 에서 바이오스장치이름을 네트워크 인터페이스 이름으로 사용하지 않겠다고 선언하는 것입니다. 커널이 업그레이드되면 grub 에 파라메터값을 다시 해줘야 하는 불편함을 없애기위해서 grub 의 기본설정을 변경해 줍니다.

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0 ipv6.disable=1"
GRUB_DISABLE_RECOVERY="true"

핵심은 ‘GRUB_CMDLINE_LINUX’ 에 ‘net.ifnames=0 biosdevname=0’ 를 추가하는 것입니다. 그리고 다음과 같이 grub2 를 다시 만들어 줍니다.
ipv6.disable=1 을 적용하면 ipv6 기반이 비활성화 됩니다.

grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.9.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.9.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.8.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.8.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.6.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.6.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-babecd961e9a465686311e3f5930f25e
Found initrd image: /boot/initramfs-0-rescue-babecd961e9a465686311e3f5930f25e.img
done

이제 네트워크 인터페이스 파일을 다음과 같이 바꿔 줍니다.

root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-enp0s3 ifcfg-eth0

[추가] 이름 변경한 ifcfg-eth0 파일 내용 중 DEVICE= 와 NAME= 또한 동일하게 변경한다.

이제 재부팅을 하면 네트워크 인터페이스 이름이 eth0 로 올라온것을 볼 수 있습니다.

1. pstree 명령어를 찾을 수 없을 때

명령 : yum -y install psmisc

2. ifconfig 명령어를 찾을 수 없을 때

명령 : yum -y install net-tools

3. autoconf 명령을 찾을 수 없을 때 (pecl 또는 phpize 명령 실행시 autoconf 는 필수 설치 항목이다.)

[에러 메시지]
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

해결 : yum -y install autoconf

4. scp 명령어를 찾을수 없을 때

해결 : yum -y install openssh-clients (설치되면 scp, sftp등이 설치된다.)

5. nslookup 명령어를 찾을 수 없을 때 (CentOS7 에서)

해결 : yum -y install bind-utils

6. wget 명령어를 찾을 수 없을 때

해결 : yum -y install wget

7. lspci 명령어를 찾을 수 없을 때

해결 : yum -y install pciutils

8. ntsysv 명령어를 찾을 수 없을 때

해결 : yum -y install ntsysv

9. smartctl 명령어를 찾을 수 없을 때

해결 : yum -y install smartmontools

10. hdparm 명령어를 찾을 수 없을 때

해결 : yum -y install hdparm

11. rdate 명령어를 찾을 수 없을 때

해결 : yum -y install rdate


최소 설치 리눅스에서는 setup, ntsysv 와 같은 명령어가 미포함 되어 있으므로 아래 명령어로 패키지를 설치해 준다.

yum install setuptool

yum install system-config-network-tui

yum install ntsysv

[출처] http://jumals.tistory.com/06


방법 1 : chpasswd ( CentOS, Ubuntu 에서 가능 )

명령 : echo '아이디:패스워드' | chpasswd


방법 2 : passwd ( CentOS는 가능. Ubuntu는 불가 )

명령 : echo '패스워드' | passwd --stdin 아이디

※ 요약

리눅스 명령어 lastb는 접속 실패 기록을 보여주는 명령어다. last 명령어가 로그인 기록과 재부팅 기록을 보기 위해 /var/log/wtmp 파일을 열람한다면, lastb는 /var/log/btmp 파일을 열람하여 실패 목록을 보여준다. lastb는 접속 실패를 기록하는 파일인 btmp 파일을 열람한다는 것을 제외하고는 last 명령어와 같다.

※ 경로

/usr/bin/lastb

※ 사용법

lastb [옵션]... [유저명]... [tty]...


※ 옵션

 옵션

 설명

 -num

 num 만큼의 줄만 출력

 -n num

 -num과 동일

 -R

 hostname필드는 출력 안 함

 -a

 출력되는 목록에서 hostname 필드는 마지막에 출력

 -d

 다른 host에서 접속한 내용만 출력

 -x

 shutdown 상태 및 runlevel이 바뀐 상태 출력

 -f file

 지정한 file에서 정보를 읽어와서 출력


[출처] http://shaeod.tistory.com/729

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS setup ntsysv 설치  (0) 2017.03.21
시스템 패스워드 한줄로 변경하기  (0) 2017.02.14
CentOS 다운로드 미러 사이트  (0) 2017.01.03
CentOS7 hostname 설정  (0) 2016.10.31
tmpwatch  (0) 2016.10.19

'Works > CentOS & RockyLinux' 카테고리의 다른 글

시스템 패스워드 한줄로 변경하기  (0) 2017.02.14
lastb - 로그인 실패 로그 확인  (0) 2017.02.14
CentOS7 hostname 설정  (0) 2016.10.31
tmpwatch  (0) 2016.10.19
du 명령어의 활용  (0) 2016.09.02


CentOS 6까지는 /etc/sysconfig/network 설정파일에 정의 도었지만 CentOS 7 부터는 새로운 init시스템(systemd) 으로 변경되면서

/etc/hostname 에 의해 정의된다.

hostnamectl 이라는 명령어가 추가되었는데, 이 명령을 이용해 hostname을 조작할 수 있다.

1. hostname 상태 확인하기

# hostnamectl status
   Static hostname: web.yufunding.com
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: c9b7cf08f05840c08378307dccc659c8
           Boot ID: 309a6f6094a8436fb89e5f38de46987d
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.36.2.el7.x86_64
      Architecture: x86-64

2. hostname 변경하기

# hostnamectl set-hostname [호스트명]

3. hostname 변경 후 확인

# hostname 명령어로 확인하거나 (Cent 4, Cent5, Cent6 부터 사용한 기본 명령어)

cat /etc/hostname 명령어로 /etc/hostname 파일에 정의한 hostname 이 입력되어 있는지 확인

/etc/hostname 에 정의가 되어 있으면 재부팅되어도 적용됨.

'Works > CentOS & RockyLinux' 카테고리의 다른 글

lastb - 로그인 실패 로그 확인  (0) 2017.02.14
CentOS 다운로드 미러 사이트  (0) 2017.01.03
tmpwatch  (0) 2016.10.19
du 명령어의 활용  (0) 2016.09.02
필요한 rpm 패키지를 다운받자  (0) 2016.08.03



tmpwatch 라는 명령

일정 시간동안 접근이 없는 파일 삭제하기
 

yum -y install tmpwatch


[root@howtounix hack]# ll
total 16
-rwxr-xr-x 1 root root 8486 Aug 24 17:36 a.out
-rw-r--r-- 1 root root 1044 Aug 24 15:42 test.c

24시간 이후로 접근이 없는 파일들 삭제

[root@howtounix hack]# tmpwatch --atime 24 ./
[root@howtounix hack]# ll
total 0


간단하네.

       -u, --atime
              Make the decision about deleting a file based on the file’s atime (access time). This is
              the default.

              Note that the periodic updatedb file system scans keep the atime of directories  recent.

       -m, --mtime
              Make  the  decision  about deleting a file based on the file’s mtime (modification time)
              instead of the atime.

       -c, --ctime
              Make the decision about deleting a file based on the file’s ctime  (inode  change  time)
              instead of the atime; for directories, make the decision based on the mtime.

       -M, --dirmtime
              Make  the  decision about deleting a directory based on the directory’s mtime (modifica-
              tion time) instead of the atime; completely ignore atime for directories.

[출처] https://opentutorials.org/module/981/8083

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS 다운로드 미러 사이트  (0) 2017.01.03
CentOS7 hostname 설정  (0) 2016.10.31
du 명령어의 활용  (0) 2016.09.02
필요한 rpm 패키지를 다운받자  (0) 2016.08.03
xferlog 항목별 분석  (0) 2016.07.27


du -sh . --exclude='패턴' (현재 위치에서 '패턴' 파일 또는 폴더를 제외하고 전체 용량을 확인)
du -sh * --exclude='패턴' (현재 위치에서 '패턴' 파일 또는 폴더를 제외한 모든 항목들의 개별 용량 확인)

용량이 1기가바이트 이상인 파일이나 디렉토리만 보고 싶다면 아래처럼 grep을 활용할 수도 있습니다.

du -sh ./* | grep G

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS7 hostname 설정  (0) 2016.10.31
tmpwatch  (0) 2016.10.19
필요한 rpm 패키지를 다운받자  (0) 2016.08.03
xferlog 항목별 분석  (0) 2016.07.27
smartctl을 이용한 하드디스크 진단 { DRDY ERR } 확인  (0) 2016.07.06