生物信息学/linux操作与生物信息


第零阶:命令入门编辑

Linux命令共有选项
选项 含义
--help 显示当前帮助后退出
--version 打印版本信息后退出

第一阶:文件夹及文件管理命令编辑


Ubutu还是CentOS编辑

压缩与解压命令编辑

tar命令的选项和参数编辑

  1用法: tar [选项...] [文件]...
  2GNU 'tar' 命令可以将多个文件打成一个压缩包,也可以从压缩包中将文件解压出来。
  3
  4示例:
  5  tar -cf archive.tar foo bar  # 将foo和bar打包为archive.tar
  6  tar -tvf archive.tar         # 完整列出archive.tar中的文件.
  7  tar -xf archive.tar          # 将archive.tar中所有的文件解压出来
  8
  9 主要运行模式:
 10
 11  -A, --catenate, --concatenate   向已有的tar包中添加文件
 12  -c, --create               创建一个新的tar包
 13  -d, --diff, --compare      比较tar包和文件系统的差别
 14      --delete               delete from the archive (not on mag tapes!)
 15  -r, --append               添加文件到包末尾
 16  -t, --list                 列出包中的内容
 17      --test-label           test the archive volume label and exit
 18  -u, --update               only append files newer than copy in archive
 19  -x, --extract, --get       extract files from an archive
 20
 21 Operation modifiers:
 22
 23      --check-device         check device numbers when creating incremental
 24                             archives (default)
 25  -g, --listed-incremental=FILE   handle new GNU-format incremental backup
 26  -G, --incremental          handle old GNU-format incremental backup
 27      --ignore-failed-read   do not exit with nonzero on unreadable files
 28      --level=NUMBER         dump level for created listed-incremental archive
 29  -n, --seek                 archive is seekable
 30      --no-check-device      do not check device numbers when creating
 31                             incremental archives
 32      --no-seek              archive is not seekable
 33      --occurrence[=NUMBER]  process only the NUMBERth occurrence of each file
 34                             in the archive; this option is valid only in
 35                             conjunction with one of the subcommands --delete,
 36                             --diff, --extract or --list and when a list of
 37                             files is given either on the command line or via
 38                             the -T option; NUMBER defaults to 1
 39      --sparse-version=MAJOR[.MINOR]
 40                             set version of the sparse format to use (implies
 41                             --sparse)
 42  -S, --sparse               handle sparse files efficiently
 43
 44 Overwrite control:
 45
 46  -k, --keep-old-files       don't replace existing files when extracting,
 47                             treat them as errors
 48      --keep-directory-symlink   preserve existing symlinks to directories when
 49                             extracting
 50      --keep-newer-files     don't replace existing files that are newer than
 51                             their archive copies
 52      --no-overwrite-dir     preserve metadata of existing directories
 53      --one-top-level[=DIR]  create a subdirectory to avoid having loose files
 54                             extracted
 55      --overwrite            overwrite existing files when extracting
 56      --overwrite-dir        overwrite metadata of existing directories when
 57                             extracting (default)
 58      --recursive-unlink     empty hierarchies prior to extracting directory
 59      --remove-files         remove files after adding them to the archive
 60      --skip-old-files       don't replace existing files when extracting,
 61                             silently skip over them
 62  -U, --unlink-first         remove each file prior to extracting over it
 63  -W, --verify               attempt to verify the archive after writing it
 64
 65 Select output stream:
 66
 67      --ignore-command-error ignore exit codes of children
 68      --no-ignore-command-error   treat non-zero exit codes of children as
 69                             error
 70  -O, --to-stdout            extract files to standard output
 71      --to-command=COMMAND   pipe extracted files to another program
 72
 73 Handling of file attributes:
 74
 75      --atime-preserve[=METHOD]   preserve access times on dumped files, either
 76                             by restoring the times after reading
 77                             (METHOD='replace'; default) or by not setting the
 78                             times in the first place (METHOD='system')
 79      --clamp-mtime          only set time when the file is more recent than
 80                             what was given with --mtime
 81      --delay-directory-restore   delay setting modification times and
 82                             permissions of extracted directories until the end
 83                             of extraction
 84      --group=NAME           force NAME as group for added files
 85      --mode=CHANGES         force (symbolic) mode CHANGES for added files
 86      --mtime=DATE-OR-FILE   set mtime for added files from DATE-OR-FILE
 87  -m, --touch                don't extract file modified time
 88      --no-delay-directory-restore
 89                             cancel the effect of --delay-directory-restore
 90                             option
 91      --no-same-owner        extract files as yourself (default for ordinary
 92                             users)
 93      --no-same-permissions  apply the user's umask when extracting permissions
 94                             from the archive (default for ordinary users)
 95      --numeric-owner        always use numbers for user/group names
 96      --owner=NAME           force NAME as owner for added files
 97  -p, --preserve-permissions, --same-permissions
 98                             extract information about file permissions
 99                             (default for superuser)
