Linux Command
- Linux Command
ls | lists files and directories |
형식 | ls [option] [{dir | file}] |
옵션 | -l : 자세히 -a : 숨긴 파일까지 전부 -R : recursive execution (하위 디렉토리까지 전부) |
pwd |
present working directory |
|
형식 |
pwd [option] |
|
옵션 |
default : 현재 디렉토리 출력 -P : Physical한 디렉토리 위치, Symbolic link 없이 |
cd | change current dir |
형식 | cd [option] [directory_address] |
옵션 | default (without directory_address) : Home 디렉토리로 이동 directory_address : 해당 하위 디렉토리로 이동.. : 이전 디렉토리로 이동/ : root 디렉토리로 이동 |
cp | Copy file or directory |
형식 | cp [option] <source> <destination> |
옵션 | default : source를 destination으로 복사, 디렉토리는 안됨 -f : forced (overwrite the target file if it aleady exists) -i : interactive (check whether doing copy) -r : recursive execution (하위 디렉토리까지 전부) |
mv | Move or rename file or directory |
형식 | mv [option] <source> <destination> |
옵션 | default : source를 destination으로 이동, 디렉토리는 안됨 -f : forced (overwrite the target file if it aleady exists) -i : interactive (check whether doing copy) |
rm | delete file |
형식 | rm [option] file |
옵션 | default : 파일 제거, 디렉토리는 안됨 -f : forced -i : interactive (check whether doing removal) -r : recursive execution (디렉토리 제거, 하위 디렉토리까지) |
mkdir | create a dir |
형식 | mkdir directory_name |
옵션 | default : 디렉토리 생성 |
rmdir | delete a dir |
형식 | rmdir directory_name |
옵션 | default : 디렉토리 제거 (the directory should be empty) ※ if the directory isn't empty, it won't be deleted.-> rm -r 또는 rm -rf로 삭제 |
cat | print contents of text file |
형식 | cat file |
옵션 | default : text file의 내용물 출력 |
more | print contents of text file in a page unit |
형식 | more file |
옵션 | default : text file의 내용물을 page 단위로 출력해서 봄 |
ln | create a link for a file |
형식 | ln [-s] <file> <link> |
옵션 | -s : file의 바로가기를 만듦 (symbolic link) -> 일반적 default : file의 바로가기를 만듦 (hard link) ※ hard link는 c언어의 reference(참조자)와 비슷 |
chmod | change file permission |
형식 | chmod permission file |
옵션 | 8bit 8bit 8bit : permission을 해당하는 bit값으로 변경ex) 777 -> rwx/rwx/rwx, 741 -> rwx/r--/--x +r, +w, +x : 모든 사용자의 r, w 또는 x를 전부 허락 -r, -w, -x : 모든 사용자의 r, w 또는 x를 전부 불허 |
※ file permission
- access permission for file or dir
- consists of read(r), write(w), execute(x) for user, group, and others
- 총 10자리로 구성 : _/___/___/___ -> filetype/user/group/others
file | directory | |
read | can read file contents (cat) | can read directory contents (ls) |
write | can modify file contents | can Add or remove file or sub directory |
execute | can execute file | can change to the directory |
ps | print the information of processes |
형식 | ps [option] |
옵션 | default : 현재 실행되고 있는 프로세스들 출력 -e : (every)모든 프로세스들 출력 -l : 자세히 출력 ※PID : process ID, PPID : parent process ID |
su | (switch user) change to other user |
형식 | su [option] [user_name] |
옵션 | default (without user_name) : change to root(super-user) user_name : 해당하는 user로 변경 |
history | Command history |
형식 | history |
옵션 | default : 지금까지 타이핑한 command 출력 ※ 방향키 ↑ : 바로 전에 타이핑한 command를 prompt로 가져옴 |
echo | print message or value of variable |
형식 | echo variable |
옵션 | variable의 값을 출력함, 또는 단순 메시지를 출력함 $HOME : Home directory의 주소를 출력 $PATH : user의 등록된 경로들을 출력 ※ $ : 변수의 값을 출력, 예를 들어, $varialble이라 하면 variable이라는 변수가 가진 값을 출력 |
tar | make a pack of files or directory |
형식 | tar option package [target] |
옵션 | -c (compress) : 패키지를 만든다 -x (extract) : 패키지를 푼다 -v (verbose) : 처리중인 과정을 보여준다 -f : package file name (이름을 설정한다) -z : with gzip (압축과 함께) ex.1) 패키지 만들기 : tar -cvf temp.tar ./address/ ex.2) 패키지 풀기 : tar -xvf temp.tar ex.3) 압축과 함께 : tar -cvfz temp.tgz ./address/ |
gzip | compress file (압축) |
형식 | gzip [option] file |
옵션 | -v (verbose) : 압축상태를 출력 -d (decompress) : 압축을 해제 -1 (fast) : 속도위주의 압축 -9 (best) : 최고 압축율 |
gunzip | extract gz file (압축 풀기) |
형식 | gunzip [option] file |
옵션 | 딱히 필요 없음. 필요하다 싶으면 찾아 보기. |
※ I/O redirection
- <, >, >>
- standard input/ output을 specific file로 변경
- > : overwrite (덮어쓰기)ex) ls > ls.txt : ls command에 의한 출력을 ls.txt에 저장 (overwrite로)
- >> : append (덧붙여 쓰기)ex) ls >> ls.txt : ls command에 의한 출력을 ls.txt에 저장 (append로)
- < : 명령어의 입력으로 특정한 파일을 받음ex) sort < name.txt : sort 명령어의 표준입력(키보드입력) 대신 name.txt 파일을 입력으로 받음
※ Pipe ( '|' )
- 한 명령어(프로그램)의 standard output을 또다른 명령어(프로그램)의 standard input으로 전달.
- ex) ps -el | more : ps -el 의 결과를 more 명령어의 입력으로 전달.
rpm | install, update, uninstall the programs |
형식 | rpm option package |
옵션 | -i : install -U : upgrade -e : erase -h : %진행상황 표시 -v : 패키지 검증 ex) rpm -ivh package.rpm : package.rpm 설치rpm -Uvh package.rpm : package.rpm 설치일반적으로 -ivh보다는 -Uvh로 설치한다고 함. ※ Redhat 리눅스용 명령어 |
yum | install & remove the programs via internet |
형식 | yum option package |
옵션 | install : install package remove : remove package ex) yum install dovecot : dovecot 설치 ※ Redhat 리눅스용 명령어 |