이 블로그 검색

2017년 11월 18일 토요일

Linux 기본

호스트 버전 확인
[root@localhost ~]# uname -a
Linux localhost 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)

[root@localhost ~]# hostnamectl
Static hostname: vm-01
Icon name: computer-vm
Chassis: vm
Machine ID: 55e73fcc6f8e433c84e7c7c4d15cf270
Boot ID: 60073b5ad7a4433c8388bebf008aaa4f
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64

-.Ubuntu
root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

root@ubuntu:~# more /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"


호스트명 변경
-.RHEL6 or earlier
/etc/sysconfig/network, /etc/hosts 에 IP 및 host name 등록 후
[root@localhost ~]# more /etc/hosts
192.168.0.1   vm-01
192.168.0.2   vm-02
[root@localhost ~]# hostname -v ‘hostname’ 후 logout login
 

-.RHEL7
[root@localhost ~]# hostnamectl set-hostname vm-01


IP 설정 및 변경
-.RHEL
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:0C:29:6C:28:37
ONBOOT=yes
#yes 는 부팅시 on
IPADDR=192.168.189.128
NETMASK=255.255.255.0
[root@localhost ~]# ifdown eth0
[root@localhost ~]# ifup eth0
[root@localhost ~]# service network restart


-.Ubuntu
root@ubuntu:~# cd /etc/network/
root@ubuntu:/etc/network# ls
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  interfaces.d
root@ubuntu:/etc/network# more interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 10.77.77.60
netmask 255.255.255.0
gateway 10.77.77.2


root@ubuntu:/etc# more resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8 #google DNS


User 생성 및 Password 설정
[root@localhost ~]#useradd shlee     # shlee User 생성
[root@localhost ~]#passwd shlee     # shlee 의 password 설정
Changing password for user ftpuser.
New UNIX password:
[root@localhost ~]#tail /etc/passwd
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
dovenull:x:380:378:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/var/lib/oprofile:/sbin/nologin
rhelvm1:x:1000:1000:rhelvm1:/home/rhelvm1:/bin/bash
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
shlee:x:1001:1001::/home/shlee:/bin/bash


Root User 패스워드 설정
testuser01@ubuntu:~$ sudo passwd root
[sudo] password for testuser01:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
testuser01@ubuntu:~$ su -
Password:
root@ubuntu:~#


명령어 경로 확인
root@ubuntu:~# which ifconfig
/sbin/ifconfig
root@ubuntu:~# locate ifconfig
/sbin/ifconfig
/usr/share/man/de/man8/ifconfig.8.gz
/usr/share/man/fr/man8/ifconfig.8.gz
/usr/share/man/man8/ifconfig.8.gz
/usr/share/man/pt_BR/man8/ifconfig.8.gz
/usr/src/linux-headers-4.4.0-62/tools/hv/hv_set_ifconfig.sh


CD-ROM 마운트
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# df
Filesystem            1K-blocks     Used Available Use% Mounted on
/dev/mapper/rhel-root  36805060 12893944  23911116  36% /
devtmpfs                1925356        0   1925356   0% /dev
tmpfs                   1941156       92   1941064   1% /dev/shm
tmpfs                   1941156     9176   1931980   1% /run
tmpfs                   1941156        0   1941156   0% /sys/fs/cgroup
/dev/sda1               1038336   178992    859344  18% /boot
/dev/fs1               41943040   787584  41155456   2% /gpfs
tmpfs                    388232       16    388216   1% /run/user/0
/dev/sr0                3704296  3704296         0 100% /run/media/root/RHEL-7.3 Server.x86_64


ISO 이미지 마운트
[root@localhost ~]# mount -o loop rhel7.3-x86_64.iso /mnt/isodevice

디렉토리별 용량 확인
[root@localhost /]# du -hs /usr
4.4G    /usr
[root@localhost /]# du -hsc /usr
4.4G    /usr
4.4G    total
[root@localhost /]# du -hsc /usr /home /bin
4.4G    /usr
4.6M    /home
0       /bin
4.4G    total


SCP 활용
ubuntu01(10.10.10.10) 에서 10.10.1.20 서버의 /home/testuser01 디렉토리에 파일 복사를 할 경우
root@ubuntu01:# scp sg3-utils-udev_1.40-0ubuntu1_all.deb  testuser01@10.10.10.20:/home/testuser01/
testuser01@10.10.10.20's password:
sg3-utils-udev_1.40-0ubuntu1_all.deb                                                               100% 5252     5.1KB/s   00:00

하위 디렉토리 모두 복사(-r 옵션)
root@ubuntu01:# scp -r /tmp testuser01@10.10.10.20:/tmp

시간 설정
root@ubuntu:~# timedatectl
      Local time: Sun 2017-11-19 19:13:54 KST
Universal time: Sun 2017-11-19 10:13:54 UTC
      RTC time: Sun 2017-11-19 10:13:54
      Time zone: Asia/Seoul (KST, +0900)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

root@ubuntu:~# timedatectl set-timezone Asia/Seoul

PATH 적용
.bashrc 파일 마지막 줄에 다음과 같이 입력
export PATH="/opt/anaconda3/bin:$PATH" 

댓글 없음:

댓글 쓰기