100      --preserve             same as both -p and -s
101      --same-owner           try extracting files with the same ownership as
102                             exists in the archive (default for superuser)
103  -s, --preserve-order, --same-order
104                             member arguments are listed in the same order as
105                             the files in the archive
106      --sort=ORDER           directory sorting order: none (default), name or
107                             inode
108
109 Handling of extended file attributes:
110
111      --acls                 Enable the POSIX ACLs support
112      --no-acls              Disable the POSIX ACLs support
113      --no-selinux           Disable the SELinux context support
114      --no-xattrs            Disable extended attributes support
115      --selinux              Enable the SELinux context support
116      --xattrs               Enable extended attributes support
117      --xattrs-exclude=MASK  specify the exclude pattern for xattr keys
118      --xattrs-include=MASK  specify the include pattern for xattr keys
119
120 Device selection and switching:
121
122  -f, --file=ARCHIVE         use archive file or device ARCHIVE
123      --force-local          archive file is local even if it has a colon
124  -F, --info-script=NAME, --new-volume-script=NAME
125                             run script at end of each tape (implies -M)
126  -L, --tape-length=NUMBER   change tape after writing NUMBER x 1024 bytes
127  -M, --multi-volume         create/list/extract multi-volume archive
128      --rmt-command=COMMAND  use given rmt COMMAND instead of rmt
129      --rsh-command=COMMAND  use remote COMMAND instead of rsh
130      --volno-file=FILE      use/update the volume number in FILE
131
132 Device blocking:
133
134  -b, --blocking-factor=BLOCKS   BLOCKS x 512 bytes per record
135  -B, --read-full-records    reblock as we read (for 4.2BSD pipes)
136  -i, --ignore-zeros         ignore zeroed blocks in archive (means EOF)
137      --record-size=NUMBER   NUMBER of bytes per record, multiple of 512
138
139 Archive format selection:
140
141  -H, --format=FORMAT        create archive of the given format
142
143 FORMAT is one of the following:
144
145    gnu                      GNU tar 1.13.x format
146    oldgnu                   GNU format as per tar <= 1.12
147    pax                      POSIX 1003.1-2001 (pax) format
148    posix                    same as pax
149    ustar                    POSIX 1003.1-1988 (ustar) format
150    v7                       old V7 tar format
151
152      --old-archive, --portability
153                             same as --format=v7
154      --pax-option=keyword[[:]=value][,keyword[[:]=value]]...
155                             control pax keywords
156      --posix                same as --format=posix
157  -V, --label=TEXT           create archive with volume name TEXT; at
158                             list/extract time, use TEXT as a globbing pattern
159                             for volume name
160
161 Compression options:
162
163  -a, --auto-compress        use archive suffix to determine the compression
164                             program
165  -I, --use-compress-program=PROG
166                             filter through PROG (must accept -d)
167  -j, --bzip2                filter the archive through bzip2
168  -J, --xz                   filter the archive through xz
169      --lzip                 filter the archive through lzip
170      --lzma                 filter the archive through xz
171      --lzop                 filter the archive through xz
172      --no-auto-compress     do not use archive suffix to determine the
173                             compression program
174  -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
175  -Z, --compress, --uncompress   filter the archive through compress
176
177 Local file selection:
178
179      --add-file=FILE        add given FILE to the archive (useful if its name
180                             starts with a dash)
181      --backup[=CONTROL]     backup before removal, choose version CONTROL
182  -C, --directory=DIR        change to directory DIR
183      --exclude=PATTERN      exclude files, given as a PATTERN
184      --exclude-backups      exclude backup and lock files
185      --exclude-caches       exclude contents of directories containing
186                             CACHEDIR.TAG, except for the tag file itself
187      --exclude-caches-all   exclude directories containing CACHEDIR.TAG
188      --exclude-caches-under exclude everything under directories containing
189                             CACHEDIR.TAG
190      --exclude-ignore=FILE  read exclude patterns for each directory from
191                             FILE, if it exists
192      --exclude-ignore-recursive=FILE
193                             read exclude patterns for each directory and its
194                             subdirectories from FILE, if it exists
195      --exclude-tag=FILE     exclude contents of directories containing FILE,
196                             except for FILE itself
197      --exclude-tag-all=FILE exclude directories containing FILE
198      --exclude-tag-under=FILE   exclude everything under directories
199                             containing FILE
200      --exclude-vcs          exclude version control system directories
201      --exclude-vcs-ignores  read exclude patterns from the VCS ignore files
202  -h, --dereference          follow symlinks; archive and dump the files they
203                             point to
204      --hard-dereference     follow hard links; archive and dump the files they
205                             refer to
206  -K, --starting-file=MEMBER-NAME
207                             begin at member MEMBER-NAME when reading the
208                             archive
209      --newer-mtime=DATE     compare date and time when data changed only
210      --no-null              disable the effect of the previous --null option
211      --no-recursion         avoid descending automatically in directories
212      --no-unquote           do not unquote input file or member names
213      --null                 -T reads null-terminated names, disable -C
214  -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
215                             only store files newer than DATE-OR-FILE
216      --one-file-system      stay in local file system when creating archive
217  -P, --absolute-names       don't strip leading '/'s from file names
218      --recursion            recurse into directories (default)
219      --suffix=STRING        backup before removal, override usual suffix ('~'
220                             unless overridden by environment variable
221                             SIMPLE_BACKUP_SUFFIX)
222  -T, --files-from=FILE      get names to extract or create from FILE
223      --unquote              unquote input file or member names (default)
224  -X, --exclude-from=FILE    exclude patterns listed in FILE
225
226 File name transformations:
227
228      --strip-components=NUMBER   strip NUMBER leading components from file
229                             names on extraction
230      --transform=EXPRESSION, --xform=EXPRESSION
231                             use sed replace EXPRESSION to transform file
232                             names
233
234 File name matching options (affect both exclude and include patterns):
235
236      --anchored             patterns match file name start
237      --ignore-case          ignore case
238      --no-anchored          patterns match after any '/' (default for
239                             exclusion)
240      --no-ignore-case       case sensitive matching (default)
241      --no-wildcards         verbatim string matching
242      --no-wildcards-match-slash   wildcards do not match '/'
243      --wildcards            use wildcards (default for exclusion)
244      --wildcards-match-slash   wildcards match '/' (default for exclusion)
245
246 Informative output:
247
248      --checkpoint[=NUMBER]  display progress messages every NUMBERth record
249                             (default 10)
250      --checkpoint-action=ACTION   execute ACTION on each checkpoint
251      --full-time            print file time to its full resolution
252      --index-file=FILE      send verbose output to FILE
253  -l, --check-links          print a message if not all links are dumped
254      --no-quote-chars=STRING   disable quoting for characters from STRING
255      --quote-chars=STRING   additionally quote characters from STRING
256      --quoting-style=STYLE  set name quoting style; see below for valid STYLE
257                             values
258  -R, --block-number         show block number within archive with each message
259                            
260      --show-defaults        show tar defaults
261      --show-omitted-dirs    when listing or extracting, list each directory
262                             that does not match search criteria
263      --show-snapshot-field-ranges
264                             show valid ranges for snapshot-file fields
265      --show-transformed-names, --show-stored-names
266                             show file or archive names after transformation
267      --totals[=SIGNAL]      print total bytes after processing the archive;
268                             with an argument - print total bytes when this
269                             SIGNAL is delivered; Allowed signals are: SIGHUP,
270                             SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; the names
271                             without SIG prefix are also accepted
272      --utc                  print file modification times in UTC
273  -v, --verbose              verbosely list files processed
274      --warning=KEYWORD      warning control
275  -w, --interactive, --confirmation
276                             ask for confirmation for every action
277
278 Compatibility options:
279
280  -o                         when creating, same as --old-archive; when
281                             extracting, same as --no-same-owner
282
283 Other options:
284
285  -?, --help                 打印当前帮助文档
286      --restrict             disable use of some potentially harmful options
287      --usage                打印简短的使用信息
288      --version              打印程序版本
289
290Mandatory or optional arguments to long options are also mandatory or optional
291for any corresponding short options.
292
293The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
294The version control may be set with --backup or VERSION_CONTROL, values are:
295
296  none, off       never make backups
297  t, numbered     make numbered backups
298  nil, existing   numbered if numbered backups exist, simple otherwise
299  never, simple   always make simple backups
300
301Valid arguments for the --quoting-style option are:
302
303  literal
304  shell
305  shell-always
306  c
307  c-maybe
308  escape
309  locale
310  clocale
压缩与解压命令汇总
压缩文件类型 压缩文件命令示例 解压缩命令示例
.tar.gz/.tgz tar zcvf FileName.tar.gz DirName tar zxvf FileName.tar.gz
.tar.bz2 tar jcvf FileName.tar.bz2 DirName tar jxvf FileName.tar.bz2
.bz2 bzip2 -z FileName bzip2 -d/bunzip2 FileName.bz2
.tar tar cf FileName.tar DirName tar xvf FileName.tar
.gz gzip FileName gzip -d/gunzip FileName.gz
.tar.xz tar zcvf FileName.tar.gz DirName tar xvJf FileName.tar.xz
.Z tar zcvf FileName.tar.gz DirName uncompress FileName.Z
.tar.Z tar zcvf FileName.tar.gz DirName tar xzf FileName.tar.Z
.rar tar zcvf FileName.tar.gz DirName unrar e FileName.rar
.zip tar zcvf FileName.tar.gz DirName unzip FileName.zip


