Skip to content
Search

Linux:UsefulCommandLines

lastmod 2026-02-06created 2016-04-2119 edits

A collection of commands frequently used in Linux.

Hardware

  • cat /proc/version or cat /etc/issue: kernel version.
  • cat /proc/cpuinfo: processor information, CPU type, model, manufacturer, etc.
  • cat /porc/meminfo: memory information, physical memory and virtual memory.
  • cat /proc/devices: list of devices currently configured in the kernel.
  • mount: information on all mounted devices.
  • df or df -u: hard disk usage.
  • cat /porc/filesystems: list of file systems configured in the kernel.
  • cat /proc/swaps: size and usage of swap partitions.
  • cat /proc/interrupts: shows the list of interrupts (IRQ) in use by devices.
  • cat /proc/ioports: input/output ports currently in use.
  • cat /proc/partitions: partition information.
  • cat /proc/uptime: how long the system has been up.
  • cat /proc/stat: various information about system status.
  • cat /proc/zoneinfo: ZONEINFO.
  • dmesg: prints the messages shown during system boot.
  • ps: information on running processes.
  • ps -p - t: list of processes and threads.
  • ps -aux: view currently running processes.
  • set or printenv: prints environment settings.

System

  • vmstat: monitors system resource status, CPU, I/O, Memory, etc.
  • cat /proc/diskstats: disk utilization and throughput, i.e. disk I/O status.
  • top: monitors system process status.
  • procrank: memory per process.
  • dumpsys meminfo [PID]: detailed memory information for the given process.
  • cat /proc/[PID]/stat: information about the given process.
  • cat /proc/[PID]/maps: memory map information for the given process.
  • cat /proc/vmstat: virtual memory statistics.
  • librank: memory usage per library.
  • free -m: view memory usage.

Network

  • cat /proc/net/netlink: network information.
  • netcfg: list of network interfaces and IP addresses.
  • netstat: check network connection status.
  • nc: cat command for networks (netcat).
  • ifconfig: network interface configuration information.
  • tcpdump: real-time packet monitoring.
  • iftop: top for networks.
  • route: shows the routing table to the given host.
  • ping: tests the connection to a remote host.
  • cat /proc/net/route: Route.

How to assign and change IP addresses on a Linux server

  • Method 1: ifconfig, netstat, route
  • Method 2: redhat-config-network, system-config-network, netconfig
  • Method 3: /etc/sysconfig/network, /etc/sysconfig/network-scaripts/ifcfg-eth0

How to change IP addresses using network configuration files

  • HOSTNAME, GATEWAY settings.
    • /etc/sysconfig/network
  • BROADCAST, NETWORK, NETMASK settings.
    • /etc/sysconfig/network-scripts/ifcfg-eth0
    • /etc/sysconfig/network-scripts/ifcfg-eth1
    • ...
    • /etc/sysconfig/network-scripts/ifcfg-ethn
  • Network script to use for applying network settings after configuring the two files above.
    • /etc/rc.d/init.d/network start|restart|stop
  • Check routing information using netstat -nr.

How to assign and use multiple IP addresses on a single Linux machine

  1. Check the initial configuration of a Linux server using one IP address
  2. Assign multiple IP addresses to one server
    • Make several copies of the ifcfg-eth0 file in the /etc/sysconfig/network-scripts directory.
      • cp ifcfg_eth0 ifcfg-eth0:0
      • cp ifcfg_eth0 ifcfg-eth0:1
      • cp ifcfg_eth0 ifcfg-eth0:2
      • cp ifcfg_eth0 ifcfg-eth0:3
    • Edit the DEVICE and IPADDR entries in each copied file.
  3. Restart using the /etc/rc.d/init.d/network script to apply it to the server.
  4. Check with ifconfig that they were actually assigned.

Network configuration using netconfig

  • Run the /usr/sbin/netconfig command.

Changing the HOSTNAME of a Linux server

  • /etc/sysconfig/network
  • hostname: command that shows the current hostname

How to use traceroute to check network communication paths

  • A command that traces the communication path to a target host.
  • Test results.
    1. Is communication with the target host working well?
      • Segments where communication is not working well are marked with "*".
    2. How many hops (number of gateways passed through) does communication to the target host take?
    3. Are there segments with delays in communication to the target host? If so, what is the cause?
      • When the ms value is higher than average.
    4. You should be able to check information on specific segments along the communication path to the target host.

How to use netstat to check network status

  • netstat is a command for comprehensively checking network connections, routing tables, network interface status, etc.
  • Also widely used as a way to perform security checks.
  • Option list.
  • -a: all, shows everything.
  • -n: prints results as decimal numeric information.
  • -r: same as route.
  • -p: prints running programs and PID information.
  • -i: network interface information.
  • -c: prints continuously.
  • -l: prints information on listening sockets.
  • -s: prints statistics for each protocol.
    • LISTEN: connection is possible.
    • SYS-SENT: state of having requested a connection.
    • SYN_RECEIVED: state of waiting for an acknowledgment message after responding to a connection request.
    • ESTABLISHED: state in which the connection is complete after all of the preceding three-step connection process has finished.
    • FIN-WAIT1, CLOSE-WAIT, FIN-WAIT2: closing process after receiving a close request to terminate the connection.
    • CLOSING: state in which a sent message was lost.
    • TIME-WAIT: state held for a while after the connection is closed
    • CLOSED: the connection is completely closed.

