728x90

 기본 환경: IDE: Eclipse, Language: Java

 

발생 Exception

Java에서 다음 Source Code를 실행할 경우,

public class Exam {
	private char[] ox=null;

	public void compare() {
		for(int i=0; i<JUNG.length(); i++) {
			if(dap.charAt(i)==JUNG.charAt(i)) {
				ox[i] = (char)'O';
			} else {ox[i] = (char)'X';}
		} // for
	} // compare
}

Exception in thread "main" java.lang.NullPointerException: Cannot store to char array because "this.ox" is null

→ NullPointerException 발생

 

 

Exception 원인

char[]를 선언 후, 배열의 크기를 지정해주는 초기화 작업을 진행하지 않음

 

 

해결 방법

public class Exam {
	private char[] ox=null;

	public void compare() {
    ox = new char[JUNG.length()];
    
		for(int i=0; i<JUNG.length(); i++) {
			if(dap.charAt(i)==JUNG.charAt(i)) {
				ox[i] = (char)'O';
			} else {ox[i] = (char)'X';}
		} // for
	} // compare
}

/*
Result
O	X	X	O	O
*/

ox = new char[JUNG.length()];

: ox 배열에 대해 크기 지정

 

 

 

참고 자료

📑 why can't I assign null to a particular index of Char Array?

📑 Primitive Types

📑 charGPT

 

728x90
728x90

이 글은 양주종의 코딩스쿨 리눅스(Linux) 기초 강좌 30강 모음 수강하며 정리한 글입니다.

 

30강 설치 후 할 일

 

(일반 사용자 id: j, pw: j)

(관리자 id: root, pw: r)

 

 

CentOS7

1.  System Time Check

[root@hj0216 ~]# date

 

2. Installed pkg num check

[root@hj0216 ~]# rpm -qa | wc -l
343

➕ pkg install 여부 확인

[root@hj0216 ~]# rdate
-bash: rdate: command not found # uninstalled
[root@hj0216 ~]# gcc
-bash: rdate: command not found # uninstalled
[root@hj0216 ~]# javac
-bash: rdate: command not found # uninstalled
[root@hj0216 ~]# locate
-bash: rdate: command not found # uninstalled

 

3. Network Test

[root@hj0216 ~]# ping -c3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=33.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=31.4 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=31.7 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 31.442/32.097/33.088/0.712 ms

 

4. ssh server connect

[root@hj0216 ~]# systemctl stop firewalld # 해당 session에서만 방화벽 끄기
[root@hj0216 ~]# systemctl disable firewalld # 모든 session에서 방화벽 끄기
[root@hj0216 ~]# systemctl start sshd # 해당 session에서만 ssh service 실행
[root@hj0216 ~]# systemctl enable sshd # 모든 session에서 ssh service 실행

[설정] -> [네트워크] -> [고급] -> [포트 포워딩]

포트 번호: 22, 80 추가

[파일] -> [환경설정] -> [입력] -> [가상머신] 호스트키 조합: F11 입력

(마우스 포인터를 리눅스에서 꺼내주는 역할)

 

PuTTY login

[root@hj0216 ~]# date
2023. 02. 05. (일) 14:18:32 KST
[root@hj0216 ~]# date -s "2000-12-12 21:30"
# 일자 및 시간 임의 지정

rdate 설치를 통한 시간 자동 설정

[root@hj0216 ~]# yum -y install rdate
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
...
==============================================================================
 Package         Arch             Version                 Repository      Size
==============================================================================
Installing:
 rdate           x86_64           1.4-25.el7              base            19 k

Transaction Summary
==============================================================================
Install  1 Package

Total download size: 19 k
Installed size: 29 k
Downloading packages:
rdate-1.4-25.el7.x86_64.rpm                               |  19 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rdate-1.4-25.el7.x86_64                                     1/1
  Verifying  : rdate-1.4-25.el7.x86_64                                     1/1

Installed:
  rdate.x86_64 0:1.4-25.el7

Complete!
[root@hj0216 ~]# rdate -s time.bora.net
[root@hj0216 ~]# date
2023. 02. 05. (일) 14:23:05 KST

timeZone 변경

