【一】Linux系统启动流程

【二】关于Linux开机与关机

# Default runlevel. The runlevels used 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:

runlevelActive

0系统关机

1单用户模式

2本地多用户模式(无法使用远程网络)

3网络多用户模式

4系统保留未定义

5带图形界面的网络多用户模式

6系统重启

init 命令:init + runlevel进行相应操作的切换

【三】Linux如何关闭和重启

Linux是一个多用户多任务的系统,关机时,需要注意一下事项:

(1)观察系统的使用状态,如谁在线,在线的用户在干什么(w)

(2)通知在线使用者关机的相关信息(可选)(wall,write)

(3)使用最安全的的关机方式(执行关机命令前执行sync将内存数据写入磁盘)

Linux系统安全关机的过程:

(1)执行sync命令将内存数据写入磁盘;

(2)关机命令下发,通知用户关机;

(3)停止系统的所有进程;

(4)卸载系统挂载的设备

【四】Linux系统关机常用命令

(1)halt:立刻关机

(2)poweroff:立刻关机

(3)shutdown -h now立刻关机(root用户使用)

(4)shutdown -h 10  10分钟后自动关闭

注:在使用shutdown命令设置重启的话,shutdown -c将取消重启

【五】Linux系统开机常用命令

(1)reboot

(2)shutdown -r now 立刻重启(root用户使用)

(3)shutdown -r 10过10分钟后重启

(4)shutdown -r 20:35在20:35时重新启动(root用户使用)

注:在使用shutdown命令设置重启的话,shutdown -c将取消重启

【六】系统信息和进程类命令命令说明

man获得命令的帮助手册,如:man cp;按q键退出

su切换用户,如su -   root;"-"表示改变用户的环境变量

who显示系统中登录的用户

w显示登录用户的详细信息

last查看最近登录系统的用户信息

date系统日期时间的设定,一般要结合参数-s使用

uname查看系统的版本 ,如uname -R

reboot重启计算机,如reboot;shutdown -r   now

shutdown关闭计算机;如:shutdown -h now 表示停止服务后再关闭

free查看内存和swap分区情况

ps显示进程信息,参数-ux为当前用户的进程;参数-aux为所有用户的进程,参数-ef为系统所有进程信息

uptime显示当前时间,系统开机运转时间,连接数,最近1,5,15分钟的系统负载。(1个CPU一般不超过0.8)

top查看系统CPU、内存等使用情况

kill删除某个进程,进程号可用ps命令获得,如kill - 9   121

vmstat查看虚拟内存的使用情况

nohup将进程在用户退出登录后仍旧继续执行

jobs查看被挂起或后台运行的进程

Ctrl + Z进程挂起

Ctrl + C进程终止

fg进程恢复到前台继续执行

bg进程恢复到后台继续执行

【七】涉及到的命令操作演示

【实战一】Linux开关机

【关机】

halt:系统关闭,电源仍然工作

poweroff:关闭电源 icpi

shutdown -h:调用poweroff,halt命令

shutdown -h 0

shutdonw -h now

【重启】

reboot

shutdown -r

shutdown -r 10

shutdown -r 20:45

(1)shutdown --help

Options:

-r                          reboot after shutdown

-h                          halt or power off after shutdown

-H                          halt after shutdown (implies -h)

-P                          power off after shutdown (implies -h)

-c                          cancel a running shutdown

-k                          only send warnings, don't shutdown

-q, --quiet                 reduce output to errors only

-v, --verbose               increase output to include informational messages

--help                  display this help and exit

--version               output version information and exit

(2)

[root@db01 /]#halt

Broadcast message from root@db01

(/dev/pts/0) at 14:27 ...

The system is going down for halt NOW!

(3)

shutdown -r now

Broadcast message from root@db01

(/dev/pts/0) at 14:35 ...

The system is going down for reboot NOW!

(4)

[root@db01 ~]#shutdown -h 20:30

Broadcast message from root@db01

(/dev/pts/0) at 14:36 ...

The system is going down for halt in 354 minutes!

(5)[root@db01 ~]#shutdown -c

