Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Reference Section

ls Command Switches

  • --all (or -a)—Shows all files, including . and ..

  • --almost-all (or -A)—Shows all files except . and ..

  • --block-size=n—Shows the size of files as n-byte blocks

  • --classify (or -F)—Appends a symbol to a filename to indicate its type

  • --color=t—Uses color for filenames, t equals never, always, or auto.

  • --dereference (or -L)—Shows items referenced by symbolic links

  • --directory (or -d)—Shows information about a directory instead of showing its contents

  • --dired (or -D)—Output for emacs dired mode

  • --escape (or -b)—Prints octal escape sequences for unprintable characters

  • --file-type (or -p)—Same as --classify

  • --format=across (or -x)—Sorts by lines instead of columns

  • --format=commas (or -m)—Shows filenames as a list separated by commas

  • --format=long (or -l)—Shows detailed (long) listings

  • --format=single-column (or -1)—Shows results as one file per line

  • --format=verbose—Same as the long format

  • --format=vertical (or -C)—Lists entries by columns

  • --full-time—Shows full date and time

  • --hide-control-chars (or -q)—Displays a ? for unprintable characters in filenames

  • --human-readable (or -h)—Shows sizes in kilobytes, megabytes, and so on, instead of raw bytes

  • --ignore=p (or -I)—Ignores files matching the pattern p

  • --ignore-backups (or -B)—Does not list files ending with ~

  • --indicator-style=classify—Same as --classify

  • --indicator-style=none—Don't classify files

  • --indicator-style=file-type—Same as --file-type

  • --inode (or -i)—Prints the inode number for the file

  • --kilobytes (or -k)—Same as block size 1024

  • -f—Does not sort, enable -aU, disable -lst

  • --literal (or -N)—Shows unprintable characters in names as-is (unlike -q)

  • --no-group (or -G)—Hides the group that owns the file

  • --numeric-uid-gid (or -n)—Shows UIDs and GIDs as numbers not names

  • -o—Shows long listings without the file group ownership information

  • --quote-name (or -Q)—Encloses filenames in double quotes

  • --quoting-style=literal—Same as --literal

  • --quoting-style=locale—Uses locale's quoting style around individual filenames

  • --quoting-style=shell—Uses shell quoting when necessary around individual filenames

  • --quoting-style=shell-always—Always uses shell quoting around individual filenames

  • --quoting-style=c—Uses C string quoting around individual filenames

  • --quoting-style=escape—Escapes special characters with backslashes

  • --reverse (or -r)—Reverses the sorting order

  • --recursive (or -R)—Lists the contents of all subdirectories

  • --si (or -h)—Similar to --human-readable, but uses powers of 1000 instead of 1024

  • --size (or -s)—Prints the size in blocks

  • --sort=size (or -S)—Sorts by file size

  • --sort=extension (or -X)—Sorts by filename suffix

  • --sort=none (or -U)—Sorts by the order the files are physically stored in their directory

  • --sort=time (or -t)—Sorts by time. By default, --time=ctime

  • --sort=version (or -v)—Sorts alphabetically, taking into account GNU version number conventions

  • --time=atime (or –u)—Sorts by access time

  • --time=access—Same as atime

  • --time=use—Same as ctime

  • --time=ctime (or -c)—Shows change time; sorts by change time if -t

  • --time=status—Same as ctime

  • --tabsize=n (or -T)—Assumes Tab stops are every n characters instead of eight characters

  • --width=n (or -w)—Assumes screen is n characters wide instead of what it actually is

printf Formatting Codes

  • %b—Expands backslash sequences

  • %c—Displays a single character

  • %d—Displays a signed number

  • %e—Displays a floating-point number, exponential (also called scientific) notation

  • %f—Displays a floating-point number

  • %g—Uses %f or %e depending on the value

  • %i—Same as %d

  • %o—Displays an octal number

  • %q—Quotes the string so it can be read properly by a shell script

  • %s—Displays an unquoted string

  • %u—Displays an unsigned number

  • %x—Displays an unsigned hexadecimal number, using lowercase letters

  • %X—Displays an unsigned hexadecimal number, using uppercase letters

  • %%—Displays a percent sign

printf Backslash Codes

  • \b—Backspace

  • \f—Form feed (that is, eject a page on a printer)

  • \n—Start a new line

  • \r—Carriage return

  • \t—Tab

  • \v—Vertical tab

  • \'—Single quote character (for compatibility with C)

  • \\—Backslash

  • \0nn is an octal number representing an 8-bit ASCII character

rm Command Switches

  • --directory (or -d)—Removes the directory

  • --force (or -f)—Never prompts the user and ignores missing files

  • --interactive (or -i)—Always prompts the user

  • --recursive (or -r or -R)—remove contents of all subdirectories

cp Command Switches

  • --archive (or -a)—Same as -dpR

  • --backup (or -b)—Makes a backup of any existing file before overwriting by adding a ~ to the name

  • --backup=none/off—Never makes numbered backups

  • --backup=numbered/t—Always makes numbered backups

  • --backup=existing/nul—Makes numbered backups if they already exist; otherwise make tilde backups

  • --backup=simple/never—Always makes tilde backups

  • --no-dereference (or -d)—Preserves links

  • --force (or -f)—Never prompts the user; always overwrites

  • --interactive (or -i)—Always prompts the user

  • --link (or -l)—Creates a hard link instead of copying

  • --preserve (or -p)—Preserves file attributes and ownership if possible

  • --parents (or -P)—Appends the source path to the destination directory

  • --recursive (or -R)—Copies any subdirectories

  • -r—Similar to --recursive, but doesn't include special handling of pipes and other files that cannot be copied properly

  • --sparse=w—Truncates sparse files (w=never), creates them in full (w=always), or truncates at the command's discretion (w=auto, default).

  • --strip-trailing-slashes—Removes trailing slashes from the pathnames of the files to copy

  • --symbolic-link (or -s)—Creates a symbolic link instead of copying

  • --suffix=s (or -S s)—Replaces pathname suffix with new suffix s

  • --target-directory=d—Copies files to directory d

  • --update (or -u)—Overwrites old files or copies missing files

  • --one-file-system (or -x)—Stays on the current file system

mv Command Switches

  • --backup (or -b)—Makes a backup of any existing file before overwriting by adding a ~ to the name

  • --backup=none/off—Never makes numbered backups

  • --backup=numbered/t—Always makes numbered backups

  • --backup=existing/nul—Make numbered backups if they already exist; otherwise make tilde backups

  • --backup=simple/never—Always make tilde backups

  • --force (or -f)—Never prompts the user; always overwrites

  • --interactive (or -i)—Always prompts the user

  • --strip-trailing-slashes—Removes trailing slashes from the pathnames of the files to copy

  • --suffix=s (or -S)—Replaces pathname suffix with new suffix s

  • --target-directory=d—Copies files to directory d

  • --update (or -u)—Overwrites old files or copies missing files

  • + Share This
  • 🔖 Save To Your Account