Neo
This user hasn't shared any biographical information
Posts by Neo
Identify processes that have open sockets
Jul 26th
The lsof can be used to find the list of processes that have active sockets open.
Let us see the list of current TCP connections using netstat command.
[liz@techpulp ~]# netstat -nt Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.20.24:40816 74.125.19.83:80 ESTABLISHED tcp 0 0 192.168.20.24:43059 74.125.19.83:80 ESTABLISHED [liz@techpulp ~]#
Now let us find which process has these TCP sockets open using lsof command.
[liz@techpulp ~]# /usr/sbin/lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
firefox-b 3288 liz 13u IPv4 157814 TCP
liz.techpulp.com:43058->cf-in-f83.google.com:http (ESTABLISHED)
firefox-b 3288 liz 40u IPv4 158205 TCP
liz.techpulp.com:43059->cf-in-f83.google.com:http (ESTABLISHED)
[liz@techpulp ~]#
So Firefox More >
Linux file compression tools/utilities
Jul 26th
Linux has various types of compression and decompression tools like tar, gzip, bzip2, zip and compress. This article describes practical usage of these utilities.
tar and untar
tar command operates on one or more files or directories and creates an archive. An archive created by tar command is called a tarball. Generally such archives will have .tar as file extension. tar is more of a archiving utility than a compression utility. Typically it is used along with file compression utilities like gzip and bzip2. See various ways of creating a tarball using -cvf option in the following examples.
[liz@techpulp ~]# tar -cvf mydir.tar mydir/ [liz@techpulp ~]# tar -cvf myfiles.tar file1.txt More >
Print first N characters of a string using printf
Jul 26th
#include <stdio.h>
int main(int argc, char *argv[])
{
char *p = "My Name is Neo";
printf("First 5 bytes of string is '%.5s'\n", p);
return 0;
}
Result
[neo@techpulp ex]# gcc example.c -o example [neo@techpulp ex]# ./example First 5 bytes of string is 'My Na' [neo@techpulp ex]#
Stack of a Running Process in Unix/Linux
Jul 26th
The command pstack can be used to view the stack trace of a running process.
Let us select a running process.
[neo@techpulp ~]# ps -e | grep konqueror 22937 pts/5 00:00:17 konqueror
Run pstack command with PID of the process.
[neo@techpulp ~]# pstack 22937 22937: konqueror (No symbols found) 0x001fb402: ???? (89c6ed8, 2, bfa39b08, 3812df0, 89c6ed8, 3c21362) 0x0325074b: ???? (89c6ed8, 8a00908) 0x03250656: ???? (89c6ed8, 3c372ec) 0x03237a59: ???? (bfa39c20, bfa39d48, bfa39de8, bfa39d1c, 0, bfa39fb4) + 4c0 0x03bb1d0d: ???? (1, bfa3a094, bfa3a09c, 0, bfa3a094, 1) + 40 0x00248de6: ???? (80485ec, 1, bfa3a094, 8048600, 8048650, 21ff2d) + 405c5f78 [neo@techpulp ~]#
There is an alternate way to use gdb and attach More >


Recent Comments