The sysctl command on Linux may be used to return information about your installed hardware; as well as virtual memory information. Below is an example looking at virtual memory information.
zsh 7 % sysctl -a | grep vm sysctl: permission denied on key 'kernel.cad_pid' sysctl: permission denied on key 'kernel.usermodehelper.bset' sysctl: permission denied on key 'kernel.usermodehelper.inheritable' vm.block_dump = 0 vm.dirty_background_bytes = 0 vm.dirty_background_ratio = 5 vm.dirty_bytes = 0 vm.dirty_expire_centisecs = 3000 vm.dirty_ratio = 10 vm.dirty_writeback_centisecs = 500 vm.drop_caches = 0 vm.extfrag_threshold = 500 vm.hugepages_treat_as_movable = 0 vm.hugetlb_shm_group = 0 vm.laptop_mode = 0 vm.legacy_va_layout = 0 vm.lowmem_reserve_ratio = 256 256 32 vm.max_map_count = 65530 vm.memory_failure_early_kill = 0 vm.memory_failure_recovery = 1 vm.min_free_kbytes = 67584 vm.min_slab_ratio = 5 vm.min_unmapped_ratio = 1 vm.mmap_min_addr = 65536 vm.nr_hugepages = 0 vm.nr_hugepages_mempolicy = 0 vm.nr_overcommit_hugepages = 0 vm.nr_pdflush_threads = 0 vm.numa_zonelist_order = default vm.oom_dump_tasks = 1 vm.oom_kill_allocating_task = 0 vm.overcommit_memory = 0 vm.overcommit_ratio = 50 vm.page-cluster = 3 vm.panic_on_oom = 0 vm.percpu_pagelist_fraction = 0 vm.scan_unevictable_pages = 0 vm.stat_interval = 1 vm.swappiness = 60 vm.vfs_cache_pressure = 100 vm.zone_reclaim_mode = 0 |
This is another example, I am hiding the error output and only showing the output I want to see.
┌──[jason@11000000.10101000.00000001.00000011]─[~] └──╼ ╼ $ sysctl -a --ignore 2>/dev/null | grep net.ipv4.route net.ipv4.route.error_burst = 500 net.ipv4.route.error_cost = 100 net.ipv4.route.gc_elasticity = 8 net.ipv4.route.gc_interval = 60 net.ipv4.route.gc_min_interval = 0 net.ipv4.route.gc_min_interval_ms = 500 net.ipv4.route.gc_thresh = -1 net.ipv4.route.gc_timeout = 300 net.ipv4.route.max_size = 2147483647 net.ipv4.route.min_adv_mss = 256 net.ipv4.route.min_pmtu = 552 net.ipv4.route.mtu_expires = 600 net.ipv4.route.redirect_load = 2 net.ipv4.route.redirect_number = 9 net.ipv4.route.redirect_silence = 2048 |
This is showing information about the IPv4 routing setup.
You may execute a command like this to change a system setting.
sudo sysctl -w vm.swappiness=1 |
This is a temporary setting.
To make this a permanent feature of your system, add this line to your /etc/sysctl.conf file.
The /etc/sysctl.conf file is very useful for changing network settings to optimise security and remove unneeded network settings like a workstation receiving routing packets.
vm.swappiness=1 |
In this example; I am using the hdparm command as root to return the identification information about one of my hard drives. The hdparm command is very powerful and you must understand many of the options available before you press RETURN.
zsh 10 [13] % sudo hdparm -i /dev/sda [sudo] password for john: /dev/sda: Model=ST3500418AS, FwRev=CC38, SerialNo=9VM6XCTQ Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4 BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=off CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=976773168 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 AdvancedPM=no WriteCache=enabled Drive conforms to: unknown: ATA/ATAPI-4,5,6,7 * signifies the current active mode |
And this is the dmidecode command that I am using to retrieve information about the CPU I have in my machine.
zsh 15 % sudo dmidecode | grep CPU Version: Intel(R) Core(TM) i3 CPU |
The sudo lshw command will also return information about your computer system and the hardware therein. The output of this command is very thorough and will help give an insight into what hardware the computer has without opening the case.
If you use the lscpu command; you may see what CPU the computer has without using sudo.
zsh 30 % lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 37 Stepping: 2 CPU MHz: 1197.000 BogoMIPS: 5866.18 Virtualisation: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 4096K NUMA node0 CPU(s): 0-3 |
Getting back to the sudo lshw command; the -html parameter to that command will generate a HTML report of all installed hardware. Use it like this.
zsh 35 % sudo lshw -html > hardware.html |