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

2,914次阅读
没有评论

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

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 清屏

符号说明

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

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

1
2
3
4
5
6
7
[root@ansheng ~]# ls
[root@ansheng ~]# echo "filename" >a.txt
[root@ansheng ~]# cat a.txt 
filename
[root@ansheng ~]# echo "filename" 1>2.txt
[root@ansheng ~]# cat a.txt 
filename

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

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

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

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

|符号|说明|
|:--|:--|
|-|返回上一级所在目录|

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