关于linux:Linux操作系统使用小技巧

9次阅读

共计 2971 个字符,预计需要花费 8 分钟才能阅读完成。

  • 虚拟机只装置 ssh,只能是连贯其余服务器。装置了 openssh-server 后,才能够被其余终端应用 ssh 连贯到
  • 近程文件传输

    • 把从本地复制到近程

      scp local_file remote_username@remote_ip:remote_folder 
      或者 
      scp local_file remote_username@remote_ip:remote_file 
      或者 
      scp local_file remote_ip:remote_folder 
      或者 
      scp local_file remote_ip:remote_file
      # 利用实例
      ➜  Desktop scp a.c lite@192.168.107.128:~/
      lite@192.168.107.128's password:
      a.c

    第 1,2 个指定了用户名,命令执行后须要再输出明码,第 1 个仅指定了近程的目录,文件名字不变,第 2 个指定了文件名;

    第 3,4 个没有指定用户名,命令执行后须要输出用户名和明码,第 3 个仅指定了近程的目录,文件名字不变,第 4 个指定了文件名;

    • 从近程复制到本地

      只须要将从本地复制到近程的命令后 2 个参数调换程序即可,如下实例:

      ➜  Desktop scp lite@192.168.107.128:~/a.c pwd
      lite@192.168.107.128's password:
      a.c
      • 须要留神的是,如果复制的是文件夹的话,须要加上参数 -r,如:scp -r xxxx
    • 给 Ubuntu 操作系统更换字体

      • 一些好的字体

        Fira Code(用于编程成果更佳,还反对连体)

        Source Code Pro

      • 装置办法

        # 先输入以后已装置的字体,确认 fc 命令可用
        ➜  ~ fc-list
        /usr/share/fonts/truetype/tlwg/TlwgTypo-Bold.ttf: Tlwg Typo:style=Bold
        /usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold /usr/share/fonts/truetype/fonts-kalapi/Kalapi.ttf: Kalapi:style=Regular        /usr/share/fonts/truetype/fonts-gujr-extra/Rekha.ttf: Rekha:style=Medium       /usr/share/fonts/truetype/tlwg/TlwgTypewriter-BoldOblique.ttf: Tlwg Typewriter:style=Bold Oblique

        再将带有.ttf 后缀的字体文件挪动到~/.local/share/fonts,没有的话,创立这个目录

        ➜  ~ cd ~/.local/share/fonts
        ➜  fonts ll
        total 3.8M
        -rw------- 1 lite lite 243K Jul 16  2019 FiraCode-Bold.ttf
        -rw------- 1 lite lite 219K Jul 16  2019 FiraCode-Light.ttf
        -rw------- 1 lite lite 215K Jul 16  2019 FiraCode-Medium.ttf
        -rw------- 1 lite lite 217K Jul 16  2019 FiraCode-Regular.ttf
        -rw------- 1 lite lite 216K Jul 16  2019 FiraCode-Retina.ttf
        -rwxrwxrwx 1 lite lite 171K Jul 18  2016 SourceCodePro-BlackIt.ttf
        -rwxrwxrwx 1 lite lite 207K Jul 18  2016 SourceCodePro-Black.ttf
        -rwxrwxrwx 1 lite lite 171K Jul 18  2016 SourceCodePro-BoldIt.ttf
        -rwxrwxrwx 1 lite lite 207K Jul 18  2016 SourceCodePro-Bold.ttf
        -rwxrwxrwx 1 lite lite 172K Jul 18  2016 SourceCodePro-ExtraLightIt.ttf
        -rwxrwxrwx 1 lite lite 209K Jul 18  2016 SourceCodePro-ExtraLight.ttf
        -rwxrwxrwx 1 lite lite 177K Jul 18  2016 SourceCodePro-It.ttf
        -rwxrwxrwx 1 lite lite 172K Jul 18  2016 SourceCodePro-LightIt.ttf
        -rwxrwxrwx 1 lite lite 209K Jul 18  2016 SourceCodePro-Light.ttf
        -rwxrwxrwx 1 lite lite 172K Jul 18  2016 SourceCodePro-MediumIt.ttf
        -rwxrwxrwx 1 lite lite 208K Jul 18  2016 SourceCodePro-Medium.ttf
        -rwxrwxrwx 1 lite lite 208K Jul 18  2016 SourceCodePro-Regular.ttf
        -rwxrwxrwx 1 lite lite 171K Jul 18  2016 SourceCodePro-SemiboldIt.ttf
        -rwxrwxrwx 1 lite lite 208K Jul 18  2016 SourceCodePro-Semibold.ttf

        最初执行 fc-cache 来更新字体 cache 文件

        ➜  fonts fc-cache

        最初就能看到成果

    • 相干链接

      • Linux 下的字体治理
      • 有哪些好的终端字体
      • Ubuntu 装置字体
      • ubuntu 下比拟好的编程字体有哪些?
      • 举荐几款连字字体,在代码编辑器中启用连字字体(Visual Studio Code)
  • 文件操作命令

    cp

    • -a:此选项通常在复制目录时应用,它保留链接、文件属性,并复制目录下的所有内容。其作用等于 dpR 参数组合。
    • -d:复制时保留链接。这里所说的链接相当于 Windows 零碎中的快捷方式。
    • -f:笼罩曾经存在的指标文件而不给出提醒。
    • -i:与 - f 选项相同,在笼罩指标文件之前给出提醒,要求用户确认是否笼罩,答复 ”y” 时指标文件将被笼罩。
    • -p:除复制文件的内容外,还把批改工夫和拜访权限也复制到新文件中。
    • -r:若给出的源文件是一个目录文件,此时将复制该目录下所有的子目录和文件。
    • -l:不复制文件,只是生成链接文件。

    详见菜鸟教程链接

  • 如果连进一个文件夹都被回绝了的话,阐明你没有 x 权限,进文件夹不能应用 ls 的命令,阐明没有 r 权限,所有 r + x 得整
  • Linux 多级目录的创立办法:mkdir -p
  • rsync– 另一种弱小的 cp 命令,能够 ssh cp,也能够选择性地复制整个文件夹

** 更齐全的卸载一个应用 apt-get 装置的软件 **

以卸载 Python2.7 为例

1. 卸载 python2.7

```bash
sudo apt-get remove python2.7
```

2. 卸载 python2.7 及其依赖

```bash
sudo apt-get remove --auto-remove python2.7
```

3. 革除 python2.7 的一些配置文件

```bash
sudo apt-get purge python2.7 
sudo apt-get purge --auto-remove python2.7
正文完
 0