GNU/Linux CLI Cheatsheet

This site is a reference for GNU Core Utils

Last updated on 14 June, 2021 at 09:50:16 Optimized for

What many would refer to as Linux CLI or maybe even Bash is a powerful toolset known as GNU core utility tools which contain many basic tools such as cat, ls and rm. The GNU Coreutils was created in 2002 by merging earlier packages textutils, fileutils and shellutils.

Website logo
For the full experience we recommend viewing this website on a desktop or tablet.

Output of Entire Files

Command Description
cat

Concatenate and write files.

tac

Concatenate and write files in reverse.

nl

Number lines and write files.

od

Write files in octal or other formats.

base32

Transform data into printable data.

base64

Transform data into printable data.

basenc

Transform data into printable data.

Formatting File Contents

Command Description
fmt

Reformat paragraph text.

pr

Paginate or columnate files for printing.

fold

Wrap input lines to fit in specified width.

Output of Parts of Files

Command Description
head

Output the first part of files.

tail

Output the last part of files.

split

Split a file into pieces.

csplit

Split a file into context-determined pieces.

Summarizing Files

Command Description
wc

Print newline, word, and byte counts.

sum

Print checksum and block counts.

cksum

Print CRC checksum and byte counts.

b2sum

Print or check BLAKE2 digests.

md5sum

Print or check MD5 digests.

sha1sum

Print or check SHA-1 digests.

sha224sum sha256sum sha384sum sha512sum

Print or check SHA-2 digests.

Operating on Sorted Files

Command Description
sort

Sort text files.

shuf

Shuffle text files.

uniq

Uniquify files.

comm

Compare two sorted files line by line.

ptx

Produce a permuted index of file contents.

tsort

Topological sort

Operating on Fields

Command Description
cut

Print selected parts of lines.

paste

Merge lines of files.

join

Join lines on a common field.

Operating on Characters

Command Description
tr

Translate, squeeze, and/or delete characters.

expand

Convert tabs to spaces.

unexpand

Convert spaces to tabs.

Directory Listing

Command Description
ls

List directory contents.

dir

Briefly ls.

vdir

Verbosely ls.

dircolors

Color setup for ls, etc.

Basic File Operations

Command Description
cp

Copy files.

dd

Convert and copy a file.

install

Copy files and set attributes.

mv

Move (rename) files.

rm

Remove files or directories.

shred

Remove files more securely.

Special Filetypes

Command Description
link

Make a hard link via the link syscall

ln

Make links between files.

mkdir

Make directories.

mkfifo

Make FIFOs (named pipes).

mknod

Make block or character special files.

readlink

Print value of a symlink or canonical file name.

rmdir

Remove empty directories.

unlink

Remove files via the unlink syscall

Changing File Attributes

Command Description
chown

Change file owners and groups.

chgrp

Change file groups.

chmod

Change access permissions.

touch

Change file timestamps.

Disk Usage

Command Description
df

Report file system disk space usage.

du

Estimate file space usage.

stat

Report file or file system status.

sync

Synchronize cached writes to persistent storage.

truncate

Shrink or extend the size of a file.

Printing text

Command Description
echo

Print a line of text.

printf

Format and print data.

yes

Print a string until interrupted.

Conditions

Command Description
false

Do nothing, unsuccessfully.

true

Do nothing, successfully.

test

Check file types and compare values.

expr

Evaluate expressions.

Redirection

Command Description
tee

Redirect output to multiple files or processes.

Filename Manipulation

Command Description
basename

Strip directory and suffix from a file name.

dirname

Strip last file name component.

pathchk

Check file name validity and portability.

mktemp

Create temporary file or directory.

realpath

Print resolved file names.

Working Context

Command Description
pwd

Print working directory.

stty

Print or change terminal characteristics.

printenv

Print environment variables.

tty

Print file name of terminal on standard input.

User Information

Command Description
id

Print user identity.

logname

Print current login name.

whoami

Print effective user ID

groups

Print group names a user is in

users

Print login names of users currently logged in.

who

Print who is currently logged in

System Context

Command Description
date

Print or set system date and time.

arch

Print machine hardware name.

nproc

Print the number of processors.

uname

Print system information.

hostname

Print or set system name.

hostid

Print numeric host identifier.

uptime

Print system uptime and load.

SELinux Context

Command Description
chcon

Change SELinux context of file

runcon

Run a command in specified SELinux context

Modified Command Invocation

Command Description
chroot

Modify the root directory

env

Modify environment variables.

nice

Modify niceness.

nohup

Immunize to hangups.

stdbuf

Modify buffering of standard streams.

timeout

Run with time limit

Process Control

Command Description
kill

Sending a signal to processes.

Delaying

Command Description
sleep

Delay for a specified time.

Numeric Operations

Command Description
factor

Show factors of numbers.

numfmt

Reformat numbers

seq

Print sequences of numbers