Linux系统常用快捷键及符号说明

1,698次阅读
没有评论

Linux系统常用快捷键及符号说明

Linux常用快捷键

快捷键 说明
Tab 命令或路径补全
Ctrl+a 光标移动至行首
Ctrl+e 光标移动至行尾
Ctrl+c 终止当前命令或程序
Ctrl+d 退出当前用户环境
Ctrl+u 删除光标前的所有字符
Ctrl+k 删除光标后的所有字符
Ctrl+d 删除光标所在位置的字符
Ctrl+w 删除光标前的所有字符
Ctrl+y 粘贴由Ctrl+u,Ctrl+d,Ctrl+w删除的字符
Ctrl+b 向光标前移动
Ctrl+f 向光标后移动
Ctrl+Shift+c 复制
Ctrl+Shift+v 粘贴
Ctrl+l 清屏

符号说明

符号 说明
> 箭头的方向就是数据的流向
  • 把文件内容清空,把要加的内容加到文件结尾
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
<span class="line">[root@ansheng ~]<span class="comment"># cat hosts </span></span>
<span class="line">127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4</span>
<span class="line">::1         localhost localhost.localdomain localhost6 localhost6.localdomain6</span>
<span class="line">[root@ansheng ~]<span class="comment"># echo "asdsdgxc" > hosts </span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat hosts </span></span>
<span class="line">asdsdgxc</span>
符号 说明
>> 追加重定向
  • 把内容追加到文件结尾
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
<span class="line">[root@ansheng ~]<span class="comment"># cat hosts </span></span>
<span class="line">asdsdgxc</span>
<span class="line">[root@ansheng ~]<span class="comment"># echo "abce12345" >> hosts </span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat hosts </span></span>
<span class="line">asdsdgxc</span>
<span class="line">abce12345</span>

标准输出(正常输出) 1(默认就是1)

<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
7
<span class="line">[root@ansheng ~]<span class="comment"># ls</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># echo "filename" >a.txt</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat a.txt </span></span>
<span class="line">filename</span>
<span class="line">[root@ansheng ~]<span class="comment"># echo "filename" 1>2.txt</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat a.txt </span></span>
<span class="line">filename</span>

错误输出(执行结果报错) 2

<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
7
8
9
10
11
<span class="line">[root@ansheng ~]<span class="comment"># cat ett.txt </span></span>
<span class="line">-bash: sdgdfhfgfdgaas3: <span class="built_in">command</span> not found</span>
<span class="line">[root@ansheng ~]<span class="comment"># asdsdfgdsfas 2>a.txt 1>b.txt</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat a.txt </span></span>
<span class="line">-bash: asdsdfgdsfas: <span class="built_in">command</span> not found</span>
<span class="line">[root@ansheng ~]<span class="comment"># cat b.txt </span></span>
<span class="line">[root@ansheng ~]<span class="comment">#</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># echo "asdsdfgdsfas" 2>a.txt 1>b.txt</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat a.txt </span></span>
<span class="line">[root@ansheng ~]<span class="comment"># cat b.txt  </span></span>
<span class="line">asdsdfgdsfas</span>

标准输入 0 三种特殊写法举例:

