Linux:UsefulCommandLines
lastmod 2026-02-06created 2016-04-2119 edits
A collection of commands frequently used in Linux.
Hardware
-
cat /proc/versionorcat /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. -
dfordf -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. -
setorprintenv: 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
-
-
/etc/sysconfig/network-scripts/ifcfg-eth0 -
/etc/sysconfig/network-scripts/ifcfg-eth1 -
... -
/etc/sysconfig/network-scripts/ifcfg-ethn
-
/etc/rc.d/init.d/network start|restart|stop
netstat -nr. How to assign and use multiple IP addresses on a single Linux machine
- Check the initial configuration of a Linux server using one IP address
- Assign multiple IP addresses to one server
- Make several copies of the ifcfg-eth0 file in the
/etc/sysconfig/network-scriptsdirectory.-
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.
- Make several copies of the ifcfg-eth0 file in the
- Restart using the
/etc/rc.d/init.d/networkscript to apply it to the server. - Check with ifconfig that they were actually assigned.
Network configuration using netconfig
- Run the
/usr/sbin/netconfigcommand.
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.
- Is communication with the target host working well?
- Segments where communication is not working well are marked with "*".
- Is communication with the target host working well?
- When the ms value is higher than average.
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.
- Linux shell:
whois -h whois.krnic.net [Domain/IP] - Web lookup URL: http://whois.nic.or.kr
- Linux shell:
- Linux shell :
whois -h whois.interrnic.net [Domain/IP] - Web lookup URL : http://www.networksolution.com/en_US/whois/index.jtml
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
-
-
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
- Use exa rather than ls! Introduction to modern Linux commands (translation)
- My Favorite CLI Tools
- [Recommended] An Illustrated Guide to Some Useful Command Line Tools
- Github - ibraheemdev/modern-unix - neatly organized with screenshots for easy viewing.
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.
- Alacritty - Terminal emulator
- alt - Find alternate files
- bat - cat with code highlighting - https://github.com/sharkdp/bat
- bb - System monitor
- chars - Unicode character search
- dot - Dot files manager
- duf - a modern du/df utility.
- dust - disk usage analysis. A nicer-looking du
- eva - Calculator
- exa - a modern ls - https://github.com/ogham/exa
- fd - an easy-to-use find - https://github.com/sharkdp/fd
- hexyl - Hex viewer that replaces the od command - https://github.com/sharkdp/hexyl
- hyperfine - Benchmarking tool
- jq - awk/XPath for JSON
- mdcat - renders Markdown in the terminal.
- ncdu - alternative to du.
- navi - open source made with Rust that provides cheat sheets interactively on the terminal command line.
- pass - Password manager
- Podman - Docker alternative
- procs - replacement for the ps command - https://github.com/dalance/procs
- Restic - Encrypted backup tool
- ripgrep - finds files with regular expressions, replacement for grep - https://github.com/BurntSushi/ripgrep
- shotgun - Take screenshots
- skim - Fuzzy Finder. Finds files asynchronously & dynamically, interactively.
- slop - Graphical region selection
- Syncthing - Decentralised file synchronisation
- tig - TUI for git
- titlecase - Convert text to title case
- up - Ultimate Plumber - CLI tool that lets you edit complex Linux pipe chains while watching a real-time preview
- Universal Ctags - Maintained ctags fork
- watchexec - Run commands in response to file system changes
- watchexec - detects file changes and runs commands.
- z - jump to frequently used directories in one go.
- zola - static site compiler.
- Changelog - The changelog for this page
- tokei - Count your code, quickly.
Command Line Tools
| Common | grep, sed, awk, cat, xargs, rev, tee, ack, tr, stdbuf, split | |
| Diff | ||
| Cutting | ||
| Sort | ||
| base64, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum | ||
| Clipboard | clip (Windows), pbcopy (Mac OSX), pbpaste (Mac OSX), xclip (Debian) | |
| E.T.C |
| Communication | ||
| User | adduser, useradd, passwd, deluser, userdel, chpass, chfn, chsh, usermod | |
| Group | ||
| E.T.C |
| Common | ||
| E.T.C |
| Login/Logout | ||
| Logging | ||
| Monitoring | ||
| E.T.C |
| Network | netcfg, netstat, nc, ifconfig, tcpdump, iftop, route, ping, nslookup, iPerf, socat | |
| E.T.C |
| Hardware (CLI) | lscpu, lshw, hwinfo, lspci, lsscsi, lsusb, Inxi, lsblk, df, Pydf, fdisk, mount, umount, free, dmidecode, hdparm | |
| Hardware (GUI) | ||
| hciattach, hciconfig, hcitool, bluetoothctl, rfkill | ||
| Keyboard | ||
| E.T.C |
| Binary | ||
| Build | ||
| E.T.C |
| Common | ||
| E.T.C |
| E.T.C |
| E.T.C |
See also
- Linux
- Shell:Basic - shell basics.
Favorite site
-
http://blueb.net/blog/1316 - Useful commands in Android adb shell
- Linux server network management
- My Favorite CLI Tools
Tutorials
- [Recommended] Welcome to Linux command line for you and me! — Linux command line for you and me 0.1 documentation