前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DAY2-Linux入门

DAY2-Linux入门

原创
作者头像
用户11039705
修改2024-03-23 23:44:23
1090
修改2024-03-23 23:44:23

Linux基础命令

1.pwd 显示当前路径

代码语言:{.linux}
复制
bio07@ecm-cefa:~$ pwd
/home/bio07

2.mkdir 创建空目录,ls 显示当前工作环境下的所有文件和目录

代码语言:{.linux}
复制
bio07@ecm-cefa:~$ mkdir project #存放生信项目
bio07@ecm-cefa:~$ mkdir tmp #存放杂七杂八
bio07@ecm-cefa:~$ mkdir src #存放源代码
bio07@ecm-cefa:~$ mkdir biosoft #存放生信软件
bio07@ecm-cefa:~$ ls 
project  src  tmp   biosoft

3.rm 删除操作

代码语言:{.linux}
复制
bio07@ecm-cefa:~$ rm biosoft
rm: cannot remove 'biosoft': Is a directory   #biosoft不是一个文件
bio07@ecm-cefa:~$ rm -r biosoft  #或者 rmdir biosoft
bio07@ecm-cefa:~$ ls
project  src  tmp
#删除文件 rm
#删除空目录 rmdir
#删除非空目录 rm -r

4.cd 改变工作的路径

代码语言:{.linux}
复制
bio07@ecm-cefa:~$ cd tmp #改变工作路径到tmp
bio07@ecm-cefa:~/tmp$ pwd 
/home/bio07/tmp
bio07@ecm-cefa:~/tmp$ cd - #回到主目录
/home/bio07

bio07@ecm-cefa:~$ mkdir rm_test
bio07@ecm-cefa:~$ cd rm_test
bio07@ecm-cefa:~/rm_test$ touch doodle.txt   #touch为新建文件命令
bio07@ecm-cefa:~/rm_test$ rm doodle.txt      #删除doodle.txt文件
bio07@ecm-cefa:~/rm_test$ mkdir huahua
bio07@ecm-cefa:~/rm_test$ cd huahua
bio07@ecm-cefa:~/rm_test/huahua$ touch haha.txt      #新建haha.txt,总结rm_test里面有huahua,huahua里面有haha.txt
bio07@ecm-cefa:~/rm_test/huahua$ cd     #返回主目录
bio07@ecm-cefa:~$ ls
biosoft  project  rm_test  src  tmp
bio07@ecm-cefa:~$ cd rm_test
bio07@ecm-cefa:~/rm_test$ ls
huahua
bio07@ecm-cefa:~/rm_test$ rm huahua
rm: cannot remove 'huahua': Is a directory
bio07@ecm-cefa:~/rm_test$ rmdir huahua
rmdir: failed to remove 'huahua': Directory not empty    #huahua里面有文件haha.txt
bio07@ecm-cefa:~/rm_test$ rm -r huahua
bio07@ecm-cefa:~/rm_test$ ls
bio07@ecm-cefa:~$ rmdir rm_test
bio07@ecm-cefa:~$ ls
biosoft  project  src  tmp

5.vi 新建脚本或者文本文档,cat加文本命查看,head查看前十行,tail查看后十行

代码语言:{.linux}
复制
bio07@ecm-cefa:~$ cd tmp
bio07@ecm-cefa:~/tmp$ vi hello_world.txt

hello world
my name is gigi, i`m here to learn something about the world.
We know the program is so difficult to learn, and we can change our mind to think about it.
The R has many rules and we may not deal with it, we should learn how to use the search engine to solve our problems.We can also ask somebody else for help.

~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
~                                                                  
                                                 5,0-1         
:x 退出并保存

esc先退出编辑模式


6. cat 查看文件,head查看前十行,tail查看后十行,后加 -n3表示查看到第三行

代码语言:{.linux}
复制
bio07@ecm-cefa:~/tmp$ cat hello_world.txt 
hello world
my name is gigi, i`m here to learn something about the world.
We know the program is so difficult to learn, and we can change our mind to think about it.
The R has many rules and we may not deal with it, we should learn how to use the search engine to solve our problems.We can also ask somebody else for help.

bio07@ecm-cefa:~/tmp$ head -n3 hello_world.txt 
hello world
my name is gigi, i`m here to learn something about the world.
We know the program is so difficult to learn, and we can change our mind to think about it.

7.cp 复制文件

代码语言:{.linux}
复制
bio07@ecm-cefa:~/tmp$ cp hello_world.txt new_file.txt    #将hello_world.txt复制文件为new_file.txt

8.mv 将文件移入文件夹或者重名命

代码语言:{.linux}
复制
bio07@ecm-cefa:~/tmp$ mv new_file.txt home.txt     #将new_file.txt名字换成home.txt
bio07@ecm-cefa:~/tmp$ mv home.txt ~   #移动home.txt到主目录中
bio07@ecm-cefa:~/tmp$ cd      #回到主目录中
bio07@ecm-cefa:~$ ls
biosoft  home.txt  project  src  tmp

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Linux基础命令
    • 1.pwd 显示当前路径
      • 2.mkdir 创建空目录,ls 显示当前工作环境下的所有文件和目录
        • 3.rm 删除操作
          • 4.cd 改变工作的路径
            • 5.vi 新建脚本或者文本文档,cat加文本命查看,head查看前十行,tail查看后十行
              • 6. cat 查看文件,head查看前十行,tail查看后十行,后加 -n3表示查看到第三行
                • 7.cp 复制文件
                  • 8.mv 将文件移入文件夹或者重名命
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档