SlideShare une entreprise Scribd logo
1  sur  27
Linux: Basic Operations - 2

                        Minsuk Lee
               Hansung University, Seoul, Korea
                   minsuk@hansung.ac.kr



NEAOSS MC2.0       CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Simple Shell usage
 • Invoking Terminal 




 • Type any command and [ENTER]
 • BIG TIPs !!
      –   Use ‘←,↑→↓’, [INS], [DEL],[HOME],[END] keys to edit command line
      –   Try [tab] - It completes filename or shows all available choices
      –   When output stops, try [SPACE], mouse scroll, ‘q’ to continue or to quit
      –   $ exit -- will end the terminal

NEAOSS MC2.0              CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
man (1)
 •   Shows manual page of Linux commands, libraries, utilities
 •   Usage : $ man [options] [section] item
      –   Item can be program, function, file, anything in /usr/share/man/*/
 •   Options :
      –   Sections
            1.   Executable programs or shell commands
            2.   System calls (functions provided by the kernel)
            3.   Library calls (functions within program libraries)
            4.   Special files (usually found in /dev)
            5.   File formats and conventions e.g. /etc/passwd
            6.   Games
            7.   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
            8.   System administration commands (usually only for root)
            9.   Kernel routines [Non standard]


      ‘$ man printf ‘ show man page of shell command printf
      ‘$ man 3 printf ‘ show man page of printf() library
      ‘$ man -a printf ‘ show man page of both of the two


NEAOSS MC2.0                        CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
man (2)
 •   Options :
      -a : display all available manual pages of the item
      -k : list all man page items includes the given item name ($ apropos –r item)
      -f : shows very short descriptions
      -Tps : output as Postscript format (to be converted into pdf)


 • Example
      $ man man
      $ man -Tps 3 printf | ps2pdf - printf.pdf


 • Alternatives
      $ info item : shows detail information, if the item is available in /usr/share/info
      $ command –help : shows help messages (options) of the command


 • PLEASE READ MAN PAGES OF COMMANDS, FUNCTIONS YOU USE !!

NEAOSS MC2.0                CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Name pattern matching
 • Specifying multiple files(directories)
      – Work for ALL commands
           • ‘*’ means any string (multiple, any characters including null)
           • ‘?’ means any single character
           • [a-s] : means any single character between ‘a ’ and ‘s ’
                – E.g., [1-7c-f], [acf2A-Z], …

      –   ‘$ rm * ’ : means everything in current directory
      –   ‘$ rm directory/* ‘ : means everything in directory
      –   ‘$ rm s*s ‘ : means files or directories start and end with ‘s ’
      –   ‘$ rm 6[ab]x* ‘ : means files or directories start with ‘6ax ’ or ‘6bx ’


 • See man page of bash ( $ man bash ) for more
      – Such as ?(patten-list), *(patten-list), +(pattern-list), …


NEAOSS MC2.0                   CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Pipe and redirection
 • Standard Input and Output
      – In Shell, It’s Keyboard input and Screen Output, by default
      – Pipe feeds standard output into other command’s standard input
      – Redirection redirects the standard input/output from/to files

      ‘$ ls –l | more’ : feed the output of ‘ls –l’ to ‘more’
      ‘$ ls –1 | sort –r | more’ : ‘ls -1’ then, ‘sort’ in reverse order, and ‘more’
      ‘$ ls –l > file ’ : redirect the output of ‘ls –l’ to file (overwrite or create)
      ‘$ ls –l >> file ’ : redirect the output of ‘ls –l’ to file (append)
      ‘$ cat a b > c ’ : concatenate file ‘a ‘ and ‘b ‘ into file ‘c ‘
      ‘$ sort < source > destination ’ : ‘sort’ source, into destination


 • Standard Error
      ‘$ command 2> file’ : redirect error message of command to file



NEAOSS MC2.0                  CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
grep
 • Prints lines matching a pattern
 • Usage : $ grep [options] pattern file…
 • Options :
      –   -i : ignore case
      –   -n : print line number
      –   -H : with file name
      –   -r : read all files under directory recursively




NEAOSS MC2.0              CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
find (1)
 •   Searches for files in a directory hierarchy
 •   Usage : $ find [options] [path...] [expression]
 •   Options :
      -H, -L, -P : controls symbolic links (see, $man find)
 •   Expression for [match test] [Action] :
      –   Match test
            -name : ‘$ find / -name thisname’ finds files with thisname, thisname can be pattern (*, ?, …)
            -executable : executable files
            -user : ‘$ find / -name user1’ finds files belonging to user1
            -atime : ‘$ find / -atime n’ finds files accessed within n days
            -ctime , -mtime : files created or modified within n days
            -newer : ‘$ find / -newer file’ finds files modified more recently than file
            -type c : ‘$ find / -type c’ finds files of type c, (c can be ‘d’ : directory, ‘f’ : regular file, ‘l’ : symbolic link, ‘b’,’c’:
                device file)
            -…
      –   Action
            -delete : delete the found files
            -exec command : apply command to the found files
               in command ‘{}’ is used for found file
               command ends with ; ( is escape code)
            -…
NEAOSS MC2.0                          CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
find (2)
 • Example
      – Just find




      – find and grep




NEAOSS MC2.0        CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
ps
 •   Reports a snapshot of the current processes
 •   Usage : ps [options]
 •   Options :
      ax : all process in system, same as ‘–e’
      r : only running process
      nnn : only process id nnn, same as ‘-pid pid_list list’ (e.g., ‘$ ps –pid 107,109’)
      l, s, u, v, x : format long, signal, user-oriented, virtual memory, register format
      m : shows threads after process




NEAOSS MC2.0                    CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
pstree
 • Display a tree of processes
 • Usages : $ pstree [options] [pid_or_user]
      – $ pstree myuser                                             (Terminal related part)
      – $ pstree




NEAOSS MC2.0              CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
top (1)
 • Display Linux tasks
 • Usage : $ top [options] [pid…]




      [Commands to change ]




                                                    See man page !
NEAOSS MC2.0            CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
top (2)
                                                       ‘;’ multiple commands
                                                       ‘>’ redirection

                                                        <type x.c>
                                                        <endless loop code>
                                x.c
                                                       Ctrl-D to end edit
                                                       Compile x.c to loop
                                                       ‘&’ execute background

                                                       execute ./loop

                                                       Ctrl-Z to suspend

                                                       ‘bg’ resume in background


NEAOSS MC2.0   CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
top (3)
 • top with a endless loop task




 • top with two endless loop tasks




NEAOSS MC2.0         CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
kill
 •   Send a signal to a process
 •   Usage : $ kill –signal [pid]
      –   $ kill -9 100 : kills process 100
      –   $ kill -9 -1 : kill all (you can kill)
 •   Signals :
      -9 (KILL) : kill process
      -1 (HUB) : restart
      Others : see man page !




NEAOSS MC2.0                       CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
tar, bzip2, gzip (1)
 •   Compresses files and directories
 •   Usage : $ tar [options] path…
      –   $ tar cvf name.tar directory : Archive (no compress) directory into name.tar
      –   $ tar xvf name.tar : Extract name.tar
 •   Options :
      –   c : create, x : extrace, t : list
      –   v : verbose (lists file names)
      –   j : use bzip2, z : use gzip for compress / uncompress
      –   f filename : specify archive filename
 •   Bzip2 : compress a file into file.bz2
      – ‘$ bzip2 file ’ to compress, ‘$ bzip2 –d file.bz2 ’ to uncompress
 •   gzip : compress a file into file.gz
      – ‘$ gzip file ’ to compress, ‘$ gzip –d file.gz ’ to uncompress


 • Example
      – ‘$ tar cjf file.bz2 files-directories ‘ : tar & compress files-directories into file.bz2
      – ‘$ tar xjvf file.bz2 ‘ : uncompress and untar file.bz2
NEAOSS MC2.0                  CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
tar, bzip2, gzip (2)

                                                             tar & bzip2



                                                           list archive

                                                            Remove temp directory



                                                          un-bzip2 and untar




NEAOSS MC2.0    CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
df, du
 •   df report file system disk space usage
 •   Usage : $ df [options] [file]
 •   Options
      -h : human readable units !




 •   du estimates file space usage
 •   Usage : $ du [options] [file]
 •   Options
      -h : human readable units !
      -s : display only total




NEAOSS MC2.0                  CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
sudo
 • Execute a command as another user (such as super user)
 • Usage : $ sudo [–u username] [command]
      – $ sudo –u other-user /bin/bash : invoke shell with user other-user
      – $ sudo /bin/bash : invoke superuser’s shell
      – $ sudo command : run command in superuser permission

      • Only selected user can get superuser permission
           • (defined in /etc/sudoers)


                                                                             ?
                                                                       $ sudo rm -rf ./*
                                                                              vs.
                                                                       $ sudo rm –rf /*
NEAOSS MC2.0               CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
chown, chmod
 •    Changes owner, permission of files and direct
 •    Usage : $ chown [owner][:group] file…
            $ chmod mode file…
 •    Options
        -R : recursively change
 •    Permission issue
        –    $ chown can be done by superuser
        –    $ chmod needs enough permission



 •    Permission (read,write,execute)

            mRWXRWXRWX
                    user                      others
                                  group


 Type (file, directory, device)



NEAOSS MC2.0                              CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
hostname, uname
      – $ hostname : name of this computer
           • Search domain, name server are defined in /etc/resolv.conf
      – $ uname : Operating System Name as compiled




NEAOSS MC2.0           CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
ifconfig
                                                              Use GUI
   • Configures a network interface
                                                     To configure Network !
   • Usage : $ ifconfig [interface or –a]
          $ ifconfig interface [aftype] options | address ...
        – interface is the name of network device
               •   (e.g., eth0 : Ethernet, lo : loopback)




NEAOSS MC2.0                       CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
ping
 • Send ICMP ECHO_REQUEST to network hosts
 • Usage : $ ping [options] destination
      – destination is ip-address (a.b.c.d) or hostname
 • Options :
      -c count : stop after count
      -i interval : ping interval
      -n : display ip address rather than hostname
      -s packetsize : set packet size




NEAOSS MC2.0                  CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
netstat (1)
 • Prints network connections, routing tables, interface statistics,
   masquerade connections, and multicast memberships
 • Usage : $ netstat [options]
 • Options :
      -r : print routing table
      -i : print interface statistics
      -n : display ip address rather than hostname
      -p : print pid and program name
      -l : print only listening sockets
      -a : print both listening & non listening
      -t, -u : print socket using tcp, udp protocol




NEAOSS MC2.0             CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
netstat (2)




NEAOSS MC2.0   CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Network files
 •    /etc/hosts : stores hostname and ip-address




 • /etc/resolv.conf : ip-address of name server
 • /etc/services : name of network services




NEAOSS MC2.0        CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
Let’s Practice
 •   find & grep
      – Build up directories
      – Try $ find , $ grep, and mix it
 •   Top
      –    Edit ‘x.c’, compile into ‘loop’
      –    $ top
      –    Run ‘loop’ background and $ top,
      –    And once more, see how ‘loop’ processes share the CPU
      –    Try ‘$ pstree’ to find ‘loop’ process
      –    $ kill the ‘loop’ process
 •   Tar, bzip2
      – As in slide
 •   Try $ df, $ du, $ chown, $ chmod, $ sudo
 •   Try $ ping, $ netstat [options], $ ifconfig



NEAOSS MC2.0                CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA

Contenu connexe

En vedette

3phase induction motor
3phase induction motor3phase induction motor
3phase induction motorNaveen Sihag
 
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーン
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーンIT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーン
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーンYukidama
 
Pumping Corn Into Wisconsin: Consideration for Ethanol Legislation
Pumping Corn Into Wisconsin: Consideration for Ethanol LegislationPumping Corn Into Wisconsin: Consideration for Ethanol Legislation
Pumping Corn Into Wisconsin: Consideration for Ethanol LegislationJustin Dohms
 
과학의날-강연-양정중학교
과학의날-강연-양정중학교과학의날-강연-양정중학교
과학의날-강연-양정중학교Minsuk Lee
 
Open Source Software Day Talk
Open Source Software Day TalkOpen Source Software Day Talk
Open Source Software Day TalkMinsuk Lee
 
The Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final UseThe Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final Usepaulageorge
 
Modelo envejecimiento normal
Modelo envejecimiento normalModelo envejecimiento normal
Modelo envejecimiento normalBrain Dynamics
 
綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗Minghua Lin
 
983896 634395133169998750
983896 634395133169998750983896 634395133169998750
983896 634395133169998750KIET
 
it's software!
it's software!it's software!
it's software!Minsuk Lee
 
PSPD Newletter Spring 2011
PSPD Newletter Spring 2011PSPD Newletter Spring 2011
PSPD Newletter Spring 2011Pratt CMFM
 
05.linux basic-operations-1
05.linux basic-operations-105.linux basic-operations-1
05.linux basic-operations-1Minsuk Lee
 
Data and Sorting Algoritm
Data and Sorting AlgoritmData and Sorting Algoritm
Data and Sorting AlgoritmMinsuk Lee
 
Portfolio Presentation 2
Portfolio Presentation 2Portfolio Presentation 2
Portfolio Presentation 2rutheast
 
왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?Minsuk Lee
 

En vedette (20)

3phase induction motor
3phase induction motor3phase induction motor
3phase induction motor
 
pengertian filsafat
pengertian filsafatpengertian filsafat
pengertian filsafat
 
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーン
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーンIT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーン
IT企業専門パソコン肩こり出張マッサージ「ほぐ神」4月末までの渋谷キャンペーン
 
Pumping Corn Into Wisconsin: Consideration for Ethanol Legislation
Pumping Corn Into Wisconsin: Consideration for Ethanol LegislationPumping Corn Into Wisconsin: Consideration for Ethanol Legislation
Pumping Corn Into Wisconsin: Consideration for Ethanol Legislation
 
과학의날-강연-양정중학교
과학의날-강연-양정중학교과학의날-강연-양정중학교
과학의날-강연-양정중학교
 
Open Source Software Day Talk
Open Source Software Day TalkOpen Source Software Day Talk
Open Source Software Day Talk
 
The Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final UseThe Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final Use
 
Modelo envejecimiento normal
Modelo envejecimiento normalModelo envejecimiento normal
Modelo envejecimiento normal
 
Aart1400 seminar
Aart1400 seminarAart1400 seminar
Aart1400 seminar
 
綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗
 
Aart1400 seminar
Aart1400 seminarAart1400 seminar
Aart1400 seminar
 
Pp R L S 2011
Pp  R L S  2011Pp  R L S  2011
Pp R L S 2011
 
983896 634395133169998750
983896 634395133169998750983896 634395133169998750
983896 634395133169998750
 
it's software!
it's software!it's software!
it's software!
 
PSPD Newletter Spring 2011
PSPD Newletter Spring 2011PSPD Newletter Spring 2011
PSPD Newletter Spring 2011
 
Presentation hasil
Presentation hasilPresentation hasil
Presentation hasil
 
05.linux basic-operations-1
05.linux basic-operations-105.linux basic-operations-1
05.linux basic-operations-1
 
Data and Sorting Algoritm
Data and Sorting AlgoritmData and Sorting Algoritm
Data and Sorting Algoritm
 
Portfolio Presentation 2
Portfolio Presentation 2Portfolio Presentation 2
Portfolio Presentation 2
 
왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?
 

Plus de Minsuk Lee

CES 처음 가는 분을 위한 가이드
CES 처음 가는 분을 위한 가이드CES 처음 가는 분을 위한 가이드
CES 처음 가는 분을 위한 가이드Minsuk Lee
 
NIA-PaaS-TA Pub 키노트
NIA-PaaS-TA Pub 키노트NIA-PaaS-TA Pub 키노트
NIA-PaaS-TA Pub 키노트Minsuk Lee
 
모두콘, 어떻게 배울 것인가 발제.
모두콘,  어떻게 배울 것인가 발제.모두콘,  어떻게 배울 것인가 발제.
모두콘, 어떻게 배울 것인가 발제.Minsuk Lee
 
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자Minsuk Lee
 
개발자, 회사.. 왜 오픈소스를 해야할까?
개발자, 회사.. 왜 오픈소스를 해야할까?개발자, 회사.. 왜 오픈소스를 해야할까?
개발자, 회사.. 왜 오픈소스를 해야할까?Minsuk Lee
 
진정한 소프트웨어 융합교육에 대하여
진정한 소프트웨어 융합교육에 대하여 진정한 소프트웨어 융합교육에 대하여
진정한 소프트웨어 융합교육에 대하여 Minsuk Lee
 
FOSS CON Korea 2018
FOSS CON Korea 2018FOSS CON Korea 2018
FOSS CON Korea 2018Minsuk Lee
 
소프트웨어 공부하는법
소프트웨어 공부하는법소프트웨어 공부하는법
소프트웨어 공부하는법Minsuk Lee
 
자기소개서, 이력서 쓰는 법
자기소개서, 이력서 쓰는 법자기소개서, 이력서 쓰는 법
자기소개서, 이력서 쓰는 법Minsuk Lee
 
왜 우리는 개발자에 집중하지 않는가?
왜 우리는 개발자에 집중하지 않는가?왜 우리는 개발자에 집중하지 않는가?
왜 우리는 개발자에 집중하지 않는가?Minsuk Lee
 
Somul 2017-이민석
Somul 2017-이민석Somul 2017-이민석
Somul 2017-이민석Minsuk Lee
 
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌국민대-컴퓨터프로그래밍-2017-1-오프라인강좌
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌Minsuk Lee
 
소프트웨어, 정말 되는 건가?
소프트웨어, 정말 되는 건가?소프트웨어, 정말 되는 건가?
소프트웨어, 정말 되는 건가?Minsuk Lee
 
소프트웨어, 소프트웨어 개발자
소프트웨어, 소프트웨어 개발자소프트웨어, 소프트웨어 개발자
소프트웨어, 소프트웨어 개발자Minsuk Lee
 
프로그램 기초
프로그램 기초프로그램 기초
프로그램 기초Minsuk Lee
 
Software Company, Open Soure Software Company
Software Company, Open Soure Software CompanySoftware Company, Open Soure Software Company
Software Company, Open Soure Software CompanyMinsuk Lee
 
Open Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code reviewOpen Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code reviewMinsuk Lee
 
국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍Minsuk Lee
 
Deview-2014-자신있는개발자에서 훌륭한개발자로
Deview-2014-자신있는개발자에서 훌륭한개발자로Deview-2014-자신있는개발자에서 훌륭한개발자로
Deview-2014-자신있는개발자에서 훌륭한개발자로Minsuk Lee
 
Samsung-OSS-Conference-20140916
Samsung-OSS-Conference-20140916Samsung-OSS-Conference-20140916
Samsung-OSS-Conference-20140916Minsuk Lee
 

Plus de Minsuk Lee (20)

CES 처음 가는 분을 위한 가이드
CES 처음 가는 분을 위한 가이드CES 처음 가는 분을 위한 가이드
CES 처음 가는 분을 위한 가이드
 
NIA-PaaS-TA Pub 키노트
NIA-PaaS-TA Pub 키노트NIA-PaaS-TA Pub 키노트
NIA-PaaS-TA Pub 키노트
 
모두콘, 어떻게 배울 것인가 발제.
모두콘,  어떻게 배울 것인가 발제.모두콘,  어떻게 배울 것인가 발제.
모두콘, 어떻게 배울 것인가 발제.
 
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자
GDG-DevFest, 만들면서 자랑하면서 성장하는 개발자
 
개발자, 회사.. 왜 오픈소스를 해야할까?
개발자, 회사.. 왜 오픈소스를 해야할까?개발자, 회사.. 왜 오픈소스를 해야할까?
개발자, 회사.. 왜 오픈소스를 해야할까?
 
진정한 소프트웨어 융합교육에 대하여
진정한 소프트웨어 융합교육에 대하여 진정한 소프트웨어 융합교육에 대하여
진정한 소프트웨어 융합교육에 대하여
 
FOSS CON Korea 2018
FOSS CON Korea 2018FOSS CON Korea 2018
FOSS CON Korea 2018
 
소프트웨어 공부하는법
소프트웨어 공부하는법소프트웨어 공부하는법
소프트웨어 공부하는법
 
자기소개서, 이력서 쓰는 법
자기소개서, 이력서 쓰는 법자기소개서, 이력서 쓰는 법
자기소개서, 이력서 쓰는 법
 
왜 우리는 개발자에 집중하지 않는가?
왜 우리는 개발자에 집중하지 않는가?왜 우리는 개발자에 집중하지 않는가?
왜 우리는 개발자에 집중하지 않는가?
 
Somul 2017-이민석
Somul 2017-이민석Somul 2017-이민석
Somul 2017-이민석
 
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌국민대-컴퓨터프로그래밍-2017-1-오프라인강좌
국민대-컴퓨터프로그래밍-2017-1-오프라인강좌
 
소프트웨어, 정말 되는 건가?
소프트웨어, 정말 되는 건가?소프트웨어, 정말 되는 건가?
소프트웨어, 정말 되는 건가?
 
소프트웨어, 소프트웨어 개발자
소프트웨어, 소프트웨어 개발자소프트웨어, 소프트웨어 개발자
소프트웨어, 소프트웨어 개발자
 
프로그램 기초
프로그램 기초프로그램 기초
프로그램 기초
 
Software Company, Open Soure Software Company
Software Company, Open Soure Software CompanySoftware Company, Open Soure Software Company
Software Company, Open Soure Software Company
 
Open Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code reviewOpen Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code review
 
국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍
 
Deview-2014-자신있는개발자에서 훌륭한개발자로
Deview-2014-자신있는개발자에서 훌륭한개발자로Deview-2014-자신있는개발자에서 훌륭한개발자로
Deview-2014-자신있는개발자에서 훌륭한개발자로
 
Samsung-OSS-Conference-20140916
Samsung-OSS-Conference-20140916Samsung-OSS-Conference-20140916
Samsung-OSS-Conference-20140916
 

06.linux basic-operations-2

  • 1. Linux: Basic Operations - 2 Minsuk Lee Hansung University, Seoul, Korea minsuk@hansung.ac.kr NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 2. Simple Shell usage • Invoking Terminal  • Type any command and [ENTER] • BIG TIPs !! – Use ‘←,↑→↓’, [INS], [DEL],[HOME],[END] keys to edit command line – Try [tab] - It completes filename or shows all available choices – When output stops, try [SPACE], mouse scroll, ‘q’ to continue or to quit – $ exit -- will end the terminal NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 3. man (1) • Shows manual page of Linux commands, libraries, utilities • Usage : $ man [options] [section] item – Item can be program, function, file, anything in /usr/share/man/*/ • Options : – Sections 1. Executable programs or shell commands 2. System calls (functions provided by the kernel) 3. Library calls (functions within program libraries) 4. Special files (usually found in /dev) 5. File formats and conventions e.g. /etc/passwd 6. Games 7. Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8. System administration commands (usually only for root) 9. Kernel routines [Non standard] ‘$ man printf ‘ show man page of shell command printf ‘$ man 3 printf ‘ show man page of printf() library ‘$ man -a printf ‘ show man page of both of the two NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 4. man (2) • Options : -a : display all available manual pages of the item -k : list all man page items includes the given item name ($ apropos –r item) -f : shows very short descriptions -Tps : output as Postscript format (to be converted into pdf) • Example $ man man $ man -Tps 3 printf | ps2pdf - printf.pdf • Alternatives $ info item : shows detail information, if the item is available in /usr/share/info $ command –help : shows help messages (options) of the command • PLEASE READ MAN PAGES OF COMMANDS, FUNCTIONS YOU USE !! NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 5. Name pattern matching • Specifying multiple files(directories) – Work for ALL commands • ‘*’ means any string (multiple, any characters including null) • ‘?’ means any single character • [a-s] : means any single character between ‘a ’ and ‘s ’ – E.g., [1-7c-f], [acf2A-Z], … – ‘$ rm * ’ : means everything in current directory – ‘$ rm directory/* ‘ : means everything in directory – ‘$ rm s*s ‘ : means files or directories start and end with ‘s ’ – ‘$ rm 6[ab]x* ‘ : means files or directories start with ‘6ax ’ or ‘6bx ’ • See man page of bash ( $ man bash ) for more – Such as ?(patten-list), *(patten-list), +(pattern-list), … NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 6. Pipe and redirection • Standard Input and Output – In Shell, It’s Keyboard input and Screen Output, by default – Pipe feeds standard output into other command’s standard input – Redirection redirects the standard input/output from/to files ‘$ ls –l | more’ : feed the output of ‘ls –l’ to ‘more’ ‘$ ls –1 | sort –r | more’ : ‘ls -1’ then, ‘sort’ in reverse order, and ‘more’ ‘$ ls –l > file ’ : redirect the output of ‘ls –l’ to file (overwrite or create) ‘$ ls –l >> file ’ : redirect the output of ‘ls –l’ to file (append) ‘$ cat a b > c ’ : concatenate file ‘a ‘ and ‘b ‘ into file ‘c ‘ ‘$ sort < source > destination ’ : ‘sort’ source, into destination • Standard Error ‘$ command 2> file’ : redirect error message of command to file NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 7. grep • Prints lines matching a pattern • Usage : $ grep [options] pattern file… • Options : – -i : ignore case – -n : print line number – -H : with file name – -r : read all files under directory recursively NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 8. find (1) • Searches for files in a directory hierarchy • Usage : $ find [options] [path...] [expression] • Options : -H, -L, -P : controls symbolic links (see, $man find) • Expression for [match test] [Action] : – Match test -name : ‘$ find / -name thisname’ finds files with thisname, thisname can be pattern (*, ?, …) -executable : executable files -user : ‘$ find / -name user1’ finds files belonging to user1 -atime : ‘$ find / -atime n’ finds files accessed within n days -ctime , -mtime : files created or modified within n days -newer : ‘$ find / -newer file’ finds files modified more recently than file -type c : ‘$ find / -type c’ finds files of type c, (c can be ‘d’ : directory, ‘f’ : regular file, ‘l’ : symbolic link, ‘b’,’c’: device file) -… – Action -delete : delete the found files -exec command : apply command to the found files in command ‘{}’ is used for found file command ends with ; ( is escape code) -… NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 9. find (2) • Example – Just find – find and grep NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 10. ps • Reports a snapshot of the current processes • Usage : ps [options] • Options : ax : all process in system, same as ‘–e’ r : only running process nnn : only process id nnn, same as ‘-pid pid_list list’ (e.g., ‘$ ps –pid 107,109’) l, s, u, v, x : format long, signal, user-oriented, virtual memory, register format m : shows threads after process NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 11. pstree • Display a tree of processes • Usages : $ pstree [options] [pid_or_user] – $ pstree myuser (Terminal related part) – $ pstree NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 12. top (1) • Display Linux tasks • Usage : $ top [options] [pid…] [Commands to change ] See man page ! NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 13. top (2) ‘;’ multiple commands ‘>’ redirection <type x.c> <endless loop code> x.c Ctrl-D to end edit Compile x.c to loop ‘&’ execute background execute ./loop Ctrl-Z to suspend ‘bg’ resume in background NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 14. top (3) • top with a endless loop task • top with two endless loop tasks NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 15. kill • Send a signal to a process • Usage : $ kill –signal [pid] – $ kill -9 100 : kills process 100 – $ kill -9 -1 : kill all (you can kill) • Signals : -9 (KILL) : kill process -1 (HUB) : restart Others : see man page ! NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 16. tar, bzip2, gzip (1) • Compresses files and directories • Usage : $ tar [options] path… – $ tar cvf name.tar directory : Archive (no compress) directory into name.tar – $ tar xvf name.tar : Extract name.tar • Options : – c : create, x : extrace, t : list – v : verbose (lists file names) – j : use bzip2, z : use gzip for compress / uncompress – f filename : specify archive filename • Bzip2 : compress a file into file.bz2 – ‘$ bzip2 file ’ to compress, ‘$ bzip2 –d file.bz2 ’ to uncompress • gzip : compress a file into file.gz – ‘$ gzip file ’ to compress, ‘$ gzip –d file.gz ’ to uncompress • Example – ‘$ tar cjf file.bz2 files-directories ‘ : tar & compress files-directories into file.bz2 – ‘$ tar xjvf file.bz2 ‘ : uncompress and untar file.bz2 NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 17. tar, bzip2, gzip (2) tar & bzip2 list archive Remove temp directory un-bzip2 and untar NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 18. df, du • df report file system disk space usage • Usage : $ df [options] [file] • Options -h : human readable units ! • du estimates file space usage • Usage : $ du [options] [file] • Options -h : human readable units ! -s : display only total NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 19. sudo • Execute a command as another user (such as super user) • Usage : $ sudo [–u username] [command] – $ sudo –u other-user /bin/bash : invoke shell with user other-user – $ sudo /bin/bash : invoke superuser’s shell – $ sudo command : run command in superuser permission • Only selected user can get superuser permission • (defined in /etc/sudoers) ? $ sudo rm -rf ./* vs. $ sudo rm –rf /* NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 20. chown, chmod • Changes owner, permission of files and direct • Usage : $ chown [owner][:group] file… $ chmod mode file… • Options -R : recursively change • Permission issue – $ chown can be done by superuser – $ chmod needs enough permission • Permission (read,write,execute) mRWXRWXRWX user others group Type (file, directory, device) NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 21. hostname, uname – $ hostname : name of this computer • Search domain, name server are defined in /etc/resolv.conf – $ uname : Operating System Name as compiled NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 22. ifconfig Use GUI • Configures a network interface To configure Network ! • Usage : $ ifconfig [interface or –a] $ ifconfig interface [aftype] options | address ... – interface is the name of network device • (e.g., eth0 : Ethernet, lo : loopback) NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 23. ping • Send ICMP ECHO_REQUEST to network hosts • Usage : $ ping [options] destination – destination is ip-address (a.b.c.d) or hostname • Options : -c count : stop after count -i interval : ping interval -n : display ip address rather than hostname -s packetsize : set packet size NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 24. netstat (1) • Prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships • Usage : $ netstat [options] • Options : -r : print routing table -i : print interface statistics -n : display ip address rather than hostname -p : print pid and program name -l : print only listening sockets -a : print both listening & non listening -t, -u : print socket using tcp, udp protocol NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 25. netstat (2) NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 26. Network files • /etc/hosts : stores hostname and ip-address • /etc/resolv.conf : ip-address of name server • /etc/services : name of network services NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 27. Let’s Practice • find & grep – Build up directories – Try $ find , $ grep, and mix it • Top – Edit ‘x.c’, compile into ‘loop’ – $ top – Run ‘loop’ background and $ top, – And once more, see how ‘loop’ processes share the CPU – Try ‘$ pstree’ to find ‘loop’ process – $ kill the ‘loop’ process • Tar, bzip2 – As in slide • Try $ df, $ du, $ chown, $ chmod, $ sudo • Try $ ping, $ netstat [options], $ ifconfig NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA