Difference between revisions of "System information"

From English Wiki
Jump to navigation Jump to search
(Created page with "The following are common and useful Linux commands and utilities for managing and finding system information. ==System information, performance and utilities == {| class="...")
 
m
 
(7 intermediate revisions by the same user not shown)
Line 27: Line 27:
 
| hostname -I || Display the host IP addresses
 
| hostname -I || Display the host IP addresses
 
|-
 
|-
| hostnamectl || Display operating system information, e.g., kernel, and release version
+
| hostnamectl || Display hostname & operating system information, e.g., kernel, and release version
 
|-
 
|-
| hostnamectl || Show or modify hostname
+
| hostnamectl '' new-name'' || Change hostname
 
|-
 
|-
 
| htop || Interactive process viewer (alternative to top)
 
| htop || Interactive process viewer (alternative to top)
 +
|-
 +
| im-config || Check text input method setup (e.g., ibus or fcitx for inputting non-Western languages)
 
|-
 
|-
 
| iostat 1 || Outputs I/O (Input/Output) statistics.
 
| iostat 1 || Outputs I/O (Input/Output) statistics.
Line 44: Line 46:
 
|-
 
|-
 
| lsof -u user || List files opened by user
 
| lsof -u user || List files opened by user
 +
|-
 +
| neofetch OR screenfetch || Display OS, desktop environment, basic system info, & OS logo (requires installation)
 
|-
 
|-
 
| mpstat 1 || Outputs processor-related statistics.
 
| mpstat 1 || Outputs processor-related statistics.
Line 59: Line 63:
 
| uname || Print system information
 
| uname || Print system information
 
|-
 
|-
| uname -a || Display basic system information, e.g., machine name and supported operating system architecture.
+
| uname -a || Print a summary of information on the system, OS, kernel, and machine
|-
 
| uname -a || Print a summary of the system, OS, kernel and system information
 
 
|-
 
|-
 
| uname -r || Display kernel version and release information
 
| uname -r || Display kernel version and release information
Line 67: Line 69:
 
| uptime || Shows how long the system has been active, and average load
 
| uptime || Shows how long the system has been active, and average load
 
|-
 
|-
| vmstat 1 || Display virtual memory statistics
+
| vmstat -s || Detailed virtual memory statistics
 +
|-
 +
| vmstat 1 || Display virtual memory statistics with constant updating
 
|-
 
|-
 
| watch df -h || Execute "df -h" to view file system information, showing periodic updates
 
| watch df -h || Execute "df -h" to view file system information, showing periodic updates
Line 147: Line 151:
 
|-
 
|-
 
| vmstat 1 || Display virtual memory statistics with constant updating
 
| vmstat 1 || Display virtual memory statistics with constant updating
|-
 
| vmstat 1 || Display virtual memory statistics
 
 
|-
 
|-
 
| xev || Interactive program for finding key bindings and codes for keyboard keys
 
| xev || Interactive program for finding key bindings and codes for keyboard keys
Line 248: Line 250:
 
| fuser -m /dev/sda1 || Show which processes are using a particular device  
 
| fuser -m /dev/sda1 || Show which processes are using a particular device  
 
|-
 
|-
| printenv || Print defined env vars
+
| printenv || Print defined environmental variables
 
|}
 
|}
 
 
Line 274: Line 276:
  
  
 +
==Startup or login problems==
 +
 +
{| class="wikitable sortable"
 +
! Command !! Function
 +
|-
 +
| loginctl unlock-session 2 ||  Unlock a borked session from tty when normal login fails, or when the regular user session is borked
 +
|-
 +
| kquitapp5 plasmashell && kstart5 plasmashell || Kill and restart a borked KDE session from termianl without logging out
 +
|-
 +
| pkill -HUP -f "cinnamon --replace"  || Kill and restart a borked Cinnamon desktop session from tty or terminal without logging out
 +
|-
 +
| sudo service mdm restart || Kill and restart a borked Cinnamon desktop session from tty or terminal without logging out
 +
|}
 +
 +
 +
 +
For a corrupted kernal or blackscreen issues, this video may be helpful.
 +
