做業一:
1) 開啓Linux系統前添加一塊大小爲15G的SCSI硬盤html
[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) 開啓系統,右擊桌面,打開終端node
沒圖形。python
3) 爲新加的硬盤分區,一個主分區大小爲5G,剩餘空間給擴展分區,在擴展分區上劃分1個邏輯分區,大小爲5Glinux
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系統sql
[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) 將邏輯分區設置爲交換分區shell
[root@bogon ~]# mkswap /dev/sdb5 Setting up swapspace version 1, size = 5242876 KiB no label, UUID=3d0072cf-8902-44c3-b13b-6c4373a130a5
6) 啓用上一步的交換分區centos
[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命令查看內存app
[root@bogon ~]# free total used free shared buff/cache available Mem: 999936 147480 675052 7064 177404 680612 Swap: 7340024 0 7340024
整理buffer與cache的做用ide
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