What is the FreeBSD equivalent of Windows "netstat 1" - freebsd

What is the FreeBSD equivalent of Windows netstat 1 (displays the selected statistics again every 1 second)?

I think, systat -ifstat 1 is what you are looking for. See man systat for more information about this command.

Related

CPU utilization for given command in Linux

For generic commands in Linux like htop, ping, who, scp etc.
how to know how much % of CPU is being used when they were executed?
are there any Linux tools which can give the stats for above commands!
while top is running:
press o to open filter options
type COMMAND=your-script-to-monitor
for htop:
press F4 to filter by command name
type in your command
From here, you can check the CPU% column
You can try also this:
ps -p <PID> %cpu

How to get to know whether the Linux process is running

Given a pid, for example 29264, how to get to know whether the process is running ?
Is there any easy way to do that ?
thx
Process status (ps) provides the information you're looking for:
ps -p 29264
Output in case the process is running (quick example on my Mac, works the same on Linux):
PID TIME CMD
127 4:54.03 /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
Otherwhise:
PID TIME CMD
kill -0 29264 ,and inspect the error (if any)
link to online linux (man 2) manual
link to online linux (man 1) manual
To get process status:
ps -p 29264 > /dev/null; echo $?

Currently running applications in Linux

I'm working on a project similar to what we call system monitor in Linux. I'm using opensuse 11.4 gnome. I was wondering if there's any command (Except ps) that lists all currently running applications on the system. I'm developing it for multi-core environment.
For example I'm browsing the web with Firefox and lets say Google Chrome simultaneously, plus I'm editing text in a text file. In this scenario, when I open my project, I want the list of all applications currently running [in my scenario, the names gEdit, Google Chrome and Firefox(but not the process these three apps generated) must be displayed as a list]
The output I want is the same as what we get in the Applications tab when we use task manager in Windows.
If anyone has a solution, please let me know it'll be highly apprecieted. I'm using netbeans to implement the project. Thanks!!!
I don't think there is a easy way of getting this done. In Linux an application may create several processes on startup - for example let's take postfix:
localhost:~ # ps -ef|grep postfix
root 3708 1 0 Apr24 ? 00:00:35 /usr/lib/postfix/master
postfix 3748 3708 0 Apr24 ? 00:00:01 qmgr -l -t fifo -u
postfix 3749 3708 0 Apr24 ? 00:00:00 pickup -l -t fifo -u -c
postfix 13504 3708 0 16:05 ? 00:00:00 cleanup -z -t unix -u -c
postfix 15458 3708 0 17:45 ? 00:00:00 cleanup -z -t unix -u -c
postfix 19907 3708 0 19:25 ? 00:00:00 cleanup -z -t unix -u -c
the processes "master", "qmgr", "pickup" and "cleanup" all belong to the application postfix. You can see that those processes each belong to one parent process "master" by looking at the third column which tells you the parent process who has startet this process. In my example all processes have been startet by process with id 3708. Another example is the Apache Webserver, which creates several httpd processes on startup - here the process names are all the same only the count varies depending on the configuration.
To come back to the problem you would like to solve: From my point of view there are two ways you could try:
Build up a database which contains associations of processes names to applications and use this to create your list of applications by using ps.
You restrict your application to list only applications which display a graphical user interface. This list should be easily build by using some X11 functions or the likes...
hope this helps...
Have you tried pstree yet? well this shows you a tree of the processes that are running on the system.
htop is what I usually use for multicore enviornment cause it shows resource utilization and you can see where your processes are pinned by adding columns. htop is more userfriendly than top and has more options. when you run it just hit 't' and it will sort the processes by their parents.
I don't know any other tools, but your other option is to go through /proc and write your own script to extract the information you need.
I hope it helps.
EDIT: I forgot to mention that processes are being forked in linux, so there is a parent process which starts a couple of other processes/threads. From your question, it seems that you are trying to find the parent process for each running process, my answers are based on that assumption.
Check out top (linux command)
And this article will help you a lot.
http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
You may want to start from xlsclients.
It probably does not have all the functionality you need, but then Linux has no well-defined notion of application.
The next thing you might find useful is xprop (look for _NET_WM_PID) but this is not guaranteed to work for all programs.

ps command output on AIX, HPUX and Solaris

I am writing a portable shell script to get system process information, I need process id, command, pwdx (linux). On linux I am able to get this information as follows.. but it fails on all other unix flavours.
$ ps -awwwwwww -u <userid> -o pid,cmd|grep -i <filter_term> | egrep -v grep
$ pwdx <pid>
what I should use on AIX, HPUX and Solaris to get the similar information, or there any cross platform command
On Solaris I have tried /usr/ucb/ps but that support formatted output and lsof for pwdx equivalent but that also doesn't show what I need
On Solaris I have tried /usr/ucb/ps but that support formatted output:
What is wrong with formatted output ?
and lsof for pwdx equivalent but that also doesn't show what I need.
That doesn't make sense. pwdx is a Solaris native command and was even originally implemented on that OS.
Linux != Unix. And in the same hand, the commands are not always going to be the same, for instance GNU ps is not like Solaris ps or HP-UX ps etc. In some cases the Vendor Unix flavors offer a "compatibility binary" like those stashed in /usr/ucb on solaris. But ultimately you need to look at the man page for each version and review the output format options.
Edit. That is for in general all commands. Including grep, egrep etc.
To show the full command name, use this
ps -eo comm
This will show the command that was run. (ps is from /usr/bin on my Solaris system 5.11)

Linux: list all available window managers

How do I get a list of all available windows managers on a linux system (Of course this would mostly not be needed but - I don't have root permissions).
Very difficult to search on Google as all results returned are for "list of window managers for linux".
Clarification: I am looking for a command that lists "All window managers that are installed" on the system that I am working on.
Interested to know it's distro dependent. My distro is RedHat.
cat /proc/version
(Linux version 2.4.21-40.ELsmp (centos#sillage.bis.pasteur.fr) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-53)) #1 SMP Wed Mar 15 13:46:01 EST 2006)
It really depend on your particular distribution or OS.
Say, on debian and ubuntu one uses:
$ update-alternatives --list x-window-manager
/usr/bin/twm
/usr/bin/fvwm2
/usr/bin/beryl
/usr/bin/beryl-xgl
/usr/bin/icewm
/usr/bin/kwin
/usr/bin/wmaker
A couple more places I found on Debian:
grep "^Exec" /usr/share/xsessions/*
grep -l "section=.Window Managers." /usr/share/menu/*
(In the second, we may want to check the command= part of each file.)
And on an old Gentoo I noticed:
find /etc/X11/Sessions/* -printf '%f\n'
Depends on your distribution/package manager. Most package managers will probably not even have a category "window managers".
Anyway, in gentoo you'd do:
$ eix -I -C x11-wm --only-names
x11-wm/enlightenment
x11-wm/twm
On Slackware there is nice xwmconfig, but I'm not sure if it exists on other distributions.

Resources