[root@hj0216 ~]# timedatectl
      Local time: 일 2023-02-05 14:23:41 KST
  Universal time: 일 2023-02-05 05:23:41 UTC
        RTC time: 일 2023-02-05 05:23:43
       Time zone: Asia/Seoul (KST, +0900)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a
[root@hj0216 ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
...
[root@hj0216 ~]# timedatectl set-timezone "Continent/Country"

 

5. Essential pkg installment

[root@hj0216 ~]# yum -y install vim gcc gcc-c++ tree psmisc bc zip unzip man-pages \
man-pages-ko rdate ntpdate strace mloacte ftp wget dialog lsof bzip2 \
rsyslog ncurses at vsftpd httpd php net-tools mariadb-server mariadb \
java-1.8.0-openjdk java-1.8.0-openjdk-devel tomcat lpr quota

# \ 줄바꿈을 위한 Enter 무시

설치되는 pkg list

vim: Vim: Vi IMproved

Bram Moolenaar가 만든 vi 호환 텍스트 편집기

gcc gcc-c++

c, c++ compiler

tree

dir 하위 구조를 계층적으로 표시해 주는 유틸리티로 전체 구조를 대략적으로 파악할 때 유용

psmisc

fuser 사용을 위한 pkg, 특정 file이나 dir를 사용하고 있는 user or process ID를 찾거나 종료시킬 때 사용

특정 파일 시스템을 umount or service stop할 때 특정 process 때문에 진행이 안 될 경우, 그 process를 kill하기 위해 사용

bc: basic calculator

zip unzip

압축 및 압축해제 pkg

man-pages, man-pages-ko: manual pages
rdate: remote date

원격지의 timeserver에서 시간정보를 가져와 local system의 시간과 동기화를 하는 명령어

ntpdate: network time protocol

NTP server를 이용해서 시간을 동기화할 때 사용하는 명령어

strace

Linux에서 서버 병목을 확인할 수 있도록 system call을 측정하는 tool

리눅스 커널과 프로세스 사이에서 발생하는 시스템 콜, 시그널 전달, 프로세스 상태 변화 등을 모니터링할 수 있음

mloacte

file, dir list를 주기적으로 DB에 저장하고, 편리하게 검색할 수 있도록 도와주는 유틸리티

ftp: File Transfer Protocol

인터넷을 통해 파일을 교환할 수 있게해주는 서비스

wget: web get

웹 상에서 파일을 다운로드 받을 때 사용하는 명령어

dialog

Shell script의 대화 상자를 사용하여 다양한 질문을 제시하거나 메세지를 표시할 수 있는 프로그램

lsof: list open files

system에서 열린 파일 목록을 알려주고 사용하는 프로세스, 디바이스 정보, 파일 종류 등 상세한 정보를 출력

bzip2

압축 pkg
rsyslog: Rocket-Fast System for Log Processing

IP network에서 로그 메세지를 전달하기 위해 UNIX, Unix 계열 컴퓨터에서 사용하는 open source

ncurses

terminal graphic lib

at

지정된 시간에 명령어나 프로그램을 실행시키는 명령어

vsftpd: Very Secure File Transfer Protocol Daemon

FTP의 보안을 강조한 파일 전송 프로토콜

httpd: http demon

서비스를 처리해주는 program을 demon이라하며, http를 처리해주는 서비스를 httpd라고 함

php

server pragramming language

net-tools: network tools

ipconfig 명령어 사용 시 필요한 pkg

mariadb-server mariadb

DB server
java-1.8.0-openjdk java-1.8.0-openjdk-devel: Java Development Kit

Java 환경에서 돌아가는 프로그램을 개발하는데 필요한 툴들을 모아놓은 SW pkg

tomcat

동적 페이지를 구현하기 위해 java에서 만든 프로그램이 servlet이며, 이런 servlet들의 실행을 돕는 프로그램이 tomcat

lpr: Line printer Demon

파일 내용 출력

quota

사용자별 디스크 사용량을 제한하는 pkg

 

6. Image Backup(Set restore point)

Essential pkg Install 후,

PuTTY logout

CentOS7 현재 시스템 상태 저장하기

VirtualBox: 파일 -> 가상 시스템 내보내기

 

➕ 가상 시스템 가져오기(기존에 사용하던 CentOS와는 다른 OS로 취급됨)

-> 내문서에 자동 저장된 가상 시스템 Default로 가져오기

-> PuTTY 실행 후, pkg 설치 상태 확인

login as: root
root@127.0.0.1's password:
Last login: Sun Feb  5 14:18:18 2023 from gateway
[root@hj0216 ~]# rpm -qa | wc -l
475

 

 

 

참고 자료

📑 리눅스 fuser 설치 및 사용법

📑 [리눅스 명령어] rdate - 타임서버와 시스템 시간 동기화

📑 strace가 -k 옵션을 만난 날

📑 리눅스 기본명령어 - wget

📑 dialog - display dialog boxes from shell scripts

📑 [Linux] rsyslog을 이용한 history 내역 남기기

📑 리눅스 vsftpd 서정하는 방법과 ftp 서버 만들기에서 파일업로드까지

📑 4. Servlet - Tomcat(WAS)과  Servlet이란?

📑 Linux, 사용자 및 그룹별 디스크사용량제한하기

 

728x90
728x90

ImageDataGenerator

이미지를 학습시킬 때 학습 데이터 양이 적을 경우, 학습 데이터를 조금씩 변형시켜 학습 데이터 양을 늘리는 방법 중 하나

 

ImageDataGenerator Processing

1. ImageDataGenerator 객체 생성

: 이미지 파일들에 사용자가 설정한 여러가지 데이터 변형 기법을 적용함

train_datagen = ImageDataGenerator(
    rescale=1./255., # scaling
    horizontal_flip=True, # 수평 뒤집기
    vertical_flip=True, # 수직 뒤집기
    width_shift_range=0.1, # 가로 이동
    height_shift_range=0.1, # 세로 이동
    rotation_range=5,# 훈련 시, 과적합 문제를 해결하기 위해 shift, ratatoin 시행
    zoom_range=1.2, # 20% 확대
    shear_range=0.7, # 절삭
    fill_mode='nearest' # 이동 시, 발생하는 빈 칸을 어떻게 채울 것인가
)

test_datagen = ImageDataGenerator(
    rescale=1./255.
)

 

2. flow() / flow_from_directory() / flow_from_dataframe() 함수로 DirectoryIterator 객체 생성

xy_train = train_datagen.flow_from_directory(
    './_data/brain/train', # data path
    target_size=(200, 200), # data shape 통일
    batch_size=10,
    # total data: 160 -> batch_size=10: 160개를 10개씩 잘라서 훈련
    # 1 epoch 당 총 16번(iteration) 훈련 진행
    # dataset_scale check: batch_size를 높게 잡아 dataset scale 확인 가능
    class_mode='binary', # 폴더 라벨링 방식 지정: binary(0 1)
    color_mode='grayscale', # 색상: 흑백 / 컬러(rgb)
    shuffle='True', # parameter, 가장 마지막에 ','가 있어도 문제 X
    )
# Found 160 images belonging to 2 classes
# total 160장의 이미지가 2 classes(2 dir, folder)에 저장

* batch_size에 따른 Iteration 수

'''
total_data: 160
batch_size: 10
x0: xy_train[0][0], y0: xy_train[0][1]
x1: xy_train[1][0], y1: xy_train[1][1]
...
x15: xy_train[15][0], y15: xy_train[15][1]
'''

 

* xy_train[0] 출력: xy_train의 1번째 batch 출력

print(xy_train[0])
'''
(array([[[[0.08627451], [0.08627451], ..., [0.0858703 ], [0.08754121]],
        ...,
        [[0.3088285 ], [0.22372028], ..., [0.17596895], [0.15582304]]]], dtype=float32),
array([1., 1., 0., 1., 1., 1., 1., 0., 1., 0.], dtype=float32))
'''

* 각 Iteration 당 shape

print(xy_train[0][0].shape) # data_x: (10, 200, 200, 1) = (batch_size, target_size_row, target_size_col, color)
print(xy_train[0][1].shape) # data_y: (10, ) = (batch_size,)

* xy_train의 data type

print(type(xy_train)) # <class 'keras.preprocessing.image.DirectoryIterator'>: tuple(x(numpy),y(numpy))의 집합
print(type(xy_train[0])) # <class 'tuple'> tuple(x(numpy),y(numpy)): 수정 불가능한 list
print(type(xy_train[0][0])) # x: <class 'numpy.ndarray'>
print(type(xy_train[0][1])) # y: <class 'numpy.ndarray'>

 

3. flow_from_directory()에 맞춘 모델 구현 및 컴파일

xy_test = train_datagen.flow_from_directory(class_mode='binary', )
# Model 최종 Output
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])

