1.
CentOS 7에 관한 글을 읽어보면 RDMA나 TCP/IP 보다 Systemd를 다루는 글이 많습니다. 처음 유닉스를 접했던 제품은 Consensys 4.2입니다. UNIX System V계열이었습니다. Unix History을 보면 긴 유닉스 역사의 앞부분입니다.
이 때부터 SysVinit에 익숙했습니다. CentOS도 6까지 SysVinit를 채택했지만 7부터 Systemd로 바뀌었습니다.글을 읽어보면 Systemd를 둘러싼 논쟁이 오래되었고 보이콧까지 나오는 상황입니다. Systemd 개발자의 태도, Systemd가 지향하는 철학을 둘러싼 논쟁입니다.
Boycott systemd
새로운 PID 1, systemd 어떻게 생각 하세요?
IT World의 Paul Venezia는 가장 강력한 반대자입니다. 고정 칼람인 The Deep End를 읽어보시면 계속 문제를 제기하고 있습니다. 아래는 글중 하나입니다.
비판의 핵심을 쉽게 이해하게 해주는 그림입니다.
저는 이용자이고 적응을 해야 하는 사람이니까 systemd와 관련한 사용법을 정리합니다.
Linux Systemd – Start/Stop/Restart Services in RHEL / CentOS 7
Awesome ! systemd Commands to Manage Linux System
Linoxide에 올라온 글중 아래가 가장 보기쉽게 정리한 자료입니다.
2.
여러분은 UTF-8과 EUC-KR중 어느 것을 사용하나요? 개발자마다 회사마다 다르지만 UTF-8이 표준이 아닐까 합니다. 그래서 EUC-KR로 개발된 소스를 UTF-8로 바꾸어 할 경우가 있었습니다. 리눅스 명령어인 iconv를 사용하면 되지만 수많은 파일을 한줄한줄 입력할 수 없습니다. 그래서 찾아보다 발견한 보물(^^)입니다.
SHELL SCRIPT FOR RECURSIVELY CONVERTING FILES, THAT ARE SAVED IN ANY CHARSET, INTO UTF-8.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
#!/bin/bash # Created by LEXO, http://www.lexo.ch # Version 1.0 # # This bash script converts all files from within a given directory from any charset to UTF-8 recursively # It takes track of those files that cannot be converted automatically. Usually this happens when the original charset # cannot be recognized. In that case you should load the corresponding file into a development editor like Netbeans # or Komodo and apply the UTF-8 charset manually. # # This is free software. Use and distribute but do it at your own risk. # We will not take any responsibilities for failures and do not provide any support. #checking Parameters if [ ! -n "$1" ] ; then echo "You did not supply any directory at the command line." echo "You need to provide the path to the directory that contains the files which you want to be converted" echo "" echo "Example: $0 /path/to/directory" echo "" echo "Important hint: You should not run this script from within the same directory where the files are stored" echo "that you want to convert right now." exit fi # This array contains file extensions that need to be checked no matter if the filetype is binary or not. # Reason: Sometimes it happens that .htm(l), .php, .tpl files etc. have a binary charset type. This script # does not convert binary file types into utf-8 because it might destroy your data. So we need to include these file types # into the conversion system manually to tell the conversion that binary files with these special extensions may be converted anyway. filestoconvert=(htm html php txt tpl asp css js) # define colors # default color reset="\033[0;00m" # Successful conversion (green) success="\033[1;32m" # No conversion needed (blue) noconversion="\033[1;34m" # file skipped because it's not mentioned in the filestoconvert array (white) fileskipped="\033[1;37m" # files that could not be converted aka error (red) fileconverterror="\033[1;31m" ## function to convert all files in a directory recusrively function convert { #clear screen first clear dir=$1 # Get a recursive file list files=(`find $dir -type f`); fileerrors="" #loop counter i=0 find "$dir" -type f |while read inputfile do if [ -f "$inputfile" ] ; then charset="$(file -bi "$inputfile"|awk -F "=" '{print $2}')" if [ "$charset" != "utf-8" ]; then #if file extension is in filestoconvert variable the file will always be converted filename=$(basename "$inputfile") extension="${filename##*.}" # If the current file has not an extension that is listed in the array $filestoconvert the current file is being skipped (no conversion occurs) if in_array $extension "${filestoconvert[@]}" ; then # create a tempfile and remember all of the current file permissions to be able to reapply those to the new converted file after conversion tmp=$(mktemp) owner=`ls -l "$inputfile" | awk '{ print $3 }'` group=`ls -l "$inputfile" | awk '{ print $4 }'` octalpermission=$( stat --format=%a "$inputfile" ) echo -e "$success $inputfile\t$charset\t->\tUTF-8 $reset" iconv -f "$charset" -t utf8 "$inputfile" -o $tmp &>2 RETVAL=$? if [ $RETVAL > 0 ] ; then # There was an error converting the file. Remember this and inform the user about the file not being converted at the end of the conversion process. fileerrors="$fileerrors\n$inputfile" fi mv "$tmp" "$inputfile" #re-apply previous file permissions as well as user and group settings chown $owner:$group "$inputfile" chmod $octalpermission "$inputfile" else echo -e "$fileskipped $inputfile\t$charset\t->\tSkipped because its extension (.$extension) is not listed in the 'filestoconvert' array. $reset" fi else echo -e "$noconversion $inputfile\t$charset\t->\tNo conversion needed (file is already UTF-8) $reset" fi fi (( ++i )) done echo -e "$success Done! $reset" echo -e "" echo -e "" if [ ! $fileerrors == "" ]; then echo -e "The following files had errors (origin charset not recognized) and need to be converted manually (e.g. by opening the file in an editor (IDE) like Komodo or Netbeans:" echo -e $fileconverterror$fileerrors$reset fi exit 0 } #end function convert() # Check if a value exists in an array # @param $1 mixed Needle # @param $2 array Haystack # @return Success (0) if value exists, Failure (1) otherwise} #end function in_array() # Usage: in_array "$needle" "${haystack[@]}" in_array() { local needle=$1 local hay=$2 shift for hay; do # echo "Hay: $hay , Needle: $needle" [[ $hay == $needle ]] && return 0 done return 1 } #end function in_array #start conversion convert $1 |
혹시 Execel로 만든 자료를 UTF-8로 변환하여 사용하여야 하는 경우가 있었습니다. CSV로 저장해서 사용했지만 글자가 깨지더군요. 혹시나 구글 스프레시트로 Copy/Paste를 해서 CSV로 저장하니 이상이 없었습니다. 그런데 Excel에서도 가능한 방법이 있더군요.(^^)
How to convert Excel to CSV and export Excel files to CSV UTF-8 format
또하나 몇 일전 CentOS 7을 설치할 때 사용한 USB를 포맷해서 다시 사용하여야 했습니다. 그런데 지워지지 않았습니다. 이것 저것 시도하다가 아래를 읽고 해결했습니다.