top<\/b> command without options:<\/p>\ntop - 11:24:59 up 7 days, 11:27, 2 users, load average: 0.00, 0.00, 0.00\r\nTasks: 109 total, 1 running, 108 sleeping, 0 stopped, 0 zombie\r\n%Cpu(s): 0.0 us, 0.1 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st\r\nMiB Mem : 3931.4 total, 2473.6 free, 139.8 used, 1318.0 buff\/cache\r\nMiB Swap: 1024.0 total, 1024.0 free, 0.0 used. 3475.6 avail Mem\r\n\r\n PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND\r\n 10 root 20 0 0 0 0 I 0.3 0.0 19:20.53 rcu_sched\r\n 11 root rt 0 0 0 0 S 0.3 0.0 0:04.84 migration\/0\r\n 1 root 20 0 169784 11300 8340 S 0.0 0.3 0:48.82 systemd\r\n 2 root 20 0 0 0 0 S 0.0 0.0 0:00.26 kthreadd\r\n 3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp\r\n 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp\r\n 6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker\/0:0H-kblockd\r\n 8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq\r\n 9 root 20 0 0 0 0 S 0.0 0.0 0:00.43 ksoftirqd\/0\r\n<\/pre>\nAs you can see, there is information about the uptime of the system, system load, percent usage of CPU cores, available memory, and the processes with all this information. In this scenario, only one process is active, and 108 are sleeping. That means that this process is using some CPU and RAM resources, and the other 108 are using nothing.<\/p>\n
The top command can be executed with options such as -i<\/b> for idle processes, -H<\/b> for information about threads, -n<\/b> number of iterations, and many more that can be seen with detailed explanation by executing the man top<\/b> command.<\/p>\nTOP(1) User Commands TOP(1)\r\n\r\nNAME\r\n top - display Linux processes\r\n\r\nSYNOPSIS\r\n top -hv|-bcEHiOSs1 -d secs -n max -u|U user -p pid -o fld -w [cols]\r\n\r\n The traditional switches `-' and whitespace are optional.\r\n\r\nDESCRIPTION\r\n The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads\r\n currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for pro\u2010\r\n cesses are all user configurable and that configuration can be made persistent across restarts.\r\n\r\n The program provides a limited interactive interface for process manipulation as well as a much more extensive interface for personal configuration -- en\u2010\r\n compassing every aspect of its operation. And while top is referred to throughout this document, you are free to name the program anything you wish. That\r\n new name, possibly an alias, will then be reflected on top's display and used when reading and writing a configuration file.\r\n<\/pre>\n<\/span>Du command<\/span><\/h2>\nThe du command is used for disk usage of files and directories. It is very often used by the system administrator when disk usage needs to be checked. The same as the top command du<\/b> command can be executed with or without arguments.<\/p>\n
If we execute the du<\/b> command in the root directory without arguments, we will get output like this:<\/p>\nroot@host:~# du\r\n4 .\/.local\/share\/nano\r\n8 .\/.local\/share\r\n12 .\/.local\r\n4 .\/.cache\r\n4 .\/.config\/procps\r\n8 .\/.config\r\n8 .\/.ssh\r\n56 .\r\n<\/pre>\nAs you can see, there is nothing explained, and there is no info about the size, whether it is in kilobytes, megabytes, or something else. Let’s execute the du command with some options in the \/<\/b> directory on your server:<\/p>\ncd \/\r\n\r\ndu -bsh *<\/pre>\nYou should receive output like this:<\/p>\n
7 bin\r\n301M boot\r\n12K dev\r\n3.0M etc\r\n4.0K home\r\n7 lib\r\n9 lib32\r\n9 lib64\r\n10 libx32\r\n16K lost+found\r\n4.0K media\r\n4.0K mnt\r\n4.0K opt\r\n128T proc\r\n38K root\r\n40M run\r\n8 sbin\r\n4.6K snap\r\n4.0K srv\r\n258M sys\r\n56K tmp\r\n2.4G usr\r\n710M var\r\n<\/pre>\nThe output is clear, and the directories and file sizes are displayed on the left.<\/p>\n
The command du -bsh *<\/b> means that we need the file space usage of all (*<\/b>) directory and files in the current directory in bytes (-b<\/b>), summarized (-s<\/b>) in human-readable format (-h<\/b>)<\/p>\n
More about the du<\/b> command can be viewed with the command man du<\/b> executed on your command line.<\/p>\nroot@host:~# man du\r\n\r\n -d, --max-depth=N\r\n print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as\r\n --summarize\r\n\r\n --files0-from=F\r\n summarize disk usage of the NUL-terminated file names specified in file F; if F is -, then read names from standard input\r\n\r\n -H equivalent to --dereference-args (-D)\r\n\r\n -h, --human-readable\r\n print sizes in human readable format (e.g., 1K 234M 2G)\r\n\r\n --inodes\r\n list inode usage information instead of block usage\r\n\r\n -k like --block-size=1K\r\n\r\n -L, --dereference\r\n dereference all symbolic links\r\n<\/pre>\n<\/span>Netstat command<\/span><\/h2>\nThe netstat command is used for printing network connections, routing tables and etc. As with previous commands, the netstat command can be executed with or without options.<\/p>\n
netstat<\/pre>\nExecuting the command netstat will give you similar output like this:<\/p>\n
root@host:~# netstat\r\nActive Internet connections (w\/o servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State\r\ntcp 0 240 24625403.test:7022 ctel-78-157-7-19.:55913 ESTABLISHED\r\nActive UNIX domain sockets (w\/o servers)\r\nProto RefCnt Flags Type State I-Node Path\r\nunix 2 [ ] DGRAM 16576 \/run\/systemd\/journal\/syslog\r\nunix 10 [ ] DGRAM 16586 \/run\/systemd\/journal\/dev-log\r\nunix 2 [ ] DGRAM 24702 \/run\/user\/0\/systemd\/notify\r\nunix 7 [ ] DGRAM 16590 \/run\/systemd\/journal\/socket\r\nunix 3 [ ] DGRAM 15146 \/run\/systemd\/notify\r\nunix 3 [ ] STREAM CONNECTED 20481\r\nunix 3 [ ] STREAM CONNECTED 20501 \/run\/dbus\/system_bus_socket\r\n<\/pre>\nLet’s execute the netstat command with some parameters, which will be explained later:<\/p>\n
netstat -tunlp<\/pre>\nYou will receive output similar like this if you have installed MySQL, Dovecot, Netdata and similar applications.<\/p>\n
root@host:~# netstat -tunlp\r\nActive Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address Foreign Address State PID\/Program name\r\ntcp 0 0 127.0.0.1:8125 0.0.0.0:* LISTEN 88780\/netdata\r\ntcp 0 0 127.0.0.1:19999 0.0.0.0:* LISTEN 88780\/netdata\r\ntcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 88311\/dovecot\r\ntcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 88311\/dovecot\r\ntcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 83830\/mysqld\r\ntcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 88311\/dovecot\r\ntcp 0 0 0.0.0.0:7022 0.0.0.0:* LISTEN 657\/sshd: \/usr\/sbin\r\ntcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 88311\/dovecot\r\ntcp6 0 0 ::1:8125 :::* LISTEN 88780\/netdata\r\ntcp6 0 0 :::993 :::* LISTEN 88311\/dovecot\r\ntcp6 0 0 :::995 :::* LISTEN 88311\/dovecot\r\ntcp6 0 0 :::110 :::* LISTEN 88311\/dovecot\r\ntcp6 0 0 :::7022 :::* LISTEN 657\/sshd: \/usr\/sbin\r\ntcp6 0 0 :::143 :::* LISTEN 88311\/dovecot\r\ntcp6 0 0 :::80 :::* LISTEN 649\/apache2\r\nudp 0 0 127.0.0.1:8125 0.0.0.0:* 88780\/netdata\r\nudp6 0 0 ::1:8125 :::* 88780\/netdata\r\n<\/pre>\nNow, the output is more clear with protocols, addresses, states, and ports. Now let’s explain the parameters:<\/p>\n
-t<\/b> - is for tcp\r\n\r\n-u<\/b> - is for udp\r\n\r\n-n<\/b> - is for numeric\r\n\r\n-l<\/b> - is for listening sockets\r\n\r\n-p<\/b> - is for the process id and the name of the running program\r\n\r\n<\/pre>\n More about the netstat<\/b> command can be viewed with the command man netstat<\/b> executed on your command line.<\/p>\nNETSTAT(8) Linux System Administrator's Manual NETSTAT(8)\r\n\r\nNAME\r\n netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships\r\n\r\nSYNOPSIS\r\n netstat [address_family_options] [--tcp|-t] [--udp|-u] [--udplite|-U] [--sctp|-S] [--raw|-w] [--l2cap|-2] [--rfcomm|-f] [--listening|-l] [--all|-a] [--nu\u2010\r\n meric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users] [--symbolic|-N] [--extend|-e[--extend|-e]] [--timers|-o] [--program|-p] [--verbose|-v]\r\n [--continuous|-c] [--wide|-W]\r\n\r\n netstat {--route|-r} [address_family_options] [--extend|-e[--extend|-e]] [--verbose|-v] [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users]\r\n [--continuous|-c]\r\n\r\n netstat {--interfaces|-i} [--all|-a] [--extend|-e[--extend|-e]] [--verbose|-v] [--program|-p] [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-\r\n users] [--continuous|-c]\r\n\r\n netstat {--groups|-g} [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users] [--continuous|-c]\r\n\r\n netstat {--masquerade|-M} [--extend|-e] [--numeric|-n] [--numeric-hosts] [--numeric-ports] [--numeric-users] [--continuous|-c]\r\n\r\n netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--udplite|-U] [--sctp|-S] [--raw|-w]\r\n\r\n netstat {--version|-V}\r\n\r\n netstat {--help|-h}\r\n<\/pre>\nThat’s it. We gave you some instructions on how to use these tools to monitor your server resources. If you have difficulties using these commands du, netstat, and top, feel free to contact our technical support<\/a>. We are available 24\/7<\/p>\nIf you liked this about using top, du, and netstat as tools to monitor server resources, please share it with your friends on social networks or simply leave a reply below.<\/p>\n","protected":false},"excerpt":{"rendered":"
In this tutorial, we will explain the usage of the top, du, and netstat as tools to monitor server resources. … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":43142,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,1707],"tags":[2032,2033,2031,1542],"yoast_head":"\nUsing Top, Du, and Netstat as Tools to Monitor Server Resources - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n \n \n\t \n\t \n\t \n