<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
7
8
9
10
11
12
13
14
15
16
17
18
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span> ansheng 2>log.txt 1>log.txt         </span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt </span>
<span class="line">ansheng</span>
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span>1 ansheng 2>log.txt 1>log.txt</span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt                     </span>
<span class="line">-bash: <span class="built_in">echo</span>1: <span class="built_in">command</span> not found</span>
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span>1 ansheng >log.txt 2>&1 </span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt </span>
<span class="line">-bash: <span class="built_in">echo</span>1: <span class="built_in">command</span> not found</span>
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span> ansheng >log.txt 2>&1 </span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt </span>
<span class="line">ansheng</span>
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span> ansheng &>log.txt</span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt </span>
<span class="line">ansheng</span>
<span class="line">[ansheng@ansheng ~]$ <span class="built_in">echo</span>1 ansheng &>log.txt </span>
<span class="line">[ansheng@ansheng ~]$ cat log.txt </span>
<span class="line">-bash: <span class="built_in">echo</span>1: <span class="built_in">command</span> not found</span>
符号 说明
. 绝对路径,以根开始的就是相对路径列如/etc/yum.repo.d/
.. 相对路径,以根开始的都是相对路径,..上一层目录,列如ansheng/linux/
\ 管道符,把前面命令正确的执行结果丢给后面继续执行说
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
7
8
<span class="line">[root@ansheng ~]<span class="comment"># find ./ -type f|xargs ls -l</span></span>
<span class="line">-rw-r--r--. 1 root root    9 12月 30 22:00 ./2.txt</span>
<span class="line">-rw-r--r--. 1 root root    9 12月 30 21:59 ./a.txt</span>
<span class="line">-rw-------. 1 root root 7340 12月 30 21:52 ./.bash_<span class="built_in">history</span></span>
<span class="line">-rw-r--r--. 1 root root  176 12月 27 21:10 ./.bash_profile</span>
<span class="line">-rw-r--r--. 1 root root  124 12月 27 21:10 ./.bashrc</span>
<span class="line">-rw-------. 1 root root   39 12月 30 15:17 ./.lesshst</span>
<span class="line">-rw-------. 1 root root 4490 12月 30 18:08 ./.viminfo</span>
符号 说明
; 命令分隔符:
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">[root@ansheng ~]<span class="comment"># ls -l;pwd</span></span>
<span class="line">总用量 8</span>
<span class="line">-rw-r--r--. 1 root root 9 12月 30 22:00 2.txt</span>
<span class="line">-rw-r--r--. 1 root root 9 12月 30 21:59 a.txt</span>
<span class="line">/root</span>
符号 说明
~ 用户家目录:
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">[root@ansheng yum.repos.d]<span class="comment"># pwd</span></span>
<span class="line">/etc/yum.repos.d</span>
<span class="line">[root@ansheng yum.repos.d]<span class="comment"># cd ~</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># pwd</span></span>
<span class="line">/root</span>
符号 说明
{} 字符或数字序列
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
7
8
9
10
11
12
13
14
15
16
17
18
<span class="line">[root@ansheng ~]<span class="comment"># echo {1..10}</span></span>
<span class="line">1 2 3 4 5 6 7 8 9 10</span>
<span class="line">···</span>

<span class="line">|符号|说明|</span>
<span class="line">|:--|:--|</span>
<span class="line">|-|返回上一级所在目录|</span>

<span class="line">```bash</span>
<span class="line">[root@ansheng ~]<span class="comment"># pwd</span></span>
<span class="line">/root</span>
<span class="line">[root@ansheng ~]<span class="comment"># cd /etc/yum.repos.d/</span></span>
<span class="line">[root@ansheng yum.repos.d]<span class="comment"># pwd</span></span>
<span class="line">/etc/yum.repos.d</span>
<span class="line">[root@ansheng yum.repos.d]<span class="comment"># cd -</span></span>
<span class="line">/root</span>
<span class="line">[root@ansheng ~]<span class="comment"># pwd</span></span>
<span class="line">/root</span>
符号 说明
\ 转义字符,让有意义的字符,脱掉它代表的意义。例如:正则里$表示以…结尾,可以用\$表示$符号本身。
<span class="line">1</span>
<span class="line">2</span>
<span class="line">3</span>
<span class="line">4</span>
<span class="line">5</span>
<span class="line">6</span>
<span class="line">[root@ansheng ~]<span class="comment"># cat ett </span></span>
<span class="line">./redhat@$</span>
<span class="line">[root@ansheng ~]<span class="comment"># sed 's/./redhat@$/./linux/g' ett </span></span>
<span class="line">sed:<span class="_">-e</span> 表达式 <span class="comment">#1,字符 14:“s”的未知选项</span></span>
<span class="line">[root@ansheng ~]<span class="comment"># sed 's/\.\/redhat\@\$/\.\/linux/g' ett </span></span>
<span class="line">./linux</span>
admin
版权声明:本站原创文章,由admin2016-07-13发表,共计2940字。
转载提示:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)