HKOI 2012 TRAINING INTRO TO LINUX waihon CUHKSHB
HKOI 2012 TRAINING INTRO TO LINUX [waihon @ /CUHK/SHB 123]$ date Sat Feb 18 13: 00 HKT 2012
If you are now in Windows now, Please reboot into Linux =)
TODAY CONTENT • Part 1 – Hello Linux World • Part 2 – Shell & Command • Part 3 – Using Linux
PART 1 – HELLO WORLD
LINUX FILE SYSTEM HIERARCHY “Where is my C: Program Files and D: ? ” • • • /bin : system. exe (C: WindowsSystem 32) /boot : kernal image for booting /dev : devices file /etc : configuration files /home : home directory for users (C: Users) /usr: user program (“Program Files”) /lib, lib 64: library (“. dll” in Windows) /sbin : admin. exe (eg. ifconfig) /var: log files
LINUX FILE SYSTEM HIERARCHY “Where is my D: ? ? ? ” • Depend on how you “mount” your partition… • You can find the devices at • /dev/sdx : if your computer can find the device • You can access the partition from • /media • /home : if the partition is a removable drive : if you mount your partition as /home
PART 2 – SHELL & COMMAND
SELF-LEARNING COMMANDS man – reference manuals man cmd : read the manual page of cmd
SELF-LEARNING COMMANDS whatis , whereis whatis cmd whereis cmd : display the man page descriptions of cmd : locate the cmd
BASIC COMMANDS ls - list directory content ls -a ls -l : list all file : long list format
BASIC COMMANDS cd – change directory cd cd ~ cd / cd dir_name cd cd. . : go to the my home directory : go to the root directory : Enter dir_name : Enter the previous directory : Enter the parent directory
BASIC COMMANDS cp – copy files and directories cp file. A file. B : copy file. A to file. B cp –r dir. A dir. B : copy dir. A to dir. B recursively cp *. txt dir. A/ : copy all. txt file to dir. A
BASIC COMMANDS rm – remove files or directories rm file. A rm –r dir. A rm *. out rm * : remove file. A : remove dir. A recursively (rmdir) : remove all. out files rm /* rm ~/*
BASIC COMMANDS mkdir – make directories mkdir dir. A : make directory dir. A mkdir –p dir. A/dir. B: make directory dir. A/dir. B even if the parent directory “dir. A” is not exist
BASIC COMMANDS rmdir – remove empty directory mkdir dir. A : make directory dir. A mkdir –p dir. A/dir. B: make directory dir. A/dir. B even if the parent directory “dir. A” is not exist
BASIC COMMANDS cat – concatenate files and print cat file. A file. B : print file. A file. B
BASIC COMMANDS ps – list of current processes ps -e : Get ALL processes ps –U user : Get the user’s processes
BASIC COMMANDS kill – send a signal to a process kill -9 12345 : send a KILL signal to process 12345
BASIC COMMANDS killall – kill all process by name killall a. out : kill all process with name a. out
MORE BASIC COMMANDS man and try them more less date uptime top find seq file head tail …… : view file (better than more) : show the system time : tell how long the system has been running : display Linux task : find file : print sequence of number : determine the file type : output the first part of the file : output the last part of the file
USEFUL COMMANDS IN OI bc – arbitrary PRECISION calculator scale = x : set the number of digits after the decimal point in the expression
USEFUL COMMANDS IN OI bc – arbitrary PRECISION calculator
USEFUL COMMANDS IN OI factor – factorize numbers factor integer in [ 0 , 264 )
USEFUL COMMANDS IN OI time – run programs and summarize system resource usage
USEFUL COMMANDS IN OI diff – compare files line by line diff file. A file. B diff –i file. A file. B : compare file. A and file. B : ignore case
USEFUL COMMANDS IN OI grep – print matching pattern ps -e | grep “firefox” : find the pattern “firefox” from the output of “ps –e” cat output. txt | grep “debug” : find if the output. txt contain pattern “debug”
USEFUL COMMANDS IN OI sort – sort lines of text files sort -r : reverse the result -n : numeric sort
TEXT EDITOR vim
TEXT EDITOR vim - basic • [Esc] • i • : • • • -> [normal mode] move cursor only -> [insert mode] eg. editing ok -> [command line mode] eg. save file Example: : w -> save file : wq -> save file and quit vim : q -> quit vim (fail if the file is edited) : q! -> quit vim without saving : wq!-> save file and quit vim!
TEXT EDITOR vim - basic • /ptn -> search for the pattern “ptn” • : 123 -> go to line 123 • dd • yy • p -> cut the line -> copy the line -> paste • u • Ctrl+r -> undo -> redo
TEXT EDITOR vim – cheat sheet
TEXT EDITOR vim –. vimrc • Locate at the home directory (~/. vimrc) • Storing the personal setting of vim • Sample :
TEXT EDITOR gedit
TEXT EDITOR gedit - feature • • nu showmatch ts=4 ……
COMPILER gcc/g++ • g++ source. cpp [–o output] [-O 2] …
COMPILER gcc/g++ - make • Use make to avoid overwriting the source code.
COMPILER fpc – Free Pascal Compiler • fpc source. pas –o output • . /output (Sorry, I have not installed pascal on my Linux)
PART 3 – USING LINUX
CHOOSING DISTRIBUTION • Distro Watch : http: //distrowatch. com/
CHOOSING DISTRIBUTION Linux Mint • Beginners • Desktop • Live Medium
CHOOSING DISTRIBUTION Ubuntu • • • Beginners Desktop Server Live Medium Netbooks
CHOOSING DISTRIBUTION fedora • Desktop • Server • Live Medium
CHOOSING DISTRIBUTION fedora • Desktop • Server
3 WAYS OF INSTALLING LINUX • 1) Format the partition and install • 2) Virtualize • 1) Virtual. Box • 2) VMware • 3) Wubi – install Linux as a software in Windows
RECOMMENDATION • Command. Line. Fu - http: //www. commandlinefu. com/ • Interesting Command
- Slides: 45