`
砚台观月
  • 浏览: 3430 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Ubuntu 基础操作 基础命令 热键 man手册使用 关机 重启等命令使用

阅读更多

作者 : 万境绝尘

转载请注明出处 http://blog.csdn.net/shulianghan/article/details/21056029

.

 

1. Linux运行等级介绍

 

Linux运行等级 

-- 0 : 关机, 如果将Linux默认运行等级设置为0, 系统将无法启动;

-- 1 : 单用户模式, 在这个等级下, 只允许 root 用户登陆;

-- 2 : 多用户模式, 在该模式下 网络文件系统(NFS)不能使用;

-- 3 : 多用户模式, 允许使用网络文件系统, 一般不使用图形界面登陆就是这种模式;

-- 4 : 用户可以自定义该运行级别;

-- 5 : 多用户图形界面模式, 该模式下可以启动图形界面;

-- 6 : 重启, 如果将Linux默认运行等级设置为0, 系统将无法重启;

 

运行等级相关命令操作 

-- 查看当前运行级别 : runlevel ;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 bin]# runlevel   
  2. N 3  

 

-- 设置运行等级 : init 3, 就是将运行等级设置为3;

 

修改默认运行等级 : 默认的运行级别在 /etc/inittab 文件中设置, 建议童鞋们将默认的运行级别设置为3, 如果想要访问图形化界面, 直接使用 startx 命令即可;

-- 第一行 : id:5:initdefault: , 将其中的 5 修改为 3 即可;

 

etc/inittab 文件内容 : 该文件有一定的学习参考价值, 在这里贴出来;

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # inittab       This file describes how the INIT process should set up  
  2. #               the system in a certain run-level.  
  3. #  
  4. # Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>  
  5. #               Modified for RHS Linux by Marc Ewing and Donnie Barnes  
  6. #  
  7.   
  8. # Default runlevel. The runlevels used by RHS are:  
  9. #   0 - halt (Do NOT set initdefault to this)  
  10. #   1 - Single user mode  
  11. #   2 - Multiuser, without NFS (The same as 3, if you do not have networking)  
  12. #   3 - Full multiuser mode  
  13. #   4 - unused  
  14. #   5 - X11  
  15. #   6 - reboot (Do NOT set initdefault to this)  
  16. #   
  17. id:3:initdefault:  
  18.   
  19. # System initialization.  
  20. si::sysinit:/etc/rc.d/rc.sysinit  
  21.   
  22. l0:0:wait:/etc/rc.d/rc 0  
  23. l1:1:wait:/etc/rc.d/rc 1  
  24. l2:2:wait:/etc/rc.d/rc 2  
  25. l3:3:wait:/etc/rc.d/rc 3  
  26. l4:4:wait:/etc/rc.d/rc 4  
  27. l5:5:wait:/etc/rc.d/rc 5  
  28. l6:6:wait:/etc/rc.d/rc 6  
  29.   
  30. # Trap CTRL-ALT-DELETE  
  31. ca::ctrlaltdel:/sbin/shutdown -t3 -r now  
  32.   
  33. # When our UPS tells us power has failed, assume we have a few minutes  
  34. # of power left.  Schedule a shutdown for 2 minutes from now.  
  35. # This does, of course, assume you have powerd installed and your  
  36. # UPS connected and working correctly.    
  37. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"  
  38.   
  39. # If power was restored before the shutdown kicked in, cancel it.  
  40. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"  
  41.   
  42.   
  43. # Run gettys in standard runlevels  
  44. 1:2345:respawn:/sbin/mingetty tty1  
  45. 2:2345:respawn:/sbin/mingetty tty2  
  46. #3:2345:respawn:/sbin/mingetty tty3  
  47. #4:2345:respawn:/sbin/mingetty tty4  
  48. #5:2345:respawn:/sbin/mingetty tty5  
  49. #6:2345:respawn:/sbin/mingetty tty6  
  50.   
  51. # Run xdm in runlevel 5  
  52. x:5:respawn:/etc/X11/prefdm -nodaemon  

 


 

 

 

2. 图形界面 (X Window) 与 命令行模式切换

 

终端界面 与 X Window 界面切换方式 

-- 切换终端界面 : ctrl + alt + F1 ~ F6 是切换到 tty1 ~ tty6;

-- 切换 X Window 界面 : ctrl + alt + F7 切换到 图形界面;

 

 

tty概念 : TeleTypes, tty 1 ~ 6 这六个 终端没有区别, 这六个文本界面运行级别是3;

-- 作用 : 使用多个用户可以同时登陆终端;

-- 登陆图形界面命令 : startx ;

-- tty7界面 : tty7 是图形化界面, 运行级别是 5;

 

文本界面 -> 图形界面 前提条件 : 这里指的是 使用 startx 命令启动图形化界面的条件;

-- tty7空闲 : 在图形界面中没有软件在运行;

-- 安装图形界面 : 操作系统必须安装了图形界面;

-- 有窗口管理员 : 有窗口管理员 KDE 等;

-- 必要服务运行 : 一些服务必须先启动;

.

 

3. 取消 Ubuntu 的待机锁屏

 

问题 : Ubuntu 待机锁屏非常麻烦, 每次进入都需要输入密码;

 

配置 : 系统设置 | 亮度和锁屏 如下图 :

-- 系统设置 


-- 亮度和锁屏 : 调节成 每次唤起 不要使用密码即可;

 

4. Ubuntu开启多窗口 跳转到桌面快捷键

 

快捷键设置 : 隐藏所有的普通窗口快捷键 : Ctrl + Super + D , 其中的 Super 键是 Windows 键, 时左边的 Ctrl 和 Alt 之间的键;


 

5. 配置截图快捷键

 

Ubuntu 自带的 gnome screen 截图工具, 可以设置快捷键调用该工具 

-- 全屏截图快捷键 : PrtScn 键即可;

-- 徐选区截图快捷键 : shift + PrtScn , 这些截图都是使用该快捷键截图截下来的;


 

 

6. 使用SSH连接远程服务器

 

(1) 使用密码登陆

 

使用ssh工具 : ssh root@115.28.42.124 命令即可登陆, 在之后提示的地方输入密码 : 

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. octopus@octopus-Vostro-270s:~$ ssh root@115.28.42.124  
  2. root@115.28.42.124's password:   
  3. Last login: Fri Mar 14 10:39:09 2014 from 124.42.2.242  
  4.   
  5. Welcome to aliyun Elastic Compute Service!  
  6.   
  7. [root@ip28 ~]#   

 

 

 

(2) 配置无密钥登陆

 

1> 本地操作

 

生成RSA公钥 : 执行 ssh-keygen , 然后一路回车;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. octopus@octopus-Vostro-270s:~$ ssh-keygen   
  2. Generating public/private rsa key pair.  
  3. Enter file in which to save the key (/home/octopus/.ssh/id_rsa):   
  4. Enter passphrase (empty for no passphrase):   
  5. Enter same passphrase again:   
  6. Your identification has been saved in /home/octopus/.ssh/id_rsa.  
  7. Your public key has been saved in /home/octopus/.ssh/id_rsa.pub.  
  8. The key fingerprint is:  
  9. 6e:06:49:bd:c5:7c:3f:8c:8d:10:a5:2a:85:59:86:4e octopus@octopus-Vostro-270s  
  10. The key's randomart image is:  
  11. +--[ RSA 2048]----+  
  12. |       .o ...    |  
  13. |      E* o o     |  
  14. |     o+ o * .    |  
  15. |     ..o + o *   |  
  16. |      + S   o =  |  
  17. |       +       . |  
  18. |        +        |  
  19. |       o         |  
  20. |                 |  
  21. +-----------------+  


创建配置文件 

 

-- 配置文件路径 : ~/.ssh/config ;

-- 配置文件内容 

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. Host ali  
  2. HostName 115.28.42.124  
  3. User root  
  4. Port 22  

 


 

 

2> 服务器端操作 

 

在服务器端创建 : ~/.ssh 目录, 将 id_rsa.pub 上传到这个目录中, 更名为 authorized_keys;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 .ssh]# ls  
  2. id_rsa.pub  
  3. [root@ip28 .ssh]# mv id_rsa.pub authorized_keys  
  4. [root@ip28 .ssh]# ls  
  5. authorized_keys   


修改配置文件 : vim /etc/ssh/ssh_config , 在文件末尾添加下面的内容;

 

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. RSAAuthentication yes  
  2. PubkeyAuthentication yes  
  3. IdentityFile .ssh/authorized_keys  


重启ssh服务命令 : service sshd restart;

 

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 .ssh]# service sshd restart  
  2. Stopping sshd:                                             [  OK  ]  
  3. Starting sshd:                                             [  OK  ]  



 

 

3> 验证无密钥登陆

 

使用 ssh ali 登陆阿里云的服务器:

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. octopus@octopus-Vostro-270s:~$ ssh ali  
  2. Last login: Fri Mar 14 10:54:12 2014 from 124.42.2.242  
  3.   
  4. Welcome to aliyun Elastic Compute Service!  
  5.   
  6. [root@ip28 ~]#   



 

 

7. Ubuntu 13.10 下 eclipse 菜单栏失效

 

菜单栏失效 : 刚装上了 eclipse , 发现菜单栏点击失效, 使用下面的命令启动eclipse 就可以使用菜单栏 : 

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. env UBUNTU_MENUPROXY= /home/octopus/eclipse/eclipse  


-- 注意 : "=" 和 后面的eclipse路径之间有一个空格;

 

-- 此时菜单栏没有在顶部状态栏上, 而是在下面, 此时菜单可用 : 


 

 

8. Linux基础操作

 

语言操作 : 终端输出出现乱码, 无法以中文(zh_CN)输出编码, 就需要将语言改为英文(en_US)的;

-- 查看语言命令 : echo $LANG ;

-- 修改语言命令 : LANG=en_US.UTF-8 , 注意上面的命令没有空格;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 bin]# echo $LANG        
  2. zh_CN.UTF-8  
  3. [root@ip28 bin]# LANG=en_US.UTF-8  
  4. [root@ip28 bin]# echo $LANG        
  5. en_US.UTF-8  



 

 

显示日期 : date 命令显示日期;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 bin]# date  
  2. Sun Mar 16 01:52:04 CST 2014  

 

-- 自定义格式 : %Y(年), %m(月), %d(日), %H(时), %M(分);

-- 注意 : 使用自定义日期格式, 要在 date 后面 加上 "+" 参数, 如 date +%Y-%m-%d ;

-- 学习更多 : 使用 man date 命令, 查看 man 手册查询更多用法和参数;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 bin]# date +%Y-%m-%d-%H:%M  
  2. 2014-03-16-02:02  
  3. [root@ip28 bin]# date +%Y-%m-%d/%H:%M  
  4. 2014-03-16/02:02  



 

 

显示日历 

-- 列出当前月日历 cal 命令, 列出当前月日历;

-- 列出某一年日历 : cal 2014 命令;

-- 列出某年某月日历 : cal 3 2014 命令;

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 bin]# cal  
  2.      March 2014       
  3. Su Mo Tu We Th Fr Sa  
  4.                    1  
  5.  2  3  4  5  6  7  8  
  6.  9 10 11 12 13 14 15  
  7. 16 17 18 19 20 21 22  
  8. 23 24 25 26 27 28 29  
  9. 30 31  
  10. [root@ip28 bin]# cal 2014  
  11.                                2014                                  
  12.   
  13.        January               February                 March          
  14. Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa  
  15.           1  2  3  4                      1                      1  
  16.  5  6  7  8  9 10 11    2  3  4  5  6  7  8    2  3  4  5  6  7  8  
  17. 12 13 14 15 16 17 18    9 10 11 12 13 14 15    9 10 11 12 13 14 15  
  18. 19 20 21 22 23 24 25   16 17 18 19 20 21 22   16 17 18 19 20 21 22  
  19. 26 27 28 29 30 31      23 24 25 26 27 28      23 24 25 26 27 28 29  
  20.                                               30 31  
  21.         April                   May                   June           
  22. Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa  
  23.        1  2  3  4  5                1  2  3    1  2  3  4  5  6  7  
  24.  6  7  8  9 10 11 12    4  5  6  7  8  9 10    8  9 10 11 12 13 14  
  25. 13 14 15 16 17 18 19   11 12 13 14 15 16 17   15 16 17 18 19 20 21  
  26. 20 21 22 23 24 25 26   18 19 20 21 22 23 24   22 23 24 25 26 27 28  
  27. 27 28 29 30            25 26 27 28 29 30 31   29 30  
  28.   
  29.         July                  August                September        
  30. Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa  
  31.        1  2  3  4  5                   1  2       1  2  3  4  5  6  
  32.  6  7  8  9 10 11 12    3  4  5  6  7  8  9    7  8  9 10 11 12 13  
  33. 13 14 15 16 17 18 19   10 11 12 13 14 15 16   14 15 16 17 18 19 20  
  34. 20 21 22 23 24 25 26   17 18 19 20 21 22 23   21 22 23 24 25 26 27  
  35. 27 28 29 30 31         24 25 26 27 28 29 30   28 29 30  
  36.                        31  
  37.        October               November               December         
  38. Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa  
  39.           1  2  3  4                      1       1  2  3  4  5  6  
  40.  5  6  7  8  9 10 11    2  3  4  5  6  7  8    7  8  9 10 11 12 13  
  41. 12 13 14 15 16 17 18    9 10 11 12 13 14 15   14 15 16 17 18 19 20  
  42. 19 20 21 22 23 24 25   16 17 18 19 20 21 22   21 22 23 24 25 26 27  
  43. 26 27 28 29 30 31      23 24 25 26 27 28 29   28 29 30 31  
  44.                        30  
  45.   
  46. [root@ip28 bin]# cal 3 2014  
  47.      March 2014       
  48. Su Mo Tu We Th Fr Sa  
  49.                    1  
  50.  2  3  4  5  6  7  8  
  51.  9 10 11 12 13 14 15  
  52. 16 17 18 19 20 21 22  
  53. 23 24 25 26 27 28 29  
  54. 30 31  



 

 

9. man 手册使用

 

分析man手册内容 : 这里以 man cal 查询的结果为例分析, 该命令查询日历命令相关用法;

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. CAL(1)                    BSD General Commands Manual                   CAL(1)  
  2. # 括号中的 1 代表 1 手册  
  3.   
  4. NAME # 命令名称 - 命令作用  
  5.      cal - displays a calendar  
  6.   
  7. SYNOPSIS # 命令基本语法  
  8.      cal [-smjy13] [[month] year]  
  9.   
  10. DESCRIPTION # 对 命令语法 中提到的参数进行详细的说明  
  11.      Cal displays a simple calendar.  If arguments are not specified, the current month is displayed.  The  
  12.      options are as follows:  
  13.   
  14.      -1      Display single month output.  (This is the default.)  
  15.   
  16.      -3      Display prev/current/next month output.  
  17.   
  18.      -s      Display Sunday as the first day of the week.  (This is the default.)  
  19.   
  20.      -m      Display Monday as the first day of the week.  
  21.   
  22.      -j      Display Julian dates (days one-based, numbered from January 1).  
  23.   
  24.      -y      Display a calendar for the current year.  
  25.        
  26.      A single parameter specifies(指定) the year (1 - 9999) to be displayed; note the year must be fully specified:  
  27.      “cal 89” will not display a calendar for 1989.  Two parameters denote the month (1 - 12and year.  If no  
  28.      parameters are specified, the current month’s calendar is displayed.  
  29.   
  30.      A year starts on Jan 1.  
  31.   
  32.      The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd of September.  By this time, most  
  33.      countries had recognized the reformation (although a few did not recognize it until the early 1900’s.)  Ten  
  34.      days following that date were eliminated by the reformation, so the calendar for that month is a bit  
  35.      unusual.  
  36.   
  37. HISTORY # 命令历史  
  38.      A cal command appeared in Version 6 AT&T UNIX.  
  39.   
  40. OTHER VERSIONS # 其它 UNIX 版本中命令介绍  
  41.      Several much more elaborate versions of this program exist, with support for colors, holidays, birthdays,  
  42.      reminders and appointments, etc. For example, try the cal from http://home.sprynet.com/~cbag-  
  43.      well/projects.html or GNU gcal.  
  44.   
  45. BSD                              June 61993                              BSD  


 

 

man手册代号 : 使用 man 7 man, 命令查看下面的 手册对应标号;

-- 1 : shell 环境的 命令 和 可执行文件 查询;

-- 2 : 系统调用, 即 内核可调用的函数;

-- 3 : 常用的函数库查询, 大部分是 C 的函数库;

-- 4 : /dev 下的设备文件说明;

-- 5 : 配置文件 和 某些文件格式;

-- 6 : 游戏查询;

-- 7 : 查询一些惯例与协议, 如 Linnux 文件系统, 网络协议等;

-- 8 : 系统管理员可用的命令;

-- 9 : kernel 相关文件;

 

man page 内容格式 

-- NAME : 命令 说明;

-- SYNOPSIS : 命令执行的语法格式;

-- DESCRIPTION : 命令的描述;

-- OPTIONS : 列举 语法 中的每一个 参数 和 选项 的值;

-- COMMANDS : 程序执行的时候, 在程序法中执行的命令;

-- FILES : 程序需要参考的文件;

-- SEE ALSO : 命令相关的其它说明;

-- EXAMPLE : 参考范例;

-- BUGS : 相关错误;

 

man手册操作查询 

-- 翻页 : 空格(向下翻页), Page Down(向下翻页), Page Up(向上翻页), Home(第一页), End(最后一页);

-- 查询字符串 : /string 向下查询字符串, ?string 向上查询字符串; n 正向查询, N 反向查询;

-- 结束查询 : q ;

 

man手册设置 

-- 数据存放路径 : man手册存放在 usr/share/man 目录中;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 etc]# cd /usr/share/man/  
  2. [root@ip28 man]# ls  
  3. bg  el  fr            hu            it.UTF-8  man1x  man3x  man5x  man7x  man9x  pl.ISO8859-2  ro         sk     zh_TW  
  4. cs  en  fr.ISO8859-1  id            ja        man2   man4   man6   man8   mann   pl.UTF-8      ru         sl  
  5. da  es  fr.UTF-8      it            ko        man2x  man4x  man6x  man8x  nl     pt            ru.KOI8-R  tr  
  6. de  fi  hr            it.ISO8859-1  man1      man3   man5   man7   man9   pl     pt_BR         ru.UTF-8   zh_CN  

 

-- 配置文件 : /etc/man.config ;

 

按照命令名称查询相关的说明文件 : 当我们要查询一个命令, 但是不知道到哪个手册中查询, 就可以使用 man -f 查询内容 进行查询, 执行该命令结果会列出相关的手册信息;

-- 查询 更多 与 man 相关的信息 : 执行命令 man -f man , 可以根据结果 查询 man 5 man.config 文件如何配置;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# man -f man  
  2. man                  (1)  - format and display the on-line manual pages  
  3. man                 (rpm) - A set of documentation tools: man, apropos and whatis.  
  4. man [manpath]        (1)  - format and display the on-line manual pages  
  5. man.config [man]     (5)  - configuration data for man  

-- 执行优先级 : 使用 man 查询内容 只能显示 1~9 中的一个手册中的内容, 在/etc/man.config 中配置查询顺序, 优先查询到的会显示出来, 一般是小号的手册显示;

 

按照关键字查询相关的说明文件 : man -k 关键字 命令, 查询man手册中 出现关键字的手册;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# man -k printf  
  2. curl_maprintf [curl_mprintf] (3)  - formatted output conversion  
  3. curl_mfprintf [curl_mprintf] (3)  - formatted output conversion  
  4. curl_mprintf         (3)  - formatted output conversion  
  5. curl_msnprintf [curl_mprintf] (3)  - formatted output conversion  
  6. curl_msprintf curl_mvaprintf [curl_mprintf] (3)  - formatted output conversion  
  7. curl_mvfprintf [curl_mprintf] (3)  - formatted output conversion  
  8. curl_mvprintf [curl_mprintf] (3)  - formatted output conversion  
  9. curl_mvsnprintf [curl_mprintf] (3)  - formatted output conversion  
  10. curl_mvsprintf [curl_mprintf] (3)  - formatted output conversion  
  11. evbuffer_add_printf [event] (3)  - execute a function when a specific event occurs  
  12. evbuffer_add_vprintf [event] (3)  - execute a function when a specific event occurs  
  13. printf               (1)  - format and print data  
  14. printf [builtins]    (1)  - bash built-in commands, see bash(1)  


man的简写方法 

 

-- 查询命令 : whatis 等价于 man -f;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# whatis man  
  2. man                  (1)  - format and display the on-line manual pages  
  3. man                 (rpm) - A set of documentation tools: man, apropos and whatis.  
  4. man [manpath]        (1)  - format and display the on-line manual pages  
  5. man.config [man]     (5)  - configuration data for man  
[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# man -f man  
  2. man                  (1)  - format and display the on-line manual pages  
  3. man                 (rpm) - A set of documentation tools: man, apropos and whatis.  
  4. man [manpath]        (1)  - format and display the on-line manual pages  
  5. man.config [man]     (5)  - configuration data for man  

 

-- 查询关键字 : apropos 等价于 man -k;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# apropos printf  
  2. curl_maprintf [curl_mprintf] (3)  - formatted output conversion  
  3. curl_mfprintf [curl_mprintf] (3)  - formatted output conversion  
  4. curl_mprintf         (3)  - formatted output conversion  
  5. curl_msnprintf [curl_mprintf] (3)  - formatted output conversion  
  6. curl_msprintf curl_mvaprintf [curl_mprintf] (3)  - formatted output conversion  
  7. curl_mvfprintf [curl_mprintf] (3)  - formatted output conversion  
  8. curl_mvprintf [curl_mprintf] (3)  - formatted output conversion  
  9. curl_mvsnprintf [curl_mprintf] (3)  - formatted output conversion  
  10. curl_mvsprintf [curl_mprintf] (3)  - formatted output conversion  
  11. evbuffer_add_printf [event] (3)  - execute a function when a specific event occurs  
  12. evbuffer_add_vprintf [event] (3)  - execute a function when a specific event occurs  
  13. printf               (1)  - format and print data  
  14. printf [builtins]    (1)  - bash built-in commands, see bash(1)  
[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 man]# man -k printf  
  2. curl_maprintf [curl_mprintf] (3)  - formatted output conversion  
  3. curl_mfprintf [curl_mprintf] (3)  - formatted output conversion  
  4. curl_mprintf         (3)  - formatted output conversion  
  5. curl_msnprintf [curl_mprintf] (3)  - formatted output conversion  
  6. curl_msprintf curl_mvaprintf [curl_mprintf] (3)  - formatted output conversion  
  7. curl_mvfprintf [curl_mprintf] (3)  - formatted output conversion  
  8. curl_mvprintf [curl_mprintf] (3)  - formatted output conversion  
  9. curl_mvsnprintf [curl_mprintf] (3)  - formatted output conversion  
  10. curl_mvsprintf [curl_mprintf] (3)  - formatted output conversion  
  11. evbuffer_add_printf [event] (3)  - execute a function when a specific event occurs  
  12. evbuffer_add_vprintf [event] (3)  - execute a function when a specific event occurs  
  13. printf               (1)  - format and print data  
  14. printf [builtins]    (1)  - bash built-in commands, see bash(1)  

 

-- 建立数据库 : 执行上面的两个特殊命令, 需要使用root用户建立 whatis 数据库;

 

 

10. info page手册

 

info page简介 : 这是个在线手册, 该手册将文件拆成一个一个的段落, 每个段落一个页面, 每个页面都有超链接跳转, 每个页面都是一个节点(Node);

-- info命令文件路径 : 支持info命令文件默认在 /usr/share/info/ 目录下;

 

info 页面格式分析 

-- File : 查询的页面的信息来自于哪个文件;

-- Node : 查询的页面属于哪个节点;

-- Next : 下一个节点的名称, 按 N 到下一个节点;

-- Up : 上一层节点, 按 U 回到上一层节点;

-- Prev : 前一个节点;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. File: info.info,  Node: Top,  Next: Getting Started,  Up: (dir)  
  2. # File 数据是哪个文件  
  3. # Node 代表页面属于哪个节点  
  4. # Next 下一个节点的名称  
  5. # Up 上一层节点  
  6.   
  7. Info: An Introduction # 节点说明  
  8. *********************  
  9.   
  10. The GNU Project distributes most of its on-line manuals in the "Info  
  11. format", which you read using an "Info reader".  You are probably using  
  12. an Info reader to read this now.  
  13.   
  14.    There are two primary Info readers: `info', a stand-alone program  
  15. designed just to read Info files, and the `info' package in GNU Emacs,  
  16. a general-purpose editor.  At present, only the Emacs reader supports  
  17. using a mouse.  
  18.   
  19.    If you are new to the Info reader and want to learn how to use it,  
  20. type the command `h' now.  It brings you to a programmed instruction  
  21. sequence.  
  22.   
  23.    To read about expert-level Info commands, type `n' twice.  This  
  24. brings you to `Info for Experts', skipping over the `Getting Started'  
  25. chapter.  
  26.   
  27. * Menu: # 按 Tab 键, 可以在下面的四个menu之间切换, 光标停在 * 上, 按 Enter 键进入对应页面  
  28.   
  29. * Getting Started::             Getting started using an Info reader.  
  30. * Expert Info::                 Info commands for experts.  
  31. * Creating an Info File::       How to make your own Info file.  
  32. * Index::                       An index of topics, commands, and variables.  