# model.add(Dense(2, activation='softmax')) # class_y: 0 1
# one_hot_encoding O: model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['acc'])

 

4. flow_from_directory()를 활용한 훈련

hist = model.fit_generator(xy_train, steps_per_epoch=16, epochs=5,
                    validation_data=xy_test,
                    validation_steps=4)
# fit_generator: flow_from_directory()의 (x, y) data batch_size 참조
# steps_per_epoch = total_data/batch_size
# validation_steps: validation data/batch_size

 

5. 훈련 결과 평가

print("Loss: ", loss[-1]) # list의 가장 마지막 값을 출력
print("Val_Loss: ", val_loss[-1])
print("Accuracy: ", accuracy[-1])
print("Val_acc: ", val_acc[-1])

'''
Result
Loss:  0.6932721734046936
Val_Loss:  0.6928479075431824
Accuracy:  0.5
Val_acc:  0.550000011920929

'''

 

ImageDataGenerator 출력(MatPlotLib)

import matplotlib.pyplot as plt

img = xy_train[0] # 1 batch(10개의 image set)을 img에 저장

plt.figure(figsize=(20, 10))
for i, img in enumerate(img[0]): # enumerate: (index, list_element)를 tuple type으로 반환
    # enumerate(img[0][0])
    # 루프가 반복될 때마다 변수 i는 현재 요소의 인덱스로 업데이트되고, img는 현재 요소의 값으로 업데이트 됨
    plt.subplot(1, 10, i+1) # subplot(row, col, Index 지정: 1, 2, ...): 전체 이미지 내에 포함된 내부 이미지 개수
    plt.axis('off')
    plt.imshow(img.squeeze()) # 차원(axis) 중, size가 1 인것을 찾아 스칼라 값으로 바꿔 해당차원을 제거
