1.file command : 파일정보를 상세히 출력한다.
# file /bin/ls
# file /root/anaconda-ks.cfg
2. cat command : 파일의 내용을 보거나 생성, 수정을 담당.
1). cat viewer : 파일내용보기
# cat /root/anaconda-ks.cfg
2). file create & append
# cat > newfile
input text
<ctrl+D>
# cat >> newfile
input new text
<ctrl+D>
3). special case
# cat -n /root/ananconda-ks.cfg
3.more command : 긴 문장을 하나의 화면으로 출력, 긴 문장 볼 때 사용
# more /root/ananconda-ks.cfg
command 응용
# cat -n /root/anaconda-ks.cfg | more
4.wc command : 라인수, 글자수, 사이즈수로 파일을 표시
# wc -l /root/anaconda-ks.cfg
# wc -w newfile
# wc -c newfile (file size 정보)
# ls -l newfile (5번 필드 - size 정보)
# wc -m newfile
command 응용
# ls -l /bin | wc -l
1. ip 확인 방법
ipconfig : ip 주소를 확인한다.
ipconfig /all : 좀더 자세히 확인한다.
2. 명령 프롬프트 기본 명령어
cls : clear screen
dir : 디렉토리 보기
date : 날짜 보기
time : 시간 보기
mkdir : 폴더 만들기
cd : 디렉토리 이동
F7 : 그 전에 친 문자들 재활용
3. 프로그램 사용
- putty.exe (SSH : 보안쉘 이용)
- 파인텀 설치
- 명령어
* 시간 관련
-> date : 날짜
-> cal : 이번달 달력
-> cal 2010 : 2010년 달력 출력
-> uptime : 컴퓨터 켜진 시간
* ID 관련
-> hosty name : host 이름
-> LANG=C : 언어 변경 (글자가 깨질때 사용한다.)
-> who : 접속자 알아보기
-> who | sort | ln : 정렬된 접속자
* message 관련
-> wall message 모든 접속자에게 메시지
-> mesg no : 수신거부 , mesg on : 수신
-> write ID : 단방향 메시지 ( ID 에게 보냄)
-> ctrl + c : 복귀
-> ctrl + d : 끄기
-> ctrl + L : 화면 비우기 ( clear )
* mail 사용
-> mail 상대아이디 : 상대에게 매일 보내기 ( 제목 , 내용(.쓰면 내용 끝) , Cc : 참조인 )
-> mail : 매일 확인 (q 종료)
4. ftp를 이용하여 홈페이지 올리기
- 파인텀으로 접속하여 폴더를 만들고 권한을 수정한다.
mkdir public_html (폴더 생성) -> chmod 701 ~ (권한 변경)
- 명령프롬프트에서 html 파일을 올린다.
ftp ijj.kr : ftp 서버에 접속
pwd : 현재 디렉토리 알기
cd public_html : public_html 디렉토리로 이동
pwd
!dir : 지금 내 컴퓨터의 디렉토리 보기
put index.html : index.html 을 서버에 올린다. ( chmod 701 을 안했다면 올라가지 않는다. )
bye ( 종료 )
- 직접 명령프롬프트에서 html 쓰기
public_html 디렉토리 안에서
cat > index.html 입력
입력 완료 후 Ctrl + D
- 파일 다운받기
* Internet Explorer 에서 다운받기 : ftp://ijj.kr (도메인 ftp 에 접속이 된다.)
* get (파일이름) : 파일을 가져온다.
[관리명령 lab]
1. mkdir command
# mkdir dir1 ---> directory 1개 생성
# mkdir dir2 dir3 --> 다수 directory 생성
# mkdir -p dir4/dir5 --> dir4 생성 후 dir5 생성
2. rmdir command : 디렉토리 삭제
# rmdir dir1
# rmdir dir2 dir3
# rmdir install.log --> Error 발생 (file 삭제 불가능)
3. touch command
1. 0kb file 생성
# touch file1
# touch file2 file3
2. 시간 정보 변경
# ls -l --> 존재하는 파일의 시간 정보 확인
# touch install.log --> 시간 정보
4. rm command : 파일삭제
# rm file1
# rm file2 file3
# rm dir2 ---> Error 발생 (dir 삭제 불가능)
# rm -r dir4 --> (-r에 의해 dir 삭제 가능)
5. cp command : 파일복사, 디렉토리복사는 불가
# cp file4 dir3
# cp -r dir3 dir4
# cp -i file3 dir3
6. mv command
1. file 이동
# mv file2 dir3
2. rename
# mv file1 new_file1
7. grep command (egrep, fgrep)
# grep 'root' /etc/passwd
# grep -c 'root' /etc/passwd --> line count
# grep -n 'root' /etc/passwd --> line number
# grep -i 'ROOT' /etc/passwd --> ignore case
# grep -v 'root' /etc/passwd --> except
# grep -w 'root' /etc/passwd --> word
* Regular Expression
# grep '^root' /etc/passwd --> line 처음부분
# grep 'login$' /etc/passwd --> line 마지막 부분
# grep 'ro.t' /etc/passwd
# grep 'ro.*' /etc/passwd
# grep '[Rr]oot' /etc/passwd
* grep command 응용
# ps -ef | grep http
8. find command
# mkdir core
# mkdir dir1 dir2
# touch dir1/core dir2/core
# find /root -name core
# find /root -name core -ls
# find /root -name core [-a] -type f
# find /root -name core -type f -ok rm {} \;
# find /root -name core -type f -exec rm {} \;
# touch sizefile
# touch timefile
# find /root -size 2
# find /root -size -2
# find /root -mtime 2
# find /root -mtime -2
# find / -user root
1. vi lab
# vi new_file ---> 새 파일 제작
# ls -l /etc > list
# vi list ---> 존재하는 파일
---------------------------------
2. 파일 permission Lab
# ls -l list
# chmod o-r list : others 그룹에서 Readonly 권한을 뺌
# chmod a=rw list : all(모든그룹)을 Read&Write 로 변경
# chmod o-rw list : others 에서 Read&Write 권한을 뺌
# chmod g-rw list : Group에서 Read&write 권한을 뺌
# chmod g+r list : Group에서 Readonly 권한을 추가
# chmod 644 list : User 를 6(Read&write), Group 을 4(Read only), others 를 4(Readonly)로 변경
# chmod 444 list : User, Group, others 모두를 Readonly로 변경
# mkdir dir1
# useradd user1 ----> 계정 발급
# passwd user1 ----> 임시 패스워드 발급
# touch dir1/file1 dir1/file2
# chmod 755 /root
# chmod 754 dir1
# su user1
$ ls -ld dir1
$ ls -l dir1 ---> -l 옵션 동작 불가능
$ exit
# chmod 753 dir1
# su user1
$ ls -l dir1 ---> 리스트 참조 불가능
$ exit
# chmod 757 dir1 ---> w 권한 부여시 파일 생성/삭제 가능
# su user1
$ touch dir1/file3
$ ls -l dir1
$ exit
3. umask filter lab
# umask
# touch dir2/file1
# umask 027
# touch dir2/file2
# umask
[special permission Lab]
1. SetUID 설정
# ls -l /usr/bin/passwd
# chmod 555 /usr/bin/passwd --> setuid 삭제
--------------------------------------------
<ctrl+alt+F2>
login : user1
password :
$ passwd
--------------------------------------------
# ps -ef | grep passwd -----> passwd 명려을 user1이 실행
# chmod 4555 /usr/bin/passwd --> setuid 설정
# ls -l /usr/bin/passwd
--------------------------------------------
$ passwd
--------------------------------------------
# ps -ef | grep passwd -----> passwd 명령을 root가 실행
2. Sticky bit 설정
# mkdir /data
# ls -ld /data
# chmod 1777 /data
# touch /data/file1 /data/file2 /data/file3
--------------------------------------------
$ cd /data
$ ls -ld /data
$ rm file1 ----------> 파일 삭제 불가능
--------------------------------------------
# chown user1 /data --------> 디렉터리 소유자 변경 root->user1
--------------------------------------------
$ ls -ld /data
$ rm file2 --------> 파일 삭제가 가능
[파일 백업 및 압축 Lab]
1. tar 백업
# mkdir /root/data
# cp /usr/sbin/sys* /root/data
# tar cvf data.tar data
# tar cf data2.tar data
2. gzip 압축
# gzip data.tar ---> gz 확장자 생성
<압축 해제>
# gunzip data.tar.gz
# gzip -d data.tar.gz
3. 압축과 백업 해제
# tar zxvf data.tar.gz --> z옵션에 의해 압축 해제 후 백업 해제
[Source 형 패키지 설치 Lab]
1. 압축 백업 해제
# tar zxvf package_name.tar.gz
2. Makefile 확인
# cd package_name
# ls Makefile
2-1. 존재하지 않을 경우
# ls configure ---> Makefile 생성 명령
# ./configure ---> Makefile 생성
3. 프로그램 생성
# make ---> 프로그램을 임의 위치에 생성
# make install ---> 프로그램 디렉터리를 생성하고 프로그램을 위치
'블라베 IT world > Linux Document' 카테고리의 다른 글
레드햇 리눅스 6.0 설치와 활용 (0) | 2013.02.13 |
---|---|
네트웍에 문제가 발생 했을 때 해결할 수 있는 방법 몇가지 (0) | 2013.02.13 |
Centos day 01 - install (0) | 2013.02.13 |
6.DNS 세팅을 변경 (0) | 2013.01.03 |
5. CENTOS에 DNS 설정하기 (0) | 2013.01.03 |