Linux Commands to Check Hardware and System Information
Contents
Hardware Information
Hardware Information
1 | sudo lshw |
CPU
CPU information
1 | lscpu |
Disk
Block Devices Information
1 | lsblk |
Disk Usage
1 | df -h |
Folder Disk Space Usage
1 | # all subdirectories size and total size |
File Disk Space Usage
1 | ls -lh . |
Memory
Memory Information
1 | sudo dmidecode -t memory |
Memory Usage
1 | free -h |
Network
Total network traffic
1 | nload |
traffic by socket
1 | iftop |
traffic by process ID (PID)
1 | nethogs |
System Information
System
Linux Distro name and version
1 | cat /etc/os-release |
Linux kernel version
1 | uname -a |
System hostname and related settings
1 | hostnamectl |
Environment Variables
1 | env |
Configuration Files
Bash Configuration Files
- /etc/profile - This is a “System wide” initialization file that is executed during login. This file provides initial environment variables and initial “PATH” locations.
- /etc/bashrc - This again is a “System Wide” initialization file. This file is executed each time a Bash shell is opened by a user. Here you can define your default prompt and add alias information. Values in this file can be overridden by their local ~/.bashrc entry.
- ~/.bash_profile - If this file exists, it is executed automatically after /etc/profile during the login process. This file can be used by each user to add individual entries. The file however is only executed once at login and normally then runs the users .bashrc file.
- ~/.bash_login - If the “.bash_profile” does not exist, then this file will be executed automatically at login.
- ~/.profile - If the “.bash_profile” or “.bash_login” do not exist, then this file is executed automatically at login.
- ~/.bashrc - This file contains individual specific configurations. This file is read at login and also each time a new Bash shell is started. Ideally, this is where you should place any aliases.
- ~/.bash_logout - This file is executed automatically during logout.
- ~/.inputrc - This file is used to customize key bindings/key strokes.
Most global config files are located in the /etc directory
- /etc/X11/ – xorg specific config files
- /etc/cups/ – sub-directory containing configuration for the Common UNIX Printing System
- /etc/xdg/ – global configs for applications following freedesktop.org specification
- /etc/ssh/ – used to configure OpenSSH server behavior for the whole system
- /etc/apparmor.d/ – contains config files for the AppArmor system
- /etc/udev/ – udev related configuration
Important Global Config Files
- /etc/resolv.conf – used to define the DNS server(s) to use
- /etc/bash.bashrc – used to define the commands to execute when a user launches the bash shell
- /etc/profile – the login shell executes the commands in .profile script during startup
- /etc/dhcp/dhclient.conf – stores network related info required by DHCP clients
- /etc/fstab – decides where to mount all the partitions available to the system
- /etc/hostname – set the hostname for the machine
- /etc/hosts – a file which maps IP addresses to their hostnames
- /etc/hosts.deny – the remote hosts listed here are denied access to the machine
- /etc/mime.types – lists MIME-TYPES and filename extensions associated with them
- /etc/motd – configure the text shown when a user logs in to the host
- /etc/timezone – set the local timezone
- /etc/sudoers – the sudoers file controls the sudo related permission for users
- /etc/httpd/conf and /etc/httpd.conf.d – configuration for the apache web server
- /etc/default/grub – contains configuration used by the update-grub for generating /boot/grub/grub.cfg
- /boot/grub/grub.cfg – the update-grub command auto-generates this file using the settings defined in /etc/default/grub
Important User-Specific Config Files
- $HOME/.xinitrc – this allows us to set the directives for starting a window manager when using the startx command
- $HOME/.vimrc – vim configuration
- $HOME/.bashrc – script executed by bash when the user starts a non-login shell
- $XDG_CONFIG_HOME/nvim/init.vim – neovim configuration
- $HOME/.editor – sets the default editor for the user
- $HOME/.gitconfig – sets the default name and e-mail address to use for git commits
- $HOME/.profile – the login shell executes the commands in the .profile script during startup
- $HOME/.ssh/config – ssh configuration for a specific user
Process
View Process
1 | top |
Kill Process
1 | kill <PID> |
References
[1] 10 Commands to Collect System and Hardware Info in Linux