Basic Linux Commands - Part 1


Nitin Venkatesh's Gravatar

Nitin Venkatesh
published Oct. 8, 2011, 11:40 a.m.


This post will be dealing with gathering basic information of your system, as to provide the most common information that’s required when posting in forums/AskUbuntu and other such places.

  1. lsb_release -a && uname -a

These two commands provide you with information about the the version of the Linux Kernel, the distribution, version of the distrubution, architecture and so on.

    nits@nits-workstation:~$ lsb_release -a && uname -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 11.04
    Release: 11.04
    Codename: natty
    Linux nits-workstation 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011 i686 i686 i386 GNU/Linux
  1. sudo lshw

This command lists your hardware. The full output is not shown purely because of its enormous length. When this command is executed, it may take a few seconds to churn out the output, so don’t freak out.

    nits@nits-workstation:~$ sudo lshw
    nits-workstation
    description: Computer
    width: 32 bits
    capabilities: smbios-2.4 dmi-2.4 smp-1.4 smp
    configuration: boot=normal cpus=1 uuid=A6BE2EF2-9DEE-11DC-B99B-00E0188501F7
    *-core
    description: Motherboard
    product: D945GCNL
    vendor: Intel Corporation
    physical id: 0
    version: AAD97184-105
    serial: BTNL74700DMK
    slot: Base Board Chassis Location
    *-cpu
    description: CPU
    product: Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz
    vendor: Intel Corp.
    physical id: 0
    bus info: cpu@0
    version: 6.15.13
    serial: 0000-06FD-0000-0000-0000-0000
    slot: LGA 775
    size: 2200MHz
    capacity: 4GHz
    width: 64 bits
    clock: 200MHz
    capabilities: boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx x86-64 constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm cpufreq
    configuration: id=1
  1. lspci

This command lists all the devices connected to the PCI buses and information about the PCI bus also.

    nits@nits-workstation:~$ lspci
    00:00.0 Host bridge: Intel Corporation 82945G/GZ/P/PL Memory Controller Hub (rev 02)
    00:02.0 VGA compatible controller: Intel Corporation 82945G/GZ Integrated Graphics Controller (rev 02)
    00:1b.0 Audio device: Intel Corporation N10/ICH 7 Family High Definition Audio Controller (rev 01)
    00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 01)
    00:1c.1 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2 (rev 01)
    00:1c.2 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 3 (rev 01)
    00:1c.3 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 4 (rev 01)
    00:1d.0 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #1 (rev 01)
    00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #2 (rev 01)
    00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #3 (rev 01)
    00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 01)
    00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 01)
    00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev e1)
    00:1f.0 ISA bridge: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge (rev 01)
    00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 01)
    00:1f.2 IDE interface: Intel Corporation N10/ICH7 Family SATA IDE Controller (rev 01)
    00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 01)
    02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)

You can use this following command to get information about the Graphics card, lspci | grep VGA

    nits@nits-workstation:~$ lspci | grep VGA
    00:02.0 VGA compatible controller: Intel Corporation 82945G/GZ Integrated Graphics Controller (rev 02)
  1. lsusb

This command shows the list of USB devices. The following is the output when I connect my thumb-drive, bluetooth dongle and my webcam

    nits@nits-workstation:~$ lsusb
    Bus 005 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 002: ID 15d9:0a4c Trust International B.V.
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 005: ID 0951:162d Kingston Technology
    Bus 001 Device 003: ID 18ec:3288 Arkmicro Technologies Inc.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  1. sudo blkid

This command shows information of the various block devices on the machine like the UUID, labels of devices, types and such information. (Useful for editing /etc/fstab)

    nits@nits-workstation:~$ sudo blkid
    /dev/sda1: LABEL="System Reserved" UUID="22F2DE0DF2DDE4D7" TYPE="ntfs"
    /dev/sda2: UUID="6E5E0E255E0DE6A5" TYPE="ntfs"
    /dev/sda4: LABEL="TestDrive" UUID="e6e47b0b-4c88-43f9-9165-81b2c1af4d1c" TYPE="ext4"
    /dev/sda5: LABEL="Storage_1" UUID="42DC637EDC636B5D" TYPE="ntfs"
    /dev/sda6: LABEL="Storage_2" UUID="D890877C9087603C" TYPE="ntfs"
    /dev/sda8: UUID="b73e274d-fdb2-45ac-acfe-9fcb48631ff7" TYPE="ext4"
    /dev/sda9: UUID="831304eb-1ee5-486c-a4a4-ef40b6c2d4dc" TYPE="ext4"
    /dev/sda10: UUID="dc6a5b75-1dbd-45d7-aecb-7c20d830bbfa" TYPE="ext4"
    /dev/sda11: UUID="9ba518d1-4a03-4b92-9b31-15db045c8cd4" TYPE="ext4"
    /dev/mapper/cryptswap1: UUID="aa02511a-1b84-4b45-aa6b-d16d232f1ddb" TYPE="swap"
  1. sudo fdisk -l

This command shows information of the different partitions present on the machine. (Useful for editing /etc/fstab)

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x27edc0d3

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 13 102400 7 HPFS/NTFS
    Partition 1 does not end on cylinder boundary.
    /dev/sda2 13 11749 94268416 7 HPFS/NTFS
    /dev/sda3 13979 60802 376101889 5 Extended
    /dev/sda4 11749 13979 17911808 83 Linux
    /dev/sda5 13979 27033 104857600 7 HPFS/NTFS
    /dev/sda6 27034 40088 104857600 7 HPFS/NTFS
    /dev/sda7 60553 60802 1999872 82 Linux swap / Solaris
    /dev/sda8 40088 42578 19998720 83 Linux
    /dev/sda9 42578 43823 9999360 83 Linux
    /dev/sda10 43823 50047 49998848 83 Linux
    /dev/sda11 50047 60552 84381696 83 Linux

    Partition table entries are not in disk order

    Disk /dev/dm-0: 2047 MB, 2047868928 bytes
    255 heads, 63 sectors/track, 248 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00f39708
  1. cat /etc/fstab