^Hshutdown: Shutdown cancelled

(6)shutdown -k 1  "The system is going down  for maintenance in 1 minute"

Broadcast message from root@db01

(/dev/pts/0) at 14:40 ...

The system is going down for maintenance in 1 minute!

The system is going down  for maintenance in 1 minute

(7)shutdown -t 60 -h now  "The system is going down  for maintenance in 1 minute"

Broadcast message from root@db01

(/dev/pts/0) at 14:41 ...

The system is going down for halt NOW!

The system is going down  for maintenance in 1 minute

【实战二】Linux进程管理命令

常用命令:

w

(1)[root@db01 ~]# w

14:47:11 up 4 min,  1 user,  load average: 0.00, 0.02, 0.00

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT

root     pts/0    10.53.110.78     14:42    0.00s  0.05s  0.01s w

注:远程登录pts,本地登录tty

(2)[root@db01 ~]# w

14:50:10 up 7 min,  2 users,  load average: 0.00, 0.00, 0.00

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT

root     pts/0    10.53.110.78     14:42    0.00s  0.04s  0.00s w

root     pts/1    10.53.110.78     14:49    4.00s  0.02s  0.01s top

ps

ps -aux

(3)[root@db01 ~]# ps -aux|more

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root         1  0.2  0.0  19364  1532 ?        Ss   14:42   0:01 /sbin/init

root         2  0.0  0.0      0     0 ?        S    14:42   0:00 [kthreadd]

root         3  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

root         4  0.0  0.0      0     0 ?        S    14:42   0:00 [ksoftirqd/0]

(4)[root@db01 ~]# ps -aux --sort time|more##按照时间排序

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root         1  0.1  0.0  19364  1532 ?        Ss   14:42   0:01 /sbin/init

root         2  0.0  0.0      0     0 ?        S    14:42   0:00 [kthreadd]

root         3  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

root         4  0.0  0.0      0     0 ?        S    14:42   0:00 [ksoftirqd/0]

root         5  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

root         6  0.0  0.0      0     0 ?        S    14:42   0:00 [watchdog/0]

root         7  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/1]

root         8  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/1]

root         9  0.0  0.0      0     0 ?        S    14:42   0:00 [ksoftirqd/1]

(4)[root@db01 ~]# ps -aux --sort pid|more##按pid排序

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root         1  0.1  0.0  19364  1532 ?        Ss   14:42   0:01 /sbin/init

root         2  0.0  0.0      0     0 ?        S    14:42   0:00 [kthreadd]

root         3  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

root         4  0.0  0.0      0     0 ?        S    14:42   0:00 [ksoftirqd/0]

root         5  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

root         6  0.0  0.0      0     0 ?        S    14:42   0:00 [watchdog/0]

root         7  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/1]

【注】VSZ:使用虚拟内存大小

RSS:使用实际内存大小

TTY:终端类型

STAT:R:运行进程S:睡眠进程I:空闲基础Z:僵死进程D:不可中断进程T:终止进程P:交换进程

(5)[root@db01 ~]# ps -A|more##显示所有进程

PID TTY          TIME CMD

1 ?        00:00:01 init

2 ?        00:00:00 kthreadd

3 ?        00:00:00 migration/0

4 ?        00:00:00 ksoftirqd/0

5 ?        00:00:00 migration/0

6 ?        00:00:00 watchdog/0

7 ?        00:00:00 migration/1

8 ?        00:00:00 migration/1

9 ?        00:00:00 ksoftirqd/1

10 ?        00:00:00 watchdog/1

11 ?        00:00:00 events/0

(6)[root@db01 ~]# ps -u root |more##查看某个用户的进程

PID TTY          TIME CMD

1 ?        00:00:01 init

2 ?        00:00:00 kthreadd

3 ?        00:00:00 migration/0

4 ?        00:00:00 ksoftirqd/0

5 ?        00:00:00 migration/0

6 ?        00:00:00 watchdog/0

7 ?        00:00:00 migration/1

8 ?        00:00:00 migration/1

9 ?        00:00:00 ksoftirqd/1

10 ?        00:00:00 watchdog/1

(7)

[root@db01 ~]# ps -ef|more

UID        PID  PPID  C STIME TTY          TIME CMD

root         1     0  0 14:42 ?        00:00:01 /sbin/init

root         2     0  0 14:42 ?        00:00:00 [kthreadd]

root         3     2  0 14:42 ?        00:00:00 [migration/0]

root         4     2  0 14:42 ?        00:00:00 [ksoftirqd/0]

root         5     2  0 14:42 ?        00:00:00 [migration/0]

root         6     2  0 14:42 ?        00:00:00 [watchdog/0]

root         7     2  0 14:42 ?        00:00:00 [migration/1]

root         8     2  0 14:42 ?        00:00:00 [migration/1]

root         9     2  0 14:42 ?        00:00:00 [ksoftirqd/1]

root        10     2  0 14:42 ?        00:00:00 [watchdog/1]

UID:用户ID

PID:进程ID

PPID:父进程ID

C:0级,没有子进程

STIME:运行时间

TTY:终端类型

(8)

[root@db01 ~]# ps -ef|grep  sshd

root      1508     1  0 14:42 ?        00:00:00 /usr/sbin/sshd

root      1693  1508  0 14:42 ?        00:00:00 sshd: root@pts/1,pts/2

root      1884  1848  0 15:08 pts/2    00:00:00 grep sshd

(9)根据CPU和mem排序 (前5行)

[root@db01 ~]# ps -aux --sort -pcpu,-pmem|head -5

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root      1767  0.1  0.0  15036  1212 pts/1    S+   14:50   0:01 top

root         1  0.0  0.0  19364  1532 ?        Ss   14:42   0:01 /sbin/init

root         2  0.0  0.0      0     0 ?        S    14:42   0:00 [kthreadd]

root         3  0.0  0.0      0     0 ?        S    14:42   0:00 [migration/0]

(10)显示父进程和子进程

[root@db01 ~]# ps -C sshd#查看进程

PID TTY          TIME CMD

1508 ?        00:00:00 sshd

1693 ?        00:00:00 sshd

[root@db01 ~]# ps -p 1508 -L#查看进程有多少线程

PID   LWP TTY          TIME CMD

1508  1508 ?        00:00:00 sshd

[root@db01 ~]# ps --ppid 1693#查看进程的子进程

PID TTY          TIME CMD

1737 pts/1    00:00:00 bash

1848 pts/2    00:00:00 bash

kill命令

SYNOPSIS

kill [-s signal|-p] [--] pid...

kill -l [signal]

(1)kill的信号

[root@db01 ~]# kill -l

1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP

6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1

15) SIGTERM

[root@db01 ~]# ps -ef|grep top

root      2011  1984  0 15:20 pts/1    00:00:00 top

root      2015  1921  0 15:20 pts/0    00:00:00 grep top

[root@db01 ~]#

[root@db01 ~]#

[root@db01 ~]# kill -9  2011

[root@db01 ~]# ps -ef|grep top

root      2017  1921  0 15:21 pts/0    00:00:00 grep top

[root@db01 ~]#

【注】进程号为1不能kill,否则系统不能使用

nohup命令

(1)[root@db01 ~]# nohup vmstat 2>1 1.log #在后台运行

Ctrl + Z

jobs

Ctrl + C

linux 系统命令启动,Linux开关机及系统进程命令相关推荐

  1. Linux系统定时重启开关机如何设置?

    在Linux系统中,我们可以通过配置cron任务或者使用systemd服务来实现定时重启或者开关机的设置. 1. 使用cron任务实现定时重启或者开关机: Cron是一个在Linux系统中用于自动化任 ...

  2. Linux快照功能 文件操作 关机和重启命令 用户管理

    一.文件的基本操作的补充 1.创建文件夹 mkdir -p 递归创建 同时创建多个文件夹,创建文件夹及其子文件夹 mkdir -p ./demo/test 二.Linux快照功能 找到快照 拍摄快照保 ...

  3. linux 文件系统 启动,linux kernel文件系统启动部分

    现在的kernel里,有个叫做ramfs的文件系统,会把initrd(或者ramdisk,为惯性叫法)里的东西挂载到early-rootfs里(即rootfs,是ramfs的一个特殊实例),执行一些在 ...

  4. arm linux 内核启动,Linux(ARM)内核启动地址

    最近在网上看到一位网友写得一篇文章,写得很好,加深了对Linux启动的认识,特意贴在这里: 内核编译链接过程是依靠vmlinux.lds文件,以arm为例vmlinux.lds文件位于kernel/a ...

  5. linux系统命令打不出字,常用的命令 linux

    find / -amin -10 # 查找在系统中最后10分钟访问的文件 find / -atime -2 # 查找在系统中最后48小时访问的文件 find / -empty # 查找在系统中为空的文 ...

  6. linux下启动、添加或删除服务命令

    在Linux系统下,一个Services的启动.停止以及重启通常是通过/etc/init.d目录下的脚本来控制的.然而,在启动或改变运行级别时,是在/etc/rcX.d中来搜索脚本.其中X是运行级别的 ...

  7. Linux系统命令(一)软件下载安装命令:rpm、Yum、apt、apt-get、sudo、man、ssh服务、镜像源修改

    本文主要是收集了一些linux的软件下载安装命令 目录 一.rpm RPM(红帽软件包管理器),使用范围已不局限于红帽系统: 二.Yum 1   apt及apt-get(Ubuntu版本) 三.man ...

  8. linux系统命令pwd,linux系统下pwd命令用法详解

    linux中用 pwd 命令来查看"当前工作目录"的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录. 在不太确定当前位置时,就会使用pwd来判定当前目录在文 ...

  9. linux一键启动,Linux一键启动、停止、重启Tomcat sh脚本

    使用方式 sh service-tomcat.sh {start|stop|restart} {si|cas|fr|all} #使用过程总配置一下即可属性名字 #1.COMMANDPREFIX #2. ...

  10. 运维人员必备的Linux系统命令汇总

    运维人员必备的Linux系统命令汇总 线上查询及帮助命令 文件和目录操作 查看文件及内容处理 文件压缩及解压缩 信息显示 搜索文件 用户管理 基础网络操作 深入网络操作 有关磁盘与文件系统 系统权限及 ...

最新文章

  1. Discovery studio画蛋白质构象叠合图
  2. js弹出一段html,html js 弹出层
  3. elasticsearch批量修改,批量更新某个字段
  4. MakeFile 文件的作用
  5. B站回港受热捧——破圈下的资本新故事
  6. MATLAB求音频信号特征的自定义函数.md
  7. 回归统计在DMP中的实战应用
  8. [css] 说说你对sass的嵌套规则的理解?
  9. 就业阶段-java语言进价_day03
  10. 020 ceph作openstack的后端存储
  11. Java多线程学习十六:读写锁 ReadWriteLock 获取锁有哪些规则
  12. 如何选择数据可视化工具?
  13. python解析dom,关于Python解析xml dom的简单应用
  14. 验证码识别库 python_python 验证码识别库pytesseract的使用
  15. Linux下互斥量加锁与解锁操作的C代码实现
  16. extremecomponents-1.0.1.jar 的使用小例子
  17. WSO2 ESB 5.0.0 集群配置
  18. 001如何将灰度视频处理为伪彩色
  19. java实现ftp文件上传失败_用java+ftp实现文件上传的问题?
  20. 图数据库查询语言Cypher

热门文章

  1. 【转】for循环中进行Promise异步操作的问题总结
  2. CSS进阶(2)—— width,height如此高深,难道你真懂得
  3. 分布式锁的原理和实现详解
  4. iOS:详细的正则表达式
  5. Linux下出现command not found的解决办法
  6. iSCSI远程块存储配置实验
  7. nagios搭建和邮件短信报警设置
  8. 佐藤hiroko-爱拯救了我(步之物语)
  9. Web服务和Microsoft平台
  10. Spring Boot入门(4)-事务管理