HKOI 2012 TRAINING INTRO TO LINUX /CUHK/SHB123]$ date Sat Feb 18 13:00: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:\Windows\System32) /boot: kernal image for booting /dev: devices file /etc: configuration files /home: home directory for users (C:\Users) /usr: user program (“Program Files”) /lib,lib64: 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: if the partition is a removable drive /home : 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: display the man page descriptions of cmd whereis cmd: locate the cmd
BASIC COMMANDS ls - list directory content ls -a: list all file ls -l: long list format
BASIC COMMANDS cd – change directory cd: go to the my home directory cd ~: go to the my home directory cd /: go to the root directory cd dir_name: Enter dir_name cd -: Enter the previous directory cd..: Enter the parent directory
BASIC COMMANDS cp – copy files and directories cp fileA fileB: copy fileA to fileB cp –r dirA dirB: copy dirA to dirB recursively cp *.txt dirA/: copy all.txt file to dirA
BASIC COMMANDS rm – remove files or directories rm fileA: remove fileA rm –r dirA: remove dirA recursively (rmdir) rm *.out: remove all.out files
BASIC COMMANDS mkdir – make directories mkdir dirA: make directory dirA mkdir –p dirA/dirB: make directory dirA/dirB even if the parent directory “dirA” is not exist
BASIC COMMANDS rmdir – remove empty directory mkdir dirA: make directory dirA mkdir –p dirA/dirB: make directory dirA/dirB even if the parent directory “dirA” is not exist
BASIC COMMANDS cat – concatenate files and print cat fileA: print fileA cat fileA fileB: print fileA fileB
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 : 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: view file less: view file (better than more) date: show the system time uptime: tell how long the system has been running top: display Linux task find: find file seq: print sequence of number file: determine the file type head: output the first part of the file tail: 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, 2 64 )
USEFUL COMMANDS IN OI time – run programs and summarize system resource usage
USEFUL COMMANDS IN OI diff – compare files line by line diff fileA fileB: compare fileA and fileB diff –i fileA fileB: 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]-> [normal mode] move cursor only i-> [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-> cut the line yy-> copy the line p-> paste u-> undo Ctrl+r-> 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] [-O2] …
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 :
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) VirtualBox 2) VMware 3) Wubi – install Linux as a software in Windows
RECOMMENDATION CommandLineFu - Interesting Command