backend 269

리눅스 텍스트 프로세싱: sort, sed 사용법

20. Text Processing cat sort uniq cut, paste, join comm, diff, patch tr sed, aspell sort 다양한 옵션이 있음 -f: ignore case -n: numeric sort -r: reverse -k: key. 아래에서 더 자세히 설명 -o: output file -t: field seporator. default는 space나 tab du -s /usr/share/* | sort -nr | headkey를 사용하는 법 sort는 tabular data 형태로 작동한다. 아래 예시는 /usr/bin 디렉토리의 파일을 크기순으로 정렬 후 10개만 보여줌. 각각의 열은 필드처럼 작동하여 이 필드를 key로 사용할 수 있다. 아래 예제에서는 5번..

backend/ubuntu 2020.12.22

리눅스 아카이빙, 압축 (Linux archiving): gzip, tar ...

18. Archiving and backup gzip, bzip2, tar, zip, rsync Compressing files 압축은 데이터의 과잉(redundancy)를 줄이는 것. lossless: 데이터를 원본 그대로 압축하는것 lossy: 데이터를 제거하여 압축하는것 (JPEG, MP3 등) GZIP root@3c28bc830cb6:~# ls -l foo.txt -rw-r--r-- 1 root root 3680 Dec 12 03:37 foo.txt root@3c28bc830cb6:~# gzip foo.txt root@3c28bc830cb6:~# ls -l foo.* -rw-r--r-- 1 root root 821 Dec 12 03:37 foo.txt.gz root@3c28bc830cb6:~# l..

backend 2020.12.21

리눅스 파일 검색: locate, find 기본 사용법, 이것만 알면 쉽다

17. Searching for files locate database를 바탕으로 주어진 substring과 맞는 파일을 탐색. updatedb라는 프로그램이 정기적으로 cron job으로 파일 데이터베이스를 업데이트한다. find locate가 파일을 이름으로만 찾았다면 find 프로그램은 특정 디렉토리에서 다양한 옵션과 특성으로 파일을 찾을 수 있다. find ~ # wordcount find ~ | wc -l Options (Test) find에는 다양한 옵션 (test라고 부름)이 존재한다. 대표적인 옵션은 -type. # directory만 찾기 find ~ -type d | wc -l # file 찾기 find ~ -type f | wc -l # size option find ~ -type f..

backend 2020.12.20

Linux Package management: 리눅스의 패키지란?

14. Package management package management는 시스템에서 소프트웨어를 설치하고 관리하는 시스템. 요즘엔 대부분의 사람들이 각 linux distributor의 패키지들을 설치한다. 이는 소스코드를 받아서 컴파일하는 초기의 리눅스에 반대되는 것이지만, 소스코드를 받아서 쓰는 방식도 여전히 널리 사용되는 방식이다. 이는 이후 챕터에서 다룰예정 Packaging syswtem 일반적으로 다른 배포판은 다른 패키징 시스템을 갖는다. 대부분의 배포판은 크게 두가지로 나뉜다 Debian: .deb (Debian, Ubuntu, Linux Mint, Raspbian) Red hat: .rpm (Fedora, CentOS, Red hat Enterprise Linux, OpenSUSE) ..

backend 2020.12.19

Linux prompt: 리눅스 쉘 프롬프트 기본 및 커스터마이징

13. Customizing the prompt 가장 기본적인 prompt는 다음처럼 생겼다. [ec2-user@ip-xxx.xx.xx.xx ~]$prompt는 전에 살펴봤던 것처럼 PS1이라는 환경변수로 정의되어 있다. (Prompt String 1의 줄임말) [ec2-user@ip-xxx.xx.xx.xx ~]$ echo $PS1 [\u@\h \W]\$이 backslashed-escaped special character들은 bash가 prompt string에서 특별하게 사용한다. \a: ASCII bell. computer beep 소리를 낸다 (?) \d: current date (Mon May 26) \h: hostname \H: full hostname \j: 현재 shell 세션에서 실행중인..

backend 2020.12.18

Linux environment: 환경변수

11. The environment shell은 세션의 정보를 environment로 유지한다. 이는 크게 두가지로 나눌 수 있는데, environment variable과 shell variable bash에 의해서 만들어진 데이터를 shell variable이라고 부르고 나머지 전부는 environment variable이다. 이와 더불어 몇몇 정보는 aliases와 shell functions에도 저장한다. shell function은 책의 나중에 다룰 예정 (shell scripting) env를 보는 방법은 printenv, set이 있다. printenv는 environment variable을 모두 보여주고 set 명령어는 shell과 env 변수를 모두 보여준다. 어떻게 environmen..

backend 2020.12.17

리눅스 권한 (Linux permission) 정리: chown, chmod

09. Permission user account는 /etc/passwd에, group은 /etc/group에 정의되어 있고 유저나 그룹이 생성되면 etc/shadow가 수정된다. root@e78e6ae9e14a:~# > foo.txt root@e78e6ae9e14a:~# ls -l foo.txt -rw-r--r-- 1 root root 0 Nov 28 16:02 foo.txt앞의 10 문자는 file attribute를 나타낸다. 첫번째 문자는 파일타입. -: regular file d: directory l: symbolic link. 이 경우 나머지 값은 rwxrwxrwx (dummy 값이다) c: terminal이나 /dev/null같은 character special file b: block s..

backend 2020.12.15

쉘 익스펜션(Shell expansion): wildecard (*), tilde (~), dot (.)

7. Seeing the world as the shell sees it expansion: 무언가 입력했을 때 shell에서 실제로는 다른 확장된 일을 해줌 root@e78e6ae9e14a:~# echo * ls.txt위처럼 *를 프린트하지 않고 wildcard가 모든 파일명을 반환함. pathname expansion wildcard로 동작하는 매커니즘을 pathname expansion이라고 부른다. root@e78e6ae9e14a:~# ls Desktop Documents Music Pictures Public Templates Videos ls.txt root@e78e6ae9e14a:~# echo D* Desktop Documents root@e78e6ae9e14a:~# echo *s Docum..

backend 2020.12.14

[book] The linux command line: Rediretion - standard intput, output, error

6. Redirection Standard input, output, and error 대부분 프로그램은 어떤 형태로든 output을 제공함. 보통은 둘가지 타입 프로그램의 결과 에러 메세지 Unix의 "모든 것은 파일이다"라는 말처럼, 프로그램은 실제로 결과를 standard output (stdout)이라는 특별한 파일로 전송하고 상태 메세지를 standard error (stderr)로 보낸다. 기본적으로 이 아웃풋과 에러는 스크린에 연결되고 따로 디스크 파일에는 저장되지 않는다. 추가적으로, 많은 프로그램은 input을 받기 위해 standard input (stdin)을 받는다. (default로 키보드) I/O redirection은 output이 어디로 가고 input이 어디로 오는지를 변경..

backend 2020.12.13

[book] The linux command line: working with commands - type, which, man, alias

5. Working with commands type: 특정 명령어가 어떤 종류인지 보여주는 명령어 명령어 종류 executable program built into the shell itself shell function alias root@37ba9ce1e69f:/# type ls ls is aliased to `ls --color=auto' root@37ba9ce1e69f:/# type type type is a shell builtin root@37ba9ce1e69f:/# type cp cp is /usr/bin/cpwhich: display an executable's location command's documentation bash는 빌트인 help 도구를 가지고 있음...

backend/ubuntu 2020.12.12