This is an old revision of the document!
linux 기초 사용법
$ history
- ls
$ ls $ ls /etc/systemd $ ls -a $ ls -l $ ls *.conf $ ls -l /etc/systemd/b*
- cd
- pwd
- rm
- cp
- touch
- mv
- mkdir
- rmdir
- cat
- head
- tail
- more
- less
- file
- clear
- pwd
- 파이프; |
- 필터; grep, tail, wc, sort, awk, sed 등
- 리디렉션; >(overwrite), »(append), <, < >
- 연속 실행 ;
- 프로세스
- foreground process
- background process
- 프로세스 번호
- 작업 번호
- 부모 프로세스, 자식 프로세스
- ps
- kill
- pstree
- 데몬; 명령 &
- 서비스;
- systemctl start/stop/restart
- systemctl status
- systemctl enable/disable
- 소켓; /lib/systemd/system 디렉토리 소켓이름.socket
- GRUB; /etc/default/grub
- uname -r; 커널 버전 확인
- /etc/issue; 우분투 버전
- wget
- curl
- ls -l
- 파일유형; d(디렉토리),-(일반), b(블록 디바이스), c(문자 디바이스), l(링크)
- 파일허가권; r(read)w(write)x(execute) 형식, 소유자-그룹-기타 순.
- 링크수
- 파일소유자
- 파일소유그룹
- 파일크기(Bytes)
- 마지막변경 날짜/시간
- 파일 이름
- chmod; u(user), g(group), o(others)
- chown
- chgrp
- whoami
- 링크
- Hard link; 원본 데이터를 직접 가르킴
- Symbolic link; ln -s, 별도의 포인터
- inode에 대한 이해
- package
- dpkg -i(–install), -r(–remove), -P(–purge), -l, -L
- apt-get; 의존성 문제 해결,
- apt-get -y install 패키지 이름
- apt-get update
- apt-get remove,
- apt-get purge,
- apt-get autoremove
- apt-cache
- apt-cache show
- apt-cache depends
- apt-cache rdepends
- 파일 압축
- xz
- bzip2
- gzip
- zip / unzip
- 파일 묶기
- tar
- 파일 위치 검색
- find
- which
- whereis
- locate
- cron; crond : /etc/crontab
- at
네트워크
- ifconfig
- ifdown
- ifup
- systemctl start/stop/restart/status networking
- nslookup
- ping
- /etc/resolv.conf; dns 서버의 정보와 호스트 이름이 들어있는 임시 사용 파일
- /etc/hosts; 호스트 이름과 FQDN이 들어있는 파일
- /etc/network/interfaces
- 사용자/그룹;
- /etc/passwd; 사용자이름:암호:사용자ID:사용자소속그룹ID:추가정보:홈디렉토리:기본쉘
- /etc/group; 그룹이름:비밀번호:그룹ID:보조그룹사용자
- adduser
- passwd
- usermod
- userdel
- chage
- groups
- groupadd
- groupmod
- groupdel
- gpasswd
- mount / unmount
- 히스토리
$ history
- 도움말
man <명령어>
$ man ls
- 로그 아웃 (사용자 계정)
$ logout $ exit
- 시스템 재부팅 (root 계정)
# reboot # shutdown -r now # init 6
런레벨 | |||
---|---|---|---|
런레벨 | 영문 모드 | 설명 | 비고 |
0 | Power Off | 종료 모드 | |
1 | Rescue | 시스템 복구 모드 | 단일 사용자 모드 |
2 | Multi-User | 사용하지 않음 | |
3 | Multi-User | 텍스트 모드의 다중 사용자 모드 | |
4 | Multi-User | 사용하지 않음 | |
5 | Graphical | 그래픽 모드의 다중 사용자 모드 | |
6 | Reboot |
- 시스템 종료 (root 계정)
# poweroff # shutdown -P now # halt -p # init 0 # shutdown -P +10 # 10분 후 종료 (P: poweroff) # shutdown -r 22:00 # 오후 10시에 재부팅 (r: reboot) # shutdown -c # 예약된 shutdown 취소 (c: cancel) # shutdown -k +15 # 현재 접속한 사용자에게 15분 후에 종료 메시지 브로드캐스팅, 실제 종료는 안됨
- raid(Redundant Array of Inexpensive/Independent Disks)
- 단순볼륨
- linear raid
- raid 0; stripping
- raid 1; mirroring, fault-tolerance
- raid 5; parity
- raid 6;
- raid 1+0, 1+6
- quota; /etc/fstab → reboot → quota heck, quotaon/quotaoff → edquota
bash shell script
- alias
- history
- 연산기능
- job control 기능
- 자동 이름 완성 기능
- 프롬프트 제어 기능
- 명령 편집 기능
- shebang(hashbang)
환경변수 HOME LANG TERM USER COLUMNS PS1 BASH HISTFILE HOSTNAME LOGNAME MAIL PATH PWD SHELL DISPLAY LINES PS2 BASH_VERSION HISTSIZE USERNAME LS_COLORS OSTYPE
- .sh
- echo
- chmod +x
- 변수
- 변수=값; = 앞뒤로 공백 없음, 문자열
- 숫자 계산; 역따옴표, expr \(, \), \*,
- 파라미터; $0, $1, $2, …
- if ~ if
- case ~ esac
- else