Commands used for System Information
| Command(s) |
Sample Output |
|
DATE The simple “date” command displays the current date and time (including the day of the week, month, time, time zone, year).
Date TZ By default, “date” command uses the time zone defined in path “/etc/localtime”. Linux user can change the time zone via Terminal by using command “TZ”.
Date --set Linux allows its user to set the current date and time of the system manually.
Example - This would set the system date to May 18, 2023 10:10 PM
|
$ date
Thu Mar 2 07:23:38 PM EST 2023
$ TZ=GMT date
Fri Mar 3 12:03:59 AM GMT 2023
$ TZ=America/New_York date
Thu Mar 2 07:04:12 PM EST 2023 |
|
DF The command “df” shows the amount of disk space used and disk space available on every file system containing each filesystem’s name and its path.
The command “df -h” shows the same result as the command “df” but now the data is in a more human-readable form that can be easily comprehended by a new user.
|
|
|
FREE The command “free” displays the amount of free and used memory in the complete system.
|
$ free
total used free shared buff/cache available
Mem: 16232800 4698636 6761664 59100 4772500 11205016
Swap: 2097152 0 2097152
|
Command Name & Description
Command(s)
freePS
The command “ps” which is also known as the process status command is used to provide information about the processes currently running on the system, including their respective process identification numbers (PIDs).Syntax: ps
ps
PS AUX & PS -EF
Both list all processes of all users. In that aspect -e and ax are completely equivalent.
Where they differ is output format specifier, -f is "full", while u is "user-oriented". The displayed columns are different:
ps -fUID PID PPID C STIME TTY TIME CMD
ps uUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ps ps -ef
ps -aux
$ ps
PID TTY TIME CMD
434765 pts/0 00:00:00 bash
441698 pts/0 00:00:00 ps
$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Feb07 ? 00:19:03 /sbin/init splash
root 2 0 0 Feb07 ? 00:00:03 [kthreadd]
root 3 2 0 Feb07 ? 00:00:00 [rcu_gp]
root 4 2 0 Feb07 ? 00:00:00 [rcu_par_gp]
root 5 2 0 Feb07 ? 00:00:00 [slub_flushwq]
root 6 2 0 Feb07 ? 00:00:00 [netns]
$ ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 169808 12472 ? Ss Feb07 19:03 /sbin/init splash
root 2 0.0 0.0 0 0 ? S Feb07 0:03 [kthreadd]
root 3 0.0 0.0 0 0 ? I< Feb07 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< Feb07 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I< Feb07 0:00 [slub_flushwq]
root 6 0.0 0.0 0 0 ? I< Feb07 0:00 [netns]
ps -f
UID PID PPID C STIME TTY TIME CMD
ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ps
ps -ef
ps -aux
UPTIME
The command “uptime” provides information about how long the system has been running in one line. The result for this command includes the current time, the time duration system has been running, the number of users who are currently logged on, and the system load averages for the past 1, 5, and 15 minutes respectively.
Syntax: uptime
uptime
$ uptime
19:59:06 up 22 days, 20:17, 1 user, load average: 0.52, 0.39, 0.38
W
The command “w” displays detailed information about the users who are logged into the system currently.
Syntax: w
w
$ w
20:00:25 up 22 days, 20:18, 1 user, load average: 0.44, 0.41, 0.38
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
tim :1 :1 07Feb23 ?xdm? 2days 0.00s /usr/libexec/gdm-x-session --run-script env
PASSWD
The command “passwd” stands for password and it is used to change the password of the user.
Syntax: passwd user_name
passwd my_user
$ passwd tim
changing password for tim.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
EXIT
The command “exit” as the name says it is used to exit from the system and log out from the current user.
Syntax: exit
exit
$ exit
logout
Connection to 192.168.1.1 closed.
SS
The ss command is a modern replacement for the classic netstat command. You can use it on Linux to get statistics about your network connections.
Use the -ltn flags to list all listening ports on your system.
ss -ltn
Use the following to see if a specific port is listening on your system. In this case, the source port (sport) and destination port (dport) is 80 or you can use the protocol name, http, instead.
ss -a '( dport = :80 or sport = :80 )'
ss -a '( dport = :http or sport = :http )'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 4096 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 4096 0.0.0.0:6767 0.0.0.0:*
LISTEN 0 4096 0.0.0.0:111 0.0.0.0:*
LISTEN 0 4096 0.0.0.0:80 0.0.0.0:*
LISTEN 0 4096 0.0.0.0:8081 0.0.0.0:*
LISTEN 0 4096 0.0.0.0:8082 0.0.0.0:*
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp LISTEN 0 4096 0.0.0.0:http 0.0.0.0:*
tcp LISTEN 0 4096 [::]:http [::]:*
SHUTDOWN
The command “shutdown” is used to shut down the system.
Syntax: shutdown
shutdown
$ shutdown
Shutdown scheduled for Thu 2023-03-02 20:12:13 EST, use 'shutdown -c' to cancel.