第二阶:文本文件处理命令编辑

文本查看命令编辑

cat和tac编辑

cat命令将文件由前向后全部打印在屏幕上。

tac命令将文件由后向前全部打印在屏幕上。

cat的选项和参数编辑

cat为Concatenate单词的缩写。

 1用法: cat [选项]... [文件]...
 2把一个或者多个文件(或者标准输入)连接在一起,并标准输出
 3
 4没有[文件], 或当[文件]为-, 读取标准输入。
 5
 6  -A, --show-all           等同于 -vET
 7  -b, --number-nonblank    为非空输出行编号, 优先级高于 -n选项
 8  -e                       等同于 -vE
 9  -E, --show-ends          每行结尾显示 $ 
10  -n, --number             为输出的每行编号
11  -s, --squeeze-blank      有连续两行以上的空白行,就替换为一行的空白行
12  -t                       等同于 -vT
13  -T, --show-tabs          将TAB符显示为^I
14  -u                       (ignored)
15  -v, --show-nonprinting   使用^和M-符号显示不能打印的字符(不在ASCII码内的字符),尤其是LFD和TAB
16
17
18Examples:
19  cat f - g  输出f的内容,然后标准输入,最后是g的内容
20  cat        将标准输入输出到标准输出
tac的选项和参数编辑
1用法: tac [选项]... [文件]...
2将每个[文件]打印到标准输出,最后一行先打印。
3
4没有[文件], 或当[文件]为-, 读取标准输入。
5
6  -b, --before             分隔符放在开头而不是结尾
7  -r, --regex              分隔符采用正则表达式
8  -s, --separator=STRING   用STRING代替newLine作为分隔符

