linux笔记

来源:互联网 发布:java双向加密 编辑:程序博客网 时间:2024/05/20 03:38

rpm -ivh

tar -xvf

useradd newuser

passwd newuser

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/linux/libxml/lib

 gcc -o xmltest CreateXmlFile.c -I/home/linux/libxml/include/libxml2  //包含头文件路径

                                                       -L/home/linux/libxml/lib/ -lxml2           //-L包含库文件路径名 -l库文件名,全称即为libxml2.so

linux查看文件依赖库关系的命令是

ldd name

 

ln -s /usr/lib/libz.so.1.y.z /usr/lib/libz.so.1

 

《深入浅出linux工具与编程》源代码 余国平著

http://download.csdn.net/detail/guoping16/3511254

《深入浅出linux工具与编程》进程间通信(管道与信号), system V进程间通信

http://www.docin.com/p-199051147.html


 mount -t vmhgfs .host:/ /mnt/hgfs

 

tcpdump host 10.10.50.113 and \(10.10.50.69\) -s 1600 -w test.out

 

readelf -s test > test.map

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

linux ps 命令查看进程状态

http://hi.baidu.com/soulfy/item/5e21ba0d930d19ca9157182c

 

linux上进程有5种状态:
1. 运行(正在运行或在运行队列中等待)
2. 中断(休眠中, 受阻, 在等待某个条件的形成或接受到信号)
3. 不可中断(收到信号不唤醒和不可运行, 进程必须等待直到有中断发生)
4. 僵死(进程已终止, 但进程描述符存在, 直到父进程调用wait4()系统调用后释放)
5. 停止(进程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信号后停止运行运行)

ps工具标识进程的5种状态码:
D 不可中断 uninterruptible sleep (usually IO)
R 运行 runnable (on run queue)
S 中断 sleeping
T 停止 traced or stopped
Z 僵死 a defunct ("zombie") process


注: 其它状态还包括W(无驻留页), <(高优先级进程), N(低优先级进程), L(内存锁页).


使用ps格式输出来查看进程状态:
ps -eo user,stat..,cmd


user 用户名
uid 用户号
pid 进程号
ppid 父进程号
'size' 内存大小, Kbytes字节.
v'size' 总虚拟内存大小, bytes字节(包含code+data+stack)
share 总共享页数
nice 进程优先级(缺省为0, 最大为-20)
priority(pri) 内核调度优先级
pmem 进程分享的物理内存数的百分比
trs 程序执行代码驻留大小
rss 进程使用的总物理内存数, Kbytes字节
time 进程执行起到现在总的CPU暂用时间
stat 进程状态
cmd(args) 执行命令的简单格式


例子:
查看当前系统进程的uid,pid,stat,pri, 以uid号排序.
ps -eo pid,stat,pri,uid --sort uid


查看当前系统进程的user,pid,stat,rss,args, 以rss排序.
ps -eo user,pid,stat,rss,args --sort rss

附:

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

addr2line工具是标准的GNU Binutils中的一部分,可以将指令的地址和可执行映像转换成文件名、函数名和源代码行数的工具。

使用gcc -Wl,Map=test_debug.map  -g  -o  test_debug  test_debug.c             -Wl,Map 生成映像文件test_debug.map  -g包含调试信息   

        addr2line 0x8048459 -e test_debug  -f                        -e 指定可执行的映像  -f 输出函数名

 

dmesg

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

gdb调试常用命令,attach,br,n,bt

gdb常用命令记录如下:

1. attach: 用gdb调试一个正在运行中的进程
gdb attach PID

2. br: 设置断点
br filename:line_num

br namespace::classname::func_name

3. n: 单步跳过   s: 单步进入

4. finish:执行到函数retun返回

5. list: 列出当前位置之后的10行代码;list line_number: 列出line_number之后的十行代码

6. bt(backtrace):列出调用栈

7. info locals:列出当前函数的局部变量

8. p var_:打印变量值

9. info breakpoints:列出所有断点

10. delete breakpoints:删除所有断点;delete breakpoints id:删除编号为id的断点;disable/enable breakpoints id:禁用/启用断点

11. break ... if ... 条件中断

还有一个小问题,网上很少提到:被调试的程序必须和源码放在同一台机器上,才能用list命令列出源码,否则提示找不到。

直接回车,总可以重复执行上一个命令。

参考: http://baigoogledu.blog.51cto.com/738227/153948

涉及到多线程调试,参考:http://wenku.baidu.com/view/ab2b0623bcd126fff7050ba0.html

 

setenv bootargs root=nfs nfsroot=192.168.1.57:/nfsrootfs/rootfs ip=192.168.1.58 console=tty1 console=ttySAC0,115200 initcall_debug=1 init=/linuxrc       //add initcall_debug=1

saveenv                                      //save env

$sudo /etc/init.d/tftpd-hpa restart          //启动tftp服务器命令。

将主机的IP地址设置为   192.168.1.56
        虚拟机设置为   192.168.1.57
        开发板设置为   192.168.1.58

共享文件的配置:sudo mount -t vmhgfs .host:/                   /mnt/hgfs

 

lwip 开源的轻量级TCP/IP协议栈,可用于RTOS中。

 

设置默认网关

route add default gw 网关IP地址 dev 网卡设备名

设置网卡IP地址

ifconfig 网卡设备名 IP地址 netmask 子网掩码

启用或者禁用网卡

ifconfig 网卡设备名 up

ifconfig 网卡设备名 down

 

 

 

 

 

 

 

 



 

原创粉丝点击