02.Linux Basic

By Yan Li

PhD in Bioinformatics, University of Liverpool

Why Linux

  • Linux is the most popular OS in the world
    • ~70% of top 10 million Alexa domains are powered by Linux (according to W3Techs)
    • from Raspberry pi to Supercomputer

Why Linux

  • Most bioinformatic softwares are on Linux
  • CLI (command-line interface) is more effecient than GUI (graphical user interface)
    • A web-based platform for non-bioinformaticians: Galaxy

Basic Linux Commands

Folder Operation

pwdPrint the full path of your current directory
lsList the files in your directory
ls –lList the files in your directory but with “longer” information
cdChange directory (cd subdirectory)
mkdir dirNameMake a directory

Basic Linux Commands

File Operations

cp filename1 filename2create a copy of a file called filename1 and call the copy filename2
cp filename directoryNamecopy the file filename into a directory called directoryName
mv file1 dirNameMove a file called file into a directory called dirName
mv file1 file2Rename file1 and call it file2
rm filenameDelete a file
rm –rf dirNameDelete a directory and all its contents

Basic Linux Commands

File read & write

catType a file to the screen (see also more and less)
headPrint the first 10 lines of a file
tailPrint the last 10 lines of a file
lessType a file to the screen one page at a time (press q to quit, spacebar for next page, b to go back a page)
touch filenameCreate an empty file
nanoA basic text editor
grepSearch for the occurrence of a pattern

Basic Linux Commands

Manage processes

topList the processes running that are using the most CPU
ps –uList your current processes
kill pidKill a process that is running where pid is the process id number
Ctrl-cStop a process
historyList previous commands you have entered
clearclear the terminal screen

Useful symbols

~Your home directorycd ~
.current directoryls .
..parent directorycd ..
*stand for "any character"ls *.txt
>Write the output of a command to a filels *.txt > output.txt
>>Append the output of a command to a fileecho "New line" >> output.txt
|Use the output of a command as input of the next commandhistory | grep "ls"


  • 在你的Home文件夹新建一个text文件,用你的用户名命名,如"username.txt"
  • 在新文件的第一行写上你的名字,
  • 把你的home文件夹地址输入到第二行
  • 把这个text文件copy到我的home文件夹