
## 출력 방향을 다르게 지정하여 파일로 저장한 방법 ##
nojeans@xudegloss:~$ ls -al > result.txt
nojeans@xudegloss:~$ cat result.txt
total 52
drwxr-x--- 6 nojeans nojeans 4096 Mar 25 12:22 .
drwxr-xr-x 3 root root 4096 Mar 13 14:57 ..
-rw------- 1 nojeans nojeans 116 Mar 25 12:12 .Xauthority
-rw------- 1 nojeans nojeans 1746 Mar 18 13:05 .bash_history
-rw-r--r-- 1 nojeans nojeans 220 Jan 6 2022 .bash_logout
-rw-r--r-- 1 nojeans nojeans 3771 Jan 6 2022 .bashrc
drwx------ 2 nojeans nojeans 4096 Mar 13 14:57 .cache
drwx------ 4 nojeans nojeans 4096 Mar 20 13:02 .config
-rw------- 1 nojeans nojeans 81 Mar 18 12:54 .lesshst
drwxrwxr-x 3 nojeans nojeans 4096 Mar 20 12:35 .local
-rw-r--r-- 1 nojeans nojeans 807 Jan 6 2022 .profile
drwx------ 2 nojeans nojeans 4096 Mar 13 14:57 .ssh
-rw-r--r-- 1 nojeans nojeans 0 Mar 13 15:01 .sudo_as_admin_successful
-rw------- 1 nojeans nojeans 774 Mar 25 12:22 .viminfo
-rw-rw-r-- 1 nojeans nojeans 0 Mar 25 12:22 result.txt
### IO Redirection : Output ###
rm remove2.txt > result.txt # 왜 모니터에서 파일로 리다이렉션되지 않음?
rm remove2.txt 1> result.txt (위, 아래 동일)
## 왜냐하면 Standard Output을 리다이렉션 한 것이지, Standard Error를 리다이렉션 한 것이 아니다 ##
rm remove2.txt 2> result.txt (Standard Error 정보를 리다이렉션 해주는 옵션 => 2)
```띄어쓰기 주의```
### IO Redirection : Input ###
- 프로그램 : 컴퓨터 하드디스크 혹은 SSD에 저장되어 있는 코드
- 프로세스 : 코드가(프로그램이) 실행되는 상태, 하나의 프로그램은 여러 개의 프로세스 가질 수 있음
- 하나의 Input에 두개의 Output
- cat 만 입력하면, 대기 상태 (원하는 글자 입력하면 2배가 되며, 나가고 싶은 경우 ctrl + d 누르기)
=> 키보드로 입력한 정보를 Standard Input으로 받음
nojeans@xudegloss:~$ nano hello.txt
nojeans@xudegloss:~$ cat < hi.txt (cat에게 입력하라고 넣어줌) hi => 잘 생각해봐,, cat에 입력 넣으면 바로 출력되잖아, 그런 느낌이다!
nojeans@xudegloss:~$ head result.txt total 52 drwxr-x--- 6 nojeans nojeans 4096 Mar 25 13:18 . drwxr-xr-x 3 root root 4096 Mar 13 14:57 .. -rw------- 1 nojeans nojeans 116 Mar 25 12:51 .Xauthority -rw------- 1 nojeans nojeans 2097 Mar 25 12:44 .bash_history -rw-r--r-- 1 nojeans nojeans 220 Jan 6 2022 .bash_logout -rw-r--r-- 1 nojeans nojeans 3771 Jan 6 2022 .bashrc drwx------ 2 nojeans nojeans 4096 Mar 13 14:57 .cache drwx------ 4 nojeans nojeans 4096 Mar 20 13:02 .config -rw------- 1 nojeans nojeans 81 Mar 18 12:54 .lesshst
nojeans@xudegloss:~$ head -n5 result.txt ## -n5 -> Command line arguments total 52 drwxr-x--- 6 nojeans nojeans 4096 Mar 25 13:18 . drwxr-xr-x 3 root root 4096 Mar 13 14:57 .. -rw------- 1 nojeans nojeans 116 Mar 25 12:51 .Xauthority -rw------- 1 nojeans nojeans 2097 Mar 25 12:44 .bash_history
nojeans@xudegloss:~$ head -n5 < result.txt ## IO Redirection => Input
total 52 drwxr-x--- 6 nojeans nojeans 4096 Mar 25 13:18 . drwxr-xr-x 3 root root 4096 Mar 13 14:57 .. -rw------- 1 nojeans nojeans 116 Mar 25 12:51 .Xauthority -rw------- 1 nojeans nojeans 2097 Mar 25 12:44 .bash_history
nojeans@xudegloss:~$ head -n5 < result.txt > test.txt nojeans@xudegloss:~$ ls result.txt test.txt nojeans@xudegloss:~$ cat test.txt total 52 drwxr-x--- 6 nojeans nojeans 4096 Mar 25 13:18 . drwxr-xr-x 3 root root 4096 Mar 13 14:57 .. -rw------- 1 nojeans nojeans 116 Mar 25 12:51 .Xauthority -rw------- 1 nojeans nojeans 2097 Mar 25 12:44 .bash_history
### IO Redirection : append ###
ls -al >> result.txt ## 덧붙인다
<< 여러 개의 명령을 하나로 합친다
nojeans@xudegloss:~$ ls -al > /dev/null # 휴지통으로 날리기
Postfix (main.cf) configuration was not changed. If you need to make changes, edit /etc/postfix/main.cf (and others) as needed. To view Postfix configuration values, see postconf(1).
After modifying main.cf, be sure to run 'systemctl reload postfix'.
Running newaliases newaliases: warning: valid_hostname: numeric hostname: 168.126.63.1 newaliases: fatal: file /etc/postfix/main.cf: parameter mydomain: bad parameter value: 168.126.63.1 dpkg: error processing package postfix (--configure): installed postfix package post-installation script subprocess returned error exit status 75 Errors were encountered while processing: postfix E: Sub-process /usr/bin/dpkg returned an error code (1)
myhostname = xudegloss.168.126.63.1
postfix.service is not active, cannot reload.
>> postfix.service는 mail 관련 패키지 설치 시 생긴 디렉토리인데...
왜 hostname에 에러가 났는지는 잘 모르겠음
>> mail 관련 패키지 설치 후 함 진행해보기 !!!
## 시간 동기화 ##
rdate -s time.bora.net
timedatectl # 타임존 변경
timedatectl list-timezones | grep Seoul
timedatectl set-timezone Asia/Seoul
## 메일 전송 -> 꼭 한번 진행 ##
<https://wpaq.com/configure-postfix-smtp-relay/#what-is-postfix>
<https://tsy0668.tistory.com/11>
<https://ubuntu.com/server/docs/install-and-configure-postfix>
```
- 프로세스 출력 = Standard Output + Standard Error (중요한 에러이기 때문에, 별도의 출력)
```jsx
## Standard Error ##
nojeans@xudegloss:~$ rm rename2.txt
rm: cannot remove 'rename2.txt': No such file or directory
```
<aside>
✅ ***** Unix Process + Command-line Arguments **
1. Output ( > )
- Standard Output : 1>
- Standard Error : 2>
- /dev/null : 휴지통
2. Input ( < )
- 프로그램은 코드 모아둔 공간, 프로세스는 프로그램 실행되는 상태
- cat, head, tail 등에 사용
3. Append ( >> )
- 추가***
</aside>