no image
Kali Linux Commands Cheat Sheet
Reference : http://www.hacoder.com/2015/09/kali-linux-commands-cheat-sheet/ Kali Linux commands cheat sheet. All basic commands from A to Z in Kali Linux has been listed below.Aapropos : Search Help manual pages (man -k)apt-get : Search for and install software packages (Debian/Ubuntu)aptitude : Search for and install software packages (Debian/Ubuntu)aspell : Spell Checkerawk : Find and Replace ..
2015.10.09
GDB 사용법
GDB 사용법 *참조도서: "유닉스 리눅스 프로그래밍 필수 유틸리티" GDB 사용 방법 GDB를 이용하기 위해서는 컴파일 과정에서 디버깅 정보를 삽입해야 한다. 컴파일 시 옵션 'g' 이용 $ gcc -g -o main main.c 컴파일이 정상 종료 되면 GDB를 실행한다. gdb [프로그램명] $ gdb main gdb [프로그램명] [프로세스PID] $ gdb main 1928 GDB가 정상 실행되면 터미널의 프롬프트가 (gdb)로 바뀌게 된다. 종료방법에는 크게 두가지가 있다. ctrl + d (gdb) q (gdb) quit 옵션에 따라 실행중인 프로그램의 소스를 다양한 방법으로 볼 수 있다. l(list) list 10 list [함수명] list - //이전 10라인을 출력한다. list [..
2015.09.05
Kali linux 부팅 디스크 만들기
이걸로 유일하게 만들어졌다
2015.08.21
원격접속과 FTP
#Telnet & SSH 1.Telnet 텔넷 사용을 위해서는 텔넷 클라이언트와 텔넷 서버가 필요. Telnet은 수퍼데몬에 의해 동작하기에 xinetd를 설치해야한다. sudo apt-get install xinetd ... sudo apt-get install telnetd ... 텔넷 서버를 동작시키려면 /etc/xinetd.conf 파일을 설정해야함 service telnet disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure = USERID ~ :wq! 를 추가해야함 그후에 sudo /etc/init.d/xinetd restart 를 통해 활성..
2015.08.16
파일의 접근 권한,setuid,gid,스티키비트,chmod
#파일의 접근 권한ls -l 을 할경우-파일의 종류-접근권한표시-하드링크개수-로그인id-그룹id-파일크기-최종수정날짜-파일명 flie [filename] : 지정한 파일의 종류를 알려준다 groups [username] : 사용자가 속한 그룹을 알려준다. 표기방법 소유자 그룹 기타사용자 rwx rwx rwx접근권한 변경 chmod [option] file&directoryname *기호모드 u:파일소유자 g:소유자가 속한그룹 o:소유자와 그룹이외의 기타사용자 a:전체사용자 +:권한부여 -:권한제거 =:접근권한설정 r:읽기 w:쓰기 x:실행 *숫자모드 0-7 0-7 0-7 r-x : 4 0 1 = 5 rw- : 4 2 0 = 6 rwx : 4 2 1 = 8 rwxrwxrwx = 777 rwxr-xr-x =..
2015.08.16
리다이렉션
#입출력 방향바구기 파일 디스크립터0 stdin 명령어의 표준입력1 stdout 명령어의 표준출력2 stderr 명령어의 표준오류 표준 입출력 장치를 파일로 바꾸는 것을 '리다이렉션'이라한다.-출력 리다이렉션 파일 덮어쓰기 : > 명령 1> 파일이름 명령 > 파일이름 (확인을 할때는 cat을 통해 확인을 한다.) 파일에 내용추가 : >> 명령 >> 파일이름 -오류 리다이렉션 오류메세지를 위의 출력 리다이렉션처럼 > 으로 한다면 리다이렉션이 되지 않는다. 명령 2> 파일이름 ***결과를 무조건 '>'으로 담을수 있는 것이아니라 성공메세지는 1> 을 통하여 실패메세지는 2>를 통하여 리다이렉션 할 수 있다. //한번에 리다이렉션하기 ls ./abc>ls.out 2>ls.err //오류 메세지 버리기 /dev..
2015.08.16
Linux 디렉터리와 파일다루기
일반파일디렉터리심벌릭 링크장치 파일 dev : 장치파일이 담긴home : 사용자 홈디렉터리media : CD-ROM꽈 USB같은 외부장치를 연결하는 디렉토리opt : 추가 패키지가 설치되는root : root계정의 홈디렉터리sys : 리눅스 커널 관련 파일usr : 기본실행파일과 라이브러리 파일,헤더파일등 많은 파일이 존재 (Unix System Resourece)bin : 실행파일(명령)boot : 부팅에 필요한 커널파일etc : 리눅스 설정을 위한 각종 파일lost+found : 파일시스템에 문제가 발생하여 복구할 경우, 문제가 되는 파일이 저장되는 디렉터리mnt : 파일시스템을 임시로 마운트하는 디렉터리proc : 프로세스정보등 커널관련정보가 저장되는 디렉터리run : 실행중인 서비스와 관련된 파일..
2015.08.16
Shell 기본 사용법
배시쉘의 출력명령은 echo와 printf이다. echo : 화면에 한줄의 문자열을 출력한다 echo [-n] [문자열] ex)echo textprintf:자료를 형식화하여 화면에 출력한다. printf 형식 [인수] %d, \n등 C언어의 printf함수 형식을 지정한다. ex) printf text printf "text\n" printf "%d\n" 100~ chsh : 사용자 로그인 셸을 바꾼다. -s shell : 지정하는 셸로 로그인 셸을바꾼다. -l : /etc/shells 파일에 저장된 셸을 출력한다. ex) chsh -l chsh -s /bin/sh user1 chsh 현재 바꿀 수 있는 쉘의 종류는 /etc/shells에 저장되어 있다.cat /etc/shells >> sh, dash,..
2015.08.16

