医学pptlinux常用commod.ppt
Start To Play,Open Your VM(Of Cause!),First Step is?,Then,Wait,if we already have a server,You can use different toolsPuttyVNC,Putty,Normally,we can use this tool,VNC,How about we already have the desktop,can we use that?,Example:VNC Viewer,Easy way,Example:VNC Sever Configuration,But,before we can use this tool,we need to configure our server.,Installyuminstalltigervnc-serverStart and set password:vncserver:1 Configure:vim/etc/sysconfig/vncserversAdd a line VNCSERVERS=1:root“Restart the VNC serverservice vncserver restartIf we want the SVN server starts automaticallychkconfig vncserver on,Play With Linux,cd,ls Were already mentioned,Navigate,Normally,we have to use command line,I dont want to re-type the same word,Try to use history:history!lineNumCtrl+R,What if my command typing is wrong?,Command line editingIn this case,you need command line editingMovingCtrl-a Move cursor to the beginning of the line.Ctrl-e Move cursor to the end of the line.Ctrl-f Move cursor forward one character;same as the right arrow key.Ctrl-b Move cursor backward one character;same as the left arrow key.Alt-f Move cursor forward one word.Alt-b Move cursor backward one word.Ctrl-l Clear the screen and move the cursor to the top left corner.The clear command does the same thing.,Command line editingEditingCtrl-d Delete the character at the cursor locationCtrl-t Transpose(exchange)the character at the cursor location with the one preceding it.Alt-t Transpose the word at the cursor location with the one preceding it.Alt-l Convert the characters from the cursor location to the end of the word to lowercase.Alt-u Convert the characters from the cursor location to the end of the word to uppercase.,What if my command typing is wrong(Con.)?,Command line editingCut And PasteCtrl-k Kill text from the cursor location to the end of line.Ctrl-u Kill text from the cursor location to the beginning of the line.Alt-d Kill text from the cursor location to the end of the current word.Alt-Backspace Kill text from the cursor location to the beginning of the word.If the cursor is at the beginning of a word,kill the previous word.Ctrl-y Paste the text at the cursor location.,What if my command typing is wrong(Con.)?,Command:ls,cd sh startStore.sh,./startStore.sh,Execute command/script,Normally,it is the easiest part,But,some exceptions are also exist,Exceptions You May Meet,Env variables issueSet the required environment variablesFormat issuedos2unixCommand not foundInstall the required softwaresAccess rightsu,sudo,chown,chgrp,chmod,How To Install The Required Softwares(1),Almost all software for a Linux system can be found on the Internet.How will them be provided:Most of them are package filesRest of them are source code,How To Install The Required Softwares(2),Most distributions belong to one of two camps of packaging technologiesThe Debian“.deb”campDebian,Ubuntu,Xandros,LinspireThe Red Hat“.rpm”campFedora,CentOS,Red Hat Enterprise Linux,OpenSUSE,Mandriva,PCLinuxOS,How To Manage The Required Softwares On Debian,Through repository:apt-get install package_nameapt-get remove package_nameThrough package:dpkg-install package_fileapt-get remove package_name,How To Manage The Required Softwares On Red Hat,Through repository:yum install package_nameyum erase package_nameThrough package:rpm-i package_fileyum erase package_name,How To Install The Required Softwares From Source Code,Dowload:wgetftpUnpackedtar xzf diction-1.11.tar.gzBuild./configmake install,Got Errors?,Check log:VI,cat,lessPipeSearch,Now,I can execute the scripts,but I got errors after I execute them,VI Introduction,Start-vi filenameQuit-:q!/wqCommand mode VS Input modeInitially,Command modeFrom Command mode to Input mode-Type“i”From Input mode to Command mode Type“Esc”,Move Cursor In VI,numberGTo line number.For example,1G moves to the first line of the file.GTo the last line of the file.Ctrl-f or Page Down Down one page.Ctrl-b or Page Up Up one page.0(zero)To the beginning of the current line$To the end of the current line.,Basic Editing In VI,aEnter Input mode and move cursor beyond the current location of cursor.A Enter Input mode and move cursor beyond the end of the line.oEnter Input mode and open a line below the current line.OEnter Input mode and pen a line above the current line.,Deleting In VI,ddDelete the current line.5dd The current line and the next 4 lines.dG From the current line to the end of the file.d$From the cursor position to the end of the current line.d0 From the cursor position to the beginning of the current line.uUndo,Cutting,Copying And Pasting In VI,dThe d command will be used as both delete and cut.p/PTo copy the text after/before the cursor.yyCopy the current line.5yyCopy the current line and the next 4 lines.ySCopy from the current cursor to the end of line.y0Copy from the current cursor to the begin of the line.yG Copy from the current cursor to the end of the file.JContact the lines below to the current line.,Finding And Replacing In VI,fFind character in one line.Type semicolon to repeat./Find in the whole file.Type“n”to repeat.:%s/Line/line/gReplace.%is a shortcut meaning from the first line to the last line.Alternately,the range could have been specified 1,5.s Specifies the operation.In this case,substitution(search and replace)g means“global”,if omitted,only the first instance of the search string on each line is replaced,Common Search Methods,locateIt look up path in database.updatedb To update the database for locate.find Find files base on different conditions.,I/O Redirect,The result of commands:stdoutStatus and error messages:stderrThe default output is connect to screenThe inputs are from the standard input:stdinThe default input is connect to the keyboardI/O Redirect allows us to change the direction of outputs and inputs,STDOUT Redirect,Operator“”Examplesls-l/usr/bin ls-output.txt test.txt Empty the file or create a new file.echo“sh startStorefront.sh”startStore.sh3.Operator“”Append content instead of empty the content.,STDERR Redirect,A program can produce output on any of several numbered file streams.We have referred to the first three of these file streams as standard input,output and error,the shell references them internally as file descriptors zero,one and two,respectively.Examplels-l/bin/usr 2 ls-error.txtRedirect the second file stream which refers to the stderror to the file.,Get Together,ls-l/bin/usr ls-output.txt 2&1There are two redirect:Redirect output to ls-output.txtRedirect STDERR to STDOUTNewer way for this task:ls-l/bin/usr&ls-output.txtRedirect STDERR and STDOUT to the ls-output.txt through“&”,If we can output both STDOUT and STDERR into the same file,Exception,ls-l/bin/usr 2/dev/null/dev/nullThis file is a system device called a bit bucket which accepts input and does nothing with it.,If we write a script,and the there are too many log which we want to ignore,STDIN Redirect,catcat movie.mpeg.0*movie.mpegConcact filescat lazy_dog.txtCreate new file through the STDIN“”cat lazy_dog.txtRead content from file and output to screen,Pipelines,Operator“|”The standard output of one command can be piped into the standard input of another.ls-l/usr/bin|lessls/bin/usr/bin|sort|less,Eventually,The Reason Is,There is a process already running!ps ef|grep javatail f storefront.logkill-9 1234The disk is fulldf Hdu-sh*|sort-nr|headdu-sh*|sort-nr|less,Dont Play So Hard,Some times,you can use cron to help you to do the scheduled job.vi/etc/crontab00 18*root/usr/sbin/bakmysql sudo/etc/init.d/cron restart Dont type so much,use tab to auto complete the command.Make the long commands to short ones with alias.alias startStore=cd/home/atg-student&./startStore.shMake the long file paths to short paths through ln.ln-s/workspace/proj-src/server-scripts/startStore.bat/scripts/startStore.bat,Dont Play So Hard,Hey,let Linux to help you to do something!,http:/billie66.github.io/TLCL/index.html,References,