通过建站学运维1901-08任务

chown命令

用途:

用于更改所有者和所属组

用法:

chown 所有者:所属组 文件名

所属组可以省略,默认和所有者同组

选项

-R级联更改所有者

用户配置文件

/etc/passwd

使用tail /etc/passwd 可以查看新添加的十个用户

添加用户命令

useadd 用户名

同时会添加一个以用户名名命的组

查看用户所属组命令

id 用户名

一个用户一般有两个组,一个主组一个附属组

添加组

groupadd 组名

组配置文件

/etc/group

tail /etc/group可以查看最新建立的十个组。


4.17硬链接和软链接

inode

使用ls -l时,显示的第二列就是inode

硬链接

inode可以当作房间的门牌号。

如果两个文件或目录使用了相同的inode那么可以认为这两个文件或目录是相同同的。

目录无法手动做硬链接

目录的inode号

一个目录的inode至少是2。
因为有目录本身和目录内的.都使用了这个inode
一个目录的inode是多少就代表他下边有多少子目录

文件的inode号

如果一个文件的inode大于2,那么说明这个文件有相关的硬链接文件。

硬链接无法跨设备和分区


4.18 软链接使用方法示例

软链接命令

ln -s 源文件 目标文件

做软链接时,源文件一定要为绝对路径。不然变更软链接文件路径时会失效。

软链接的作用

1,方便使用和查询
2,一个文件可以在多个位置访问。
3,磁盘扩容。当源文件占用空间过大又不能随便移动该文件时,使用软链接。

软链接应用实例

磁盘两个分区/123和/abc。
/123已经满了。/abc还有空间。
/123/下的aaa文件越来越大,已经快放不下了。
这时:

1,复制/123/aaa到/abc下:mv /123/aaa /abc
2,删除原文件:rm -f /123/aaa
3,创建软链接文件:ln -s /abc/aaa /123/aaa


4.19 yum工具

yum

安装软件包的一种工具。

特点:可以联网,可以解决依赖。

linux的软件依赖

软件在安装的过程中,通常会出现:

安装a时提示a依赖b,b依赖c的情况。

使用yum的话,直接安装a会自动把b和c都安装好。

yum命令用法

yum install -y 软件包名(安装软件)

yum remove 包名(卸载软件)

yum list(查看软件仓库内的软件)

yum grouplist (套件列表)

yum groupinstall (套件安装)