Menu菜单 

 

-- 切换菜单项 : 使用 Tab 键, 可以切换 Menu项;

-- 菜单跳转 : 将光标移动到 Menu 菜单的 * 或者 文字上, 按 Enter 键, 就可以跳转到该项;

 

info操作 

-- 翻页 : 空格 (向下翻页), Page Down (向下翻页), Page Up (向上翻页);

-- Menu操作 : Tab (菜单项切换), Enter (进入节点);

-- 光标跳转 : B (光标 -> 开头), E (光标 -> 结尾);

-- 节点跳转 : N (跳转到下一个节点), P (跳转到上一个节点), U (跳转到上一层节点);

-- 查询关键字 : 按 S 或者 / 键, 输入关键字, 在按 Enter 键, 光标就会定位到查询到关键字的地方;

-- 显示求助菜单 : H ;

-- 查询命令 : ? ;

-- 退出查询 : q ;

 

 

11. 重要的热键

 

Tab键 

-- 列出文件命令列表 : 打出一半文件与命令, 按 两次 Tab 键, 就会列出相关的文件;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 ~]# vim .vim  
  2. .viminfo  .vimrc    

-- 命令补齐 : 输入命令一半, 按Tab键, 会将命令补齐;

 

-- 文件名称补齐 : 输入文件名一半, 按Tab键, 会将文件名补齐;

 

