CIFS mount SAMBA mount
∖∖192.168.xx.x∖mnt /mnt/avm cifs rw,username=xxx,password=xxx,uid=1000,gid=1000,iocharset=utf8,noauto,user,dir_mode=0755,file_mode=06
44,_netdev 0 0
linux - How to use sprof? - Stack Overflow
Given an application my_app', which links against a shared object my_sobj', and has been compiled with the '-g' compile flag:
#set the environment variable LD_PROFILE to the name of the shared obj
export LD_PROFILE=my_obj
#run your application
my_app
#this should create a file /var/tmp/my_sobj.profile
#now run sprof
sprof my_sobj my_sobj.profile
This gives profile information for the shared library, not for my_app
Socket disconnect detect
POLLRDHUP (since Linux 2.6.17)
Stream socket peer closed connection, or shut down writing half of connection. The _GNU_SOURCE feature test macro must be defined (before including any header files) in order to obtain this definition.
EPIPE
This socket was connected but the connection is now broken. In this case, send generates a SIGPIPE signal first; if that signal is ignored or blocked, or if its handler returns, then send fails with EPIPE.
tcp_disconnect.py This program easily translates to C & Java. By TCP rules, the only way for a server program to know if a client has disconnected, is to try to read from the socket. Specifically, if select() says there is data, but recv() returns 0 bytes of data, then this implies the client has disconnected. But a server program might want to confirm that a tcp client is still connected without reading data. For example, before it performs some task or sends data to the client. This program will demonstrate how to detect a TCP client disconnect without reading data. The method to do this: 1) select on socket as poll (no wait) 2) if no recv data waiting, then client still connected 3) if recv data waiting, the read one char using PEEK flag 4) if PEEK data len=0, then client has disconnected, otherwise its connected. Note, the peek flag will read data without removing it from tcp queue. To see it in action: 0) run this program on one computer 1) from another computer, connect via telnet port 12345, 2) type a line of data 3) wait to see it echo, 4) type another line, 5) disconnect quickly, 6) watch the program will detect the disconnect and exit. I hope this is helpful to someone. John Masinter, 17-Dec-2008. """
SIOCOUTQ SIOCINQ
SIOCINQ
Returns the amount of queued unread data in the receive
buffer. Argument is a pointer to an integer. The socket
must not be in LISTEN state, otherwise an error (EINVAL)
is returned.
SIOCATMARK
Returns true when the all urgent data has been already
received by the user program. This is used together with
SO_OOBINLINE .
Argument is an pointer to an integer for the test result.
SIOCOUTQ
Returns the amount of unsent data in the socket send queue
in the passed integer value pointer. The socket must not
be in LISTEN state, otherwise an error (EINVAL)
is returned.
Linux provides a SIOCOUTQ ioctl() to query how much data is in the TCP output buffer:
http://www.kernel.org/doc/man-pages/online/pages/man7/tcp.7.html
You can use that, plus the value of SO_SNDBUF, to determine whether the outgoing buffer has enough space for any particular message. So strictly speaking, the answer to your question is "yes".
But there are two problems with this approach. First, it is Linux-specific. Second, what are you planning to do when there is not enough space to send your whole message? Loop and call select again? But that will just tell you the socket is ready for writing again, causing you to busy-loop.
For efficiency's sake, you should probably bite the bullet and just deal with partial writes; let the network stack worry about breaking your stream up into packets for optimal throughput.
linux serial communications
picocom -f n -p n -b 115200 -i -r -l /dev/ttyUSB0
picocom -b 115200 -l -r /dev/ttyUSB0 #OpenWrt
Exit: C-a C-x // Ctrl-C Ctrl-A Ctrl-X
screen /dev/ttyUSB0 115200
cu -l /dev/ttyUSB0 -s 115200
~. Drop the connection and exit.
ser2net
Sniffer:
jpnevulator --ascii --timing-print --tty /dev/ttyS0:SB9600d --tty "/dev/ttyUSB0:Motorola MTM800" --read
3G Modem
comgt {info,sig,reg} -d /dev/ttyUSB0
stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
-brkint -imaxbel
$ stty -F /dev/ttyUSB0 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^∖; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
$ stty -F /dev/ttyUSB0 -g
500:5:1cb2:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
Ubuntu fix:
dialout:x:20:alex,rttymgr
id -Gn |grep dialout
sudo adduser $USER dialout
installed apps
To get a list of packages installed locally and save as a text file called packages on your desktop do this in your terminal:
dpkg --get-selections
sudo apt-get -y update
sudo apt-get dselect-upgrade
cat installed-applications.txt | cut -f 1 | tr "∖n" " "
dpkg --get-selections | grep -v deinstall > ~/Desktop/packages
cat ~/Desktop/packages > sudo dpkg --set-selections && sudo apt-get dselect upgrade
rcconf позволяет отключать при загрузке ненужные сервисы.
sysv-rc-conf позволяет делать то же самое, только на разных уровнях запуска.
dpkg --get-selections | grep -v "deinstall" вывести полный список установленных пакетов.
dpkg --get-selections > installed_programs.txt - сохранить список всех установленных в системе пакетов.
sudo dpkg --set-selections < installed_programs.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade - установить все пакеты из списка.
COLUMNS=150 dpkg -l > packages.txt - краткая информация об установленных пакетах (версия пакета и краткое описание).