plt.tight_layout()
plt.show()

 

통합 Source Code

# imageDataGenerator.py

import numpy as np

from tensorflow.keras.preprocessing.image import ImageDataGenerator


# 1. Data
train_datagen = ImageDataGenerator(
    rescale=1./255.,
    horizontal_flip=True, # 수평 뒤집기
    vertical_flip=True, # 수직 뒤집기
    width_shift_range=0.1, # 가로 이동
    height_shift_range=0.1, # 세로 이동
    rotation_range=5,# 훈련 시, 과적합 문제를 해결하기 위해 shift, ratatoin 시행
    zoom_range=1.2, # 20% 확대
    shear_range=0.7, # 절삭
    fill_mode='nearest' # 이동 시, 발생하는 빈 칸을 어떻게 채울 것인가
)

test_datagen = ImageDataGenerator(
    rescale=1./255.
)
# test data: data preprocessing X


xy_train = train_datagen.flow_from_directory(
    './_data/brain/train', # data path
    target_size=(200, 200), # data shape 통일
    batch_size=10,
    # total data: 160 -> batch_size=10: 160개를 10개씩 잘라서 훈련
    # 1 epoch 당 총 16번(iteration) 훈련 진행
    # dataset_scale check: batch_size를 높게 잡아 dataset scale 확인 가능
    class_mode='binary', # 폴더 라벨링 방식 지정: binary(0 1)
    color_mode='grayscale', # 색상: 흑백 / 컬러(rgb)
    shuffle='True', # parameter, 가장 마지막에 ','가 있어도 문제 X
    )
# Found 160 images belonging to 2 classes
# total 160장의 이미지가 2 classes(2 dir, folder)에 저장


xy_test = train_datagen.flow_from_directory(
    './_data/brain/test',
    target_size=(200, 200),
    batch_size=10,
    class_mode='binary',
    color_mode='grayscale',
    shuffle='True',
    )