Ctrl + C键 : 终端目前程序操作;

 

Ctrl + D键 : 键盘输入结束符, 用于结束文件 和 输入, 相当于 exit 命 和 EOF文件结束符; 

 

 

12. Linux系统关机

 

关机前执行的操作 

-- 查看使用状态 : 使用 who 命令, 查看哪些用户在使用系统;

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 ~]# who  
  2. root     pts/0        2014-03-16 12:04 (114.66.200.219)  
  3. root     pts/1        2014-03-16 16:09 (114.66.200.219)  

-- 查看网络状态 : 使用 netstat -a 命令, 查看网络状况;

 

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 ~]# netstat -a  
  2. Active Internet connections (servers and established)  
  3. Proto Recv-Q Send-Q Local Address               Foreign Address             State        
  4. tcp        0      0 localhost:8005              *:*                         LISTEN        
  5. tcp        0      0 localhost:cslistener        *:*                         LISTEN        
  6. tcp        0      0 *:8009                      *:*                         LISTEN        
  7. tcp        0      0 *:mysql                     *:*                         LISTEN        
  8. tcp        0      0 *:http                      *:*                         LISTEN        
  9. tcp        0      0 *:webcache                  *:*                         LISTEN        
  10. tcp        0      0 *:hosts2-ns                 *:*                         LISTEN        
  11. tcp        0      0 *:tproxy                    *:*                         LISTEN        
  12. tcp        0      0 *:us-cli                    *:*                         LISTEN        
  13. tcp        0      0 *:8085                      *:*                         LISTEN        
  14. tcp        0      0 *:ftp                       *:*                         LISTEN        
  15. tcp        0      0 *:ssh                       *:*                         LISTEN        
  16. tcp        0      0 *:8086                      *:*                         LISTEN        
  17. tcp        0      0 *:8087                      *:*                         LISTEN        
  18. tcp        0      0 ip28.hichina.com:19052      hg-in-f82.1e100.net:https   TIME_WAIT     

