linux获取IP地址
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
int sock_fd;
struct my_addr;
struct ifreq ifr;
unsigned char * addr;
#define ETH_INTERFACE_NAME "eth0"
/**//* Get socket file descriptor */
if ((sock_fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)...{
perror("socket");
exit(1);
}
/**//* Get IP Address */
strncpy(ifr.ifr_name, ETH_INTERFACE_NAME, IF_NAMESIZE);
ifr.ifr_name[IFNAMSIZ-1]='\0';
if (ioctl(sock_fd, SIOCGIFADDR, &ifr) < 0)...{
perror("ioctl");
exit(1);
}
memcpy(&my_addr, &ifr.ifr_addr, sizeof(my_addr));
addr=inet_ntoa(my_addr.sin_addr);
相关文档:
sudo是linux下常用的允许普通用户使用超级用户权限的工具。
它的主要配置文件是sudoers,linux下通常在/etc目录下,如果是solaris,缺省不装sudo的,编译安装后通常在安装目录的 etc目录下,不过不管sudoers文件在哪儿,sudo都提供了一个编辑该文件的命令:visudo来对该文件进行修改。强烈推荐使用该命令修改 sudoers,因为 ......
嵌入式Linux下彩色LCD驱动的设计与实现
摘要:本文介绍了如何在嵌入在开发彩色LCD显示驱动的方法,并对Linux中的显示驱动程序结构和框架作一介绍。
长期以来,在常见的掌上电脑(PDA)等小型手持式设备上,由于硬件条件等的限制,我们看到的显示器件通常是单色LCD,用户界面也非常简单,几乎看不到 PC ......
To enable dumps for every daemon:
ulimit -c unlimited >/dev/null 2>&1 (-c maximum size of core files)
ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1
Dump for system
:
DAEMON_COREFILE_LIMIT='unlimited'
The same for every daemon (in /etc/sysconfig/_daemon_ ......
Here is small script that does this. Debian or Ubuntu GNU/Linux does
not comes with any SYS V init script (located in /etc/init.d directory)
.
You create a script as follows and use it to stop or flush the iptables rules.
Please don't type rules at command prompt. Use the script to sp ......
2009-10-27
1,重启 reboot
2009-10-28
1,忘记了root用户密码的解决帮
启动后按esc进入修复模式,选择修复,并选择最后一个。root,进去后,更改密码:passwd root
然后根据提示输入两次密码就行了。
2009-10-29
1,ls
ls -a 查看所有文件
ls -l 查看详细的属性
&nbs ......