SlideShare a Scribd company logo
1 of 16
Linux: Basic Operations - 1

                        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
man (3) – „$ man ls‟




NEAOSS MC2.0     CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
man (4) – „$ man 3 printf‟




NEAOSS MC2.0       CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
ls
 •   Lists directory contents
 •   Usage : $ ls [options] file-or-directory…
      –   If file-or-directory is missing, current directory is assumes


 •   Options :
      -a : list all, including hidden files and directories (starting with .)
      -l : show details (permission, owner, group, size, dates)
      -R : list files recursively traversing child directories
      -1 : lists one item in one line




NEAOSS MC2.0                     CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
cd (1)
 •   Changes the shell working (current) directory
 •   Usage : $cd directory
      – Directory can be
           • directory-name, /adir/bdir/cdir, ..
      – Linux DO NOT USE „\‟(„‟), BUT USE „/‟ in directory hierarchy
      – „.‟ means current directory, „..‟ means parent directory
      – If no directory is specified, it assumes home directory
      – If directory name starts with „/‟,
           it‟s absolute directory from the root directory
      – If directory does not start with „/‟,
           it‟s relative to current directory
 • Examples
      „$ cd‟ moves current directory to my home (same as „$ cd ~‟
      „$ cd ..‟ move current directory to parent directory
      „$ cd /usr/share/man‟ move current directory to /usr/share/man
      „$ cd ~user‟ moves current directory to user‟s home directory
NEAOSS MC2.0                  CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
cd (2)
 • Some more information on directories
      „$ pwd‟ shows current directory
      „$ mkdir directory‟ makes a new directory
      „$ rmdir directory‟ removes the directory
      „$ pushd directory‟ saves current directory,
         and moves to the specified directory
         „$ dirs‟ shows the pushed directory
      „$ popd‟ returns to the saved directory




NEAOSS MC2.0        CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
cp, mv
 •   Copies files and directories
 •   Usage: $ cp [options] source… destination
      – If destination is existing directory, source is copied into the destination directory
      – If destination file is existing, it‟s overwritten
 •   Options:
      -a : copy as is (preserving all the attributes of the source)
      -b : make a backup of each existing destination file
      -f : if destination file exists and cannot be opened, remove it and retry
      -i : prompt before overwrite
      -l : link (hard) files instead of copying
      -n : do not overwrite (ignoring –i)
      -r : copy directories recursively
      -s : make symbolic links instead of copying
      -u : copy only when source is newer than destination

 •   Usage: $ mv [options] source… destination
      – Rename source to destination or move source to destination directory

NEAOSS MC2.0                CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
rm
 • removes files or directories
 • Usage: $ rm file…
      – Remove files
 • Options
      -f : never prompt
      -i : prompt before every removal
      -r : remove directories and its contents recursively
      -v : verbose mode, (explain what is being done)
 • IMPORTANT NOTICE !!!
      – THERE IS NO “RECYCLING BIN or TRASH CAN” in Linux for UNDELETE
           • Desktop file browser usually support UNDELETE function, but not for „rm‟


 • How to delete a file with name starts with „-‟ ?
      – „$ rm -- -foo‟     or   „$ rm ./-foo‟

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
more
 •   Displays files on screen page by page
 • Usages : $ more [options] file…
 • Options:
      -num : specifies screen size in lines
         (e.g., „$ more -7 file‟)
 • Commands after screen stops:
      ‘h’ : help screen
      [SPACE] or ‘z’ : next num lines
      [ENTER] or ‘1’ : next line
      ‘q’ : exit
      ‘f ‘ : next screen
      ‘b’ : 또는 - ^B : 이전 페이지(back)
      ‘/pattern ‘ : find and go to the position of pattern
      ‘n’ : find next occurrence of the pattern                                vi (text editor)
      ‘=‘ : print current line number                                           commands
      ‘!command ’ : run shell command
      ‘^L’ (Ctrl-L) : refresh screen
      ‘:n’ : next file
      ‘:p’ : previous file
      ‘:f’ : show current file name and line number
NEAOSS MC2.0                      CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
cat
 •   Concatenates files and print on display
 •   Usage : $ cat [options] file…
      – Concatenate files, and print on display (standard output)
      – Used to print, create simple file
 • Options :
           •   -E : display „$‟ at the end of each line
           •   -b : number non-empty lines
           •   -n : number all lines
           •   -T : show TAB as ^I
           •   -v : show non-printing control characters except LF and TAB




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

      „# cat /dev/cdrom > foo.iso‟


 • 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
Let‟s Practice
 •   Open a terminal                                                                      /etc is a directory of
 •   Move to /etc and see what‟s in it, and see /etc/passwd                               System Configuration
      –   $ cd /etc
      –   $ ls or $ ls –l or $ ls –l | more                                               /etc/passwd is
      –   $ more /etc/passwd or $ cat /etc/passwd
                                                                                          A user list of a System
 •   Copy /etc/passwd into my home directory as sample
      –   $ cp /etc/passwd ~/sample
 •   Return to my home directory and Triple it into big-sample, and see
      –   $ cd ~ or just $ cd                                   // move back to my home
      –   $ cat sample sample sample > big-sample // cat sample three times and redirect into big-sample
      –   $ ls –l                                               // see the file size
      –   $ more big-sample                                     // try all commands of more
      –   $ sort big-sample > sorted-sample                     // see what happens in sorted-sample
 •   Make a new directory „data‟ and copy sample and move results the files into it
      –   $ mkdir data                                           //
      –   $ cp sample data
      –   $ mv *-sample data
      –   $ ls –l data
      –   $ ls –l
 •   Remove Everything
      –   $ rm –rfi sample data                                  // see what happening, answer with „n‟ !!
      –   $ rm –rf sample data
      –   $ ls -l
NEAOSS MC2.0                      CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA

More Related Content

What's hot

linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014Peter Martin
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Ahmed El-Arabawy
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
 
Linux shell env
Linux shell envLinux shell env
Linux shell envRahul Pola
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commandsswtjerin4u
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingGanesh Bhosale
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commandsSagar Kumar
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
Course 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesCourse 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesAhmed El-Arabawy
 
TP2 Big Data HBase
TP2 Big Data HBaseTP2 Big Data HBase
TP2 Big Data HBaseAmal Abid
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpAhmed El-Arabawy
 
Linux system admin useful commands
Linux system admin useful commandsLinux system admin useful commands
Linux system admin useful commandsali98091
 
Bash shell
Bash shellBash shell
Bash shellxylas121
 

What's hot (20)

Unix shell scripting tutorial
Unix shell scripting tutorialUnix shell scripting tutorial
Unix shell scripting tutorial
 
linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014linux-commandline-magic-Joomla-World-Conference-2014
linux-commandline-magic-Joomla-World-Conference-2014
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Linux shell env
Linux shell envLinux shell env
Linux shell env
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scripting
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Course 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesCourse 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment Variables
 
TP2 Big Data HBase
TP2 Big Data HBaseTP2 Big Data HBase
TP2 Big Data HBase
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux system admin useful commands
Linux system admin useful commandsLinux system admin useful commands
Linux system admin useful commands
 
Scripting and the shell in LINUX
Scripting and the shell in LINUXScripting and the shell in LINUX
Scripting and the shell in LINUX
 
Bash shell
Bash shellBash shell
Bash shell
 
Directories description
Directories descriptionDirectories description
Directories description
 
BASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUXBASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUX
 

Viewers also liked

Portfolio Presentation 2
Portfolio Presentation 2Portfolio Presentation 2
Portfolio Presentation 2rutheast
 
Modelo envejecimiento normal
Modelo envejecimiento normalModelo envejecimiento normal
Modelo envejecimiento normalBrain Dynamics
 
Open Source Software Day Talk
Open Source Software Day TalkOpen Source Software Day Talk
Open Source Software Day TalkMinsuk Lee
 
3phase induction motor
3phase induction motor3phase induction motor
3phase induction motorNaveen Sihag
 
PSPD Newletter Spring 2011
PSPD Newletter Spring 2011PSPD Newletter Spring 2011
PSPD Newletter Spring 2011Pratt CMFM
 
岸角客家文化
岸角客家文化岸角客家文化
岸角客家文化Minghua Lin
 
A auga e_o_corpo_humano
A auga e_o_corpo_humanoA auga e_o_corpo_humano
A auga e_o_corpo_humanoLuisa Dacosta
 
it's software!
it's software!it's software!
it's software!Minsuk Lee
 
왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?Minsuk Lee
 
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
 
綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗Minghua Lin
 
これからの司法書士に求められるIT力強化セミナー
これからの司法書士に求められるIT力強化セミナーこれからの司法書士に求められるIT力強化セミナー
これからの司法書士に求められるIT力強化セミナーYukidama
 
Space Foundation Overview
Space Foundation OverviewSpace Foundation Overview
Space Foundation OverviewSpaceFoundation
 
The Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final UseThe Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final Usepaulageorge
 
08.file system
08.file system08.file system
08.file systemMinsuk Lee
 

Viewers also liked (20)

Portfolio Presentation 2
Portfolio Presentation 2Portfolio Presentation 2
Portfolio Presentation 2
 
Modelo envejecimiento normal
Modelo envejecimiento normalModelo envejecimiento normal
Modelo envejecimiento normal
 
Open Source Software Day Talk
Open Source Software Day TalkOpen Source Software Day Talk
Open Source Software Day Talk
 
3phase induction motor
3phase induction motor3phase induction motor
3phase induction motor
 
PSPD Newletter Spring 2011
PSPD Newletter Spring 2011PSPD Newletter Spring 2011
PSPD Newletter Spring 2011
 
岸角客家文化
岸角客家文化岸角客家文化
岸角客家文化
 
A auga e_o_corpo_humano
A auga e_o_corpo_humanoA auga e_o_corpo_humano
A auga e_o_corpo_humano
 
Presentation hasil
Presentation hasilPresentation hasil
Presentation hasil
 
it's software!
it's software!it's software!
it's software!
 
왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?왜 소프트웨어를 배워야할까?
왜 소프트웨어를 배워야할까?
 
Aart1400 seminar
Aart1400 seminarAart1400 seminar
Aart1400 seminar
 
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
 
綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗綠色奇蹟—溪州馬拉巴栗
綠色奇蹟—溪州馬拉巴栗
 
これからの司法書士に求められるIT力強化セミナー
これからの司法書士に求められるIT力強化セミナーこれからの司法書士に求められるIT力強化セミナー
これからの司法書士に求められるIT力強化セミナー
 
Space Foundation Overview
Space Foundation OverviewSpace Foundation Overview
Space Foundation Overview
 
Bluetooth 1
Bluetooth 1Bluetooth 1
Bluetooth 1
 
The Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final UseThe Complete Roadmap Workbook Final Use
The Complete Roadmap Workbook Final Use
 
08.file system
08.file system08.file system
08.file system
 
pengertian filsafat
pengertian filsafatpengertian filsafat
pengertian filsafat
 
Eshopping1
Eshopping1Eshopping1
Eshopping1
 

Similar to 05.linux basic-operations-1

09.using shell
09.using shell09.using shell
09.using shellMinsuk Lee
 
2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptxPriyadarshini648418
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSMohamed Abdallah
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpointbijanshr
 
14_0930_Intro_to_Linux.pdf
14_0930_Intro_to_Linux.pdf14_0930_Intro_to_Linux.pdf
14_0930_Intro_to_Linux.pdfssuser9606e5
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxRajesh Kumar
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.pptKiranMantri
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux Kuldeep Tiwari
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdfharikrishnapolaki
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptxGuhanSenthil2
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystemShay Cohen
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginnersSuKyeong Jang
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 

Similar to 05.linux basic-operations-1 (20)

09.using shell
09.using shell09.using shell
09.using shell
 
2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
14_0930_Intro_to_Linux.pdf
14_0930_Intro_to_Linux.pdf14_0930_Intro_to_Linux.pdf
14_0930_Intro_to_Linux.pdf
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
Linux Fundamentals
Linux FundamentalsLinux Fundamentals
Linux Fundamentals
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
 
redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 

More from 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
 
Data and Sorting Algoritm
Data and Sorting AlgoritmData and Sorting Algoritm
Data and Sorting AlgoritmMinsuk Lee
 
국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍Minsuk Lee
 

More from 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
 
Binary search
Binary searchBinary search
Binary search
 
Open Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code reviewOpen Source 그리고 git과 github, code review
Open Source 그리고 git과 github, code review
 
Data and Sorting Algoritm
Data and Sorting AlgoritmData and Sorting Algoritm
Data and Sorting Algoritm
 
국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍국민대학교 컴퓨터프로그래밍
국민대학교 컴퓨터프로그래밍
 

05.linux basic-operations-1

  • 1. Linux: Basic Operations - 1 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. man (3) – „$ man ls‟ NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 6. man (4) – „$ man 3 printf‟ NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 7. ls • Lists directory contents • Usage : $ ls [options] file-or-directory… – If file-or-directory is missing, current directory is assumes • Options : -a : list all, including hidden files and directories (starting with .) -l : show details (permission, owner, group, size, dates) -R : list files recursively traversing child directories -1 : lists one item in one line NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 8. cd (1) • Changes the shell working (current) directory • Usage : $cd directory – Directory can be • directory-name, /adir/bdir/cdir, .. – Linux DO NOT USE „\‟(„‟), BUT USE „/‟ in directory hierarchy – „.‟ means current directory, „..‟ means parent directory – If no directory is specified, it assumes home directory – If directory name starts with „/‟, it‟s absolute directory from the root directory – If directory does not start with „/‟, it‟s relative to current directory • Examples „$ cd‟ moves current directory to my home (same as „$ cd ~‟ „$ cd ..‟ move current directory to parent directory „$ cd /usr/share/man‟ move current directory to /usr/share/man „$ cd ~user‟ moves current directory to user‟s home directory NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 9. cd (2) • Some more information on directories „$ pwd‟ shows current directory „$ mkdir directory‟ makes a new directory „$ rmdir directory‟ removes the directory „$ pushd directory‟ saves current directory, and moves to the specified directory „$ dirs‟ shows the pushed directory „$ popd‟ returns to the saved directory NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 10. cp, mv • Copies files and directories • Usage: $ cp [options] source… destination – If destination is existing directory, source is copied into the destination directory – If destination file is existing, it‟s overwritten • Options: -a : copy as is (preserving all the attributes of the source) -b : make a backup of each existing destination file -f : if destination file exists and cannot be opened, remove it and retry -i : prompt before overwrite -l : link (hard) files instead of copying -n : do not overwrite (ignoring –i) -r : copy directories recursively -s : make symbolic links instead of copying -u : copy only when source is newer than destination • Usage: $ mv [options] source… destination – Rename source to destination or move source to destination directory NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 11. rm • removes files or directories • Usage: $ rm file… – Remove files • Options -f : never prompt -i : prompt before every removal -r : remove directories and its contents recursively -v : verbose mode, (explain what is being done) • IMPORTANT NOTICE !!! – THERE IS NO “RECYCLING BIN or TRASH CAN” in Linux for UNDELETE • Desktop file browser usually support UNDELETE function, but not for „rm‟ • How to delete a file with name starts with „-‟ ? – „$ rm -- -foo‟ or „$ rm ./-foo‟ NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 12. 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
  • 13. more • Displays files on screen page by page • Usages : $ more [options] file… • Options: -num : specifies screen size in lines (e.g., „$ more -7 file‟) • Commands after screen stops: ‘h’ : help screen [SPACE] or ‘z’ : next num lines [ENTER] or ‘1’ : next line ‘q’ : exit ‘f ‘ : next screen ‘b’ : 또는 - ^B : 이전 페이지(back) ‘/pattern ‘ : find and go to the position of pattern ‘n’ : find next occurrence of the pattern vi (text editor) ‘=‘ : print current line number commands ‘!command ’ : run shell command ‘^L’ (Ctrl-L) : refresh screen ‘:n’ : next file ‘:p’ : previous file ‘:f’ : show current file name and line number NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 14. cat • Concatenates files and print on display • Usage : $ cat [options] file… – Concatenate files, and print on display (standard output) – Used to print, create simple file • Options : • -E : display „$‟ at the end of each line • -b : number non-empty lines • -n : number all lines • -T : show TAB as ^I • -v : show non-printing control characters except LF and TAB NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA
  • 15. 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 „# cat /dev/cdrom > foo.iso‟ • 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
  • 16. Let‟s Practice • Open a terminal /etc is a directory of • Move to /etc and see what‟s in it, and see /etc/passwd System Configuration – $ cd /etc – $ ls or $ ls –l or $ ls –l | more /etc/passwd is – $ more /etc/passwd or $ cat /etc/passwd A user list of a System • Copy /etc/passwd into my home directory as sample – $ cp /etc/passwd ~/sample • Return to my home directory and Triple it into big-sample, and see – $ cd ~ or just $ cd // move back to my home – $ cat sample sample sample > big-sample // cat sample three times and redirect into big-sample – $ ls –l // see the file size – $ more big-sample // try all commands of more – $ sort big-sample > sorted-sample // see what happens in sorted-sample • Make a new directory „data‟ and copy sample and move results the files into it – $ mkdir data // – $ cp sample data – $ mv *-sample data – $ ls –l data – $ ls –l • Remove Everything – $ rm –rfi sample data // see what happening, answer with „n‟ !! – $ rm –rf sample data – $ ls -l NEAOSS MC2.0 CC-BY 2.0 KR, © Korea OSS Promotion Forum, NIPA