# Found 120 images belonging to 2 classes.
# x,y가 dictionary(k, v) 형태로 들어가 있음


print(xy_train) # <keras.preprocessing.image.DirectoryIterator object at 0x000002134BCFCA60>

print(xy_train)
# <keras.preprocessing.image.DirectoryIterator object at 0x000002134BCFCA60>
# data type: tuple(x(numpy), y(numpy))의 집합
'''
print(xy_train[0])
(array([[[[0.08627451], [0.08627451], ..., [0.0858703 ], [0.08754121]],
        ...,
        [[0.3088285 ], [0.22372028], ..., [0.17596895], [0.15582304]]]], dtype=float32),
array([1., 1., 0., 1., 1., 1., 1., 0., 1., 0.], dtype=float32))


total_data: 160
batch_size: 10
x0: xy_train[0][0], y0: xy_train[0][1]
x1: xy_train[1][0], y1: xy_train[1][1]
...
x15: xy_train[15][0], y15: xy_train[15][1]

'''

print(xy_train[0][0].shape) # data_x: (10, 200, 200, 1) = (batch_size, target_size_row, target_size_col, color)
print(xy_train[0][1].shape) # data_y: (10, ) = (batch_size,)

print(type(xy_train)) # <class 'keras.preprocessing.image.DirectoryIterator'>: tuple(x(numpy),y(numpy))의 집합
print(type(xy_train[0])) # <class 'tuple'> tuple(x(numpy),y(numpy)): 수정 불가능한 list
print(type(xy_train[0][0])) # x: <class 'numpy.ndarray'>
print(type(xy_train[0][1])) # y: <class 'numpy.ndarray'>


# 2. Model
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten

model = Sequential()
model.add(Conv2D(64,(2,2), input_shape=(200,200,1)))
model.add(Conv2D(64, (3,3), activation='relu'))
model.add(Conv2D(64, (3,3), activation='relu'))
model.add(Flatten())
model.add(Dense(16, activation='relu'))
model.add(Dense(16, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# model.add(Dense(2, activation='softmax')) # class_y: 0 1
# one_hot_encoding O: model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['acc'])
# one_hot_encoding X: model.compile(loss='sparse_categorical_crossentropy', optimizer='adam', metrics=['acc'])


# 3. Compile and Train
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])
hist = model.fit_generator(xy_train, steps_per_epoch=16, epochs=5,
                    validation_data=xy_test,
                    validation_steps=4)
# fit_generator: flow_from_directory(x, y, batch_size) 참조
# steps_per_epoch = total_data/batch_size
# validation_steps: validation_data/batch_size

accuracy = hist.history['acc']
val_acc = hist.history['val_acc']

loss = hist.history['loss']
val_loss = hist.history['val_loss']

'''
print("Loss: ", loss)
len(loss) = hist.fit(epochs)
변수 hist에서 epoch마다 loss를 list 형태로 저장
'''

print("Loss: ", loss[-1]) # list의 가장 마지막 값을 출력
print("Val_Loss: ", val_loss[-1])
print("Accuracy: ", accuracy[-1])
print("Val_acc: ", val_acc[-1])

'''
Result
Loss:  0.6932721734046936
Val_Loss:  0.6928479075431824
Accuracy:  0.5
Val_acc:  0.550000011920929

'''


import matplotlib.pyplot as plt

img = xy_train[0] # 1 batch(10개의 image set)을 img에 저장

plt.figure(figsize=(20, 10))
for i, img in enumerate(img[0]): # enumerate: (index, list_element)를 tuple type으로 반환
    # enumerate(img[0][0])
    # 루프가 반복될 때마다 변수 i는 현재 요소의 인덱스로 업데이트되고, img는 현재 요소의 값으로 업데이트 됨
    plt.subplot(1, 10, i+1) # subplot(row, col, Index 지정: 1, 2, ...): 전체 이미지 내에 포함된 내부 이미지 개수
    plt.axis('off')
    plt.imshow(img.squeeze()) # 차원(axis) 중, size가 1 인것을 찾아 스칼라 값으로 바꿔 해당차원을 제거
'''
squeeze()
x3: array([[[0]],
           [[1]],
           [[2]],
           [[3]],
           [[4]],
           [[5]]])
x3.shape: (6,1,1)

x3.squeeze()
array([0, 1, 2, 3, 4, 5])
'''
plt.tight_layout()
plt.show()

 

 

 

➕ Tuple, List 차이

List[]: 요소값의 생성, 삭제, 수정 가능

Tuple(): 요소값 삭제, 변경 불가

-> 요소가 1개인 경우, 요소뒤에 반드시 ',' 사용

-> x1 = 1, 2, 3 처럼 () 생략 가능

 

소스 코드

🔗 HJ0216/TIL

 

참고 자료

📑 [이미지 전처이]. ImagedataGenerator 클래스 : 이미지 제너레이터

📑 Boost Your CNN with the Keras ImageDataGenerator

📑 ImgaeDataGenerator.flow_from_directory을 이용해 이미지 증식하는 방법

📑 컨볼루션 신경망 모델 만들어보기

📑 이미지 전처리

 

728x90
728x90

이 글은 양주종의 코딩스쿨 리눅스(Linux) 기초 강좌 30강 모음 수강하며 정리한 글입니다.

 

29강 출력 내용 저장

 

(일반 사용자 id: j, pw: j)

(관리자 id: root, pw: r)

 

 

출력 내용 저장(명령어 > 파일명)

[49][~]$cal > a1
[50][~]$nl a1
     1        2월 2023
     2  일 월 화 수 목 금 토
     3            1  2  3  4
     4   5  6  7  8  9 10 11
     5  12 13 14 15 16 17 18
     6  19 20 21 22 23 24 25
     7  26 27 28

[51][~]$who > a2
[52][~]$rpm -qa > rpmList
[53][~]$ll
합계 20
-rw-rw-r--. 1 j j   144  2월  4 12:55 a1
-rw-rw-r--. 1 j j    49  2월  4 12:56 a2
-rw-rw-r--. 1 j j 11016  2월  4 12:56 rpmList

>: 표준 출력(모니터)에 대해 redirection, 재지향을 통해서 파일로 출력함

 

⚠️ 만일 기존 파일과 동일한 이름의 파일명으로 저장할 경우, 덮어쓰기 됨

[55][~]$nl a2
     1  j        pts/0        2023-02-03 22:51 (gateway)
[56][~]$date > a2
[57][~]$nl a2
     1  2023. 02. 04. (토) 12:59:00 KST

 

⚠️ 덮어쓰기가 아닌 내용 추가를 하고 싶은 경우, '>>' 활용

[57][~]$nl a2
     1  2023. 02. 04. (토) 12:59:00 KST
[58][~]$who >> a2
[59][~]$nl a2
     1  2023. 02. 04. (토) 12:59:00 KST
     2  j        pts/0        2023-02-03 22:51 (gateway)

 

➕ PuTTY에서의 복사, 붙여넣기

복사: 드래그

붙여넣기: 오른쪽 마우스 클릭

 

728x90
728x90

이 글은 양주종의 코딩스쿨 리눅스(Linux) 기초 강좌 30강 모음 수강하며 정리한 글입니다.

 

28강 bash - 3

 

(일반 사용자 id: j, pw: j)

(관리자 id: root, pw: r)

 

 

PS1: Prompt Status1, 명령 프롬프트

PS2: Prompt Status2, 보조 프롬프트

[j@hj0216 ~]$ echo $PS1
[\u@\h \w]\$
[j@hj0216 ~]$ echo $PS2
>

 

PS1, PS2 설정 변경

[j@hj0216 ~]$ PS1='[\!][\w]\$'
[31][~]$

[\!]: command number

[w]: current location

[43][~]$PS2='HELLO'
[43][~]$echo '
HELLO'


[44][~]$

 

자동 완성(tab)

[44][~]$history
    1  2023-02-04 08:02:55 history
    2  2023-02-04 08:09:26 echo $SHELL
    3  2023-02-04 08:10:21 env

자동 완성이 가능한 리스트 출력(tab * 2)

[45][~]$h
h            hardlink     head         history      hostn
h2ph         hash         help         hostid       hwclo
halt         hdsploader   hexdump      hostname
728x90