-- 查看后台执行程序状况 : 使用 ps -aux 命令;

 

 

[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. [root@ip28 ~]# ps -aux  
  2. Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ  
  3. USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND  
  4. root         1  0.0  0.0  10348   160 ?        Ss    2013   0:05 init [3]                                                     
  5. root         2  0.0  0.0      0     0 ?        S<    2013   0:00 [migration/0]  
  6. root         3  0.0  0.0      0     0 ?        SN    2013   0:00 [ksoftirqd/0]  
  7. root         4  0.0  0.0      0     0 ?        S<    2013   0:00 [watchdog/0]  
  8. root         5  0.0  0.0      0     0 ?        S<    2013   0:20 [events/0]  
  9. root         6  0.0  0.0      0     0 ?        S<    2013   0:00 [khelper]  
  10. root        15  0.0  0.0      0     0 ?        S<    2013   0:12 [kthread]  
  11. root        19  0.0  0.0      0     0 ?        S<    2013   0:01 [kblockd/0]  
  12. root        20  0.0  0.0      0     0 ?        S<    2013   0:00 [kacpid]  
  13. root        64  0.0  0.0      0     0 ?        S<    2013   0:00 [cqueue/0]  


 

 

数据同步写入磁盘 : sync 命令, 将内存中的数据写入磁盘中;

-- 使用前提 : Linux中的数据, 在读写的时候都先在内存中存放, 到达一定条件才会将数据从内存中写入磁盘;

-- 使用场景 : U盘拔出前, 关机 重启之前;

 

shutdown命令作用 

-- 选择关机模式 : 可以选择 关机 , 重启 还是 进入单用户模式;

-- 设置关机时间 : 可以按照时间 延迟 设置关机时间;

-- 设置关机消息 : 将关机的信息显示给在线的用户;

-- 发出警告信息 : 使用关机命令可以向在线用户发出信息这个属性, 可以向用户发出一些信息, 并不是要真正关机;

-- 是否检查文件 : 选择是否要用 fsck 检查文件系统;

 

shutdown命令参数解析 

-- "-t" : 后面加上秒数, 过多少秒关机;

-- "-k" : 发出警告, 不是真的关机;

-- "-r" : 关机后重启;

-- "-h" : 立即关机;

-- "-n" : 不使用 init 程序, 直接关机;

-- "-f" : 关机并开机后, 掠过 fsck 磁盘检查;

-- "-F" : 重启后执行 fsck 磁盘检查;

-- "-c" : 取消 shutdown 命令;

 

关机命令示例 

-- 立即关机 : shutdown -h now ;

-- 定时关机 : shutdown -h 20:00 ;

-- 延时关机 : shutdown -h +10, 10分钟后关机;

-- 立即重启 : shudown -r now;

-- 重启提示 : shutdown -r +30 'The system is reboot after 30 minutes !' , 30分钟后关重启, 并将重启信息发送给所有在线用户;

-- 发出警告 : shutdown -k now 'Fuck !', 现在发出警告, 不关机;

 

其它命令 

-- 关机 : halt , poweroff 都是关机命令;

-- 通过改变运行等级关机 : init 0, 也可以进行关机;

-- 重启 : reboot;

-- 通过改变运行等级重启 : init 6 ;

 

.

作者 : 万境绝尘

转载请注明出处 http://blog.csdn.net/shulianghan/article/details/21056029

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics