Mac computer needs to be set before logging in
For Mac Pro , there is often a situation: login is no problem, but there will be problems if you do not operate for more than 5 minutes , you cannot enter, and you have to restart 终端
. The solution is:
[1] On mac, open the terminal and do not log in to the server
[2] Then run the following command locally
cat >~/.ssh/config
Host *
ServerAliveInterval 120
TCPKeepAlive no
^C
Login server
Open the mailbox and find the email sent by Mr. Zeng to everyone, which contains the user name, password and ip address. The login method is:, ssh 用户名@ip地址
such as:
ssh [email protected]
Enter, then enter the password
Modify command line color matching
Copy and paste the following two lines of code:
echo 'export PS1="\[\033]2;\h:\u \w\007\033[33;1m\]\u \033[35;1m\t\033[0m \[\033[36;1m\]\w\[\033[0m\]\n\[\e[32;1m\]$ \[\e[0m\]"' >> ~/.bashrc
source ~/.bashrc
View help documentation
man command, help command, or --help parameter of a command
man ls ## 用 man 命令查看 ls 命令的帮助文档
help ls ## 用 help 命令查看 ls 命令的帮助文档
ls --help ## 用 --help 参数查看 ls 命令的帮助文档
pwd command
ls command
List the directory files:
ls ## 列出当前目录的文件
ls ./ ## 同上,‘.’号代表当前目录
ls ./*txt ## 列出当前目录下以 txt 结尾的文件
ls ../ ## 列出上层目录的文件
ls -a ## 列出当前目录下的所有文件,包括隐藏文件
ls -l ## 列出当前目录下文件的详细信息
ll ## ls -la 的简写
ls -lh ## 加上 -h 参数,以 K、M、G 的形式显示文件大小
ls -lh / ## 列出根目录下文件的详细信息
cd command
Switch working directory
cd .. ## 切换到上层目录,相对路径
cd / ## 切换到根目录
cd /teach/ ## 切换到根目录下的teach,绝对路径
cd - ## 返回上一次的工作目录
cd ~ ## 回到用户家目录
cd ## 同上,回到用户家目录
mkdir
# 创建目录
mkdir dir0
ls
mkdir dir0/sub1/sub2
ls
ls dir0
mkdir -p dir0/sub1/sub2
ls dir0
ls dir0/sub1/
mkdir -p test{1..3}/test{1..3}
tree
mkdir command
Introduction to mkdir command
The mkdir command is used to create a directory with a specified name. The creating user is required to have permission in the current directory, and the specified directory name cannot be an existing directory in the current directory.
Command format
mkdir [options] [directory]
Command parameters
-m --mode=mode, when creating a directory, set the permissions of the directory at the same time;
-p --parents if the created upper-level directory has not been created yet, it will also create the upper-level directory;
-v --verbose create a new one every time All directories show information
-h --help help information
Examples of commonly used commands
Create an empty directory test1
mkdir test1
Create multiple directories recursively
mkdir -p /test2/test22
Create a directory with 777 permissions
mkdir -m 777 test3
Create /text5/text6 in the current directory with a permission of 750
mkdir -p-m 750 text5/text6
touch
ls
touch file.txt new.txt
ls
touch file{1..5}
ls
rm
rm -i file.txt
ls file*
rm file*
rm -r test1
Command-rm
The standard format of a complete instruction:
Linux common format——# command body (space) [ option] (space) [ operating object]
An instruction can contain multiple options, and the operation objects can also be multiple.
Command: rm (remove, remove, delete)
Role: remove/delete documents
Syntax : #rm [option] The path of the document to be removed [path 2 path 3 …]
Options:
-f: force, force deletion, do not prompt whether to delete
-r: recursion, which means recursion [if the operation object is a directory, then -r must]
Generally in use, if you are sure to delete the command directly: #rm -rf file path.
mv
mv file1 Data/file2
cp
cp readme.txt Data/
mkdir dir0
cp -r dir0 Data/
ln
ln -s /teach/software/Miniconda3-latest-Linux-x86_64.sh ./
tar
## 解压
tar -zxvf Data.tar.gz
## 压缩
tar -zcvf Data.tar.gz Data ...
cat
cat readme.txt
cat -n readme.txt
## 写入文件
cat >file
Welcome to Biotrainee() !
^C ## 这里是按Crtl C
## 查看
cat file
Welcome to Biotrainee() !
head、tail
head -n 20 Data/example.fq
## 查看 .bashrc 的最后 10 行
tail ~/.bashrc
## 查看第20行
head -n 20 Data/example.fq | tail -1
less
Press q to exit
less Data/example.fq
less -S Data/example.fq
less -N Data/example.fq
zless -N Data/reads.1.fq.gz
wc
cat -n readme.txt
cat readme.txt | wc
wc -l readme.txt
cut
less -S Data/example.gtf | cut -f 1,3-5
less -S Data/example.gtf | cut -d 'h' -f 1
sort
less -S Data/example.gtf | sort -k 4 | less -S
less -S Data/example.gtf | sort -n -k 4 | less -S
uniq
less -S Data/example.gtf | cut -f 3 | sort | uniq -c
paste
less -S Data/example.fq | paste - - - | less -S
paste file1 file2
tr
cat readme.txt | tr 'e' 'E'
cat readme.txt | tr '\n' '\t'
cat readme.txt | tr -d 'e'
grep
grep Biotrainee -r ./
less -S Data/example.fq | grep 'gene'
less -S Data/example.fq | grep -w 'gene'
less -S Data/example.fq | grep -v -w 'gene'
Regular expression
cat readme.txt | grep '^T'
cat readme.txt | grep ')$'
cat readme.txt | grep 'f.ee'
cat readme.txt | grep 'f\?ee'
cat readme.txt | grep 're\+'
cat readme.txt | grep [bB]
and
cat readme.txt | sed '1i Welcome to Biotrainee() '
cat readme.txt | sed '1a Welcome to Biotrainee() '
cat readme.txt | sed '1c Welcome to Biotrainee()
cat readme.txt | sed 's/is/IS/g'
cat readme.txt | sed '/^$/d'
cat readme.txt | sed 'y/abc/ABC/'
awk
less -S Data/example.gtf | awk '{print $9}' | less -S
less -S Data/example.gtf | awk '{print $9,$10}' | less -S
less -S Data/example.gtf | awk -F '\t' '{print $9}' | less -S
less -S Data/example.gtf | awk '{if($3=="gene") print $0}' | less -S
less -S Data/example.gtf | awk '{if($3=="gene") {print $0} else{print $3 " is not gene "}}' | less -S
less -S Data/example.gtf | awk '/gene/{print $0}' | less -S
less -S Data/example.gtf | awk 'BEGIN{print "find UTR feature"} /UTR/{print $0} END{print "end"}'
less -S Data/example.gtf | awk 'BEGIN{FS="\t"} {print $9}' | less -S
less -S Data/example.gtf | awk 'BEGIN{FS="\t";OFS="\t"} {gsub("gene","Gene",$3);print $0}' | less -S