* [https://www.youtube.com/watch?v=tTS2KVCJ-MQ An Update Borked My Linux System. How Did I Fix It?]
  
  

Latest revision as of 05:26, 9 March 2024

The following are common and useful Linux commands and utilities for managing and finding system information.


1 System information, performance and utilities

Command Function
arch Display system architecture (e.g., x86_64)
cal Displays the current month's calendar; can also show calendar of any specified month or year (years 0-9999)
cat /etc/*rel* Show detailed OS and release version information
cat /etc/redhat-release Show which version of Redhat installed
date Display the current system date and time
date -d Print formatted date
free -h Display free and used memory (in human readable format)
free -m OR -g Display free and used system memory in megabytes or gigabytes, respectively
hostname Display the system's hostname
hostname -I Display the host IP addresses
hostnamectl Display hostname & operating system information, e.g., kernel, and release version
hostnamectl new-name Change hostname
htop Interactive process viewer (alternative to top)
im-config Check text input method setup (e.g., ibus or fcitx for inputting non-Western languages)
iostat 1 Outputs I/O (Input/Output) statistics.
last reboot Display system reboot history
lsb_release -a Display operating system distributor ID, description, release, and codename.
lslogins Display information on known users
lsof List all open files on the system
lsof -u user List files opened by user
neofetch OR screenfetch Display OS, desktop environment, basic system info, & OS logo (requires installation)
mpstat 1 Outputs processor-related statistics.
route -n Display kernel IP routing table
tail 100 /var/log/messages Display the last 100 syslog messages (using /var/log/syslog for Debian based systems.)
tcpdump -i eth0 Capture and display all packets on interface eth0
tcpdump -i eth0 'port 80' Monitor all traffic on port 80 (HTTP)
top Display and manage the top processes
uname Print system information
uname -a Print a summary of information on the system, OS, kernel, and machine
uname -r Display kernel version and release information
uptime Shows how long the system has been active, and average load
vmstat -s Detailed virtual memory statistics
vmstat 1 Display virtual memory statistics with constant updating
watch df -h Execute "df -h" to view file system information, showing periodic updates


2 Hardware management

Command Function
badblocks -s /dev/sda Test for unreadable blocks on disk sda
badblocks dev -v Search for bad sectors on device
badblocks dev -v > file Search for bad sectors on device and save to a file
cat /proc/cpuinfo More information about CPU e.g model, model, name, cores, vendor id
cat /proc/meminfo More information about hardware memory, e.g., total and free memory
df Display file system information
df -h Display file system information in human-readable format
dmesg Outputs the kernel ring buffer messages.
dmidecode Outputs the system's hardware information on DMI/SMBIOS related to the BIOS.
free Display system memory (RAM and swap); -h human readable; -m megabytes; -g gigabytes
free -h Display free and used memory (in human readable format)
hdparm -i /dev/sda Display data on a specified disk
hdparm -tT /dev/sda Output read speed test performance for a disk
insmod Install modular device drivers
iostat Detailed information on CPU cores and devices (via sysstat)
iostat 1 Real-time (constantly updating) iostat data
lp -d lp -P Identify name of printer
lp -nc, lpr c Print c copies of a file
lpq Displays items in print cue
lpr file Print file to the printer
lprm file Cancel print jobs
lsblk Display information on a system’s block devices
lscpu Detailed CPU information
lshw Outputs the system's hardware configuration information.
lslocks Display system locks
lsmem Display memory usage information
lsmod List kernel modules that are currently loaded
lsof Display currently open files
lspci -tv Display a system's PCI devices.
lsusb Display USB ports and devices
lsusb -tv Display system's USB devices.
setxbmap Change to different keyboard setup
top, htop Display memory usage and processes
vmstat -s Detailed virtual memory statistics
vmstat 1 Display virtual memory statistics with constant updating
xev Interactive program for finding key bindings and codes for keyboard keys
xmodmap -pke Display list of keyboard key codes (keymaps)
xmodmap -pm Display list of modifier key mappings
xmodmap .Xmodmap Update Xmodmap file of keyboard settings (in user directory)


3 Machine state

Command Function
reboot Restart the system
shutdown -f Do a fast shutdown
shutdown -h now Shut down the system now
shutdown -r Reboot the system; time argument is optional
shutdown -t time Shutdown the system at a specified time, e.g., 11.00 for 11am
shutdown -t +#min Shutdown within a specified number of minutes
shutdown message Shutdown and broadcast a message


4 Important system directories and files

Command Function
/etc system­-wide config­uration files
/etc/*release* OS and version information
/etc/bash.bashrc Global config file for bash shell
/etc/group Group information
/etc/hosts Config­uration for network hosts
/etc/inittab Login and runlevel configuration
/etc/n­etw­ork­/in­ter­faces Location of network interface information
/etc/n­etworks Config­uration for networks
/etc/p­asswd User account information
/etc/profile Global environmental config files
/etc/redhat-release OS information (for RHEL)
/etc/s­hadow Where passwords are stored
/etc/skel Skeleton and template home directory for new home direct­ories
/etc/ssh/sshd_config ‘’OR’’ ssh_config SSHD configuration file (e.g., to change assigned port numbers)
/etc/s­ysl­og.conf Config­uration for syslog logging daemon
/etc/s­yst­emd­/system Daemon config file and setup
/proc/­cpuinfo CPU info
/usr/share/X11/xkb/symbols/ Location of system keyboard keymaps
/var/log System logs
/var/l­og/­mes­sages System messages
/var/l­og/­syslog System logs
~/.bas­h_l­ogin If ~/.bas­h_p­rofile is not found, bash attempts to read this script
~/.bas­h_p­rofile User’s personal startup file
~/.bashrc User config file for bash shell
~/.profile User environmental config file
~/.profile Profile file used by bash if .bash_profile and .bash_login do not exist
~/.XCompose User-defined compose keys (for dead keys, compose keys)
alias Show defined aliases
export VAR Make a VAR available to child process
fuser Show which processes are using a particular file, device, or system resource
fuser -m /dev/sda1 Show which processes are using a particular device
printenv Print defined environmental variables


5 System init or runlevels

These are common init levels or runlevels in Unix based systems, though these may vary slightly among different distributions or operating systems. Users will generally do their work in Runlevel 5, which is the standard GUI runlevel.

Runlevel status or command Function
Runlevel 0 System halt, for shutting down the system
Runlevel 1 Single-user mode (no GUI)
Runlevel 2 Multi-user mode without networking (or GUI)
Runlevel 3 X-server is loaded, for basic GUI elements; multi-user mode with networking (in command line interface)
Runlevel 4 User-definable mode
Runlevel 5 Full graphical environment; multi-user mode with networking and full GUI
Runlevel 6 Reboots for a system restart


6 Startup or login problems

Command Function
loginctl unlock-session 2 Unlock a borked session from tty when normal login fails, or when the regular user session is borked
kquitapp5 plasmashell && kstart5 plasmashell Kill and restart a borked KDE session from termianl without logging out
pkill -HUP -f "cinnamon --replace" Kill and restart a borked Cinnamon desktop session from tty or terminal without logging out
sudo service mdm restart Kill and restart a borked Cinnamon desktop session from tty or terminal without logging out


For a corrupted kernal or blackscreen issues, this video may be helpful.


7 See also