Linux硬件资源管理

  PCI设备

  1.         显卡
                $>>dmesg |grep -i vga
    [    0.000000] Console: colour VGA+ 80x25
    [    0.262267] vgaarb: device added: PCI:0000:00:0f.0,decodes=io+mem,owns=io+mem,locks=none
    [    0.262271] vgaarb: loaded
    [    0.262272] vgaarb: bridge control possible 0000:00:0f.0
    [    1.969021] fbcon: svgadrmfb (fb0) is primary device
            网卡
                $>>lscpi |grep -i eth
    02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
            声卡
                $>>lspci |grep -i vga
    00:0f.0 VGA compatible controller: VMware SVGA II Adapter

  CPU信息

      通过/proc文件系统查看  $>> cat /proc/cpuinfo

  1. processor : 0
  2. vendor_id : GenuineIntel
  3. cpu family : 6
  4. model : 94
  5. model name : Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  6. stepping : 3
  7. microcode : 0x6a
  8. cpu MHz : 2601.000
  9. cache size : 6144 KB
  10. physical id : 0
  11. siblings : 1
  12. core id : 0
  13. cpu cores : 1
  14. apicid : 0
  15. initial apicid : 0
  16. fpu : yes
  17. fpu_exception : yes
  18. cpuid level : 22
  19. wp : yes
  20. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2
  21.  
  22. ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf
  23.  
  24. eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand
  25.  
  26. hypervisor lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp fsgsbase
  27.  
  28. tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt
  29. bogomips : 5202.00
  30. clflush size : 64
  31. cache_alignment : 64
  32. address sizes : 42 bits physical, 48 bits virtual
  33. power management:

  内存信息
          $>>free -m 或 cat /proc/meminfo

  1. total used free shared buff/cache available
  2. Mem: 1824 713 300 10 810 912
  3. Swap: 2047 0 2047
  4. total //内存总数
  5. used //已经使用的内存数
  6. free //空闲的内存数
  7. shared //多个进程共享的内存总额
  8. page cache //磁盘缓存的大小

 磁盘分区信息

  $>>fdisk -l         //分区情况
       $>>df -h         //大小情况
       $>>du -h         //使用情况

  1. [root@ ~]# fdisk -l
  2. Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
  3. Units = sectors of 1 * 512 = 512 bytes
  4. Sector size (logical/physical): 512 bytes / 512 bytes
  5. I/O size (minimum/optimal): 512 bytes / 512 bytes
  6. Disk label type: dos
  7. Disk identifier: 0x000ab2c2
  8. Device Boot Start End Blocks Id System
  9. /dev/sda1 * 2048 1026047 512000 83 Linux
  10. /dev/sda2 1026048 41943039 20458496 8e Linux LVM
  11. Disk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectors
  12. Units = sectors of 1 * 512 = 512 bytes
  13. Sector size (logical/physical): 512 bytes / 512 bytes
  14. I/O size (minimum/optimal): 512 bytes / 512 bytes
  15. Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
  16. Units = sectors of 1 * 512 = 512 bytes
  17. Sector size (logical/physical): 512 bytes / 512 bytes
  18. I/O size (minimum/optimal): 512 bytes / 512 bytes
  19. [root@ ~]# df -h
  20. Filesystem Size Used Avail Use% Mounted on
  21. /dev/mapper/centos-root 18G 4.2G 14G 24% /
  22. devtmpfs 898M 0 898M 0% /dev
  23. tmpfs 913M 100K 913M 1% /dev/shm
  24. tmpfs 913M 9.0M 904M 1% /run
  25. tmpfs 913M 0 913M 0% /sys/fs/cgroup
  26. /dev/sda1 497M 157M 341M 32% /boot
  27. tmpfs 183M 20K 183M 1% /run/user/1000
  28. tmpfs 183M 0 183M 0% /run/user/0

