1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【Linux 操作系统】Ubuntu 基础操作 基础命令 热键 man手册使用 关机 重启等命令使用

【Linux 操作系统】Ubuntu 基础操作 基础命令 热键 man手册使用 关机 重启等命令使用

时间:2019-02-23 05:13:06

相关推荐

【Linux 操作系统】Ubuntu 基础操作 基础命令 热键 man手册使用 关机 重启等命令使用

.

作者:万境绝尘

转载请注明出处:/shulianghan/article/details/21056029

.

1. Linux运行等级介绍

Linux运行等级:

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

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

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

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

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

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

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

运行等级相关命令操作:

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

[root@ip28 bin]# runlevel N 3

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

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

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

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

# inittab This file describes how the INIT process should set up#the system in a certain run-level.## Author: Miquel van Smoorenburg, <miquels@drinkel.>#Modified for RHS Linux by Marc Ewing and Donnie Barnes## Default runlevel. The runlevels used by RHS are:# 0 - halt (Do NOT set initdefault to this)# 1 - Single user mode# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)# 3 - Full multiuser mode# 4 - unused# 5 - X11# 6 - reboot (Do NOT set initdefault to this)# id:3:initdefault:# System initialization.si::sysinit:/etc/rc.d/rc.sysinitl0:0:wait:/etc/rc.d/rc 0l1:1:wait:/etc/rc.d/rc 1l2:2:wait:/etc/rc.d/rc 2l3:3:wait:/etc/rc.d/rc 3l4:4:wait:/etc/rc.d/rc 4l5:5:wait:/etc/rc.d/rc 5l6:6:wait:/etc/rc.d/rc 6# Trap CTRL-ALT-DELETEca::ctrlaltdel:/sbin/shutdown -t3 -r now# When our UPS tells us power has failed, assume we have a few minutes# of power left. Schedule a shutdown for 2 minutes from now.# This does, of course, assume you have powerd installed and your# UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"# If power was restored before the shutdown kicked in, cancel it.pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty2#3:2345:respawn:/sbin/mingetty tty3#4:2345:respawn:/sbin/mingetty tty4#5:2345:respawn:/sbin/mingetty tty5#6:2345:respawn:/sbin/mingetty tty6# Run xdm in runlevel 5x: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 命令即可登陆, 在之后提示的地方输入密码 :

octopus@octopus-Vostro-270s:~$ ssh root@115.28.42.124root@115.28.42.124's password: Last login: Fri Mar 14 10:39:09 from 124.42.2.242Welcome to aliyun Elastic Compute Service![root@ip28 ~]#

(2) 配置无密钥登陆

1> 本地操作

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