Reference :  http://www.hacoder.com/2015/09/kali-linux-commands-cheat-sheet/


Kali Linux commands cheat sheet. All basic commands from A to Z in Kali Linux has been listed below.

A

  • apropos : Search Help manual pages (man -k)
  • apt-get : Search for and install software packages (Debian/Ubuntu)
  • aptitude : Search for and install software packages (Debian/Ubuntu)
  • aspell : Spell Checker
  • awk : Find and Replace text, database sort/validate/index

B

  • basename : Strip directory and suffix from filenames
  • bash : GNU Bourne-Again SHell
  • bc : Arbitrary precision calculator language
  • bg : Send to background
  • break : Exit from a loop
  • builtin : Run a shell builtin
  • bzip2 : Compress or decompress named file(s)

C

  • cal : Display a calendar
  • case : Conditionally perform a command
  • cat : Concatenate and print (display) the content of files
  • cd : Change Directory
  • cfdisk : Partition table manipulator for Linux
  • chgrp : Change group ownership
  • chmod : Change access permissions
  • chown : Change file owner and group
  • chroot : Run a command with a different root directory
  • chkconfig : System services (runlevel)
  • cksum : Print CRC checksum and byte counts
  • clear : Clear terminal screen
  • cmp : Compare two files
  • comm : Compare two sorted files line by line
  • command : Run a command – ignoring shell functions •
  • continue : Resume the next iteration of a loop •
  • cp : Copy one or more files to another location
  • cron : Daemon to execute scheduled commands
  • crontab : Schedule a command to run at a later time
  • csplit : Split a file into context-determined pieces
  • cut : Divide a file into several parts

D

  • date : Display or change the date & time
  • dc : Desk Calculator
  • dd : Convert and copy a file, write disk headers, boot records
  • ddrescue : Data recovery tool
  • declare : Declare variables and give them attributes •
  • df : Display free disk space
  • diff : Display the differences between two files
  • diff3 : Show differences among three files
  • dig : DNS lookup
  • dir : Briefly list directory contents
  • dircolors : Colour setup for `ls’
  • dirname : Convert a full pathname to just a path
  • dirs : Display list of remembered directories
  • dmesg : Print kernel & driver messages
  • du : Estimate file space usage

E

  • echo : Display message on screen •
  • egrep : Search file(s) for lines that match an extended expression
  • eject : Eject removable media
  • enable : Enable and disable builtin shell commands •
  • env : Environment variables
  • ethtool : Ethernet card settings
  • eval : Evaluate several commands/arguments
  • exec : Execute a command
  • exit : Exit the shell
  • expect : Automate arbitrary applications accessed over a terminal
  • expand : Convert tabs to spaces
  • export : Set an environment variable
  • expr : Evaluate expressions

F

  • false : Do nothing, unsuccessfully
  • fdformat : Low-level format a floppy disk
  • fdisk : Partition table manipulator for Linux
  • fg : Send job to foreground
  • fgrep : Search file(s) for lines that match a fixed string
  • file : Determine file type
  • find : Search for files that meet a desired criteria
  • fmt : Reformat paragraph text
  • fold : Wrap text to fit a specified width.
  • for : Expand words, and execute commands
  • format : Format disks or tapes
  • free : Display memory usage
  • fsck : File system consistency check and repair
  • ftp : File Transfer Protocol
  • function : Define Function Macros
  • fuser : Identify/kill the process that is accessing a file

G

  • gawk : Find and Replace text within file(s)
  • getopts : Parse positional parameters
  • grep : Search file(s) for lines that match a given pattern
  • groupadd : Add a user security group
  • groupdel : Delete a group
  • groupmod : Modify a group
  • groups : Print group names a user is in
  • gzip : Compress or decompress named file(s)

H

  • hash : Remember the full pathname of a name argument
  • head : Output the first part of file(s)
  • help : Display help for a built-in command
  • history : Command History
  • hostname : Print or set system name

I

  • iconv : Convert the character set of a file
  • id : Print user and group id’s
  • if : Conditionally perform a command
  • ifconfig : Configure a network interface
  • ifdown : Stop a network interface
  • ifup : Start a network interface up
  • import : Capture an X server screen and save the image to file
  • install : Copy files and set attributes

J

  • jobs : List active jobs
  • join : Join lines on a common field

K

  • kill : Stop a process from running
  • killall : Kill processes by name

L

  • less : Display output one screen at a time
  • let : Perform arithmetic on shell variables
  • ln : Create a symbolic link to a file
  • local : Create variables
  • locate : Find files
  • logname : Print current login name
  • logout : Exit a login shell
  • look : Display lines beginning with a given string
  • lpc : Line printer control program
  • lpr : Off line print
  • lprint : Print a file
  • lprintd : Abort a print job
  • lprintq : List the print queue
  • lprm : Remove jobs from the print queue
  • ls : List information about file(s)
  • lsof : List open files

M

  • make : Recompile a group of programs
  • man : Help manual
  • mkdir : Create new folder(s)
  • mkfifo : Make FIFOs (named pipes)
  • mkisofs : Create an hybrid ISO9660/JOLIET/HFS filesystem
  • mknod : Make block or character special files
  • more : Display output one screen at a time
  • mount : Mount a file system
  • mtools : Manipulate MS-DOS files
  • mtr : Network diagnostics (traceroute/ping)
  • mv : Move or rename files or directories
  • mmv : Mass Move and rename (files)

N

  • netstat : Networking information
  • nice Set : the priority of a command or job
  • nl Number : lines and write files
  • nohup : Run a command immune to hangups
  • notify-send : Send desktop notifications
  • nslookup : Query Internet name servers interactively

O

  • open : Open a file in its default application
  • op : Operator access

P

  • passwd : Modify a user password
  • paste : Merge lines of files
  • pathchk : Check file name portability
  • ping : Test a network connection
  • pkill : Stop processes from running
  • popd : Restore the previous value of the current directory
  • pr : Prepare files for printing
  • printcap : Printer capability database
  • printenv : Print environment variables
  • printf : Format and print data •
  • ps : Process status
  • pushd : Save and then change the current directory
  • pwd : Print Working Directory

Q

  • quota : Display disk usage and limits
  • quotacheck : Scan a file system for disk usage
  • quotactl : Set disk quotas

R

  • ram : ram disk device
  • rcp : Copy files between two machines
  • read : Read a line from standard input
  • readarray : Read from stdin into an array variable
  • readonly : Mark variables/functions as readonly
  • reboot : Reboot the system
  • rename : Rename files
  • renice : Alter priority of running processes
  • remsync : Synchronize remote files via email
  • return : Exit a shell function
  • rev : Reverse lines of a file
  • rm : Remove files
  • rmdir : Remove folder(s)
  • rsync : Remote file copy (Synchronize file trees)

S

  • screen : Multiplex terminal, run remote shells via ssh
  • scp : Secure copy (remote file copy)
  • sdiff : Merge two files interactively
  • sed : Stream Editor
  • select : Accept keyboard input
  • seq : Print numeric sequences
  • set: Manipulate shell variables and functions
  • sftp : Secure File Transfer Program
  • shift : Shift positional parameters
  • shopt : Shell Options
  • shutdown : Shutdown or restart linux
  • sleep : Delay for a specified time
  • slocate : Find files
  • sort : Sort text files
  • source : Run commands from a file `.’
  • split : Split a file into fixed-size pieces
  • ssh : Secure Shell client (remote login program)
  • strace : Trace system calls and signals
  • su : Substitute user identity
  • sudo : Execute a command as another user
  • sum : Print a checksum for a file
  • suspend : Suspend execution of this shell
  • symlink : Make a new name for a file
  • sync : Synchronize data on disk with memory

