Breaking

Monday, 5 March 2018

Linux Useful System Admin Commands


uptime
This command displays a one-line summary showing...
Example: uptime
11:42pm up 18 days, 8:45, 1 user, load average: 0.00, 0.00, 0.00
  • Current time (11.42pm)
  • Number of days since last boot (up 18 days)
  • Number of users logged in (1 user)
  • System utilization for the last 1, 5 and 15-minute intervals (load average

who
This command will display...
  • All users logged in
  • tty device(line) they are using
  • When they logged in
  • Idle time
  • Where they logged in from
Options:
  • -i display idle time
  • -H print column headings
Example: who -iH
USER
LINE
LOGIN-TIME
IDLE
FROM
roger
ttyp0
Jun 5 23:27
.
(omni)


id
This command displays a one-line summary for the current user listing...
  • username and number
  • primary group and number
  • other groups and numbers
Example: id
uid=1000(roger) gid=100(users) groups=100(users),16(dialout),40(game)

free
This command displays statistics on memory usage. The values represent KB's.
Example...

total
used
free
shared
buffers
cached
Mem:
63208
61484
1724
27848
1060
49360
-/+ buffers/cache:
11064
52144



Swap:
128516
6500
122016




du
This command stands for disk usage and will print the size of the current directory and subdirectories in 1 KB sizes.

df
This command displays information for each file system.
Example: df
Filesystem
1024-blocks
Used
Available
Capacity
Mounted on
/dev/sda1
497667
301229
170736
64%
/
/dev/sda2
7469935
5721885
1360884
81%
/usr

env
This command lists all shell (environment) variables and their contents for the current user.





ps
This command lists process status. There are many options for this command. Below are the two most common.
Example: ps u  (process status for current user)
USER
PID
%CPU
%MEM
SIZE
RSS
TTY
STAT
START
TIME
COMMAND
roger
418
0.0
1.7
1808
1124
p0
S
23:27
0:01
-bash
roger
690
0.0
0.5
872
356
p0
R
00:09
0:00
ps u
      • PID = Unique Process ID
      • SIZE = Virtual image size; size of text+data+stack
      • RSS = Resident set size; kilobytes of program in memory
      • TTY = Controlling tty
      • STAT = Information about the status of the process
        • R = runnable
        • S = sleeping
        • D = uninterruptible sleep
        • T = stopped or traced
        • Z = zombie process
        • Second field = W if the process has no resident pages.
        • Third field = N if the process has a positive nice value
Example: ps ax (process status of all processes for all users and system)

top
This command displays a full screen of information of the top processes. It will update automatically until the program is stopped. To stop the display, enter q.
12:26am
up 18 days
9:29
1 user
load average: 0.00, 0.00, 0.00
39 processes: 38 sleeping, 1 running, 0 zombie, 0 stopped


CPU states: 0.5% user, 0.0% system, 0.0% nice, 99.5% idle


Mem: 63208K av, 60848K used, 2360K free, 271

Swap: 128516K av, 6500K used, 122016K free,  48696K cached


PID
USER
PRI
NI
SIZE
RSS
SHARE
STAT
LIB
%CPU
%MEM
TIME
COMMAND
769
roger
19
0
584
584
428
R
0
0.5
0.9
0:00
top
1
root
0
0
256
232
196
S
0
0.0
0.3
0:02
init
2
root
0
0
0
0
0
SW
0
0.0
0.0
0:03
kflushd
3
root
-12
-12
0
0
0
SW<
0
0.0
0.0
0:00
kswapd
31485
root
0
0
288
288
232
S
0
0.0
0.4
0:00
mingetty
428
root
0
0
252
224
196
S
0
0.0
0.3
0:00
mingetty
142
root
0
0
264
208
208
S
0
0.0
0.3
0:00
mingetty
9
root
0
0
224
188
172
S
0
0.0
0.2
0:21
update
61
root
0
0
348
308
256
S
0
0.0
0.4
0:31
syslogd
59
root
0
0
464
412
232
S
0
0.0
0.6
0:00
klogd
130
root
0
0
1192
1092
932
S
0
0.0
1.7
0:00
_upsd
73
root
0
0
836
800
352
S
0
0.0
1.2
0:12
named
87
root
0
0
2484
1756
1612
S
0
0.0
2.7
0:00
httpd
90
at
0
0
288
248
224
S
0
0.0
0.3
0:00
atd
93
root
0
0
324
292
244
S
0
0.0
0.4
0:00
cron
96
root
0
0
308
292
228
S
0
0.0
0.4
0:05
inetd
105
root
0
0
324
292
236
S
0
0.0
0.4
0:00
lpd
31763
root
0
0
412
412
328
S
0
0.0
0.6
0:00
mgetty




System Info - procinfo
procinfo gathers some system data from the /proc directory and prints it formatted on the screen.

Some of the information displayed is
  • Last Boot time
  • Load Average
  • average number of jobs running
  • number of runnable processes
  • total number of processes
  • PID of the last process run (idem)
  • Swap info
  • Memory resources
  • Number of disks
  • IRQ info
  • Installed modules (with the -a or -m option)
  • File Systems (with the -a or -m option)
To automatically update the displayed info every 30 seconds
procinfo -fn30
To exit, simply press q 

No comments:

Post a Comment