yum provides /*/命令(查找命令所存在的软件包)


4.20 rpm工具

获取rpm包

1,通过centos安装光盘获取

1.1 启用vmware的光盘
4-48.png
1.2挂载光驱

[root@2019xy-01 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@2019xy-01 ~]# ls
anaconda-ks.cfg
[root@2019xy-01 ~]# cd /mnt
[root@2019xy-01 mnt]# ls
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL
[root@2019xy-01 mnt]# cd Packages
[root@2019xy-01 Packages]#

挂载光驱后,/mnt/Packages下就是rpm包。

2,通过网络获取

2.1安装yum-utils

[root@2019xy-01 Packages]# yum install -y yum-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nwsuaf.edu.cn
 * extras: mirrors.nwsuaf.edu.cn
 * updates: mirrors.nwsuaf.edu.cn
 ......
     ......
作为依赖被安装:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3             python-chardet.noarch 0:2.2.1-1.el7_1            
  python-kitchen.noarch 0:1.1.1-5.el7                

完毕!
[root@2019xy-01 Packages]# 

2.2通过网络下载rpm包

yumdownloader 包名

[root@2019xy-01 ~]# yumdownloader wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nwsuaf.edu.cn
 * extras: mirrors.nwsuaf.edu.cn
 * updates: mirrors.nwsuaf.edu.cn
wget-1.14-18.el7.x86_64.rpm                                                      | 547 kB  00:00:00     
[root@2019xy-01 ~]# ls
anaconda-ks.cfg  wget-1.14-18.el7.x86_64.rpm

将wget的安装包下载到了本目录内

rpm的用法

rpm安装rpm包: rpm -ivh xxxx.rpm
rpm -qa :查询系统已经安装过的所有的包
卸载包:rpm -e 包名,如 rpm -e wget
查看一个包有无安装:rpm -q 包名,如 rpm -q vim-enhanced
rpm -qa |grep vim [grep命令是用来过滤指定关键词的]
rpm -ql 包名,可以列出该包都安装了哪些文件(会列出文件在系统里的路径)
rpm -qf /usr/bin/wget 可以反查询,查一个文件是由哪个rpm包安装得来的

补充: which命令查看一个文件在哪里,如 which ifconfig

转载于:https://my.oschina.net/u/4067478/blog/3005932

Ubuntu下libxml2的交叉编译 2014-12-26 13:10 本站整理 浏览(587) Ubuntu下libxml2的交叉编译,有需要的朋友可以参考下。 环境为Ubuntu 14.04 LTS 64位 英文版本。 使用的交叉编译工具是arm-linux-gcc-4.3.2.tgz。 一、准备libxml2库 libxml2是一个跨平台的xml文件操作库。 项目地址:http://www.xmlsoft.org/ 我使用的是最新版本libxml2-2.9.2.tar.gz 二、安装 我在在官网提供的网址https://git.gnome.org/browse/libxml2/上下载了几个版本的.tar.gz在Ubuntu下解压以后都没有看到configure文件,然后在ftp://xmlsoft.org/libxml2/下载的版本里却有configure文件……折腾一早上,简直坑爹,希望朋友们少走弯路…… 在解压文件夹下 rootroot@rootroot-virtual-machine:~/wyb$ cd libxml2-2.9.2/ rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ ./configure --prefix=/home/rootroot/wyb/libxml2-2.9.2/install CC=arm-linux-gcc LD=arm-linux-ld --enable-shared --enable-static --host=arm-linux --with-python=/home/rootroot/wyb/libxml2-2.9.2/python rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make install 注意修改自己的交叉编译工具。如果不指定python路径(--with-python=/home/rootroot/wyb/libxml2-2.9.2/python),make之后会提示: rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ make make[4]: Entering directory `/home/rootroot/wyb/libxml2-2.9.2/python' CC libxml.lo cc1: warning: include location "/usr/include/python2.7" is unsafe for cross-compilation In file included from /usr/include/python2.7/Python.h:8, from libxml.c:14: /usr/include/python2.7/pyconfig.h:15:52: error: arm-linux-gnueabi/python2.7/pyconfig.h: No such file or directory In file included from /usr/include/python2.7/Python.h:77, from libxml.c:14: /usr/include/python2.7/pymath.h:18: warning: redundant redeclaration of 'copysign' /usr/include/python2.7/pymath.h:26: warning: redundant redeclaration of 'hypot' libxml.c: In function 'xmlPythonFileReadRaw': libxml.c:297: error: expected '(' before numeric constant libxml.c: In function 'xmlPythonFileRead': libxml.c:362: error: expected '(' before numeric constant make[4]: *** [libxml.lo] Error 1 make[4]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2/python' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/rootroot/wyb/libxml2-2.9.2' make: *** [all] Error 2 rootroot@rootroot-virtual-machine:~/wyb/libxml2-2.9.2$ 参考资料: http://blog.csdn.net/q1302182594/article/details/44975527 Linux中交叉编译libxml2 三、测试 随便找一个测试程序: // test.c #include #include #include int main(int argc, char **argv) { xmlDocPtr doc = NULL; xmlNodePtr root_node = NULL, node = NULL, node1 = NULL; doc = xmlNewDoc(BAD_CAST "1.0"); root_node = xmlNewNode(NULL, BAD_CAST "root"); xmlDocSetRootElement(doc, root_node); xmlNewChild(root_node, NULL, BAD_CAST "node1",BAD_CAST "content of node1"); node=xmlNewChild(root_node, NULL, BAD_CAST "node3",BAD_CAST"node has attributes"); xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes"); node = xmlNewNode(NULL, BAD_CAST "node4"); node1 = xmlNewText(BAD_CAST"other way to create content"); xmlAddChild(node, node1); xmlAddChild(root_node, node); xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1); xmlFreeDoc(doc); xmlCleanupParser(); xmlMemoryDump(); return(0); } 编译: rootroot@rootroot-virtual-machine:~/wyb$ arm-linux-gcc -I /home/rootroot/wyb/libxml2-2.9.2/install/include/libxml2 -L /home/rootroot/wyb/libxml2-2.9.2/install/lib -lxml2 test.c -o test rootroot@rootroot-virtual-machine:~/wyb$ file test test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped rootroot@rootroot-virtual-machine:~/wyb$
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值