T

  • tail : Output the last part of file
  • tar : Tape ARchiver
  • tee : Redirect output to multiple files
  • test : Evaluate a conditional expression
  • time : Measure Program running time
  • times : User and system times
  • touch : Change file timestamps
  • top : List processes running on the system
  • traceroute : Trace Route to Host
  • trap : Run a command when a signal is set(bourne)
  • tr : Translate, squeeze, and/or delete characters
  • true : Do nothing, successfully
  • tsort : Topological sort
  • tty : Print filename of terminal on stdin
  • type : Describe a command

U

  • ulimit : Limit user resources
  • umask : Users file creation mask
  • umount : Unmount a device
  • unalias : Remove an alias
  • uname : Print system information
  • unexpand : Convert spaces to tabs
  • uniq : Uniquify files
  • units : Convert units from one scale to another
  • unset : Remove variable or function names
  • unshar : Unpack shell archive scripts
  • until : Execute commands (until error)
  • uptime : Show uptime
  • useradd : Create new user account
  • userdel : Delete a user account
  • usermod : Modify user account
  • users : List users currently logged in
  • uuencode : Encode a binary file
  • uudecode : Decode a file created by uuencode

V

  • v : Verbosely list directory contents (`ls -l -b’)
  • vdir : Verbosely list directory contents (`ls -l -b’)
  • vi : Text Editor
  • vmstat : Report virtual memory statistics