head和tail编辑

head 命令查看文件头部, -n 选项可以指定查看前几行。

tail 命令查看文件尾部, -n 选项可以指定查看后几行。

head的选项和参数编辑
 1用法: 
 2    head/tail [选项]... [文件]...
 3打印每个文件的前/后10行道标准输出
 4[文件]多于一个时,打印前/后10行的同时打印文件名。
 5
 6没有[文件], 或当[文件]为-, 读取标准输入。
 7
 8head和taill共有选项:
 9  -c, --bytes=[-]NUM       打印每个文件的前NUM个字节(bytes);
10                             在NUM前加'-', 打印除最后NUM个字节的所有内容
11  -n, --lines=[-]NUM       打印前NUM行;
12                             在NUM前加'-', 打印除最后NUM行的所有行
13  -q, --quiet, --silent    打印前NUM行时不给出文件名
14head的选项:
15
16
17  -v, --verbose            打印前NUM行时给出文件名
18  -z, --zero-terminated    行分隔符是NULL,而非换行符
19tail的选项:
20Mandatory arguments to long options are mandatory for short options too.
21  -c, --bytes=[+]NUM       output the last NUM bytes; or use -c +NUM to
22                             output starting with byte NUM of each file
23  -f, --follow[={name|descriptor}]
24                           output appended data as the file grows;
25                             an absent option argument means 'descriptor'
26  -F                       same as --follow=name --retry
27  -n, --lines=[+]NUM       output the last NUM lines, instead of the last 10;
28                             or use -n +NUM to output starting with line NUM
29      --max-unchanged-stats=N
30                           with --follow=name, reopen a FILE which has not
31                             changed size after N (default 5) iterations
32                             to see if it has been unlinked or renamed
33                             (this is the usual case of rotated log files);
34                             with inotify, this option is rarely useful
35      --pid=PID            with -f, terminate after process ID, PID dies
36  -q, --quiet, --silent    never output headers giving file names
37      --retry              keep trying to open a file if it is inaccessible
38  -s, --sleep-interval=N   with -f, sleep for approximately N seconds
39                             (default 1.0) between iterations;
40                             with inotify and --pid=P, check process P at
41                             least once every N seconds
42  -v, --verbose            always output headers giving file names
43  -z, --zero-terminated    line delimiter is NUL, not newline
44NUM可以有一个乘法器后缀:b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024,等等,用于T, P, E, Z, Y。
tail的选项和参数编辑


文本处理命令编辑

第三阶:shell中的各种符号编辑

  • 元字符
  • 通配符
  • 扩展字符

第四阶:高级目录管理编辑

第五阶:任务管理编辑

  • 任务提交及批处理
  • Shell脚本编写

第六阶:生信软件安装与管理编辑

  • 生信软件安装
  • 使用conda管理生物信息软件

cd与ls编辑

bashrc编辑

权限控制编辑

文件操作编辑

文本编辑编辑

打包压缩编辑

生物软件安装编辑

高级文件操作编辑

进程管理编辑

数据流重定向编辑

文本操作编辑

正则表达式编辑

sed一波流编辑

惊人的awk编辑

参数传递xargs编辑