Linux基础命令(四)
作业一:
1) 开启Linux系统前添加一块大小为15G的SCSI硬盘
[root@bogon ~]# 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: 0x0002d1bd Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 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/cl-root: 18.2 GB, 18249416704 bytes, 35643392 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/cl-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
2) 开启系统,右击桌面,打开终端
没图形。
3) 为新加的硬盘分区,一个主分区大小为5G,剩余空间给扩展分区,在扩展分区上划分1个逻辑分区,大小为5G
Command (m for help): p Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 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: 0x0cddc761 Device Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 31457279 10484736 5 Extended
/dev/sdb5 10489856 20975615 5242880 83 Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
4) 格式化主分区为ext3系统
[root@bogon ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
5) 将逻辑分区设置为交换分区
[root@bogon ~]# mkswap /dev/sdb5
Setting up swapspace version 1, size = 5242876 KiB
no label, UUID=3d0072cf-8902-44c3-b13b-6c4373a130a5
6) 启用上一步的交换分区
[root@bogon ~]# swapon -a /dev/sdb5
7) 查看交换分区的状态
[root@bogon ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2097148 0 -1
/dev/sdb5 partition 5242876 0 -2
作业二:free命令查看内存
[root@bogon ~]# free
total used free shared buff/cache available
Mem: 999936 147480 675052 7064 177404 680612
Swap: 7340024 0 7340024
整理buffer与cache的作用
Cache:缓存区,是高速缓存,是位于CPU和主内存之间的容量较小但速度很快的存储器,因为CPU的速度远远高于主内存的速度,CPU从内存中读取数据需等待很长的时间,而 Cache保存着CPU刚用过的数据或循环使用的部分数据,这时从Cache中读取数据会更快,减少了CPU等待的时间,提高了系统的性能。 Cache并不是缓存文件的,而是缓存块的(块是I/O读写最小的单元);Cache一般会用在I/O请求上,如果多个进程要访问某个文件,可以把此文件读入Cache中,这样下一个进程获取CPU控制权并访问此文件直接从Cache读取,提高系统性能。 Buffer:缓冲区,用于存储速度不同步的设备或优先级不同的设备之间传输数据;通过buffer可以减少进程间通信需要等待的时间,当存储速度快的设备与存储速度慢的设备进行通信时,存储慢的数据先把数据存放到buffer,达到一定程度存储快的设备再读取buffer的数据,在此期间存储快的设备CPU可以干其他的事情。 Buffer:一般是用在写入磁盘的,例如:某个进程要求多个字段被读入,当所有要求的字段被读入之前已经读入的字段会先放到buffer中。
计算真实的内存使用率
used/total=内存使用率
147480/9999936=0.1474894393241167
作业三:dd命令测试硬盘速度
[root@bogon ~]# dd if=/dev/zero of=/luchuangao.txt bs=2M count=2
2+0 records in
2+0 records out
4194304 bytes (4.2 MB) copied, 0.015345 s, 273 MB/s
作业四:查找一个名为firewall的进程,并且将其强制杀死
[root@bogon ~]# ps aux | grep firewall
root 626 0.0 2.6 327200 26332 ? Ssl 15:27 0:01 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root 2376 0.0 0.0 112648 960 pts/0 R+ 16:01 0:00 grep --color=auto firewall
[root@bogon ~]# pkill -9 firewall
作业五:rpm命令
1) 挂载光盘文件到/media目录
[root@bogon ~]# mount /dev/cdrom /media/
mount: /dev/sr0 is write-protected, mounting read-only
2) 进去/media目录下的Packages目录
[root@bogon ~]# cd /media/Packages/
3) 查看系统已安装的所有rpm包
[root@bogon Packages]# rpm -qa
4) 查看系统是否安装dhcp软件包
[root@bogon ~]# rpm -qa | grep dhcp
dhcp-libs-4.2.5-47.el7.centos.x86_64
dhcp-common-4.2.5-47.el7.centos.x86_64
5) 安装dhcp软件包
[root@bogon ~]# yum install dhcp -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-47.el7.centos will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
dhcp x86_64 12:4.2.5-47.el7.centos base 511 k Transaction Summary
=======================================================================================================================================================================
Install 1 Package Total download size: 511 k
Installed size: 1.4 M
Downloading packages:
dhcp-4.2.5-47.el7.centos.x86_64.rpm | 511 kB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 12:dhcp-4.2.5-47.el7.centos.x86_64 1/1
Verifying : 12:dhcp-4.2.5-47.el7.centos.x86_64 1/1 Installed:
dhcp.x86_64 12:4.2.5-47.el7.centos Complete!
6) 查看dhcp软件包的信息
[root@bogon ~]# rpm -qi dhcp
Name : dhcp
Epoch : 12
Version : 4.2.5
Release : 47.el7.centos
Architecture: x86_64
Install Date: Fri 17 Mar 2017 03:58:04 PM CST
Group : System Environment/Daemons
Size : 1452668
License : ISC
Signature : RSA/SHA256, Mon 21 Nov 2016 01:32:14 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : dhcp-4.2.5-47.el7.centos.src.rpm
Build Date : Tue 15 Nov 2016 01:54:04 AM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://isc.org/products/DHCP/
Summary : Dynamic host configuration protocol software
Description :
DHCP (Dynamic Host Configuration Protocol) is a protocol which allows
individual devices on an IP network to get their own network
configuration information (IP address, subnetmask, broadcast address,
etc.) from a DHCP server. The overall purpose of DHCP is to make it
easier to administer a large network. To use DHCP on your network, install a DHCP service (or relay agent),
and on clients run a DHCP client daemon. The dhcp package provides
the ISC DHCP service and relay agent.
7) 查看dhcp软件包中所包含的所有文件
[root@bogon ~]# rpm -ql dhcp
/etc/NetworkManager
/etc/NetworkManager/dispatcher.d
/etc/NetworkManager/dispatcher.d/12-dhcpd
/etc/dhcp
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/usr/bin/omshell
/usr/lib/systemd/system/dhcpd.service
/usr/lib/systemd/system/dhcpd6.service
/usr/lib/systemd/system/dhcrelay.service
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-4.2.5
/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
/usr/share/doc/dhcp-4.2.5/dhcpd6.conf.example
/usr/share/doc/dhcp-4.2.5/ldap
/usr/share/doc/dhcp-4.2.5/ldap/README.ldap
/usr/share/doc/dhcp-4.2.5/ldap/dhcp.schema
/usr/share/doc/dhcp-4.2.5/ldap/dhcpd-conf-to-ldap
/usr/share/man/man1/omshell.1.gz
/usr/share/man/man5/dhcpd.conf.5.gz
/usr/share/man/man5/dhcpd.leases.5.gz
/usr/share/man/man8/dhcpd.8.gz
/usr/share/man/man8/dhcrelay.8.gz
/usr/share/systemtap/tapset/dhcpd.stp
/var/lib/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
8) 查看/bin/ls文件是由哪个软件包产生
[root@bogon ~]# rpm -qf /bin/ls
coreutils-8.22-18.el7.x86_64
9) 卸载dhcp软件包
[root@bogon ~]# yum erase dhcp -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-47.el7.centos will be erased
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Removing:
dhcp x86_64 12:4.2.5-47.el7.centos @base 1.4 M Transaction Summary
=======================================================================================================================================================================
Remove 1 Package Installed size: 1.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 12:dhcp-4.2.5-47.el7.centos.x86_64 1/1
Verifying : 12:dhcp-4.2.5-47.el7.centos.x86_64 1/1 Removed:
dhcp.x86_64 12:4.2.5-47.el7.centos Complete!
作业六:yum命令
1) 自定义yum仓库:createrepo
[root@bogon ~]# yum install createrepo -y
[root@bogon ~]# mkdir /luchuangao
[root@bogon ~]# cp /rpm_bak/base/packages/httpd-2.4.6-45.el7.centos.x86_64.rpm /luchuangao/
[root@bogon ~]# createrepo /luchuangao/
Spawning worker 0 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
2) 自定义repo文件
[root@bogon yum.repos.d]# cat httpd.repo
[local]
name=local repo
baseurl=file:///luchuangao
enabled=1
gpgcheck=0
[root@bogon yum.repos.d]#
3) 使用yum命令安装httpd软件包
[root@bogon ~]# yum install httpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
httpd x86_64 2.4.6-45.el7.centos local 2.7 M Transaction Summary
================================================================================================
Install 1 Package Total download size: 2.7 M
Installed size: 9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : httpd-2.4.6-45.el7.centos.x86_64 1/1
Verifying : httpd-2.4.6-45.el7.centos.x86_64 1/1 Installed:
httpd.x86_64 0:2.4.6-45.el7.centos Complete!
[root@bogon ~]#
4) 卸载httpd软件包:yum –y remove 软件名
[root@bogon ~]# yum remove httpd -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be erased
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================
Package Arch Version Repository Size
================================================================================================
Removing:
httpd x86_64 2.4.6-45.el7.centos @local 9.4 M Transaction Summary
================================================================================================
Remove 1 Package Installed size: 9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : httpd-2.4.6-45.el7.centos.x86_64 1/1
Verifying : httpd-2.4.6-45.el7.centos.x86_64 1/1 Removed:
httpd.x86_64 0:2.4.6-45.el7.centos Complete!
[root@bogon ~]#
5) 使用yum安装组件'KDE 桌面':yum –y groupinstall 组件名
[root@bogon ~]# yum grouplist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Installed Groups:
Development Tools
Available Groups:
Compatibility Libraries
Console Internet Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
[root@bogon ~]#
[root@bogon ~]# yum groupinstall "KDE Plasma Workspaces" -y
6) 掌握使用yum删除组件‘KDE 桌面’:yum –y groupremove 组件名
[root@bogon ~]# yum groupremove "KDE Plasma Workspaces" -y
7) 掌握清除yum缓存:yum clean all
[root@bogon ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: httpd local
Cleaning up everything
Cleaning up list of fastest mirrors
[root@bogon ~]#
8) 使用yum查找软件包:yum search 软件包名
[root@bogon ~]# yum search vsftpd
Loaded plugins: fastestmirror, langpacks
httpd | 2.9 kB 00:00:00
local | 3.6 kB 00:00:00
(1/3): httpd/primary_db | 3.3 kB 00:00:00
(2/3): local/group_gz | 155 kB 00:00:00
(3/3): local/primary_db | 3.0 MB 00:00:00
Determining fastest mirrors
===================================== N/S matched: vsftpd ======================================
vsftpd.x86_64 : Very Secure Ftp Daemon Name and summary matches only, use "search all" for everything.
作业六:源码安装python
[root@bogon ~]# yum install zlib-devel -y
[root@bogon ~]# tar -xf Python-3.6.0
[root@bogon ~]# cd Python-3.6.0
[root@bogon Python-3.6.0]# ./configure --prefix=/usr/local/python3.6
[root@bogon Python-3.6.0]# make && make install
[root@bogon ~]# echo 'PATH=/usr/local/python3.6/bin:$PATH' >>/etc/profile
[root@bogon ~]# tail -1 /etc/profile
PATH=/usr/local/python3.6/bin:$PATH
[root@bogon ~]# source /etc/profile
[root@bogon ~]# python3.6
Python 3.6.0 (default, Mar 17 2017, 16:47:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@bogon ~]#
参考链接:http://www.cnblogs.com/linhaifeng/articles/6045600.html#_label16
补充:
ls命令执行过程
ls--------->shell---------->PATH---------->/usr/bin/ls--------->alias
杀死后台进程
[root@bogon shell]# jobs
[1]+ Running ./test.sh &
[root@bogon shell]# kill -9 %1
[root@bogon shell]#
[1]+ Killed ./test.sh
Linux基础命令(四)的更多相关文章
- Linux基础命令四
iptables iptables -F:关闭防火墙 crontab -l查看定时任务 crontab -e :编辑定时任务 log日志相关: ls /var/log:查看日志 du -sh /v ...
- 第四节,Linux基础命令
第四节,Linux基础命令 命令是系统操作员对系统传入的指令,传入指令后回车,系统接收到指令做出相应的行为 1.查看用户位于系统什么位置 [pmd]检查操作用户位于系统的什么位置 命令 ...
- 【Python之路】第一篇--Linux基础命令
pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 . 表示当前目录 .. 表示上级目录 / 表示根目录 ls ...
- Linux基础命令-查看基本硬件信息
Linux基础命令-查看基本硬件信息 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.查看CPU信息 [root@node101.yinzhengjie.org.cn ~]# l ...
- Linux 基础命令及基本目录
Linux 基础命令及基本目录 一.网卡 1.网卡配置文件路径 /etc/sysconfig/network-scripts/ifcfg-eth0 配置文件: TYPE=Ethernet # 以太 ...
- Linux——基础命令用法(上)
一.Linux基础命令 1.Linux命令行的格式 命令行的格式为:用户名+主机名+当前工作目录 输入内容的命令格式为:命令 [-短选项/--长选项] [参数] [root@localhost ~]# ...
- day04 Linux基础命令
day04 Linux基础命令 查看帮助信息命令 1.man命令:man命令的功能是查看指定命令的详细解释. 格式:man [具体需要被查看的命令] [root@localhost ~]# man r ...
- linux基础命令学习笔记(二)
linux基础命令学习笔记(二) 1.kill :终止进程 kill pid (唯一标示一个进程) kill -9 强制终止 kill -15 命令未结束不能终止 # ps aux 查看所有进程 ...
- 2.Linux基础命令
linux内一切皆文件,没有文件夹只有目录,目录也是一种文件 1.一些常用按键: 将鼠标的光标从虚拟机里切换回来:Ctrl+Alt 拖动Ubuntu内的对话框:Alt键+鼠标左键拖动 清屏:Ctrl+ ...
随机推荐
- Resources.FindObjectsOfTypeAll<T>()的坑(Ghost prefab)
今天遇到了一个Bug,因为调用Resources.FindObjectsOfTypeAll<T>()遍历整个场景,结果遍历出的对象不对.比较哈希一查果然是两个.原来prefab本身和pre ...
- DDR3内存详解,存储器结构+时序+初始化过程
DDR3内存详解,存储器结构+时序+初始化过程 标签: DDR3存储器博客 2017-06-17 16:10 1943人阅读 评论(1) 收藏 举报 分类: 硬件开发基础(2) 转自:http:/ ...
- python之字符串处理
#!/usr/bin/env python #-*- coding:utf-8 -*- ############################ #File Name: strformat.py #A ...
- Makefile 之 $(Q)
# To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full command ...
- application/x-www-form-urlencoded接口响应报文中文乱码
1.如何处理乱码 在进行接口测试时,在用httpclient post请求时,对于Content-Type:application/json来说,在写测试脚本时只需要为头信息和post请求指定相应编码 ...
- JSON学习【转自慕课网】
视频网址 从慕课网视频里的PPT截图过来的,因为是用PHP讲的,而且后面讲的一般,所以只截取了前两节课的基础内容,其实只看一下第一张PPT就可以了.
- SQL Server Replace函数
REPLACE用第三个表达式替换第一个字符串表达式中出现的所有第二个给定字符串表达式. 语法REPLACE ( 'string_expression1' , 'string_expression2' ...
- ImportError: cannot import name gof
今天打开spyder说调试一个theano程序,但是import theano提示 ImportError: cannot import name gof 最后解决方案 pip install --u ...
- 浏览器配置工具.bat
在Web安装的ActiveX控件,默认安装在C:\WINDOWS\Downloaded Program Files目录下,但是有时候由于Internet Explorer的安全设置,会阻止Active ...
- MySQL Error: Illegal mix of collations for operation 'concat'
在使用concat连接字符串时出现错误:MySQL Error: Illegal mix of collations for operation 'concat' 原因:字段操作默认为UTF8的编码, ...