实用一些指令及其特殊字符在指令中的含义

ctrl+r

Searches for commands you've already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing a portion of the command will search through your command history. When you find it, simply press Enter.

History

The history command shows a very long list of commands that you have typed. Each command is displayed next to a number. You can type !x to execute a previously typed command from the list (replace the X with a number). If you history output is too long, then use history | less for a scrollable list.

ctrl+a or Home

Moves the cursor to the start of a line.

ctrl+e or End

Moves the cursor to the end of a line.

esc+b

Moves to the beginning of the previous or current word.

ctrl+k

Deletes from the current cursor position to the end of the line.

ctrl+u

Deletes from the start of the line to the current cursor position.

ctrl+w

Deletes the word before the cursor.

System Information Commands

  • df: The df command displays filesystem disk space usage for all mounted partitions. "df -h" is probably the most useful - it uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable")

  • du: The du command displays the disk usage for a directory. It can either display the space used for all subdirectories or the total for the directory you run it on. Example:

user@users-desktop:~$ du /media/floppy
1032    /media/floppy/files
1036    /media/floppy/
user@users-desktop:~$ du -sh /media/floppy
1.1M    /media/floppy/
  • -s means "Summary" and -h means "Human Readable"

  • free: The free command displays the amount of free and used memory in the system. "free -m" will give the information using megabytes, which is probably most useful for current computers.

  • top: The top ('table of processes') command displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press "q".

  • uname -a: The uname command with the -a option prints all system information, including machine name, kernel name & version, and a few other details. Most useful for checking which kernel you're using.

  • lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release you're running, for example:

user@computer:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.10
Release:        11.10
Codename:       oneiric

ip addr reports on your system's network interfaces.


&
  &命令可用在其他任何命令的后面,它用来通知计算机在后台运行某一命令。通过把作业放在后台,用户可以继续使用当前的shell来处理其他命令;如果命令在前台运行的话,那么用户在此进程结束前不能继续使用当前的shell

grep
  grep命令用来在指定的对象中搜索指定的文本。语法是:grep〈text〉〈file〉。它还可以和其他命令的结果联合使用,例如:
         ps -ef|grep-v root


  这一命令要求grep接受ps命令的输出,并除去所有包含单词root的进程(-v的含义是显示与文本不匹配的内容)。在不使用-v选项时,这一命令将显示进程清单中所有包含单词root的进程。

Linux常见特殊符号

 
1,> 重定向输出符号
    用法:命令 >文件名
    特性:覆盖(当输入文件和输出文件是同一文件,文
           件内容被清空;不适合连续重定向)
    典型应用:合并文件(cat a b >c);清空文件(cat
            /dev/null);文件打印
2,>> 重定向输出符号
     用法:命令 >>文件名
     特性:追加
3,2> 错误重定向输出符号
     用法:命令 2>文件名
      特性:覆盖
4,2>>错误重定向输出符号
     用法:命令 2>>文件名
     特性:错误信息的追加
   典型应用:命令>文件名 命令 2>文件名
           命令 >/dev/null 2>/dev/null==命令>
            /dev/null
5,|  管道符号
      用法:命令1| 命令2
     机制:上一个的命令输出作为下一个命令的输入
6,*  匹配任意字符
7,? 匹配任意一个字符
8,& 后台进程符
     用法:命令(程序) &
9,&& 逻辑与
     用法:命令1 && 命令2
     机制:如果命令1执行成功,继续执行命令2;否则,
          不执行命令2
10,|| 逻辑或
      用法:命令1 || 命令2
      机制:如果命令1执行成功,不执行命令2;否则,
          才执行命令2
11,! 逻辑非
            机制:排除指定范围
12,[x-y]  指定范围
13,#  注释
14,""    双引号
            机制:把它所包含的内容作为普通字符,但‘’\
                      $ `` 除外
15‘’ 单引号
              机制:把它所包含的内容作为普通字符,无例外
16,``  倒引号
            机制:执行它所包含的内容
17,\  转义字符
            用法; \符号
            机制:把符号的特定含义去掉,使其变成普通标点
                        符号
18,$  变量调用符号
            用法: $变量
            机制:调用变量,从而得到‘变量的值’
19,; 命令分隔符
            用法:命令1 ; 命令2
            机制;一行语句中,顺次执行各命令
20() 整体执行
21,{ } 变量分离
22,<  重定向输入符号
            用法:命令 <文件名



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值