外部设备使用
        在Linux系统中硬件设备都以文件的形式存在;不同的硬件设备具有不同的文件类型;设备文件在/dev目录下

  1. [root@ ~]# cd /dev/
  2. [root@ dev]# ls
  3. agpgart crash initctl mqueue rfkill stdin tty18 tty3 tty41 tty53 tty8 vcs1
  4.  
  5. vfio
  6. autofs disk input net rtc stdout tty19 tty30 tty42 tty54 tty9 vcs2
  7.  
  8. vga_arbiter
  9. block dm-0 kmsg network_latency rtc0 tty tty2 tty31 tty43 tty55 ttyS0 vcs3
  10.  
  11. vhost-net
  12. bsg dm-1 log network_throughput sda tty0 tty20 tty32 tty44 tty56 ttyS1 vcs4
  13.  
  14. vmci
  15. btrfs-control dmmidi loop-control null sda1 tty1 tty21 tty33 tty45 tty57 ttyS2 vcs5
  16.  
  17. vsock
  18. bus dri lp0 nvram sda2 tty10 tty22 tty34 tty46 tty58 ttyS3 vcs6
  19.  
  20. zero
  21. cdrom fb0 lp1 oldmem sg0 tty11 tty23 tty35 tty47 tty59 uhid vcsa
  22. centos fd lp2 port sg1 tty12 tty24 tty36 tty48 tty6 uinput
  23.  
  24. vcsa1
  25. char full lp3 ppp shm tty13 tty25 tty37 tty49 tty60 urandom
  26.  
  27. vcsa2
  28. console fuse mapper ptmx snapshot tty14 tty26 tty38 tty5 tty61 usbmon0
  29.  
  30. vcsa3
  31. core hidraw0 mcelog pts snd tty15 tty27 tty39 tty50 tty62 usbmon1
  32.  
  33. vcsa4
  34. cpu hpet mem random sr0 tty16 tty28 tty4 tty51 tty63 usbmon2
  35.  
  36. vcsa5
  37. cpu_dma_latency hugepages midi raw stderr tty17 tty29 tty40 tty52 tty7 vcs
  38.  
  39. vcsa6

系统运行机制

  系统启动过程
          开机自检->MBR引导->GRUB菜单->加载内核->init进程初始化->登录系统

  系统运行级别
            $>>cat /etc/inittab

  1. # 0 - halt (Do NOT set initdefault to this) //关机
  2. # 1 - Single user mode //单用户模式
  3. # 2 - Multiuser, without NFS (The same as 3, if you do not have networking)//无网络支持的多用户模式
  4. # 3 - Full multiuser mode //有网络支持的多用户模式
  5. # 4 - unused //保留,未使用
  6. # 5 - X11 //有网络支持的X-Windows支持的多用户模式
  7. # 6 - reboot (Do NOT set initdefault to this) //重新引导,重启
  8. #
  9. id:5:initdefault:
  10. eg:切换到第3运行级别
  11. $>>systemctl isolate multi-user.target systemctl isolate runlevel3.target
  12. eg:切换到第5运行级别
  13. $>>systemctl isolate graphical.target systemctl isolate runlevel5.target
  14. eg:设置默认第三启动级别
  15. $>>systemctl set-default multi-user.target
  16. $>>systemctl get-default //查看当前运行启动级别
  17. eg:设置默认第五启动级别
  18. $>>systemctl set-default graphical.target

系统用户管理

  用户账号分类

  用户账号密码配置文件

/etc/passwd 每个字段的作用
root:x:0:0:root:/root:/bin/bash        
用户名:密码占位符:UID:GID:用户描述:用户主目录:登录后使用的shell

系统中的伪用户
        Linux中任何一个命令的操作都必须有一个用户的身份。伪用户一般和系统或者程序服务相关