This command outputs the contents of the /etc/fstab file

    nits@nits-workstation:~$ cat /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid -o value -s UUID' to print the universally unique identifier
    # for a device; this may be used with UUID= as a more robust way to name
    # devices that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc nodev,noexec,nosuid 0 0
    /dev/sda8 / ext4 errors=remount-ro 0 1
    /dev/sda9 /home ext4 defaults 0 2
    #/dev/sda7 none swap sw 0 0
    /dev/mapper/cryptswap1 none swap sw 0 0
    #
    #
    #Nitin's Additions
    #
    #Storage_1
    UUID=42DC637EDC636B5D /mnt/Storage_1 ntfs-3g auto,users,uid=1000,gid=100,dmask=027,fmask=137,utf8 0 0
    #Storage_2
    UUID=D890877C9087603C /mnt/Storage_2 ntfs-3g auto,users,uid=1000,gid=100,dmask=027,fmask=137,utf8 0 0
    #Workshop
    UUID=dc6a5b75-1dbd-45d7-aecb-7c20d830bbfa /mnt/Workshop ext4 relatime 0 0
    #DlCenter
    UUID=9ba518d1-4a03-4b92-9b31-15db045c8cd4 /mnt/DlCenter ext4 relatime 0 0
    #TestDrive
    UUID=e6e47b0b-4c88-43f9-9165-81b2c1af4d1c /mnt/TestDrive ext4 relatime 0 0
  1. sudo mount -l

This command shows information of which partitions are mounted and where they are mounted.

    nits@nits-workstation:~$ sudo mount -l
    /dev/sda8 on / type ext4 (rw,errors=remount-ro,commit=0)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    none on /sys type sysfs (rw,noexec,nosuid,nodev)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    none on /sys/kernel/debug type debugfs (rw)
    none on /sys/kernel/security type securityfs (rw)
    none on /dev type devtmpfs (rw,mode=0755)
    none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
    none on /dev/shm type tmpfs (rw,nosuid,nodev)
    none on /var/run type tmpfs (rw,nosuid,mode=0755)
    none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
    /dev/sda5 on /mnt/Storage_1 type fuseblk (rw,noexec,nosuid,nodev,allow_other,blksize=4096,default_permissions) [Storage_1]
    /dev/sda6 on /mnt/Storage_2 type fuseblk (rw,noexec,nosuid,nodev,allow_other,blksize=4096,default_permissions) [Storage_2]
    /dev/sda10 on /mnt/Workshop type ext4 (rw,relatime,commit=0)
    /dev/sda11 on /mnt/DlCenter type ext4 (rw,relatime,commit=0)
    /dev/sda4 on /mnt/TestDrive type ext4 (rw,relatime,commit=0) [TestDrive]
    /dev/sda9 on /home type ext4 (rw,commit=0)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    /home/nits/.Private on /home/nits type ecryptfs (ecryptfs_check_dev_ruid,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs,ecryptfs_sig=d66442a87cac6932,ecryptfs_fnek_sig=4d92224358eba517)
    gvfs-fuse-daemon on /home/nits/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=nits)
  1. cat /proc/cpuinfo

This command displays the information about the CPU of the machine.

    nits@nits-workstation:~$ cat /proc/cpuinfo
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 6
    model : 15
    model name : Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz
    stepping : 13
    cpu MHz : 1200.000
    cache size : 2048 KB
    physical id : 0
    siblings : 2
    core id : 0
    cpu cores : 2
    apicid : 0
    initial apicid : 0
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 10
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dts
    bogomips : 4389.23
    clflush size : 64
    cache_alignment : 64
    address sizes : 36 bits physical, 48 bits virtual
    power management:
  1. cat /proc/meminfo

This command shows you information of the memory in your machine.

    nits@nits-workstation:~$ cat /proc/meminfo
    MemTotal: 2049852 kB
    MemFree: 82412 kB
    Buffers: 185072 kB
    Cached: 896260 kB
    SwapCached: 80 kB
    Active: 1083608 kB
    Inactive: 778592 kB
    Active(anon): 680916 kB
    Inactive(anon): 334188 kB
    Active(file): 402692 kB
    Inactive(file): 444404 kB
    Unevictable: 16 kB
    Mlocked: 16 kB
    HighTotal: 1177300 kB
    HighFree: 3392 kB
    LowTotal: 872552 kB
    LowFree: 79020 kB
    SwapTotal: 1999868 kB
    SwapFree: 1999356 kB
    Dirty: 896 kB
    Writeback: 0 kB
    AnonPages: 780844 kB
    Mapped: 157744 kB
    Shmem: 234236 kB
    Slab: 50924 kB
    SReclaimable: 30880 kB
    SUnreclaim: 20044 kB
    KernelStack: 3856 kB
    PageTables: 14304 kB
    NFS_Unstable: 0 kB
    Bounce: 0 kB
    WritebackTmp: 0 kB
    CommitLimit: 3024792 kB
    Committed_AS: 4722356 kB
    VmallocTotal: 122880 kB
    VmallocUsed: 28444 kB
    VmallocChunk: 44368 kB
    HardwareCorrupted: 0 kB
    HugePages_Total: 0
    HugePages_Free: 0
    HugePages_Rsvd: 0
    HugePages_Surp: 0
    Hugepagesize: 4096 kB
    DirectMap4k: 20472 kB
    DirectMap4M: 888832 kB