How to use whois to check information on organizations using a network

  • You can look up information on a specific domain, or on the organization using a specific IP Address or a specific network.
  • Look up information on organizations using domestic (Korean) domains.
  • Look up information on organizations using international domains.

Setting LAN card speed and transfer mode using ethtool

  • Check Ethernet settings: ethtool eth0
  • Change Ethernet settings: ethtool -s eth0 [speed 10|100|1000] [duplex half|full] [autoneg on|off]

Capturing TCP packets and monitoring packet data using tcpdump

  • tcpdump is a command for monitoring or dumping all or the headers of data packets sent and received through a specified network interface.
  • Option list.
    • -i: specifies the target network interface.
      ex) tcpdump -i eth0
    • -w: saves to the specified file.
      ex) tcpdump -i eth0 -w TCPDUMP(파일이름)
    • -r: views a file containing saved packet headers in text format.
      ex) tcpdump -r TCPDUMP
    • -c: specifies the number of packet headers to check.
      ex) tcpdump -i eth0 -c 10
  • Checking all data packets sent and received on a specific port of the server.
    • tcpdump -w tcpdump.log -s 1500 tcp port 22 and host 192.168.0.100
      Captures, at a length of 1500, all packets on tcp port 22 among the communication data packets between the current local server and the 192.168.0.100 server, and saves them to the tcpdump.log file.
    • How to view the contents of the tcpdump.log file in ASCII mode: tcpdump -Xqnr tcpdump.log

Checking network interface settings using mii-tool

  • Check the settings of the LAN cards currently installed in the server
  • Option list.
    • -v: view details.
    • -r: reset.

Checking and changing LAN card mode settings using modprobe

  • Check and change Ethernet settings.
    • lsmod: check currently loaded modules.
    • /etc/modules.conf: check module names.
  • modprobe 랜카드모듈명 speed_duplex=설정번호
    • speed_duplex=0: auto detection mode. //(speed is set to 10M. duplex is set to auto-detection mode.)//
    • speed_duplex=1: 10M, half duplex mode.
    • speed_duplex=2: 10M, full duplex mode.
    • speed_duplex=3: 100M, half duplex mode.
    • speed_duplex=4: 100M, full duplex mode.

Introduction to modern Linux commands

Recently, repositories on GitHub developing Linux commands written in Rust have been catching the eye. Having tried them myself, many of the commands have pretty colors and flashy output and were convenient, so I'd like to collect and introduce the commands I found.

Command Line Tools

Text

Common

grep, sed, awk, cat, xargs, rev, tee, ack, tr, stdbuf, split

Diff

diff, patch

Cutting

cut, head, tail, less, more, split, watch

Sort

uniq, sort

Hash

base64, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum

Clipboard

clip (Windows), pbcopy (Mac OSX), pbpaste (Mac OSX), xclip (Debian)

E.T.C

regexp, parallel

User Management

Communication

write, wall, mesg, mail, biff, who, w, last

User

adduser, useradd, passwd, deluser, userdel, chpass, chfn, chsh, usermod

Group

gpasswd, addgroup, groupadd, groupmod, delgroup, groupdel

E.T.C

Linux:User, /etc/passwd, /etc/shadow, /etc/group

Filesystem

Common

ls, readlink, realpath

E.T.C

Filesystem

Logging

Login/Logout

last, lastlog, lastb

Logging

logrotate

Monitoring

watch

E.T.C

Linux

Network

Network

netcfg, netstat, nc, ifconfig, tcpdump, iftop, route, ping, nslookup, iPerf, socat

E.T.C

Linux:Network

Hardware

Hardware (CLI)

lscpu, lshw, hwinfo, lspci, lsscsi, lsusb, Inxi, lsblk, df, Pydf, fdisk, mount, umount, free, dmidecode, hdparm

Hardware (GUI)

hardinfo

Filesystem

lsof, lsblk, fsck, fdisk, blkid, du, df

Bluetooth

hciattach, hciconfig, hcitool, bluetoothctl, rfkill

Keyboard

showkey

E.T.C

Hardware, Linux:Hardware

Binary

Binary

otool, objdump, nm, rebase, fallocate

Build

ld

E.T.C

GNU Binutils

Mutual Exclusion

Common

flock

E.T.C

mutex

System

Module

lsmod, insmod, rmmod

Logging

dmesg

E.T.C

OS, Linux:Kernel:Module

Terminal

tty

watch

E.T.C

See also

Favorite site

Tutorials

author Zer0 sitemap