bin,daemon,shutdown,halt,linux默认都有这些伪用户,伪用户通常不需要或无法登陆系统,可以没有宿主目录
        eg:/etc/passwd文件中常见的伪用户Nobody

  添加系统用户

  1. [root@ dev]# useradd
  2. -d, --home-dir HOME_DIR home directory of the new account //目录,创建用户时指定用户主目录
  3. -g, --gid GROUP name or ID of the primary group of the new account//用户组,指定用户所属组
  4. -G, --groups GROUPS list of supplementary groups of the new account//用户组,指定用户所属的附加组
  5. faillog databases
  6. -m, --create-home create the user's home directory //不创建用户宿主目录
  7. -s, --shell SHELL login shell of the new account //指定用户的登录shell
  8. -u, --uid UID user ID of the new account //指定用户号
  9. eg:创建一个用户名称为sam,指定宿主目录为/opt/sam,登录的shell为/bin/sh.
  10. [root@ dev]# useradd -d /opt/sam -s /bin/sh sam
  11. [root@ dev]# tail -1 /etc/passwd
  12. sam:x:1001:1001::/opt/sam:/bin/sh
  13.  
  14. eg:创建一个用户名为test,UID为2010,指定起始组为root,附加组为ftp,登录shell为/bin/sh
  15. [root@ dev]# useradd -u 2010 -g root -G ftp -s /bin/sh test
  16. [root@ dev]# tail -1 /etc/passwd
  17. test:x:2010:0::/home/test:/bin/sh
  18. 注:当所创建用户无法正常显示时!将/etc/skel/下的所有文件拷贝到新建用户的宿主目录下
  19. [root@ skel]# cd /etc/skel/
  20. [root@ skel]# ls
  21. [root@ skel]# ls -a
  22. . .. .bash_logout .bash_profile .bashrc .mozilla
  23. [root@ skel]# ls -a /opt/sam/
  24. . .. .bash_logout .bash_profile .bashrc .mozilla

      删除用户
          如果一个用户的账号不再使用,可以从系统中删除,删除用户账号就是要/etc/passwd等系统文件中的该用户记录删除,必要时删除用户宿主目录

  1. [root@ skel]# userdel
  2. -r, --remove remove home directory and mail spool //把用户的主目录一起删除
  3. eg:删除用户sam
  4. [root@ skel]# userdel sam
  5. [root@ skel]# tail -1 /etc/passwd
  6. test:x:2010:0::/home/test:/bin/sh
  7. [root@ skel]# ls /opt/ //不加-r ,其主目录还是存在
  8. rh sam
  9. eg:删除用户test,并删除宿主目录
  10. [root@ skel]# userdel -r test
  11. [root@ skel]# tail -1 /etc/passwd
  12. enmoedu:x:1000:1000:enmoedu:/home/enmoedu:/bin/bash
  13. [root@ skel]# ls /home/
  14. enmoedu

      修改用户信息
        根据实际情况更改用户的相关属性,如用户号、主目录、用户组等,跟useradd差不多

  1. [root@ skel]# usermod
  2. -d, --home HOME_DIR new home directory for the user account
  3. -g, --gid GROUP force use GROUP as new primary group
  4. -G, --groups GROUPS new list of supplementary GROUPS
  5. -a, --append append the user to the supplemental GROUPS
  6. -s, --shell SHELL new login shell for the user account
  7. -u, --uid UID new UID for the user account

  用户密码管理

  1. eg:交互式配置用户密码
  2. [root@ skel]# useradd sam
  3. Creating mailbox file: File exists
  4. [root@ skel]# passwd sam
  5. Changing password for user sam.
  6. New password:
  7. BAD PASSWORD: The password is shorter than 8 characters
  8. Retype new password:
  9. passwd: all authentication tokens updated successfully.
  10. eg:无交互式配置用户密码
  11. [root@ skel]# echo 123456 | passwd --stdin sam
  12. Changing password for user sam.
  13. passwd: all authentication tokens updated successfully.

  密码配置文件

  1. /etc/shadow
  2. [root@ skel]# cat /etc/shadow|grep root
  3. root:$6$hvU.3oadtx9DHSDw
  4.  
  5. $Qq27h05p4y2KlIa5BTeu0y7U3plXmPQJqBCQWwvsi1E6hJ27JflijHHnLTH/HyDgacxip76PoAFJ.G7mKyLRj/::0:99999:7:::

