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
Command | Annotation |
---|---|
pwd | Print the full path of your current directory |
ls | List the files in your directory |
ls –l | List the files in your directory but with “longer” information |
cd | Change directory (cd subdirectory) |
mkdir dirName | Make a directory |
Basic Linux Commands
File Operations
Command | Annotation |
---|---|
cp filename1 filename2 | create a copy of a file called filename1 and call the copy filename2 |
cp filename directoryName | copy the file filename into a directory called directoryName |
mv file1 dirName | Move a file called file into a directory called dirName |
mv file1 file2 | Rename file1 and call it file2 |
rm filename | Delete a file |
rm –rf dirName | Delete a directory and all its contents |
Basic Linux Commands
File read & write
Command | Annotation |
---|---|
cat | Type a file to the screen (see also more and less) |
head | Print the first 10 lines of a file |
tail | Print the last 10 lines of a file |
less | Type 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 filename | Create an empty file |
nano | A basic text editor |
grep | Search for the occurrence of a pattern |
Basic Linux Commands
Manage processes
Command | Annotation |
---|---|
top | List the processes running that are using the most CPU |
ps –u | List your current processes |
kill pid | Kill a process that is running where pid is the process id number |
Ctrl-c | Stop a process |
history | List previous commands you have entered |
clear | clear the terminal screen |
Useful symbols
Symbols | Annotation | Examples |
---|---|---|
~ | Your home directory | cd ~ |
. | current directory | ls . |
.. | parent directory | cd .. |
* | stand for "any character" | ls *.txt |
> | Write the output of a command to a file | ls *.txt > output.txt |
>> | Append the output of a command to a file | echo "New line" >> output.txt |
| | Use the output of a command as input of the next command | history | grep "ls" |
Workshop
- 在你的
Home
文件夹新建一个text文件,用你的用户名命名,如"username.txt" - 在新文件的第一行写上你的名字,
- 把你的
home
文件夹地址输入到第二行 - 把这个text文件copy到我的
home
文件夹