process
:
Process Types
:
Interactive process
:Batch process
:Daemon
:Threads
:Kernel threads
:Process ID = PID
:Parent Process ID = PPID
: ID of a parent that started this process.Thread ID = TID
: each thread has a unique TID.ps
: provides information about running processes
ps
: displays all processes running
ps -ef
: displays all process in the system
ps -eLf
: more info about thread
현재 몇개의 process가 실행되고 있는지 확인하기
pstree
: displays the processes in the form of a tree diagram
systemd가 init process임을 알 수 있다.
맥OS에서는 brew install pstree
맥OS에서 init process는 /sbin/launched임을 알 수 있다.
top update process status regulary
top
:
htop
: top과 동일한 system process monitoring tool. (더 사용자 친화적, 직관적)
kill
: to terminate a process
kill을 test해보기 위해, process 중간에 sleep을 하는 program을 생성하고
sleep하는 동안 kill로 해당 process를 종료시켜볼 것이다.
gcc는 GNU 프로젝트에서 만든 컴파일러 모음.
전통적으로 리눅스/유닉스 표준 C 컴파일러 역할.
최적화가 잘 되어 있고, GNU/Linux 배포판에서는 보통 gcc가 기본.
LLVM 프로젝트의 C, C++, Objective-C 컴파일러 프론트엔드.
애플이 macOS와 iOS 개발을 위해 강하게 밀고 있는 컴파일러.
GCC보다 컴파일 속도가 빠르고 에러 메시지가 친절.
macOS에 기본 내장된 gcc는 사실 Clang을 가리키는 심볼릭 링크.
그래서 gcc --version 치면 Apple clang version이 나옴
In Linux, a job
is a command launched from a terminal window(=shell)
Foreground job
: runs directly from the shell.
Background job
:
Use suffix '&' to launch a command in the background
forground job들은 실행이 완료되기 전까지 shell을 쓸 수가 없다.
ls, pwd와 같은 작은 job은 문제가 되지 않지만,
실행시간이 긴 job들은 shell을 쓸 수 없게 되어서 Background job이 만들어졌다.
example :
mysleep을 background job으로 실행되도록 했으니
ls, pwd와 같은 job들을 계속해서 사용할 수 있다.
jobs
: displays all jobs running in the both foreground and background.
fg
and bg
: command to run a job in the background and foreground, repectively.
Managing jobs example :
ps
:
top
:
jobs
:
In Linux(Unix), "Everything is a file".
Filesystem is structured like a tree.
하나의 disk는 여러 partitions로 구분되어 있음
mount
: command is used to attach a filesystem somewhere within the filesystem tree.
왜 쓰는가?
sudo mount /dev/sdb1 /mnt/usb
sudo mount -t cifs //192.168.0.10/shared /mnt/shared -o username=user
sudo mount --bind ~/original_dir ~/mount_point
'mount'
실제 partition이 출력되지만, 가상의 partition들도 존재하기 때문에 많이 출력됨.
/dev/nvme0n1p2 partition은 /에 ext4 type으로 mount되어 있다.
(아래와 같이 실제로 file system 상에 존재하는지 확인해볼 수 있음.)
(blkid로 UUID, 파일시스템 종류까지 확인 가능)
/dev/vda2를 /home에 마운트.
home directory에 작업한 것은 /dev/vda2에 작성됨
booting할 때, 어떤 partition을 어떤 directory에 mount할 것인지 정의할 수 있음 (/etc/fstab)
UUID는 disk partition 이름임. 그 partition을 /boot/efi에 vfat 타입으로 mount를 하겠다.
macOS에서는 /etc/fstab 파일이 존재할 수 있지만, 기본적으로는 비어 있거나 거의 사용되지 않는다고 함.
대부분의 마운트는 자동 마운트(autofs)로 관리되며, /etc/fstab에 직접 기록하는 경우는 드뭄
diff
: is used to compare files and directoriesrsync
: -av
src/ user@host:dest/-avz
src/ user@host:dest/gzip
: The most frequently used Linux compression utilitybzip2
: Produces files significantly smaller than those produced by gzipzip
: Often requried to decompress archives from Windowsxz
: Maximum compression, slowest compressiontar
: is often used to group files in an archive and then compress the whole archive at once
묶어만
놓기(tar -cvf
), 풀기(tar -xvf-zcvf
(모으고 나서 gzip
으로 압축)-jcvf
(모으고 나서 bz2
으로 압축)-Jcvf
(모으고 나서 xz
형식으로 압축)실제로 xz
형식이 가장 압축률이 높은지 확인해보기
-zcvf
*.tar.gz
생성
-jcvf
*.tar.bz2
생성
-Jcvf
*.tar.xz
생성
파일 사이즈 비교하기