#WITHYOU
Lum7671's Weblog
#WITHYOU
Linux Tips

기억하고 싶은 Linux 팁

Here document

Keybase 와 shell의 “here document” 기능을 사용한 예:

% keybase pgp sign -c << EOF
hello
EOF
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

hello
-----BEGIN PGP SIGNATURE-----

wsFcBAEBCAAQBQJbzu4wCRDbzYs3KlGl4QAAvvUQAFqpyLCc8DeS5jNNLGr2hdqL
55zKqntXq/4J++JzlcASzkde5fdh34IA8ALi3ZBMrdI36pxpGShmL7+aVTR941WH
EnHv/emEhIEkLPve+VJVx0Rc8ylwRJ4wi4rP4bKoBD29J4wmU26PaaCqZNpIdTWu
VbjASz5KDrBJjZkPlTV3hpoJUl0zAoHPBmtkPfx+KXDI88oRiA8Y8h7FAxlwicwy
WMM4KLmXlGNHSBGMPRFOUjgAKo5YnXjAsKgrDiTW8hubsYXWgO5NUCDa9lWsNoW+
bVrynqgGYfTgovy66Y4b7uzU8wzVKiDhRSR5B1MUOiquAjD0veRQdl9RMmZ4Hpz5
z/SdPKk/PYNhg84wQdgQRmtwYUau8utXmqXrqsnyBzzp4fYomFWxcITPr7uki8ks
AsvGJv0cw6zUyMUpPjyO7l2qsrDPvZiQe+Nqe5rueoZ3YWjHWYCUy/IyIziUGhv+
xv6InINIazqEqgsNUwVF0fexF0tEkla/ggXRjTQ7Ht0uYlngV6DmJ0QXNsOs3f2y
E6XIR2Z3iQwo1XPCtYbmXNzZ4n4nBB2vpcBN3o6L/kyU7ITcBgfCylZSkACh9A96
aNaEilAX7Xty31128XlAET8E+loFmRLZnozL426Y1t62yTzpsww1a5YpMPgaR91/
ClWaFiPcpFuSYRB38cnV
=5W1g
-----END PGP SIGNATURE-----
% 

ssh, password 자동입력

% ssh-keygen -t rsa -b 2048
% ssh-copy-id id@server

용어, Shebang (Unix)

예)

#!/usr/bin/env zsh

/etc/crontab

# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

apt, upgrade 패키지 확인.

% sudo apt upgrade --just-print -V
...
다음 패키지를 과거 버전으로 유지합니다:
   nginx-common (1.10.1-0ubuntu1 => 1.10.1-0ubuntu1.2)
   nginx-extras (1.10.1-0ubuntu1 => 1.10.1-0ubuntu1.2)
...   
% sudo apt list --upgradeable
Listing... 완료
nginx-common/yakkety-updates,yakkety-updates,yakkety-security,yakkety-security 1.10.1-0ubuntu1.2 all [upgradable from: 1.10.1-0ubuntu1]
nginx-extras/yakkety-updates,yakkety-security 1.10.1-0ubuntu1.2 amd64 [upgradable from: 1.10.1-0ubuntu1]

※ apt list 의 옵션 : —installed, —all-versions

grep, recursive

% grep -ilR Connection dbtool/
dbtool/src/DBTool/DB/Connection.php
dbtool/src/DBTool/DB/SqliteConnection.php
dbtool/src/DBTool/DB/ConnectionProperties.php
dbtool/src/DBTool/DB/ConnectionException.php
dbtool/src/DBTool/DB/MySqlConnection.php

rsync, 옵션 ‘—delete’ 의 예외 처리.

—delete’는 대상 디렉토리에 필요 없는 파일을 지워준다. 원 소스 디렉토리와 똑같이 만들어주기 위한 방법으로 옵션을 주는데… 예외적인 처리를 하고 싶을 때 아래와 같은 옵션을 준다.

% rsync -rvzc --filter=':e /static' --delete

—filter=’:e /static’” 를 추가해서 /static 파일(혹은 디렉토리)를 제외하고 rsync 가 된다.

locale 환경 변수 수정

% sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

타임존(timezone)을 한국으로 설정하기.

$HOME/.zshrc 에 다음과 같이 추가 한다.

# set timezone #
TZ='Asia/Seoul'; export TZ

sticky-bit

chmod o+t /path
chmod +t /path
chmod 1757 /path
find / -perm +1000
chmod o-t /path