W

  • wait : Wait for a process to complete
  • watch : Execute/display a program periodically
  • wc : Print byte, word, and line counts
  • whereis : Search the user’s $path, man pages and source files for a program
  • which : Search the user’s $path for a program file
  • while : Execute commands
  • who : Print all usernames currently logged in
  • whoami : Print the current user id and name (`id -un’)
  • wget : Retrieve web pages or files via HTTP, HTTPS or FTP
  • write : Send a message to another user

x

  • xargs : Execute utility, passing constructed argument list(s)
  • xdg-open : Open a file or URL in the user’s preferred application.


'O / S > Linux' 카테고리의 다른 글

GDB 사용법  (0) 2015.09.05
Kali linux 부팅 디스크 만들기  (0) 2015.08.21
원격접속과 FTP  (0) 2015.08.16
파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
리다이렉션  (0) 2015.08.16

GDB 사용법

Kail-KM
|2015. 9. 5. 02:37

GDB 사용법


*참조도서: "유닉스 리눅스 프로그래밍 필수 유틸리티"

GDB 사용 방법

<<실행>>
GDB를 이용하기 위해서는 컴파일 과정에서 디버깅 정보를 삽입해야 한다.

    컴파일 시 옵션 'g' 이용
    $ gcc -g -o main main.c

컴파일이 정상 종료 되면 GDB를 실행한다.

    gdb [프로그램명]
    $ gdb main
    gdb [프로그램명] [프로세스PID]
    $ gdb main 1928

GDB가 정상 실행되면 터미널의 프롬프트가 (gdb)로 바뀌게 된다.

<<종료>>
종료방법에는 크게 두가지가 있다.

    ctrl + d
    (gdb) q
    (gdb) quit

<<소스보기>>
옵션에 따라 실행중인 프로그램의 소스를 다양한 방법으로 볼 수 있다.

    l(list)
    list 10
    list [함수명]
    list -  //이전 10라인을 출력한다.
    list [파일명]:[함수명]
    list [파일명]:10

list 명령어를 사용하면 소스코드가 10줄 단위로 출력된다.
다음의 명령을 통해 출력단위를 변경할 수 있다.

    set listsize 20

<<세그멘테이션 폴트가 발생했을대>>
컴파일한 프로그램을 실행했을때 segmentation fault 가 발생하여
비정상 종료되었다면 다음의 명령어를 통해 오류 지점을 확인할 수 있다.

    (gdb) r(run)

run 명령어는 GDB가 프로그램을 실행시켜 이상이 발생했을때의 파일과 지점을 출력해준다.
또한 관련 함수 또는 변수에 담긴 값을 출력하여 오류수정에 많은 도움을 준다.

오류 지점에 도달하기 전 과정을 확인하기 위해서는 다음 명령어를 이용하면 된다.

    (gdb) bt

bt명령어는 백트레이스로 프로그램 스택을 역으로 탐색한다.

<<브레이크포인트>>
브레이크포인트는 다음의 방법들을 통해 설정 가능하다.

    (GDB) b(break) [함수명]
    (GDB) break 10
    (GDB) break [파일명]:[함수명]
    (GDB) break [파일명]:10
    (GDB) break +2  //현재 행에서 2개 행 이후 브레이크포인트 설정
    (GDB) break -2  //현재 행에서 2개 행 이전 브레이크포인트 설정
    (GDB) break *0x8049000  //메모리주소에 설정(어셈블리로 디버깅시 이용)
    (GDB) break 10 if var == 0  //var 변수의 값이 0일때 10번 행에 설정

브레이크포인트의 발동 조건은 다양하게 변경 가능하다.

    (GDB) condition [N] var == 0   //var변수가 0일때 N번 브레이크포인트 동작
    (GDB) condition [N] func(i) > 5

현재 설정된 브레이크포인트의 목록은 다음의 명령으로 확인 가능하다.

    (GDB) info break

브레이크포인트는 GDB가 종료될때까지 유효하다.
따라서 필요없을때는 다음의 방법들을 통해 설정을 지운다.

    (GDB) cl(clear) [함수명]
    (GDB) clear 10
    (GDB) clear [파일명]:[함수명]
    (GDB) clear [파일명]:10
    (GDB) d   //모든 브레이크포인트 지움
    (GDB) disable br  //모든 브레이크포인트 비활성화
    (GDB) disable br 1 3  //1번, 3번 브레이크포인트 비활성화
    (GDB) ensable br  //모든 브레이크포인트 활성화
    (GDB) ensable br 1 3  //1번, 3번 브레이크포인트 활성화

<<프로그램 실행>>
프로그램의 실행은 run 명령어를 이용한다.
만일 이미 실행중일때는 재실행한다.

    (gdb) r(run)

프로그램 실행시 인자를 지정하기 위해서는 다음과 같이 이용한다.

    (gdb) run arg1 arg2

실행중인 프로그램을 종료할 때는 kill 명령어를 이용한다.

    (gdb) k(kill)

현재 실행중인 행의 수행을 멈추기 위해서는 step 명령어를 이용한다.
step 명령어는 한행씩 동작하도록 한다. next 명령어와는 함수 호출시 다른 결과를 보인다.

    (gdb) s(step)
    (gdb) step 6   //step을 6번 수행

현재 행의 실행이 멈춘상태에서 다음 행을 실행하기 위해서는

    (gdb) n(next)
    (gdb) next 6   //next를 6번 수행

만일 step명령을 이용중 루프에 빠져 나오지 못할경우에는 until 명령어를 이용한다.

    (gdb) u(until)

한행씩이 아닌 다시 연달아서 실행하기 위해서는

    (gdb) c(continue)

함수가 매우 길어 끝나는 지점으로 이동하기 위해서는 finish 명령어를 사용한다.

    (gdb) finish

함수의 남은 부부을 수행하지 않고 빠져나오기 위해서는 return 명령어를 사용한다.

    (gdb) return

return 명령어를 사용시 return 값을 임의로 지정하기 위해서는 다음과 같이 이용한다.

    (gdb) return 1234

<<와치포인트 설정>>
와치포인트는 변수값의 변화와 코드의 변화를 확인할때 편리하게 이용가능하다.

    (gdb) watch [변수명]   //변수에 값이 써질 때 브레이크
    (gdb) rwatch [변수명]  //변수의 값이 읽혀질 때 브레이크
    (gdb) awatch [변수명]  //변수에 읽기, 쓰기 경우에 브레이크

<<변수와 레지스터 값 검사>>
현재 위치한 행에서 접근 가능한 지역변수들 목록 확인

    (gdb) info locals

현재 위치한 행에서 접근 가능한 전역변수들 목록 확인

    (gdb) info variables

확인하고싶은 변수의 값을 출력하기 위해서는 print 명령어를 사용한다.

    (gdb) p(print) [변수명]  //변수의 값
    (gdb) print [함수명]   //함수의 주소 값

포인터 변수의 경우 위의 방법으로 하면 주소값만이 출력된다.
포인터 변수의 값 또는 포인터 구조체 등의 값을 보기 위해서는 * 를 붙여준다.

    (gdb) print *[변수명]

이중 포인터라면 ** 를 붙여준다.

GDB는 변수 뿐만 아니라 레지스터의 값도 확인할 수 있다.

    (gdb) print $[레지스터명]

print 명령어는 지역변수를 우선하여 보여주기 때문에
지역변수와 전역변수에서 동일한 이름을 사용할때 전역변수를 확인하기 위해서는 :: 을 이용한다.

    (gdb) print 'main.c'::[변수명]

파일명은 '따옴표' 으로 감싸야한다.

특정 함수에 있는 변수를 확인하기 위해서는

    (gdb) print [함수명]::[변수명]

print 명령어로 변수 또는 레지스터를 확인할 때는 기본적으로 10진수로 출력한다.
이를 다른 형식으로 보고싶을 때는 다음과 같은 방법을 이용한다.

    (gdb) print/t [변수명]    //2진수로
    (gdb) print/o [변수명]    //8진수로
    (gdb) print/d [변수명]    //10진수로 (int)
    (gdb) print/u [변수명]    //부호없는 10진수로 (unsigned int)
    (gdb) print/x [변수명]    //16진수로
    (gdb) print/c [변수명]    //최초 1바이트 값을 문자형으로
    (gdb) print/f [변수명]    //부동소수점값
    (gdb) print/a [변수명]    //가장 가까운 심볼의 오프셋

print 명령어는 값을 보여줄뿐 아니라 값을 설정하는 것도 가능하다.

    (gdb) print [변수명] = [값]

<<화면에 변수의 값을 자동으로 디스플레이하기>>
display 명령어를 이용하면 매 단계가 진행될때마다 자동으로 변수의 값을 출력해준다.

    (gdb) display [변수명]

display 변수를 해제하기 위해서는 undisplay 명령어를 이용한다.

    (gdb) undisplay [N]

display 역시 x,c,o 등등을 이용해 다양한 형태로 출력 가능하다.


출처 : http://kwanseob.blogspot.kr/2012/03/gdb.html

'O / S > Linux' 카테고리의 다른 글

Kali Linux Commands Cheat Sheet  (0) 2015.10.09
Kali linux 부팅 디스크 만들기  (0) 2015.08.21
원격접속과 FTP  (0) 2015.08.16
파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
리다이렉션  (0) 2015.08.16


rufus-2.2.exe


이걸로 유일하게 만들어졌다

'O / S > Linux' 카테고리의 다른 글

Kali Linux Commands Cheat Sheet  (0) 2015.10.09
GDB 사용법  (0) 2015.09.05
원격접속과 FTP  (0) 2015.08.16
파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
리다이렉션  (0) 2015.08.16

원격접속과 FTP

Kail-KM
|2015. 8. 16. 13:32

#Telnet & SSH

 1.Telnet

텔넷 사용을 위해서는 텔넷 클라이언트와 텔넷 서버가 필요.

Telnet은 수퍼데몬에 의해 동작하기에 xinetd를 설치해야한다.

sudo apt-get install xinetd

...

sudo apt-get install telnetd

...

텔넷 서버를 동작시키려면 /etc/xinetd.conf 파일을 설정해야함

service telnet


        disable = no

        flags = REUSE

        socket_type = stream

        wait = no

        user = root

        server = /usr/sbin/in.telnetd

        log_on_failure = USERID

~

:wq! 를 추가해야함

그후에 

sudo /etc/init.d/xinetd restart 를 통해 활성화시킨다.

***port 23이 열려 있어야함


telnet>open xxxx

...

 2.SSH (Secure Shell)

텔넷에서 텔넷 클라이언트와 리눅스 사이에 주고받는 데이터가 암호화되지 않기에 이를 보완된것이 바로 SSH이다.

...

ssh 192.168.x.x -l user1


#VNC -- p.624


#파일 송수신

FTP는 TCP/IP 프로토콜중 5계층에 있는 프로토콜로, 다른 운영체제와도 파일을 주고 받을수 있다.

 1.FTP서버 설치,설정

sudo apt-get install vsftpd

...

ps -ef | grep vsftpd  : 작동하는지 확인

 2.FTP 클라이언트 사용

ftp 192.168.0.2

...

사용자 : 

암호 :

...

get 파일명 mget 파일명

put 파일명 mput 파일명

prompt hash

bin bye

open user

cd !cd

pwd !pwd

ls !ls

mkdir dir rmdir

 3.익명 FTP 사용

sudo vi /etc/vsftpd.conf

..

anonymous_enable=YES

...

sudo service vsftpd restart

...

id : anoymous

passwd : E-mail

...

'O / S > Linux' 카테고리의 다른 글

GDB 사용법  (0) 2015.09.05
Kali linux 부팅 디스크 만들기  (0) 2015.08.21
파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
리다이렉션  (0) 2015.08.16
Linux 디렉터리와 파일다루기  (0) 2015.08.16

#파일의 접근 권한

ls -l 을 할경우

-파일의 종류

-접근권한표시

-하드링크개수

-로그인id

-그룹id

-파일크기

-최종수정날짜

-파일명


flie [filename] : 지정한 파일의 종류를 알려준다

groups [username] : 사용자가 속한 그룹을 알려준다.


표기방법

소유자 그룹 기타사용자

   rwx rwx rwx

접근권한 변경

chmod [option] file&directoryname


*기호모드

u:파일소유자

g:소유자가 속한그룹

o:소유자와 그룹이외의 기타사용자

a:전체사용자


+:권한부여

-:권한제거

=:접근권한설정


r:읽기

w:쓰기

x:실행


*숫자모드

0-7 0-7 0-7

r-x : 4 0 1 = 5

rw- : 4 2 0 = 6

rwx : 4 2 1 = 8


rwxrwxrwx = 777

rwxr-xr-x = 755

rw-rw-rw- = 666

r-xr-xr-x = 555


기본접근권한 확인하고 변경하기

umask [option] [mask value] : 기본 접근권한출력하거나 변경한다.

-S : 마스크 값을 문자로 출력한다.

마스크값

:마스크값이 022 일경우 ----w--w- 에게 권한을 부여하지 않겠다는것

즉, 그룹과 기타사용자에게 쓰기 권한을 부여하지않는다. = 755


특수 접근권한

SetUID : 맨앞자리가 4

SetGID : 맨앞자리가 2

Sticky bit : 맨앞이 1

-1.SetUID : SetUID가 설정된 파일을 실행하면 해당 파일이 실행되는 동안에는 파일을 실행한 사용자의 권한이 아니라 파일 소유자의 권한으로 실행할수 있도록한다.

ex)chmod 4755 set.exe

-2.SetGID : 위의 것과 거의 동일. 파일이 실행되는 동안 파일 소유 그룹의 권한을 쇨행 된다.

ex)chmod 2755 set.exe

-3.스티키비트 : 디렉터리에 스티키 비트가 설정되어 있으면 이 디렉터리에는 누구나 파일을 생성 할 수 있다. 파일은 파일을 생성한 계정으로 소유자가 설정되며, 다른 사용자가 생성한 파일은 삭제 할수 없다. 

기타사용자의 실행권한에 't' 로 표시가 된다.

ex)chmod 1755 temp

'O / S > Linux' 카테고리의 다른 글

Kali linux 부팅 디스크 만들기  (0) 2015.08.21
원격접속과 FTP  (0) 2015.08.16
리다이렉션  (0) 2015.08.16
Linux 디렉터리와 파일다루기  (0) 2015.08.16
Shell 기본 사용법  (0) 2015.08.16

리다이렉션

Kail-KM
|2015. 8. 16. 13:30

#입출력 방향바구기


파일 디스크립터

0  stdin 명령어의 표준입력

1  stdout 명령어의 표준출력

2  stderr 명령어의 표준오류

표준 입출력 장치를 파일로 바꾸는 것을 '리다이렉션'이라한다.

-출력 리다이렉션

파일 덮어쓰기 : >

명령 1> 파일이름

명령 > 파일이름

(확인을 할때는 cat을 통해 확인을 한다.)

파일에 내용추가 : >>

명령 >> 파일이름


-오류 리다이렉션

오류메세지를 위의 출력 리다이렉션처럼 > 으로 한다면 리다이렉션이 

되지 않는다.

명령 2> 파일이름

***결과를 무조건 '>'으로 담을수 있는 것이아니라 성공메세지는

1> 을 통하여 실패메세지는 2>를 통하여 리다이렉션 할 수 있다.

  //한번에 리다이렉션하기 ls ./abc>ls.out 2>ls.err

  //오류 메세지 버리기 /dev/null은 버리고 싶은 내용을 담는 장치 파일로 이  파일에 전달된 모든 내용은 시스템에서 사라지고 복구할 수 없다.

  //한파일로 리다이렉션하기 ls ./abc>lsout 2>&1

(표준출력파일은 &1이라고 표현한다.) 

-입력 리다이렉션

< : 표준 입력을 바꾼다.

명령 0<파일이름

명령 < 파일이름

cat 명령이 파일을 읽어서 출력하는 기능은 표준 입력을 자동으로 파일로 리다이렉션 한 것으로 < 를 생략한 것이다.

'O / S > Linux' 카테고리의 다른 글

원격접속과 FTP  (0) 2015.08.16
파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
Linux 디렉터리와 파일다루기  (0) 2015.08.16
Shell 기본 사용법  (0) 2015.08.16
Kali Linux 2.0 Adob Flash Install  (0) 2015.08.14

일반파일

디렉터리

심벌릭 링크

장치 파일


<디렉터리의 용도>

dev : 장치파일이 담긴

home : 사용자 홈디렉터리

media : CD-ROM꽈 USB같은 외부장치를 연결하는 디렉토리

opt : 추가 패키지가 설치되는

root : root계정의 홈디렉터리

sys : 리눅스 커널 관련 파일

usr : 기본실행파일과 라이브러리 파일,헤더파일등 많은 파일이 존재 (Unix System Resourece)

bin : 실행파일(명령)

boot : 부팅에 필요한 커널파일

etc : 리눅스 설정을 위한 각종 파일

lost+found : 파일시스템에 문제가 발생하여 복구할 경우, 문제가 되는 파일이 저장되는 디렉터리

mnt : 파일시스템을 임시로 마운트하는 디렉터리

proc : 프로세스정보등 커널관련정보가 저장되는 디렉터리

run : 실행중인 서비스와 관련된 파일이 저장된다

srv : FTP나 Web등 시스템에서 제공하는 서비스의 데이터가 저장된다.

tmp : 임시 데이터가 저장된다. 재시작 시 모두 삭제된다.

var : 시스템 운영중에 발생하는 데어탄 로그등이 저장되는 디렉터리


명령어

<디렉터리 관련>

pwd : 현재 디렉터리 확인

cd : 디렉터리 이동

ls : 디렉터리 내용보기

          -a

          -d:지정한 디렉토리 ㅈ체정보를 출력

          -i: inode 번호를 출력

          -l

          -A

          -F:파일의 종류를 표시(*:실행파일,/:디렉터리,@:심벌릭 링크)

          -R:하위 디렉터리의 목록까지 출력

mkdir : 디렉터리 생성

          -p: 중간디렉터리가 없을경우 자동으로 생성

          mkdir -p temp/mid/bin 의 경우 mid가 없을경우 자동생성됨

          mkdir tmp1 tmp2 tmp3 은 3개의 디렉터리를 생성

rmdir:디렉터리 삭제

          -p:중간디렉터리 삭제

rm : 디렉터리와 그 내용까지 모두 삭제


<파일출력>

cat : 파일내용을 출력

          -n:행번호를 출력

more:파일내용을 화면단위로 출력

          +행번호 : 출력을 시작할 행번호를 지정

less : 파일내용을 화면단위로 출력

tail : 파일 뒷부분 출력

          

<파일 사용 명령>

cp file1 file2 : 파일1을 파일2로 복사

cp file Directory : 파일1을 디렉터리로 복사

cp -r 디렉터리1 디렉터리2 디렉터리1을 디렉터리2로 복사한다 (목적디렉터리가 없을경우 생성되며 원본디렉터리                                                                                                                     아래있던 내용 또한함꼐복사됨)

          인자가 여러개인경우 : cp teest test1 test2 ./temp  (마지막인자에 디렉터리가 와야함)

mv:파일을 이동한다.

          mv 파일1 파일2 : 파일1의 이름을 파일2로 변경한다.

          mv 파일 디렉터리 : 파일을 디렉터리로 이동한다

rm : 파일삭제

          -r  지정한디렉터리와 그하위의 모든파일을 삭제한다.


ln : 파일의 링크를 생선한다.

          -s:심벌릭 링크 파일을 생성한다.

          ln data1 data1.ln  : 이경우 inode의 번호가 같고 이름만 다른것이다.

          ln -s data1 data1.sln: 이경우 inode가 다르다. 하지만 심벌릭 링크를 열고 수정하면 원본 파일이 수정된다.


touch : 빈 파일을 생성한다.

          - a : 접근시간만 변경한다

          -m : 수정시간만 변경한다.

grep : 지정한 패턴을 포함하는 행을 찾는다

grep [옵션] 패턴 [파일명]

          -l : 대아패턴을 포함하는 파일이름을 출력한다.

          -n:행번호를 출력한다.

          grep root /etc/passwd

          grep -n unix ~/*.txt

          grep -l hello *.c


find 경로 검색 조건 [동작] : 조건에 맞는 파일을 지정한 위치에서 찾는다.

          -name filename : 파일 이름으로 검색

          -type 파일종류 : 파일 종류로 검색한다.

          -user loginID : 지정한 사용자가 오휴나 모든 파일을 검색한다.

          -perm 접근권한 : 지정한 사용권한과 일치하는 파일을 검색한다.

 -동작

          -exec 명령{} \; : 검색된 파일에 명령을 실행한다.

          -ok 명령 {} \; : 사용자으 확인을 받아서 명령을 실행한다.

          -print : 검새된 파일의 절대 경로명을 화면에 출력

          -ls  : 검색결과를 긴 목록형식으로 출력          

                    find ~ -name hello.c

                    find /tmp -user user1 -exec rm {} \;

whereis : 지정된 경로에서 명령의 바이너리 파일이나 매뉴얼 파일의 위치를 찾는다.

which : 명렁어 파일의 위치를 찾아서 그 경로나 에일리어스를 출력

'O / S > Linux' 카테고리의 다른 글

파일의 접근 권한,setuid,gid,스티키비트,chmod  (0) 2015.08.16
리다이렉션  (0) 2015.08.16
Shell 기본 사용법  (0) 2015.08.16
Kali Linux 2.0 Adob Flash Install  (0) 2015.08.14
kali linux 2.0 한글  (0) 2015.08.14

Shell 기본 사용법

Kail-KM
|2015. 8. 16. 13:28

<출력하기>

배시쉘의 출력명령은 echo와 printf이다.


echo : 화면에 한줄의 문자열을 출력한다

        echo [-n] [문자열]

        ex)echo text

printf:자료를 형식화하여 화면에 출력한다.

        printf 형식 [인수]

        %d, \n등 C언어의 printf함수 형식을 지정한다.

  ex)   printf text

        printf "text\n"

        printf "%d\n" 100

~                                           


chsh : 사용자 로그인 셸을 바꾼다.

-s shell : 지정하는 셸로 로그인 셸을바꾼다.

-l : /etc/shells 파일에 저장된 셸을 출력한다.

  ex) chsh -l

chsh -s /bin/sh user1

chsh


현재 바꿀  수 있는 쉘의 종류는 /etc/shells에 저장되어 있다.

cat  /etc/shells >> sh, dash, bash, rbash 가 존재한다.

rbash의 경우 배시쉘의 심벌릭 링크이다.


<로그인쉘과 서브쉘>

사용자는 프롬프트에서 다른쉘을 실행할수 있는데, 이렇게 새로 생성된 쉘을 서브쉘이라 한다.


<출력하기>

배시쉘의 출력명령은 echo와 printf이다.


echo : 화면에 한줄의 문자열을 출력한다

echo [-n] [문자열]

ex)echo text

printf:자료를 형식화하여 화면에 출력한다.

printf 형식 [인수]

%d, \n등 C언어의 printf함수 형식을 지정한다.

  ex) printf text

printf "text\n"

printf "%d\n" 100


<특수문자>

* : *는 임의의 문자열을 나타내는 특수 문자로 주료 여러파일의 이름을 나열할때 파일 이름을 간단히 표현하는 데 사용된다. 명령을 실행할ㄸ ㅐ 파일이름을 적어야하는 자리에 대신 사용할경우 모든파일을 나타낸다.

ls *  : 현재 디렉터리의 모든 파일과 서브 디렉터리를 나열

cp * /tmp : 현재 디렉터리의 모든 파일을 /tmp 아래로 복사한다.

ls -F t* : t,tmp,temp와 같이 t로 시작하는 모든 파일의 이름과 파일종류를  출력한다.

cp *.txt ../ch3 : 확장자가 txt인 모든파일을 ch3디렉터리로 복사한다.

ls -l h*d : 파일명이 h로 시작,d로 끝나는 모든 파일의 상세정보를출력


?와 [ : 모두 하나의 문자를 나타내는데 사용된다.

?는 길이가 1인 임의의 한문잘ㄹ, []는 괄호안에 포함된 문자중 하나를 나타낸다.

ls t*.txt. : t 다음에 임의의 한문자가 오고 파일의 확장자가 txt인 모든 ㅍ일의 이름을 출력한다.

ls -l tmp[135].txt : tmp다음에 1,3,5중한글자가 오는txt파일 출력

ls [0-9]* : 파일명이 숫자로 시작하는 모든파일목록을 출력

ls [A-Za-z]*[0-9] : 파일명이 영문으로 시작하고 숫자로끝나는모든파일출력

~와 -  : 디렉터리를 나나내느 특수문자

~만 사용하면 현재 작업중인 사용자의 홈디렉터리를 나타내고, 다른 사용자의 로그인 ID와 함께 사용하면 해당 사용자의 홈 디렉터리를 나타낸다.

-는 cd 명령으로 디렉터리를 이전하기 직전의 작업디렉터리를 나타낸다.

cp *.txt ~/ch3 : 확장자가txt인 파일을 현재작업중인 사용자홈ㄷ렉터리 아래 tmp 디렉터리로 복사한다.

cp ~user2/linux.txt . : 현재디렉터리로 user2의홈디렉터리에서linux.txt를 찾아 복사 한다.

cd - : 이전 작업 디렉터리로 이동한다.


;과 | : 명령과 명령을 연결한다.

; : 연결된 명령을 왼쪽부터 차례로 실행하고,

|는 왼족명령의 실행결과를 오른쪽 명령의 입력으로 전달한다.

date;ls;pwd : 왼쪽부터 차례로 수행

ls -al / | more : 모든파일의 상세정보를 한 화면씩 출력한다. ls의 결과가 more 명령의 입력으로 전달되어 페이지 단위로 출력되는 것이다.


''와"" : 문자를 감싸서 문자열로 만들어 주고, 문자열 안에 사용된 특수 문자의 기능을 없앤다. 

'' : 모든 특수문자를

"" : $,``,\을 제외한 모든 특수문자를 일반 문자로 간주하여 처리

echo '$SHELL' : $SHELL 문자열이 출력됨

echo "$SHELL" : 셸 환경 변수인 shell에 저장된 값인 현재 셸의 종류가 출력


`` : ~의 no shift 형태 , 쉘은 ``로 감싸인 문자열을 명령으로 해석하여 명령의 실행 결과로 바뀌게 한다.

echo "Today is `date`":`date`는 명령어로 해석되어 출력된다.

ls /platform/'uname -m`: uname -m 명령의 실행결과를 문자열로 바꿔 디렉터리 이름으로 사용한다.


\ : 특수문자 앞에 쓰이며, 해당 특수 문자의 효과를 업새고 일반 문자처럼 처리.

ls - t\* : t*이라는 이름을 가진 파일의 정보를 출력한다. 만약 \가 없을 경우 t로 시작하는 모든 파일의 상세정보를 출력

echo \$SHELL : $SHELL을 출력한다. 

>,<,>> : 입출력의 방향을 바꾸는 특수문자

'O / S > Linux' 카테고리의 다른 글

리다이렉션  (0) 2015.08.16
Linux 디렉터리와 파일다루기  (0) 2015.08.16
Kali Linux 2.0 Adob Flash Install  (0) 2015.08.14
kali linux 2.0 한글  (0) 2015.08.14
Ubuntu Alt_R 한글 변환 설정  (0) 2015.07.09