I wrote some small descriptions of my other favorites, but moved them into this page in an attempt to reduce the clutter on my home page.
man
Program manuals available without a search engine.
View manual for programs / configuration files
man ssh
man sshd_config
man jail.conf
View a specific section’s manual for pipe
man 2 pipe
man 7 pipe
Tips
When you install a new program with pacman
or apt
, it will normally include
manuals for its executables, config files, and more.
If you are unsure of how to use an executable, consider checking if it has a manpage with
man <executable name>
The same goes for configuration files.
man <config file name>
- Typically, configuration file man page names exclude the
/etc/program/
part of the file path. i.e. the manpage for/etc/fail2ban/jail.conf
isman jail.conf
The manpage will include information on how to use the executable like command-line parameters, expected inputs/outputs, and exit codes.
Section Numbers
per man 1 man
, where 1 is the section number
The table below shows the section numbers of the manual followed by the
types of pages they contain.
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions, e.g. /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
Pager
Manuals will be paged using the pager specified in $MANPAGER
or $PAGER
. On a normal install,
this is less
head and tail
Simple, extensible file previewers.
Beginning of a File - head
head big.txt
- first 10 lineshead -n 3 big.txt
- first 3 lineshead -n -5 big.txt
- up to the 5th-to-last line (exclusive)
End of a File - tail
tail big.txt
- last 10 linestail -n 3 big.txt
last 3 linestail -n +5 big.txt
starting at the 5th line (inclusive)
Following Output
tail
also comes with follow output feature. This can be useful when
watching logging/output files written to in real-time by other programs.
tail -f output.txt
last 10 lines and print new lines when they are writtentail -n +0 -f output.txt
all lines and print new lines when they are written
See Also
man head
man tail
less
A lightweight file pager
Open a file for paging
less file.txt
Page a command with lots of output
curl example.com | less
Hotkeys
less
hotkeys are similar to those in vim
-
q
- exit less -
j
- up one line -
k
- down one line -
g
- top of file -
G
- bottom of file -
=
- display location in status message -
/pattern<cr>
- search for the pattern in the file- notably, this will not
-
<number><cr>
- go to line at number- you don’t need to press
:
first like invim
- you don’t need to press
-
-N<cr>
- enable line numbers- this also works when passed as a command-line flag
See also
df
df
displays disk limits (size
, used
, avail
) of mounted filesystems.
Typically, the most important mountpoints to consider are root (/
) and boot (/boot
)
Human-Readable Form (-h
)
$ df -h
Filesystem Size Used Avail Use% Mounted on
dev 7.8G 0 7.8G 0% /dev
run 7.8G 1.3M 7.8G 1% /run
/dev/nvme0n1p3 457G 32G 402G 8% /
tmpfs 7.8G 22M 7.8G 1% /dev/shm
tmpfs 7.8G 1.2M 7.8G 1% /tmp
/dev/nvme0n1p1 511M 104M 408M 21% /boot
tmpfs 1.6G 12K 1.6G 1% /run/user/1000
- I
alias df='df -h'
in my.zshrc
to get the human-readable form by default.
Default Form
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
dev 8104460 0 8104460 0% /dev
run 8115748 1232 8114516 1% /run
/dev/nvme0n1p3 478232320 33257164 420608820 8% /
tmpfs 8115748 22396 8093352 1% /dev/shm
tmpfs 8115748 1192 8114556 1% /tmp
/dev/nvme0n1p1 523248 105996 417252 21% /boot
tmpfs 1623148 12 1623136 1% /run/user/1000
See Also
fdisk
fdisk
gives you full control when partitioning hard-drives, ssds, flash-drives, and other disks.
List Available Disks and Partitions
$ sudo fdisk -l
[sudo] password for joe:
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: PM961 NVMe SAMSUNG 512GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1D01CEB6-E01F-4B03-9C66-A4A697097A0E
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 1050623 1048576 512M EFI System
/dev/nvme0n1p2 1050624 26216447 25165824 12G Linux swap
/dev/nvme0n1p3 26216448 1000214527 973998080 464.4G Linux root (x86-64)
Format a Disk
Common situations to want to format a disk with fdisk
include
- Performing a fresh Linux installation
- Re-partitioning a mangled flash drive
NOTE: While fdisk
is a powerful tool, keep in mind that it will let you format and wipe
your disks more easily than a GUI tool. Use care so you don’t accidentally delete your data!
NOTE: Make sure to double-check you are modifying the correct disk before applying changes.
$ sudo fdisk /dev/sda
...
Command (m for help):
- Type
m
to get help for all the actions available in the interface - Key Commands
m
- print the help menup
- print the current partition tabled
- delete a partitionn
- add a new partitionq
- quit without applying changesw
- write partition changes to disk (this can destroy the previous partition scheme!)
Once your partitions are set up, you may want to use mkfs
to install a filesystem on it
See also
man fdisk
- https://wiki.archlinux.org/title/Fdisk
du
- estimate directory sizedf
- mountpoint statistics- https://man.archlinux.org/man/mkfs.8
lsblk
lsblk
gives an overview of the disks available on the system
Example
My NAS has 6 6TB hard-disks and 1 512MB NVMe
worker@nas $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 5.5T 0 disk
├─sda1 8:1 0 2G 0 part
└─sda2 8:2 0 5.5T 0 part
sdb 8:16 0 5.5T 0 disk
├─sdb1 8:17 0 2G 0 part
└─sdb2 8:18 0 5.5T 0 part
sdc 8:32 0 5.5T 0 disk
├─sdc1 8:33 0 2G 0 part
└─sdc2 8:34 0 5.5T 0 part
sdd 8:48 0 5.5T 0 disk
├─sdd1 8:49 0 2G 0 part
└─sdd2 8:50 0 5.5T 0 part
sde 8:64 0 5.5T 0 disk
├─sde1 8:65 0 2G 0 part
└─sde2 8:66 0 5.5T 0 part
sdf 8:80 0 5.5T 0 disk
├─sdf1 8:81 0 2G 0 part
└─sdf2 8:82 0 5.5T 0 part
nvme0n1 259:0 0 465.8G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
├─nvme0n1p2 259:2 0 464.3G 0 part /
└─nvme0n1p3 259:3 0 976M 0 part [SWAP]