Linux硬件资源管理与外设设备使用、系统运行机制及用户管理
Linux硬件资源管理
PCI设备
- 显卡
$>>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
- processor : 0
- vendor_id : GenuineIntel
- cpu family : 6
- model : 94
- model name : Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
- stepping : 3
- microcode : 0x6a
- cpu MHz : 2601.000
- cache size : 6144 KB
- physical id : 0
- siblings : 1
- core id : 0
- cpu cores : 1
- apicid : 0
- initial apicid : 0
- fpu : yes
- fpu_exception : yes
- cpuid level : 22
- wp : yes
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2
- ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf
- eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand
- hypervisor lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp fsgsbase
- tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt
- bogomips : 5202.00
- clflush size : 64
- cache_alignment : 64
- address sizes : 42 bits physical, 48 bits virtual
- power management:
内存信息
$>>free -m 或 cat /proc/meminfo
- total used free shared buff/cache available
- Mem: 1824 713 300 10 810 912
- Swap: 2047 0 2047
- total //内存总数
- used //已经使用的内存数
- free //空闲的内存数
- shared //多个进程共享的内存总额
- page cache //磁盘缓存的大小
磁盘分区信息
$>>fdisk -l //分区情况
$>>df -h //大小情况
$>>du -h //使用情况
- [root@ ~]# fdisk -l
- Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk label type: dos
- Disk identifier: 0x000ab2c2
- Device Boot Start End Blocks Id System
- /dev/sda1 * 2048 1026047 512000 83 Linux
- /dev/sda2 1026048 41943039 20458496 8e Linux LVM
- Disk /dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- [root@ ~]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/centos-root 18G 4.2G 14G 24% /
- devtmpfs 898M 0 898M 0% /dev
- tmpfs 913M 100K 913M 1% /dev/shm
- tmpfs 913M 9.0M 904M 1% /run
- tmpfs 913M 0 913M 0% /sys/fs/cgroup
- /dev/sda1 497M 157M 341M 32% /boot
- tmpfs 183M 20K 183M 1% /run/user/1000
- tmpfs 183M 0 183M 0% /run/user/0
外部设备使用
在Linux系统中硬件设备都以文件的形式存在;不同的硬件设备具有不同的文件类型;设备文件在/dev目录下
- [root@ ~]# cd /dev/
- [root@ dev]# ls
- agpgart crash initctl mqueue rfkill stdin tty18 tty3 tty41 tty53 tty8 vcs1
- vfio
- autofs disk input net rtc stdout tty19 tty30 tty42 tty54 tty9 vcs2
- vga_arbiter
- block dm-0 kmsg network_latency rtc0 tty tty2 tty31 tty43 tty55 ttyS0 vcs3
- vhost-net
- bsg dm-1 log network_throughput sda tty0 tty20 tty32 tty44 tty56 ttyS1 vcs4
- vmci
- btrfs-control dmmidi loop-control null sda1 tty1 tty21 tty33 tty45 tty57 ttyS2 vcs5
- vsock
- bus dri lp0 nvram sda2 tty10 tty22 tty34 tty46 tty58 ttyS3 vcs6
- zero
- cdrom fb0 lp1 oldmem sg0 tty11 tty23 tty35 tty47 tty59 uhid vcsa
- centos fd lp2 port sg1 tty12 tty24 tty36 tty48 tty6 uinput
- vcsa1
- char full lp3 ppp shm tty13 tty25 tty37 tty49 tty60 urandom
- vcsa2
- console fuse mapper ptmx snapshot tty14 tty26 tty38 tty5 tty61 usbmon0
- vcsa3
- core hidraw0 mcelog pts snd tty15 tty27 tty39 tty50 tty62 usbmon1
- vcsa4
- cpu hpet mem random sr0 tty16 tty28 tty4 tty51 tty63 usbmon2
- vcsa5
- cpu_dma_latency hugepages midi raw stderr tty17 tty29 tty40 tty52 tty7 vcs
- vcsa6
系统运行机制
系统启动过程
开机自检->MBR引导->GRUB菜单->加载内核->init进程初始化->登录系统
系统运行级别
$>>cat /etc/inittab
- # 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 //有网络支持的X-Windows支持的多用户模式
- # 6 - reboot (Do NOT set initdefault to this) //重新引导,重启
- #
- id:5:initdefault:
- eg:切换到第3运行级别
- $>>systemctl isolate multi-user.target 或 systemctl isolate runlevel3.target
- eg:切换到第5运行级别
- $>>systemctl isolate graphical.target 或 systemctl isolate runlevel5.target
- eg:设置默认第三启动级别
- $>>systemctl set-default multi-user.target
- $>>systemctl get-default //查看当前运行启动级别
- eg:设置默认第五启动级别
- $>>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
添加系统用户
- [root@ dev]# useradd
- -d, --home-dir HOME_DIR home directory of the new account //目录,创建用户时指定用户主目录
- -g, --gid GROUP name or ID of the primary group of the new account//用户组,指定用户所属组
- -G, --groups GROUPS list of supplementary groups of the new account//用户组,指定用户所属的附加组
- faillog databases
- -m, --create-home create the user's home directory //不创建用户宿主目录
- -s, --shell SHELL login shell of the new account //指定用户的登录shell
- -u, --uid UID user ID of the new account //指定用户号
- eg:创建一个用户名称为sam,指定宿主目录为/opt/sam,登录的shell为/bin/sh.
- [root@ dev]# useradd -d /opt/sam -s /bin/sh sam
- [root@ dev]# tail -1 /etc/passwd
- sam:x:1001:1001::/opt/sam:/bin/sh
- eg:创建一个用户名为test,UID为2010,指定起始组为root,附加组为ftp,登录shell为/bin/sh
- [root@ dev]# useradd -u 2010 -g root -G ftp -s /bin/sh test
- [root@ dev]# tail -1 /etc/passwd
- test:x:2010:0::/home/test:/bin/sh
- 注:当所创建用户无法正常显示时!将/etc/skel/下的所有文件拷贝到新建用户的宿主目录下
- [root@ skel]# cd /etc/skel/
- [root@ skel]# ls
- [root@ skel]# ls -a
- . .. .bash_logout .bash_profile .bashrc .mozilla
- [root@ skel]# ls -a /opt/sam/
- . .. .bash_logout .bash_profile .bashrc .mozilla
删除用户
如果一个用户的账号不再使用,可以从系统中删除,删除用户账号就是要/etc/passwd等系统文件中的该用户记录删除,必要时删除用户宿主目录
- [root@ skel]# userdel
- -r, --remove remove home directory and mail spool //把用户的主目录一起删除
- eg:删除用户sam
- [root@ skel]# userdel sam
- [root@ skel]# tail -1 /etc/passwd
- test:x:2010:0::/home/test:/bin/sh
- [root@ skel]# ls /opt/ //不加-r ,其主目录还是存在
- rh sam
- eg:删除用户test,并删除宿主目录
- [root@ skel]# userdel -r test
- [root@ skel]# tail -1 /etc/passwd
- enmoedu:x:1000:1000:enmoedu:/home/enmoedu:/bin/bash
- [root@ skel]# ls /home/
- enmoedu
修改用户信息
根据实际情况更改用户的相关属性,如用户号、主目录、用户组等,跟useradd差不多
- [root@ skel]# usermod
- -d, --home HOME_DIR new home directory for the user account
- -g, --gid GROUP force use GROUP as new primary group
- -G, --groups GROUPS new list of supplementary GROUPS
- -a, --append append the user to the supplemental GROUPS
- -s, --shell SHELL new login shell for the user account
- -u, --uid UID new UID for the user account
用户密码管理
- eg:交互式配置用户密码
- [root@ skel]# useradd sam
- Creating mailbox file: File exists
- [root@ skel]# passwd sam
- Changing password for user sam.
- New password:
- BAD PASSWORD: The password is shorter than 8 characters
- Retype new password:
- passwd: all authentication tokens updated successfully.
- eg:无交互式配置用户密码
- [root@ skel]# echo 123456 | passwd --stdin sam
- Changing password for user sam.
- passwd: all authentication tokens updated successfully.
密码配置文件
- /etc/shadow
- [root@ skel]# cat /etc/shadow|grep root
- root:$6$hvU.3oadtx9DHSDw
- $Qq27h05p4y2KlIa5BTeu0y7U3plXmPQJqBCQWwvsi1E6hJ27JflijHHnLTH/HyDgacxip76PoAFJ.G7mKyLRj/::0:99999:7:::
Linux硬件资源管理与外设设备使用、系统运行机制及用户管理的更多相关文章
- Linux-PAM(Linux下的密碼認證和安全机制)系統管理員指南(中文版)
he Linux-PAM 系统管理员指南作者:Andrew G. Morgan, morgan@linux.kernel.org翻译:孙国清(Thomas Sun),thomassun@yeah.ne ...
- 从零开始学Linux系统(五)用户管理和权限管理
权限管理: 常识: chmod U-所有者 g-所属组 O-其他人r-4-可读 w-2-可写 x-1-可执行 s-4-SetUID s-2-SetGID t-1-粘着位 注:目 ...
- Linux学习笔记(六)Linux常用命令:关机、重启以及系统运行级别
一.shutdown命令 shutdown [选项] [时间] 常用选项 -c 取消前一个关机命令 -h 关机 -r 重启 shutdown命令关机或重启会保存当前系统正在使用的资源,因此关机或重启最 ...
- Linux学习--第十三天--日志、系统运行级别、grub加密
日志 rsyslogd取代了syslogd. /var/log/cron #定时任务相关日志 /var/log/cups #打印信息相关日志 /var/log/dmesg #开机内核自检相关日志,dm ...
- NET快速信息化系统开发框架 V3.2 -> “用户管理”主界面使用多表头展示、增加打印功能
RDIFrameowrk.NET 用户管理是使用非常频繁的模块,由于需要展示的字段比较多,以前的展示方式显得不是太规范,现3.2版本用户管理主界面进行了全新的设计,数据列表展示使用了Dev家族全新的G ...
- 我记录综合系统学习研究之用户管理五(如何利用wojilu打造一个全新的SNS应用)
wojilu框架特别适合快速开发多用户分享内容应用,比如知乎,digg这类应用. 对于博客等用户程序,要有4个入口:1)用户展示入口(展示自己的应用) 2)用户后台管理入口(管理自己的应用) 3)聚合 ...
- malloc&&free的系统运行机制及其源代码的理解
一.malloc()和free()的基本概念以及基本用法: 1.函数原型及说明: void *malloc(long NumBytes):该函数分配了NumBytes个字节,并返回了指向这块内存的指针 ...
- 深入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 ...
- 用户管理 之 Linux 用户(user)和用户组(group)管理概述
一.理解Linux的单用户多任务,多用户多任务概念:Linux 是一个多用户.多任务的操作系统:我们应该了解单用户多任务和多用户多任务的概念: 1.Linux 的单用户多任务:单用户多任务:比如我们以 ...
随机推荐
- 【Python图像特征的音乐序列生成】关于图像特征的描述词
查阅了很久的资料,决定依据Yoshida的<Image retrieval system using impression words>这篇论文里的词语来定义. Yoshida 等的 Ar ...
- [视觉识别]OpenCV + CNN 大神符识别
数据集 Mnist数据集:http://yann.lecun.com/exdb/mnist/ 训练 import numpy as np from keras.datasets import mnis ...
- stixel world论文总结
1.The Stixel World - A Compact Medium Level Representation of the 3D-World:http://pdfs.semanticschol ...
- Cordova 本地项目创建方法
l 创建项目 需要在终端上输入:cordova create [目录][项目ID][APP名称] 运行:cordova create hello com.example.hello hello 将在 ...
- Node.js 中文学习资料和教程导航
这篇文章来自 Github 上的一位开发者收集整理的 Node.js 中文学习资料和教程导航.Node 是一个服务器端 JavaScript 解释器,它将改变服务器应该如何工作的概念,它的目标是帮助程 ...
- Dede技巧
解决DEDE图集上传图片时跳出302错误 本地上传图集的时候突然提示网页出错,还爆出302错误. 解决办法是在include/userlogin.class.php文件中的第二行session_s ...
- JVM内存模型与GC算法(简介)
JVM内存模型如上图,需要声明一点,这是<Java虚拟机规范(Java SE 7版)>规定的内容,实际区域由各JVM自己实现,所以可能略有不同.以下对各区域进行简短说明. 1.1程序计数器 ...
- xmpp 协议详解
XMPP(可扩展消息处理现场协议)是基于可扩展标记语言(XML)的协议,它用于即时消息(IM)以及在线现场探测.它在促进服务器之间的准即时操作.这个协议可能最终允许因特网用户向因特网上的其他任何人发送 ...
- js函数式编程(二)-柯里化
这节开始讲的例子都使用简单的TS来写,尽量做到和es6差别不大,正文如下 我们在编程中必然需要用到一些变量存储数据,供今后其他地方调用.而函数式编程有一个要领就是最好不要依赖外部变量(当然允许通过参数 ...
- centos 7 忘记root 密码
@@@@首先开启系统,出现下图界面以后,按e键. @@@使用下放下箭头找到图中的位置,在下图中 修改 ro 为 rw , 添加init=sysroot/bin/sh @@@按Ctrl + x 进入单用 ...