加入收藏 | 设为首页 | 会员中心 | 我要投稿 百客网 - 百科网 (https://www.baikewang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Unix > 正文

一些有用的UNIX命令

发布时间:2022-12-19 11:29:27 所属栏目:Unix 来源:
导读:  你将从这里发现一些有用的UNIX命令,它们将会是你探索下一代测序数据的有力支撑。此外,从你还可以发现更多更有用的命令.

  直接在命令行处敲这些命令将会详细介绍它们.

  or Ctrl-l: clear screen
  你将从这里发现一些有用的UNIX命令,它们将会是你探索下一代测序数据的有力支撑。此外,从你还可以发现更多更有用的命令.
 
  直接在命令行处敲这些命令将会详细介绍它们.
 
  or Ctrl-l: clear screen
 
  上下箭头键可以用来浏览之前用过的命令
 
  Ctrl-r 搜索使用过的命令的历史
 
  ## Ctrl-r opens this query tool
  ## start typing part of the command you issued a while back and it will show
  ## up in the query tool -- I think the history gets deleted after logging out
  (reverse-i-search)`':
  使用Tab键可以补齐命令,文件名和文件夹
 
  or Ctrl-d: 退出Shell
 
  : 从命令行关机
 
  : 显示你感兴趣的命令的详细手册
 
  使用空格翻页.q键退出.
 
  man man
  ## displays the man-page of man ;-)
  man ssh
  ## displays man-page of the ssh client
  文件系统相关
 
  这里给出了友好的UNIX文件系统的介绍。阅读 可以大致解释一个典型的Unix文件系统.
 
  : 在文件夹之间移动
 
  cd .. : 返回到上一目录. 例如, 如果你在/home/cartwrightlab/desktop 目录并且想返回/home ,那么使用 cd ../..
 
  pwd
  /home/cartwrightlab/desktop
  cd ../..
  pwd
  /home
  : 拷贝文件
 
  cp dir1/foo.txt dir2/
  ## copies foo.txt from dir1 to dir2
  cp -r dir1/ dir2/
  ## copies dir1 and its contents to dir2
  : 列出文件夹下所有的内容
 
  ls -l
  ## list files with detailed info
  ls -a
  ## show all files including hidden files
  ls -lh
  ## show a list of files including their sizes in human readable form
  ls -lha
  ## well...
  : make a new directory
 
  unix grep 命令_unix命令行_unix 命令行数
 
  mkdir foo
  ## makes directory foo
  : 移动文件或重命名文件
 
  mv foo.txt newdirectory/foo.txt
  ## moves foo.txt into newdirectory
  mv foo.txt cat.txt
  ## renames foo.txt to cat.txt
  ?
  : 根据正则表达式对多个文件重命名 表示重命名的规则
 
  rename 's/.txt$/.fasta/' *
  ## changes the file extension for all files (*) in a directory from .txt to .fasta
  : 删除文件或文件夹
 
  rm foo.txt
  ## delete foo.txt
  rm -r foo
  ## delete the directory foo and its contents
  : 搜索文件 -- 有一个极好的教程介绍如何很好地使用这个强大的命令
 
  find /home/user -name pattern
  ## searches for files in /home/user that match the pattern
  : 汇报磁盘系统使用情况
 
  df -h
  ## reports the size, used space, and available
  ## space of every device available on the system
  ##
  ## useful if you want to know how much space you
  ## have left to work with -- Can I really extract this tarball?!
  : 估计特定文件夹下的内容占据的空间大小
 
  du -h /home/user
  ## estimates the size of the user's home directory
  ## and the contained directories
  ##
  ## can be used to estimate the size of any directory
  : 打印你所处的路径
 
  注意: 你处理文件的所有命令都假设你在该文件夹内. 如果不是的话, 你可以使用相对路径. 例如: 你的文件 (file_1.txt)在文件夹 home/cartwrightlab/Documents/TruSeq/ 下, 而你在另一个文件夹下工作 home/cartwrightlab/Documents, 如果你要想重命名 file_1 而不离开你目前的文件夹的话, 你该使用如下命令:
 
  mv TruSeq/file_1.txt TruSeq/newfile_1.txt
  注意, 你并不需要输入完整的路径unix命令行,因为TruSeq 是Documents的子目录.
 
  挂载 : 挂载一个设备
 
  一个设备可以是一个硬盘. 设备一般在目录/dev下都可找到. 然而,不同系统之间的名字有所不同. 比如 /dev/sdb1 是你刚插入到电脑的USB驱动器. 你将它挂载到/mnt文件夹, 可通过如下命令:
 
  mount /dev/sdb1 /mnt
  : 卸载文件系统
 
  为了将刚才挂载的驱动器卸载, 你需要使用如下命令. 然而,这个过程会长一些, 因为可能还有数据没有写入呢!
 
  umount /mnt
  和文本文件打交道 处理文本文件的额外信息可以参考 .
 
  : 将文件内容打印到标准输出; 你当然可以像man命令那样搜索模式
 
  less foo.txt
  : 将文件的前10行打印到标准输出,对于大文件很有用
 
  head foo.txt
  只打印前5行的话:
 
  head -n 5 foo.txt
  : 将文件的最后10行打印到标准输出
 
  tail foo.txt
  只打印最后5行的话:
 
  tail -n 5 foo.txt
  : 很容易使用的文本编辑器
 
  然而Nano处理大文件并不合适, 详细的编辑大文件的方法可参考: .
 
  nano foo.txt
  :连接文本并打印到标准输出,或重定向到另一文件
 
  cat foo.txt
  ## dump foo.txt to standard out (the screen)
  cat foo1.txt foo2.txt foo3.txt > foo_combined.txt
  ## dump foo1.txt through foo3.txt to another file
  cat *.txt > combined.txt
  ## dump all text files in current directory to another file
  : 在文件内搜索符合模式的内容 -- 返回满足模式的行
 
  ## Simple pattern matching and full-fledged support for regular expressions.
  ## There are tons of how-to's on the web.
  grep pattern foo.txt
  ## basic usage to look for pattern in file foo.txt
  cat foo.txt | grep pattern
  ## same as above using cat and a pipe (see I/O Redirection)
  cat *.txt | grep pattern
  ## search for a pattern in all text files in the present directory
  : 报告或省略重复的行
 
  cat foo.txt | uniq > foo-filtered.txt
  ## only retain uniq lines in foo.txt and save these in
  ## foo-filtered.txt
  ##
  ## think about filtering out duplicate sequences etc.
  : 强大的文本编辑器,但学习起来很不容易. 那为什么还要学习vi呢? 因为任何新安装Unix或Linux的电脑上都有它 .
 
  : 统计一个文件的行数,字数和字节数
 
  wc -l foo.txt
  ## counts the number of lines in foo.txt
  cat foo.txt | wc -l
  ## same as above using a pipe (see I/O Redirection)
 

(编辑:百客网 - 百科网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章