Hi,
I will continue to explain Linux Commands for Beginners in this tutorial series.
You should read second article before this.
https://ittutorial.org/linux-commands-tutorial-for-beginners-2-system-commands/
3. System Statistic Commands
System statistic commands in Linux are generally used to learn about cpu, disk and memory, or other necessary information like hostname time TOP resource consumers about the system.
These commands are as follows.
- df
- du
- free
- hostname
- time
- who
- lsmod
- Vmstat
- iostat
- Top
df
This command provides the user detailed information about disk usage.
Use and output of this command are as follows. df command shows disk usage in Bytes .
Df -k shows disk usage in Kilobytes and df -h shows in Gigabytes.
[[email protected] ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_oracletest-lv_root 20228748 15107056 4071068 79% / tmpfs 20480000 142892 20337108 1% /dev/shm /dev/sda1 487652 122091 335865 27% /boot /dev/mapper/vg_oracletest-lv_home 10190136 5259268 4390196 55% /home /dev/mapper/vg_oracletest-LVDbOra1 165008748 76505512 80098244 49% /oradata /dev/sdb1 61792296 53640 58593132 1% /backup [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_oracletest-lv_root 20228748 15107060 4071064 79% / tmpfs 20480000 142892 20337108 1% /dev/shm /dev/sda1 487652 122091 335865 27% /boot /dev/mapper/vg_oracletest-lv_home 10190136 5259268 4390196 55% /home /dev/mapper/vg_oracletest-LVDbOra1 165008748 76505560 80098196 49% /oradata /dev/sdb1 61792296 53640 58593132 1% /backup [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_oracletest-lv_root 20G 15G 3.9G 79% / tmpfs 20G 140M 20G 1% /dev/shm /dev/sda1 477M 120M 328M 27% /boot /dev/mapper/vg_oracletest-lv_home 9.8G 5.1G 4.2G 55% /home /dev/mapper/vg_oracletest-LVDbOra1 158G 73G 77G 49% /oradata /dev/sdb1 59G 53M 56G 1% /backup [[email protected] ~]#
du
This command provides and summarize disk usage of each FILE, recursively for directories. Usage and output are as follows.
[[email protected] backup]# du 24 ./.patch_storage/29585399_Apr_9_2019_19_12_47/original_patch/custom/scripts 28 ./.patch_storage/29585399_Apr_9_2019_19_12_47/original_patch/custom 28 ./.patch_storage/29585399_Apr_9_2019_19_12_47/original_patch/etc/config 32 ./.patch_storage/29585399_Apr_9_2019_19_12_47/original_patch/etc 88 ./.patch_storage/29585399_Apr_9_2019_19_12_47/original_patch 100 ./.patch_storage/29585399_Apr_9_2019_19_12_47 180 ./.patch_storage/29517242_Apr_17_2019_23_27_10/original_patch/etc/config 184 ./.patch_storage/29517242_Apr_17_2019_23_27_10/original_patch/etc 268 ./.patch_storage/29517242_Apr_17_2019_23_27_10/original_patch 276 ./.patch_storage/29517242_Apr_17_2019_23_27_10 8 ./.patch_storage/NApply/2019-04-18_07-21-20AM 8 ./.patch_storage/NApply/2019-04-18_07-21-09AM 8 ./.patch_storage/NApply/2019-04-18_07-21-25AM 8 ./.patch_storage/NApply/2019-04-18_07-21-05AM 36 ./.patch_storage/NApply 436 ./.patch_storage 12 ./.opatchauto_storage/system_patches/29547676 20 ./.opatchauto_storage/system_patches 24 ./.opatchauto_storage 4 ./rman 468 . [[email protected] backup]#
You can use du -sh command for disk usage in Gigabyte under spesific directory.
[[email protected] oradata]# [[email protected] oradata]# du -sh * 16G 13c 1.6G agent 20G app 9.4G app19c 177M arc_eksik.rman 2.3G em12105_linux64_disk1.zip 995M em12105_linux64_disk2.zip 1.3G em12105_linux64_disk3.zip 4.0K export 3.8G gc_inst 16K lost+found 17G middleware 4.0K oldbackup 1.6G oradata 119M OraInstall2017-04-21_03-24-54PM 1.2G swlib 26M thread_1_seq_4739.1080.926947103 [[email protected] oradata]#
free
This command provides the user with the amount of free and used memory(RAM) in the operating system. Its use is as follows.
[[email protected] ~]# free total used free shared buffers cached Mem: 49463392 49270332 193060 45031644 256076 45826880 -/+ buffers/cache: 3187376 46276016 Swap: 4194300 3166452 1027848 [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# free -k total used free shared buffers cached Mem: 49463392 49270368 193024 45031644 256092 45826896 -/+ buffers/cache: 3187380 46276012 Swap: 4194300 3166452 1027848 [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# free -m total used free shared buffers cached Mem: 48304 48115 188 43976 250 44752 -/+ buffers/cache: 3112 45191 Swap: 4095 3092 1003 [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# free -g total used free shared buffers cached Mem: 47 46 0 42 0 43 -/+ buffers/cache: 3 44 Swap: 3 3 0 [[email protected] ~]#
hostname
it displays the name of the machine. Use of this command is as follows.
[[email protected] ~]# [[email protected] ~]# hostname MehmetSalih [[email protected] ~]#
time
This command shows how long a given command is run. Its use is as follows.
[[email protected] ~]# time real 0m0.000s user 0m0.000s sys 0m0.000s [[email protected] ~]#
who
This command lists the active users in the system. Use of the command is as follows.
[[email protected] ~]# who root pts/0 2019-09-09 13:52 (ittutorial.org) root pts/1 2019-09-09 13:56 (ittutorial.org) oracle pts/2 2019-09-16 17:13 (:2.0) root pts/3 2019-09-10 11:44 (ittutorial.org) oracle pts/4 2019-09-16 16:46 (:2.0) [[email protected] ~]#
lsmod
This command provides the user with information about all modules installed in the operating system. Use of the command is as follows.
[[email protected] ~]# lsmod Module Size Used by fuse 77921 0 oracleasm 53591 1 autofs4 34292 3 8021q 20994 0 garp 7297 1 8021q stp 2256 1 garp llc 5608 2 garp,stp ip6t_REJECT 4486 2 nf_conntrack_ipv6 10595 3 nf_defrag_ipv6 11368 1 nf_conntrack_ipv6 xt_state 1370 3 nf_conntrack 84658 2 nf_conntrack_ipv6,xt_state ip6table_filter 1671 1 ip6_tables 18368 1 ip6table_filter ipv6 339234 130 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6 ext3 214449 1 jbd 73252 1 ext3 uinput 8917 0 sg 30968 0 vmw_balloon 6875 0 serio_raw 5631 0 vmxnet3 44918 0 crc32c_intel 14496 0 ghash_clmulni_intel 4707 0 microcode 115607 0 pcspkr 2150 0 vmw_vmci 63353 0 i2c_piix4 11994 0 shpchp 27901 0 ext4 533275 4 jbd2 100929 1 ext4 mbcache 7575 2 ext3,ext4 sd_mod 41045 8 crc_t10dif 1547 1 sd_mod mptsas 59857 5 mptscsih 45921 1 mptsas mptbase 99360 2 mptsas,mptscsih scsi_transport_sas 34071 1 mptsas sr_mod 15980 0 cdrom 40900 1 sr_mod aesni_intel 45744 0 ablk_helper 2997 1 aesni_intel cryptd 10460 3 ghash_clmulni_intel,aesni_intel,ablk_helper lrw 4222 1 aesni_intel aes_x86_64 7967 1 aesni_intel xts 3466 1 aesni_intel gf128mul 7999 2 lrw,xts pata_acpi 3782 0 ata_generic 3758 0 ata_piix 26525 0 vmwgfx 128627 0 ttm 80627 1 vmwgfx drm 274140 2 vmwgfx,ttm i2c_core 31228 2 i2c_piix4,drm dm_mirror 14208 0 dm_region_hash 11094 1 dm_mirror dm_log 9681 2 dm_mirror,dm_region_hash dm_mod 84383 14 dm_mirror,dm_log [[email protected] ~]#
Vmstat
vmstat command displays information about processes, memory, paging, block IO and CPU activity.
If you use vmstat n, vmstat generates instant result in every n second.
[[email protected] ~]# vmstat procs --- --------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 3166260 175388 264560 45839080 0 1 93 58 1 3 0 0 99 0 0 [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# vmstat 3 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 3166260 174564 264708 45839328 0 1 93 58 1 3 0 0 99 0 0 0 0 3166260 174412 264976 45839348 0 0 626 188 6499 11970 0 0 99 0 0 0 0 3166260 173284 264976 45839384 0 0 271 44 6289 11801 0 0 99 0 0 ^C [[email protected] ~]# [[email protected] ~]#
iostat
iostat displays CPU statistics and I/O statistics for devices, partitions and network filesystems (NFS).
[[email protected] ~]# iostat Linux 3.8.13-118.13.3.el6uek.x86_64 (MehmetSalih) 09/16/2019 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.35 0.00 0.16 0.38 0.00 99.11 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn sda 8.63 107.10 141.16 66372171 87483024 sdd 0.00 0.00 0.00 2393 0 sdb 0.29 32.79 41.16 20324106 25505496 sdc 80.38 2825.08 1661.52 1750816266 1029715953 dm-0 1.26 43.82 28.99 27154355 17965160 dm-1 3.73 10.50 19.38 6507625 12009696 dm-2 0.01 0.03 0.04 16499 23944 dm-3 10.81 52.74 92.75 32685947 57484080 [[email protected] ~]#
TOP
top command displays dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
[[email protected] ~]# top top - 17:50:14 up 7 days, 4:09, 5 users, load average: 0.28, 0.21, 0.19 Tasks: 503 total, 1 running, 502 sleeping, 0 stopped, 0 zombie Cpu(s): 0.3%us, 0.2%sy, 0.0%ni, 99.1%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 49463392k total, 49289872k used, 173520k free, 265704k buffers Swap: 4194300k total, 3166256k used, 1028044k free, 45839860k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13063 oracle -2 0 1405m 1192 1048 S 1.7 0.0 70:43.21 asm_vktm_+asm 19390 root 20 0 15348 1444 824 R 1.7 0.0 0:00.08 top 29901 oracle -2 0 6580m 19m 17m S 1.7 0.0 66:29.81 ora_vktm_prod 1 root 20 0 19412 576 352 S 0.0 0.0 1:39.06 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.56 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:20.30 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 6 root 20 0 0 0 0 S 0.0 0.0 0:05.90 kworker/u:0 7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/u:0H 8 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/0 9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 10 root 20 0 0 0 0 S 0.0 0.0 5:22.63 rcu_sched 11 root RT 0 0 0 0 S 0.0 0.0 0:00.93 watchdog/0 12 root RT 0 0 0 0 S 0.0 0.0 0:00.89 watchdog/1 13 root 20 0 0 0 0 S 0.0 0.0 0:19.36 ksoftirqd/1 14 root RT 0 0 0 0 S 0.0 0.0 0:02.09 migration/1 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H 17 root RT 0 0 0 0 S 0.0 0.0 0:00.95 watchdog/2 18 root 20 0 0 0 0 S 0.0 0.0 0:18.61 ksoftirqd/2 19 root RT 0 0 0 0 S 0.0 0.0 0:00.04 migration/2 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/2:0H 22 root RT 0 0 0 0 S 0.0 0.0 0:01.25 watchdog/3 23 root 20 0 0 0 0 S 0.0 0.0 0:04.11 ksoftirqd/3 24 root RT 0 0 0 0 S 0.0 0.0 0:00.02 migration/3 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/3:0H 27 root RT 0 0 0 0 S 0.0 0.0 0:01.26 watchdog/4 28 root 20 0 0 0 0 S 0.0 0.0 0:01.58 ksoftirqd/4 29 root RT 0 0 0 0 S 0.0 0.0 0:00.02 migration/4 31 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/4:0H 32 root RT 0 0 0 0 S 0.0 0.0 0:01.27 watchdog/5 33 root 20 0 0 0 0 S 0.0 0.0 0:00.67 ksoftirqd/5 34 root RT 0 0 0 0 S 0.0 0.0 0:06.90 migration/5 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/5:0H 37 root RT 0 0 0 0 S 0.0 0.0 0:01.29 watchdog/6 38 root 20 0 0 0 0 S 0.0 0.0 0:06.32 ksoftirqd/6 39 root RT 0 0 0 0 S 0.0 0.0 0:00.04 migration/6 41 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/6:0H 42 root RT 0 0 0 0 S 0.0 0.0 0:01.26 watchdog/7 [[email protected] ~]#
I will continue to explain Linux commands in the next article.
Do you want to learn Linux System Administration for Beginners, then read the following articles.
1,839 views last month, 1 views today