LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-12-2019, 07:17 PM   #1
mintner
LQ Newbie
 
Registered: Sep 2019
Posts: 3

Rep: Reputation: Disabled
show first 10 processes with ps command


Why -11 instead of -10 to show the first 10 processes on the system?
[root@server1 ~]# ps ax | head -11
 
Old 11-12-2019, 07:24 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by mintner View Post
Why -11 instead of -10 to show the first 10 processes on the system?
[root@server1 ~]# ps ax | head -11
Welcome to LQ

What's on the first line when you run that? Is it a process?

How many processes are displayed when you run that?
 
Old 11-12-2019, 07:28 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,311
Blog Entries: 28

Rep: Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137
I think to show the first 11 lines, which includes the header line.

Code:
  PID TTY      STAT   TIME COMMAND
 
Old 11-12-2019, 07:40 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
This looked like homework to me, so I opted to take take a teacher’s stance rather than answer the question
I’m sorry I didn’t make that clear.

Last edited by scasey; 11-12-2019 at 07:45 PM.
 
1 members found this post helpful.
Old 11-12-2019, 07:57 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
he did have the answer, he just didn't know the why, Promote learning.
Code:
 nl = number line (just a guess to the why its called nl, Number Line.
userx@FreeBSD.edy:~
$ ps -aux | head -11 | nl
     1	USER         PID  %CPU %MEM     VSZ    RSS TT  STAT STARTED      TIME COMMAND
     2	root          11 290.2  0.0       0     64  -  RNL  16:21   751:58.87 [idle]
     3	userx      33858  51.2  3.9 2603196 320308  -  S    19:56     0:08.38 /usr/loca
     4	userx      33325  24.7  4.4  478436 360672  -  S    19:48     1:30.04 mpv --pla
     5	root       22834  16.1  1.1  118192  89944  -  S    16:22    13:43.98 /usr/loca
     6	userx      34166  15.1  5.3 2853760 432976  -  S    19:16     0:43.22 /usr/loca
     7	userx      96605  10.8  0.6   99784  47744  -  S    16:22     9:30.20 xfwm4
     8	root          12   3.0  0.0       0    288  -  WL   16:21     6:27.07 [intr]
     9	userx      79315   2.8  2.6 2490664 210388  -  S    19:53     0:02.27 /usr/loca
    10	userx      35777   2.7  5.8 2782196 468164  -  S    19:16     0:53.86 /usr/loca
    11	userx      34676   0.6  1.6 2404124 133932  -  S    19:56     0:00.29 /usr/loca

Last edited by BW-userx; 11-12-2019 at 08:00 PM.
 
Old 11-12-2019, 08:43 PM   #6
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,311
Blog Entries: 28

Rep: Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137
I didn't occur to me that this might be a homework question, and, I must say, I never heard of the head command, you OP taught me something.
 
Old 11-13-2019, 10:22 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Interesting; 15k posts and " I never heard of the head command".
Just goes to show how experience differs - I can't remember not knowing that and it's mate 'tail'.
 
Old 11-13-2019, 10:40 PM   #8
nigelc
Member
 
Registered: Oct 2004
Location: Sydney, Australia
Distribution: Mageia 7
Posts: 406
Blog Entries: 4

Rep: Reputation: 80
man head, just like man tail.
 
Old 11-14-2019, 07:29 AM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
more | less?
 
Old 11-16-2019, 02:49 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
most!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: What Are Zombie Processes And How To Find & Kill Zombie Processes? LXer Syndicated Linux News 0 12-10-2017 04:12 PM
Limitations of System Processes and Oracle Processes in RHEL AS3.0 sathyguy Linux - Enterprise 0 03-02-2007 11:52 PM
monitoring active processes and identifying the required processes. gajaykrishnan Programming 2 08-13-2004 01:58 AM
Stunnel does not show up in processes after running it. Doctor Nick Linux - Software 9 08-07-2004 08:53 PM
How can I use "top" to show all of the processes preswang Linux - General 10 10-16-2003 02:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration