Linux command line tips 1

By | June 24, 2015

The Linux command line environment is very powerful and full of very useful command line instructions that are ignored by a lot o people.
Following are some of the discovered commands I find very usefull:

The “ls like” group:

List all the usb devices:

[root@localhost ~]# lsusb
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 1bcf:2883 Sunplus Innovation Technology Inc.
Bus 003 Device 003: ID 8087:07da Intel Corp.
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 1bcf:0c31 Sunplus Innovation Technology Inc. SPIF30x Serial-ATA bridge
Bus 001 Device 003: ID 0458:006a KYE Systems Corp. (Mouse Systems)
Bus 001 Device 002: ID 045e:0750 Microsoft Corp. Wired Keyboard 600
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

List all the pci devices:

[root@localhost ~]# [root@localhost ~]# lspci
00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)
00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation HM76 Express Chipset LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 650M] (rev a1)
03:00.0 Network controller: Intel Corporation Centrino Wireless-N 2230 (rev c4)
04:00.0 Ethernet controller: Qualcomm Atheros AR8161 Gigabit Ethernet (rev 10)

List all the cpus

[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 58
Model name: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
Stepping: 9
CPU MHz: 1294.828
CPU max MHz: 3300.0000
CPU min MHz: 1200.0000
BogoMIPS: 4589.38
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 6144K
NUMA node0 CPU(s): 0-7

List all scsi devices

[root@localhost ~]# lsscsi
[0:0:0:0] disk ATA Hitachi HTS54757 A60A /dev/sda
[2:0:0:0] disk ATA INTEL SSDSC2CT18 300i /dev/sdb
[6:0:0:0] disk TOSHIBA MK7559GSM /dev/sdc

Display the current calendar

[root@localhost ~]# cal
June 2015
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Find what rpm provides a command line

[root@localhost ~]# dnf whatprovides lsscsi
Last metadata expiration check performed 1:40:28 ago on Wed Jun 24 13:51:44 2015.
lsscsi-0.28-1.fc22.x86_64 : List SCSI devices (or hosts) and associated information
Repo : @System

lsscsi-0.28-1.fc22.x86_64 : List SCSI devices (or hosts) and associated information
Repo : fedora

Find what process is listening to a port

[root@localhost ~]# [root@localhost ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2197/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1663/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1650/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2313/sendmail: acce
tcp 0 0 0.0.0.0:64922 0.0.0.0:* LISTEN 1946/skype
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1017/rpcbind

Advertisements