Skip to content

Latest commit

 

History

History
127 lines (64 loc) · 3.2 KB

useful_one_liners.md

File metadata and controls

127 lines (64 loc) · 3.2 KB

Useful one-liners

  • expr: perform arithmetic or boolean operations or evaluate regular expressions

  • m4: simple macro processor

  • yes: print a string a lot

  • cal: nice calendar

  • env: run a command (useful in scripts)

  • printenv: print out environment variables (useful in debugging and scripts)

  • look: find English words (or lines in a file) beginning with a string

  • cut, paste and join: data manipulation

  • fmt: format text paragraphs

  • pr: format text into pages/columns

  • fold: wrap lines of text

  • column: format text fields into aligned, fixed-width columns or tables

  • expand and unexpand: convert between tabs and spaces

  • nl: add line numbers

  • seq: print numbers

  • bc: calculator

  • factor: factor integers

  • toe: table of terminfo entries

  • nc: network debugging and data transfer

  • socat: socket relay and tcp port forwarder (similar to netcat)

  • dd: moving data between files or devices

  • file: identify type of a file

  • tree: display directories and subdirectories as a nesting tree; like ls but recursive

  • stat: file info

  • time: execute and time a command

  • timeout: execute a command for specified amount of time and stop the process when the specified amount of time completes.

  • lockfile: create semaphore file that can only be removed by rm -f

  • logrotate: rotate, compress and mail logs.

  • watch: run a command repeatedly, showing results and/or highlighting changes

  • tac: print files in reverse

  • comm: compare sorted files line by line

  • strings: extract text from binary files

  • tr: character translation or manipulation

  • iconv or uconv: conversion for text encodings

  • split and csplit: splitting files

  • sponge: read all input before writing it, useful for reading from then writing to the same file, e.g., grep -v something some-file | sponge some-file

  • units: unit conversions and calculations; converts furlongs per fortnight to twips per blink (see also /usr/share/units/definitions.units)

  • apg: generates random passwords

  • xz: high-ratio file compression

  • ldd: dynamic library info

  • nm: symbols from object files

  • ab: benchmarking web servers

  • strace: system call debugging

  • cssh: visual concurrent shell

  • rsync: sync files and folders over SSH or in local file system

  • host and dig: DNS lookups

  • lsof: process file descriptor and socket info

  • dstat: useful system stats

  • iostat: Disk usage stats

  • mpstat: CPU usage stats

  • vmstat: Memory usage stats

  • htop: improved version of top

  • last: login history

  • w: who's logged on

  • id: user/group identity info

  • ss: socket statistics

  • dmesg: boot and system error messages

  • sysctl: view and configure Linux kernel parameters at run time

  • hdparm: SATA/ATA disk manipulation/performance

  • lsblk: list block devices: a tree view of your disks and disk partitions

  • lshw, lscpu, lspci, lsusb, dmidecode: hardware information, including CPU, BIOS, RAID, graphics, devices, etc.

  • lsmod and modinfo: List and show details of kernel modules.

  • fortune, ddate, and sl: um, well, it depends on whether you consider steam locomotives and Zippy quotations "useful"