octopus@octopus-Vostro-270s:~$ ssh-keygen Generating public/private rsa key pair.Enter file in which to save the key (/home/octopus/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/octopus/.ssh/id_rsa.Your public key has been saved in /home/octopus/.ssh/id_rsa.pub.The key fingerprint is:6e:06:49:bd:c5:7c:3f:8c:8d:10:a5:2a:85:59:86:4e octopus@octopus-Vostro-270sThe key's randomart image is:+--[ RSA 2048]----+| .o ... ||E* o o||o+ o * . ||..o + o * ||+ S o = || + . || + || o || |+-----------------+

创建配置文件:

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

--配置文件内容:

Host aliHostName 115.28.42.124User rootPort 22

2> 服务器端操作

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

[root@ip28 .ssh]# lsid_rsa.pub[root@ip28 .ssh]# mv id_rsa.pub authorized_keys[root@ip28 .ssh]# lsauthorized_keys

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

RSAAuthentication yesPubkeyAuthentication yesIdentityFile .ssh/authorized_keys

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

[root@ip28 .ssh]# service sshd restartStopping sshd:[ OK ]Starting sshd:[ OK ]

3> 验证无密钥登陆

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

octopus@octopus-Vostro-270s:~$ ssh aliLast login: Fri Mar 14 10:54:12 from 124.42.2.242Welcome to aliyun Elastic Compute Service![root@ip28 ~]#

7. Ubuntu 13.10 下 eclipse 菜单栏失效

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

env UBUNTU_MENUPROXY= /home/octopus/eclipse/eclipse

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

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

8. Linux基础操作

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

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

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

[root@ip28 bin]# echo $LANGzh_CN.UTF-8[root@ip28 bin]# LANG=en_US.UTF-8[root@ip28 bin]# echo $LANGen_US.UTF-8

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

[root@ip28 bin]# dateSun Mar 16 01:52:04 CST

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

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

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

[root@ip28 bin]# date +%Y-%m-%d-%H:%M-03-16-02:02[root@ip28 bin]# date +%Y-%m-%d/%H:%M-03-16/02:02

显示日历:

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

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

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

[root@ip28 bin]# calMarch Su Mo Tu We Th Fr Sa12 3 4 5 6 7 89 10 11 12 13 14 1516 17 18 19 20 21 2223 24 25 26 27 28 2930 31[root@ip28 bin]# cal JanuaryFebruary March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa1 2 3 4 1 15 6 7 8 9 10 11 2 3 4 5 6 7 8 2 3 4 5 6 7 812 13 14 15 16 17 18 9 10 11 12 13 14 15 9 10 11 12 13 14 1519 20 21 22 23 24 25 16 17 18 19 20 21 22 16 17 18 19 20 21 2226 27 28 29 30 3123 24 25 26 27 2823 24 25 26 27 28 2930 31April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa1 2 3 4 51 2 3 1 2 3 4 5 6 76 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 1413 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 2120 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 2827 28 29 30 25 26 27 28 29 30 31 29 30July AugustSeptemberSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa1 2 3 4 5 1 2 1 2 3 4 5 66 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 1313 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 2727 28 29 30 31 24 25 26 27 28 29 30 28 29 3031OctoberNovemberDecember Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa1 2 3 4 1 1 2 3 4 5 65 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 1312 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 2726 27 28 29 30 3123 24 25 26 27 28 29 28 29 30 3130[root@ip28 bin]# cal 3 March Su Mo Tu We Th Fr Sa12 3 4 5 6 7 89 10 11 12 13 14 1516 17 18 19 20 21 2223 24 25 26 27 28 2930 31

9. man 手册使用

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

CAL(1)BSD General Commands Manual CAL(1)# 括号中的 1 代表 1 手册NAME # 命令名称 - 命令作用cal - displays a calendarSYNOPSIS # 命令基本语法cal [-smjy13] [[month] year]DESCRIPTION # 对 命令语法 中提到的参数进行详细的说明Cal displays a simple calendar. If arguments are not specified, the current month is displayed. Theoptions are as follows:-1Display single month output. (This is the default.)-3Display prev/current/next month output.-sDisplay Sunday as the first day of the week. (This is the default.)-mDisplay Monday as the first day of the week.-jDisplay Julian dates (days one-based, numbered from January 1).-yDisplay a calendar for the current year.A single parameter specifies(指定) the year (1 - 9999) to be displayed; note the year must be fully specified:“cal 89” will not display a calendar for 1989. Two parameters denote the month (1 - 12) and year. If noparameters are specified, the current month’s calendar is displayed.A year starts on Jan 1.The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd of September. By this time, mostcountries had recognized the reformation (although a few did not recognize it until the early 1900’s.) Tendays following that date were eliminated by the reformation, so the calendar for that month is a bitunusual.HISTORY # 命令历史A cal command appeared in Version 6 AT&T UNIX.OTHER VERSIONS # 其它 UNIX 版本中命令介绍Several much more elaborate versions of this program exist, with support for colors, holidays, birthdays,reminders and appointments, etc. For example, try the cal from /~cbag-well/projects.html or GNU gcal.BSDJune 6, 1993BSD

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 目录中;

[root@ip28 etc]# cd /usr/share/man/[root@ip28 man]# lsbg el fr hu it.UTF-8 man1x man3x man5x man7x man9x pl.ISO8859-2 ro skzh_TWcs en fr.ISO8859-1 id ja man2 man4 man6 man8 mann pl.UTF-8ru slda es fr.UTF-8it ko man2x man4x man6x man8x nlpt ru.KOI8-R trde fi hr it.ISO8859-1 man1man3 man5 man7 man9 plpt_BR ru.UTF-8 zh_CN

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

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

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

[root@ip28 man]# man -f manman (1) - format and display the on-line manual pagesman (rpm) - A set of documentation tools: man, apropos and whatis.man [manpath] (1) - format and display the on-line manual pagesman.config [man](5) - configuration data for man

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

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

[root@ip28 man]# man -k printfcurl_maprintf [curl_mprintf] (3) - formatted output conversioncurl_mfprintf [curl_mprintf] (3) - formatted output conversioncurl_mprintf (3) - formatted output conversioncurl_msnprintf [curl_mprintf] (3) - formatted output conversioncurl_msprintf curl_mvaprintf [curl_mprintf] (3) - formatted output conversioncurl_mvfprintf [curl_mprintf] (3) - formatted output conversioncurl_mvprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsnprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsprintf [curl_mprintf] (3) - formatted output conversionevbuffer_add_printf [event] (3) - execute a function when a specific event occursevbuffer_add_vprintf [event] (3) - execute a function when a specific event occursprintf(1) - format and print dataprintf [builtins] (1) - bash built-in commands, see bash(1)

man的简写方法:

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

[root@ip28 man]# whatis manman (1) - format and display the on-line manual pagesman (rpm) - A set of documentation tools: man, apropos and whatis.man [manpath] (1) - format and display the on-line manual pagesman.config [man](5) - configuration data for man

[root@ip28 man]# man -f manman (1) - format and display the on-line manual pagesman (rpm) - A set of documentation tools: man, apropos and whatis.man [manpath] (1) - format and display the on-line manual pagesman.config [man](5) - configuration data for man

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

[root@ip28 man]# apropos printfcurl_maprintf [curl_mprintf] (3) - formatted output conversioncurl_mfprintf [curl_mprintf] (3) - formatted output conversioncurl_mprintf (3) - formatted output conversioncurl_msnprintf [curl_mprintf] (3) - formatted output conversioncurl_msprintf curl_mvaprintf [curl_mprintf] (3) - formatted output conversioncurl_mvfprintf [curl_mprintf] (3) - formatted output conversioncurl_mvprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsnprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsprintf [curl_mprintf] (3) - formatted output conversionevbuffer_add_printf [event] (3) - execute a function when a specific event occursevbuffer_add_vprintf [event] (3) - execute a function when a specific event occursprintf(1) - format and print dataprintf [builtins] (1) - bash built-in commands, see bash(1)

[root@ip28 man]# man -k printfcurl_maprintf [curl_mprintf] (3) - formatted output conversioncurl_mfprintf [curl_mprintf] (3) - formatted output conversioncurl_mprintf (3) - formatted output conversioncurl_msnprintf [curl_mprintf] (3) - formatted output conversioncurl_msprintf curl_mvaprintf [curl_mprintf] (3) - formatted output conversioncurl_mvfprintf [curl_mprintf] (3) - formatted output conversioncurl_mvprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsnprintf [curl_mprintf] (3) - formatted output conversioncurl_mvsprintf [curl_mprintf] (3) - formatted output conversionevbuffer_add_printf [event] (3) - execute a function when a specific event occursevbuffer_add_vprintf [event] (3) - execute a function when a specific event occursprintf(1) - format and print dataprintf [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: 前一个节点;

File: info.info, Node: Top, Next: Getting Started, Up: (dir)# File 数据是哪个文件# Node 代表页面属于哪个节点# Next 下一个节点的名称# Up 上一层节点Info: An Introduction # 节点说明*********************The GNU Project distributes most of its on-line manuals in the "Infoformat", which you read using an "Info reader". You are probably usingan Info reader to read this now.There are two primary Info readers: `info', a stand-alone programdesigned just to read Info files, and the `info' package in GNU Emacs,a general-purpose editor. At present, only the Emacs reader supportsusing a mouse.If you are new to the Info reader and want to learn how to use it,type the command `h' now. It brings you to a programmed instructionsequence.To read about expert-level Info commands, type `n' twice. Thisbrings you to `Info for Experts', skipping over the `Getting Started'chapter.* Menu: # 按 Tab 键, 可以在下面的四个menu之间切换, 光标停在 * 上, 按 Enter 键进入对应页面* Getting Started:: Getting started using an Info reader.* Expert Info:: Info commands for experts.* Creating an Info File:: How to make your own Info file.* 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 键, 就会列出相关的文件;

[root@ip28 ~]# vim .vim.viminfo .vimrc

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

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

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

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

12. Linux系统关机

关机前执行的操作:

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

[root@ip28 ~]# whorootpts/0 -03-16 12:04 (114.66.200.219)rootpts/1 -03-16 16:09 (114.66.200.219)

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

[root@ip28 ~]# netstat -aActive Internet connections (servers and established)Proto Recv-Q Send-Q Local AddressForeign Address Statetcp 00 localhost:8005 *:*LISTENtcp 00 localhost:cslistener *:*LISTENtcp 00 *:8009 *:*LISTENtcp 00 *:mysql *:*LISTENtcp 00 *:http *:*LISTENtcp 00 *:webcache *:*LISTENtcp 00 *:hosts2-ns *:*LISTENtcp 00 *:tproxy*:*LISTENtcp 00 *:us-cli*:*LISTENtcp 00 *:8085 *:*LISTENtcp 00 *:ftp *:*LISTENtcp 00 *:ssh *:*LISTENtcp 00 *:8086 *:*LISTENtcp 00 *:8087 *:*LISTENtcp 00 :19052hg-in-:https TIME_WAIT

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

[root@ip28 ~]# ps -auxWarning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQUSER PID %CPU %MEM VSZ RSS TTYSTAT START TIME COMMANDroot 1 0.0 0.0 10348 160 ? Ss 0:05 init [3] root 2 0.0 0.000 ? S< 0:00 [migration/0]root 3 0.0 0.000 ? SN 0:00 [ksoftirqd/0]root 4 0.0 0.000 ? S< 0:00 [watchdog/0]root 5 0.0 0.000 ? S< 0:20 [events/0]root 6 0.0 0.000 ? S< 0:00 [khelper]root 15 0.0 0.000 ? S< 0:12 [kthread]root 19 0.0 0.000 ? S< 0:01 [kblockd/0]root 20 0.0 0.000 ? S< 0:00 [kacpid]root 64 0.0 0.000 ? S< 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 ;

.

作者:万境绝尘

转载请注明出处:/shulianghan/article/details/21056029

.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。