Linux硬件资源管理与外设设备使用、系统运行机制及用户管理的更多相关文章

  1. Linux-PAM(Linux下的密碼認證和安全机制)系統管理員指南(中文版)

    he Linux-PAM 系统管理员指南作者:Andrew G. Morgan, morgan@linux.kernel.org翻译:孙国清(Thomas Sun),thomassun@yeah.ne ...

  2. 从零开始学Linux系统(五)用户管理和权限管理

    权限管理: 常识: chmod  U-所有者  g-所属组  O-其他人r-4-可读  w-2-可写  x-1-可执行  s-4-SetUID    s-2-SetGID    t-1-粘着位 注:目 ...

  3. Linux学习笔记(六)Linux常用命令:关机、重启以及系统运行级别

    一.shutdown命令 shutdown [选项] [时间] 常用选项 -c 取消前一个关机命令 -h 关机 -r 重启 shutdown命令关机或重启会保存当前系统正在使用的资源,因此关机或重启最 ...

  4. Linux学习--第十三天--日志、系统运行级别、grub加密

    日志 rsyslogd取代了syslogd. /var/log/cron #定时任务相关日志 /var/log/cups #打印信息相关日志 /var/log/dmesg #开机内核自检相关日志,dm ...

  5. NET快速信息化系统开发框架 V3.2 -> “用户管理”主界面使用多表头展示、增加打印功能

    RDIFrameowrk.NET 用户管理是使用非常频繁的模块,由于需要展示的字段比较多,以前的展示方式显得不是太规范,现3.2版本用户管理主界面进行了全新的设计,数据列表展示使用了Dev家族全新的G ...

  6. 我记录综合系统学习研究之用户管理五(如何利用wojilu打造一个全新的SNS应用)

    wojilu框架特别适合快速开发多用户分享内容应用,比如知乎,digg这类应用. 对于博客等用户程序,要有4个入口:1)用户展示入口(展示自己的应用) 2)用户后台管理入口(管理自己的应用) 3)聚合 ...

  7. malloc&&free的系统运行机制及其源代码的理解

    一.malloc()和free()的基本概念以及基本用法: 1.函数原型及说明: void *malloc(long NumBytes):该函数分配了NumBytes个字节,并返回了指向这块内存的指针 ...

  8. 深入GPU硬件架构及运行机制

    目录 一.导言 1.1 为何要了解GPU? 1.2 内容要点 1.3 带着问题阅读 二.GPU概述 2.1 GPU是什么? 2.2 GPU历史 2.2.1 NV GPU发展史 2.2.2 NV GPU ...

  9. 用户管理 之 Linux 用户(user)和用户组(group)管理概述

    一.理解Linux的单用户多任务,多用户多任务概念:Linux 是一个多用户.多任务的操作系统:我们应该了解单用户多任务和多用户多任务的概念: 1.Linux 的单用户多任务:单用户多任务:比如我们以 ...

随机推荐

  1. 【Python图像特征的音乐序列生成】关于图像特征的描述词

    查阅了很久的资料,决定依据Yoshida的<Image retrieval system using impression words>这篇论文里的词语来定义. Yoshida 等的 Ar ...

  2. [视觉识别]OpenCV + CNN 大神符识别

    数据集 Mnist数据集:http://yann.lecun.com/exdb/mnist/ 训练 import numpy as np from keras.datasets import mnis ...

  3. stixel world论文总结

    1.The Stixel World - A Compact Medium Level Representation of the 3D-World:http://pdfs.semanticschol ...

  4. Cordova 本地项目创建方法

    l  创建项目 需要在终端上输入:cordova create [目录][项目ID][APP名称] 运行:cordova create hello com.example.hello hello 将在 ...

  5. Node.js 中文学习资料和教程导航

    这篇文章来自 Github 上的一位开发者收集整理的 Node.js 中文学习资料和教程导航.Node 是一个服务器端 JavaScript 解释器,它将改变服务器应该如何工作的概念,它的目标是帮助程 ...

  6. Dede技巧

    解决DEDE图集上传图片时跳出302错误   本地上传图集的时候突然提示网页出错,还爆出302错误. 解决办法是在include/userlogin.class.php文件中的第二行session_s ...

  7. JVM内存模型与GC算法(简介)

    JVM内存模型如上图,需要声明一点,这是<Java虚拟机规范(Java SE 7版)>规定的内容,实际区域由各JVM自己实现,所以可能略有不同.以下对各区域进行简短说明. 1.1程序计数器 ...

  8. xmpp 协议详解

    XMPP(可扩展消息处理现场协议)是基于可扩展标记语言(XML)的协议,它用于即时消息(IM)以及在线现场探测.它在促进服务器之间的准即时操作.这个协议可能最终允许因特网用户向因特网上的其他任何人发送 ...

  9. js函数式编程(二)-柯里化

    这节开始讲的例子都使用简单的TS来写,尽量做到和es6差别不大,正文如下 我们在编程中必然需要用到一些变量存储数据,供今后其他地方调用.而函数式编程有一个要领就是最好不要依赖外部变量(当然允许通过参数 ...

  10. centos 7 忘记root 密码

    @@@@首先开启系统,出现下图界面以后,按e键. @@@使用下放下箭头找到图中的位置,在下图中 修改 ro 为 rw , 添加init=sysroot/bin/sh @@@按Ctrl + x 进入单用 ...