Linux: Bash基本命令

Linux: Bash基本命令

0 切换目录 cd

1 查看当前目录 pwd

2 生成目录 mkdir

3 搜索文件

4 查看当前的文件 ls

5 删除文件但保留特定类型 rm !(*)
例如: rm !(
.tex|
.eps)其中,.tex, .eps格式的文件会被保留下来。

6 打开pdf文档

目录

    gnome-open xxx.pdf (用系统默认的软件打开pdf,在我的电脑上就是Foxit reader)
    evince xxx.pdf (用evince打开pdf, 这个是linux系统默认自带的工具,不能对pdf做任何注释和修改,但优点是快速稳定)
    content
    目录

      7 equivalent bash command
      to rename a bash variable/command

      alias fire='firefox'
      fire
      

      similar way is to set environment variable

      export fire=firefox
      

      however when you wish to use this variable, you need call it with a '$'

      $fire
      

      8 find files or directory

      • find
      # find file by filename
      find /etc/path -name filename.type
      # find file by size bigger than 1M
      find /etc/path -size +1M
      
      • grep
      ### grep 'texts' d*
      

      9 view file content
      you can use 'more' command to view a file, you can also use 'vim' to view a file, under vi mode you can modify a file, under more modle you can make any modification to your file. eg:

      vi ~/.bashrc
      more ~/.bashrc
      

      10 bash variable

      • read bash variable
        To know the content of a bash variable name, you can use the above command.
      echo variablename
      

      11 environment path setting

      • non interective environment file: /etc/profile; ~/.bash_profile
        this environment setting will be loaded every time you run a bash command.
      • interective environment file: /etc/bashrc; ~/.bashrc
        this environment setting will be loaded only once when you first log in as a user.
        The bash environment files under /etc/ are configured by root for all users, normal user can only view them without any modification.
        When you have made any change to bash environment setting file, you need to make them available by executing the above command.
      source ~/.bashrc ~/.bash_profile
      

      12 give file access permission

      chmod 777
      

      13 SFTP远程文件访问
      通过sftp可以远程访问服务器的文件,并且可以通过get命令将文件复制到本地

      sftp username@serverIP
      cd proper/location
      get -r foldername
      get filename.type
      exit
      

      参考:
      [1]https://askubuntu.com/questions/43264/how-to-open-a-pdf-file-from-terminal