Switches - Reverse Flashcards
type
returns all of the places that contain an executable named file
type -a
uname
show all information
uname -a
history
clear the history
history -c
man
search man pages for a topic; requires the whatis database to work
man -k
man -k ““system information””
man
select the section in the man page to open
man #
man 5 passwd
xargs
specify the delimiter
xargs -d
defaults to space
cat
display a “”$”” at the end of each line
cat -E
–show-ends
cat
adds line numbers to the beginning of every line.
cat -n
–number
cat
adds line numbers to the beginning of every line that contains text
cat -b
–number-nonblank
cat
compresses groups of blank lines down to a single blank line
cat -s
–squeeze-blank
cat
displays tab characters as ““∧I””
cat -T
–show-tabs
cat
displays most control and other special characters using carat ( ∧ ) and M- notations.
cat -v
–show-nonprinting
join
use CHAR as input and output field separator
join -t CHAR
join
ignore differences in case when comparing fields
join -i
–ignore-case
expand
have tabs NUMBER characters apart; not 8
expand -t NUMBER
–tabs=NUMBER
sort
ignore case
sort -f
–ignore-case; (fold)
sort
sort by three-letter month abbreviation ( JAN through DEC )
sort -M
–month-sort
sort
compare according to string numerical value
sort -n
–numeric-sort
sort
reverse the result of comparisons
sort -r
–reverse
sort
sort via a key; KEYDEF gives location and type
sort -k KEYDEF
–key=KEYDEF
(KEYDEF can be two numbered fields separated by commas; to sort on multiple fields.)
E.G. sort -k 3 listing1.1.txt
split
put NUMBER bytes per output file
split -b NUMBER
–bytes=NUMBER
split
put at most NUMBER bytes of records per output file
split -C NUMBER
–line-bytes=NUMBER
split
put NUMBER lines/records per output file
split -l NUMBER
–lines=NUMBER
tr
first truncate SET1 to length of SET2
tr -t
–truncate-set1
tr
delete characters in SET1; do not translate
tr -d
–delete
unexpand
use comma separated LIST of tab positions (enables -a)
unexpand -t LIST
–tabs=LIST
fmt
maximum line width (default of 75 columns)
fmt -w NUMBER
–width=NUMBER
nl
use STYLE for numbering body lines
nl -b STYLE
–body-numbering=STYLE
STYLE is:
t (The default behavior is to number lines that aren’t empty. You can make this default explicit by using a style code of t .)
a (This style code causes all lines to be numbered; including empty lines.)
n (This style code causes all line numbers to be omitted; which may be desirable for headers or footers.)
pREGEXP (This option causes only lines that match the specified regular expression ( REGEXP ) to be numbered.)
nl
use STYLE for numbering header lines
nl -h STYLE
–header-numbering=STYLE
STYLE is: t (The default behavior is to number lines that aren’t empty. You can make this default explicit by using a style code of t .) a (This style code causes all lines to be numbered; including empty lines.) n (This style code causes all line numbers to be omitted; which may be desirable for headers or footers.)
pREGEXP (This option causes only lines that match the specified regular expression ( REGEXP ) to be numbered.)
nl
use STYLE for numbering footer lines
nl -f STYLE
–footer-numbering=STYLE
STYLE is: t (The default behavior is to number lines that aren’t empty. You can make this default explicit by using a style code of t .) a (This style code causes all lines to be numbered; including empty lines.) n (This style code causes all line numbers to be omitted; which may be desirable for headers or footers.)
pREGEXP (This option causes only lines that match the specified regular expression ( REGEXP ) to be numbered.)
nl
use CC for logical page delimiters
nl -d CC
–section-delimiter=CC
nl
insert line numbers according to FORMAT
nl -n FORMAT --number-format=FORMAT format is: ln (left justified; no leading zeros); rn (right justified; no leading zeros); rz (right justified with leading zeros).
pr
output COLUMN columns and print columns down; unless -a is used
pr -NUMBER
–columns=NUMBER
default is 80
pr
double space the output
pr -d
–double-space
pr
use form feeds instead of newlines to separate pages (by a 3-line page header with -F or a 5-line header and trailer without -F)
pr -f
- -form-feed
- F
pr
set the page length to PAGE_LENGTH (66) lines (default number of lines of text 56; and with -F 63). implies -t if PAGE_LENGTH <= 10
pr -l NUMBER
–length=NUMBER
pr
use a centered STRING instead of filename in page header; -h “””” prints a blank line; don’t use -h””””
pr -h STRING
–header=STRING
pr
omit page headers and trailers; implied if PAGE_LENGTH <= 10
pr -t
–omit-header
pr
offset each line with MARGIN (zero) spaces; do not affect -w or -W; MARGIN will be added to PAGE_WIDTH
pr -o
–indent=NUMBER
pr
set page width to NUMBER (72) characters for multiple text-column output only; -s[char] turns off (72)
pr -w NUMBER
–width=NUMBER
head
print the first NUM bytes of each file; with the leading ‘-‘; print all but the last NUM bytes of each file
head -c NUMBER
–bytes=[-]NUMBER
head
print the first NUM lines instead of the first 10; with the leading ‘-‘; print all but the last NUM lines of each file
head -n NUMBER
–lines=[-]NUMBER
tail
output the last NUMBER bytes; or use -c +NUMBER to output starting with byte NUMBER of each file
tail -c NUMBER
–bytes=[+]NUMBER
tail
output the last NUM lines; instead of the last 10; or use -n +NUM to output starting with line NUM
tail -n NUMBER
–lines=[+]NUMBER
tail
output appended data as the file grows;
tail -f
–follow[={name|descriptor}]
tail
with -f; terminate after process ID; PID dies
tail –pid=NUMBER
cut
select only these bytes
cut -b LIST
–bytes=LIST
LIST can be a single number (such as 4 ); a closed range of numbers (such as 2-4 ); or an open range of numbers (such as -4 or 4- ).
cut
select only these characters
cut -c LIST
–characters=LIST
LIST can be a single number (such as 4 ); a closed range of numbers (such as 2-4 ); or an open range of numbers (such as -4 or 4- ).
cut
select only these fields; also print any line that contains no delimiter character; unless the -s option is specified
cut -f LIST
–fields=LIST
LIST can be a single number (such as 4 ); a closed range of numbers (such as 2-4 ); or an open range of numbers (such as -4 or 4- ).
cut
use DELIM instead of TAB for field delimiter
cut -d STRING
–delimiter=STRING
cut
do not print lines not containing delimiters
cut -s
–only-delimited
wc
print the newline counts
wc -l
–lines
wc
print the word counts
wc -w
–words
wc
print the byte counts
wc -c
–bytes
wc
print the character counts
wc -m
–chars
wc
print the maximum display width
wc -L
–max-line-length
grep
Suppress normal output; instead print a count of matching lines for each input file. With the -v; –invert-match option (see below); count non-matching lines.
grep -c
–count
grep
Obtain patterns from file STRING; one per line. If this option is used multiple times or is combined with the -e (–regexp) option; search for all patterns given. The empty file contains zero patterns; and therefore matches nothing.
grep -f STRING
–file=STRING
grep
Ignore case distinctions; so that characters that differ only in case match each other.
grep -i
–ignore-case
grep
Read all files under each directory; recursively; following symbolic links only if they are on the command line. Note that if no file operand is given; grep searches the working directory. This is equivalent to the -d recurse option.
grep -r
–recursive
or use rgrep
grep
Interpret PATTERN as a list of fixed strings (instead of regular expressions); separated by newlines; any of which is to be matched.
grep -F
–fixed-strings
or use fgrep
grep
Interpret PATTERN as an extended regular expression (ERE; see below).
grep -E
–extended-regexp
or use egrep
sed
Display the current line number
sed =
sed
Append text to the file.
sed a\text
sed
Insert text into the file
sed i\text
sed
Append text from filename into the file
sed r filename
sed
Replace the selected range of lines with the provided text
sed c\text
sed
Replace text that matches the regular expression ( regexp ) with replacement
sed s/regexp/replacement/[g]
sed
Write the current pattern space to the specified file.
sed w filename
sed
Immediately quit the script; but print the current pattern space.
sed q
sed
Immediately quit the script.
sed Q
rpm
Modifies the Linux system having a root directory located at dir . This option can be used to maintain one Linux installation discrete from another one (say; during OS installation or emergency maintenance).
rpm –root STRING
rpm
Forces installation of a package even when it means overwriting existing files or packages.
rpm –force
used with: -i ; -U ; -F
rpm
Displays a series of hash marks ( # ) to indicate the progress of the operation.
rpm -h
–hash
used with: -i ; -U ; -F
rpm
Used in conjunction with the -h option to produce a uniform number of hash marks for each package.
rpm -v
used with: -i ; -U ; -F
rpm
Specifies that no dependency checks be performed. Installs or removes the package even if it relies on a package or file that’s not present or is required by a package that’s not being uninstalled.
rpm –nodeps
used wih: -i ; -U ; -F ; -e
rpm
Checks for dependencies; conflicts; and other problems without actually installing the package.
rpm –test
used with: -i ; -U ; -F
rpm
Sets the installation directory to STRING (works only for some packages).
rpm –prefix STRING
used with: -i ; -U ; -F
rpm
Queries or verifies all packages.
rpm -a
–all
used with: -q ; -V
rpm
Queries or verifies the package that owns file
rpm -f STRING
–file STRING
used with: -q ; -V
rpm
Queries the uninstalled RPM STRING
rpm -p STRING
used with -q
rpm
Displays package information; including the package maintainer; a short description; and so on
rpm -i
used with -q
rpm
Displays the packages and files on which this one depends
rpm -R
–requires
used with -q
rpm
Displays the files contained in the package.
rpm -l
–list
used with -q
rpm
Installs a package; system must not contain a package of the same name
rpm -i
rpm
Installs a new package or upgrades an existing one
rpm -U
rpm
Upgrades a package only if an earlier version already exists
rpm -F
–freshen
rpm
Queries a package—finds whether a package is installed; what files it contains; and so on
rpm -q
rpm
Verifies a package—checks that its files are present and unchanged since installation
rpm -v
–verify
rpm
Uninstalls a package
rpm -e
rpm
Builds a binary package; given source code and configuration files; moved to the rpmbuild program with RPM version 4.2
rpm -b
rpm
Builds a binary package; given a source RPM file; moved to the rpmbuild program with RPM version 4.2
rpm –rebuild
rpm
Rebuilds the RPM database to fix errors
rpm –rebuilddb
cpio
extract an archive
cpio -i
cpio
create directories
cpio –make-directories
yum
Installs one or more packages by package name. Also installs dependencies of the specified package or packages.
yum install
yum
Updates the specified package or packages to the latest available version. If no packages are specified; yum updates every installed package.
yum update
yum
Checks to see whether updates are available. If they are; yum displays their names; versions; and repository area ( updates or extras ; for instance).
yum check-update
yum
Works like update with the –obsoletes flag set; which handles obsolete packages in a way that’s superior when performing a distribution version upgrade
yum upgrade
yum
Deletes a package from the system; similar to rpm -e ; but yum also removes depended-on packages
yum remove
or erase
yum
Displays information about a package; such as the installed version and whether an update is available
yum list
yum
Displays information about packages that provide a specified program or feature. For instance; typing yum provides samba lists all the Samba-related packages; including every available update. Note that the output can be copious.
yum provides
or whatprovides
yum
Searches package names; summaries; packagers; and descriptions for a specified keyword. This is useful if you don’t know a package’s name but can think of a word that’s likely to appear in one of these fields but not in these fields for other packages
yum search
yum
Displays information about a package; similar to the rpm -qi command
yum info
yum
Cleans up the Yum cache directory. Running this command from time to time is advisable; lest downloaded packages chew up too much disk space.
yum clean
yum
Enters the Yum shell mode; in which you can enter multiple Yum commands one after another
yum shell
yum
Displays packages matching the specified dependency.
yum resolvedep
yum
Installs the specified local RPM files; using your Yum repositories to resolve dependencies
yum localinstall
yum
Updates the system using the specified local RPM files; using your Yum repositories to resolve dependencies. Packages other than those updated by local files and their dependencies are not updated
yum localupdate
yum
Displays dependencies of the specified package.
yum deplist
dpkg
Installs a package
dpkg -i
–install
dpkg
Reconfigures an installed package: runs the post-installation script to set site-specific options
dpkg –configure
dpkg
Removes a package but leaves configuration files intact
dpkg -r
–remove
dpkg
Removes a package; including configuration files
dpkg -P
–purge
dpkg
Displays currently installed packages
dpkg –get-selections
dpkg
Displays information about an installed package
dpkg -p
–print-avail
dpkg
Displays information about an uninstalled package file
dpkg -I
–info
dpkg
Lists all installed packages whose names match pattern
dpkg -l STRING
–list pattern
dpkg
Lists the installed files associated with a package
dpkg -L
–listfiles
dpkg
Locates the package(s) that own the file(s) specified by pattern
dpkg -S STRING
–search pattern
dpkg
pattern -C or –audit Searches for partially installed packages and suggests what to do with them
dpkg -c
–audit
dpkg
Modifies the Linux system using a root directory located at STRING . Can be used to maintain one Linux installation discrete from another one; say during OS installation or emergency maintenance.
dpkg –root=STRING
used with: all
dpkg
Disables packages that rely on one that is being removed.
dpkg -B
–auto-deconfigure
used with -r
dpkg
Overrides defaults that would ordinarily cause dpkg to abort. Consult the dpkg man page for details of what (specified by things ) this option does.
dpkg –force-things
used with: assorted
dpkg
ignores dependency information for the specified package
dpkg –ignore-depends=package
used with: -i; -r
dpkg
Checks for dependencies; conflicts; and other problems without actually installing or removing the package
dpkg –no-act
used with: -i; -r
dpkg
Installs all packages that match the package-name wildcard in the specified directory and all subdirectories
dpkg –recursive
used with: -i
dpkg
Doesn’t install the package if a newer version of the same package is already installed.
dpkg -G
used with: -i
dpkg
Doesn’t install the package if the same version of the package is already installed.
dpkg -E
–skip-same-version
used with: -i
apt-cache
displays information about the packages listed on the command line.
apt-cache showpkg
eg: apt-cache showpkg samba
apt-cache
You can learn how many packages you’ve installed; how many dependencies are recorded; and various other statistics about the package database
apt-cache stats
apt-cache
Find Unmet Dependencies
apt-cache unmet
apt-cache
Display Dependencies
apt-cache depends
apt-cache
Locate All Packages
apt-cache pkgnames
If you include a second parameter; as in apt-cache pkgnames sa ; the program returns only those packages that begin with the specified string.
apt-get
Downloads package files but doesn’t install them.
apt-get -d
–download-only
used with: upgrade ; dselect- upgrade ; install ; source
apt-get
Attempts to fix a system on which dependencies are unsatisfied.
apt-get -f
–fix-broken
used with: install ; remove
apt-get
Ignores all package files that can’t be retrieved (because of network errors; missing files; or the like)
apt-get -m
–ignore-missing ; or –fix-missing
used with: upgrade ; dselect- upgrade ; install ; remove ; source
apt-get
Omits some progress indicator information. May be doubled (for instance; -qq ) to produce still less progress information
apt-get -q
–quiet
used with: all
apt-get
Performs a simulation of the action without actually modifying; installing; or removing files
apt-get -s
–simulate ; –just- print ; –dry-run ; – recon ; or –no-act
used with: all
apt-get
Produces a ““yes’’ response to any yes/no prompt in installation scripts.
apt-get -y
–yes ; or –assume- yes
used with: all
apt-get
Compiles a source package after retrieving it.
apt-get -b
–compile; or –build
used with: source
apt-get
auses apt-get to not upgrade a package if an older version is already installed.
apt-get –no-upgrade
used with: install
apt-get
Obtains updated information about packages available from the installation sources listed in /etc/apt/sources.list .
apt-get update
apt-get
Upgrades all installed packages to the newest versions available; based on locally stored information about available packages.
apt-get upgrade
apt-get
Performs any changes in package status (installation; removal; and so on) left undone after running dselect .
apt-get dselect-upgrade
apt-get
Similar to upgrade ; but performs ``smart’’ conflict resolution to avoid upgrading a package if doing so would break a dependency.
apt-get dist-upgrade
apt-get
Installs a package by package name (not by package filename); obtaining the package from the source that contains the most up-to-date version.
apt-get install
apt-get
Removes a specified package by package name
apt-get remove
apt-get
Retrieves the newest available source package file by package filename using information about available packages and installation archives listed in /etc/apt/sources.list
apt-get source
apt-get
Checks the package database for consistency and broken package installations
apt-get check
apt-get
Performs housekeeping to help clear out information about retrieved files from the Debian package database. If you don’t use dselect for package management; run this from time to time in order to save disk space.
apt-get clean
apt-get
Similar to clean ; but removes information only about packages that can no longer be downloaded.
apt-get autoclean
aptitude
install package STRING
aptitude install STRING
aptitude
uninstall package STRING
aptitude install STRING-
also remove STRING
aptitude
uninstall package STRING
aptitude remove STRING
also install STRING-
aptitude
less conservative about removing packages in the upgrade process; and so it is more likely to complete its tasks. However; it may break software in the process.
aptitude full-upgrade
aptitude
conservative about removing packages or installing new ones and so may fail
aptitude safe-upgrade
aptitude
earches the database for packages matching the specified name
aptitude search
aptitude
removes already-downloaded packages that are no longer available
aptitude autoclean
aptitude
removes all downloaded packages
aptitude clean
aptitude
displays a complete list of options.
aptitude help
alien
converts to debian
alien –to-deb
alien
converts to rpm
alien –to-rpm
alien
converts to tgz
alien –to-tgz
ldconfig
Display Verbose Information
ldconfig -v
ldconfig
causes ldconfig not to perform its primary duty of updating the library cache. It will; though; update symbolic links to libraries; which is a secondary duty of this program.
ldconfig -N
ldconfig
causes ldconfig to update the links contained in the directories specified on the command line. The system won’t examine the directories specified in /etc/ld.so.conf or the trusted directories ( /lib and /usr/lib )
ldconfig -n
ldconfig
the opposite of -N ; it causes ldconfig to update the cache but not manage links.
ldconfig -X
ldconfig
change the configuration file from /etc/ld.so.conf to STRING
ldconfig -f STRING
ldconfig
change the cache file that ldconfig creates to STRING
ldconfig -C STRING
ldconfig
tells ldconfig to treat dir as if it were the root ( / ) directory. This option is helpful when you’re recovering a badly corrupted system or installing a new OS
ldconfig -r STRING
ldconfig
Causes ldconfig to display the current cache—all of the library directories and the libraries they contain
ldconfig -p
uname
display all information
uname -a
uname
displays the system’s node name; that is; its network hostname.
uname -n
–nodename
uname
displays the kernel name; which is Linux on a Linux system
uname -s
–kernel-name
uname
find the kernel version
uname -v
–kernel-version
uname
The actual kernel version number
uname -r
–kernel-release
uname
returns information about your machine. This is likely to be a CPU code; such as i686 or x86_64 .
uname -m
–machine
uname
may return information about your CPU; such as the manufacturer; model; and clock speed; in practice; it returns unknown on many systems
uname -p
–processor
uname
theoretically returns hardware platform information; this option often returns unknown
uname -i
–hardware-platform
uname
returns the OS name—normally GNU/Linux for a Linux system
uname -o
–operating-system
ps
Display Help
ps –help
ps
Display All Processes
ps -A
also -e
ps
Display All Processes
ps -e
also -A
ps
Lift the BSD-style ““must have a tty”” restriction;
displays all processes owned by the user who gives the command
ps x
ps
display processes owned by user STRING
ps -u STRING
–User user
also U STRING
STRING may be a user name or uid
ps
display processes owned by user STRING
ps U STRING
–User user
also U STRING
STRING may be a user name or uid
ps
Display Process Hierarchy
ps -H
–forest
also -f
ps
Display Process Hierarchy
ps -f
–forest
also -f
ps
don’t truncate output at 80 columns
ps -w
also w
top
how often top updates
top -d NUMBER
defaults to 5 seconds
top
only display the listed processes
top -p NUMBER
NUMBER is a pid
up to 20 pids can be listed
top
display NUMBER updates then quit
top -n NUMBER
top
specifies batch mode; in which top doesn’t use the normal screen-update commands. You might use this to log CPU use of targeted programs to a file; for instance
top -b
top
display help
top h while running
also ?
top
kill a process
top k while running
top
quit
top q while running
top
change a process’s priority
top r while running
top
changes the display’s update rate
top s while running
top
sets the display to sort by CPU usage; which is the default
top P while running
top
change the display to sort by memory usage with this command
top M while running
nice
run the program with NUMBER niceness
nice -n NUMBER
also -NUMBER
–adjustment=NUMBER
nice
run the program with NUMBER niceness
nice -NUMBER
also -n NUMBER
–adjustment=NUMBER
renice
Specify the scheduling priority to be used for the process; process group; or user.
renice [-n] NUMBER
–priority NUMBER
renice
change niceness on the pid NUMBER
renice -p NUMBER
renice
change niceness on the gid NUMBER
renice -g NUMBER
renice
change niceness on the uid NUMBER
renice -u NUMBER
e.g. renice 7 16580 -u pdavison tbaker
kill
List signal names
kill -l
kill
specify the signal to send
common signals are 1(SIGHUP); 9(SIGKILL); 15(SIGTERM)
kill -s STRING
killall
Interactively ask for confirmation before killing
killall -i
–interactive
lspci
Increases verbosity of output.
lspci -v
This option may be doubled ( -vv ) or tripled ( -vvv ) to produce yet more output
lspci
Displays information in numeric codes rather than translating the codes to manufacturer and device names.
lspci -n
lspci
Displays both the manufacturer and device names and their associated numeric codes
lspci -nn
lspci
Displays the PCI configuration space for each device as a hexadecimal dump.
lspci -x
This is an extremely advanced option. Tripling ( -xxx ) or quadrupling ( -xxxx ) this option displays information about more devices
lspci
hows IRQ numbers and other data as seen by devices rather than as seen by the kernel
lspci -b
lspci
Displays a tree view depicting the relationship between devices
lspci -t
lspci
Displays only devices that match the listed specification. This can be used to trim the results of the output
-s [[[[ domain ]:] bus ]:] [ slot ][.[ func ]]
lspci -s STRING
lspci
Shows data on the specified device.
lspci -d STRING
-d [ vendor ]: [ device ]
lspci
Uses the specified file to map vendor and device IDs to names. (The default is /usr/share/misc/pci.ids .)
lspci -i STRING
lspci
Dumps data in a machine-readable form intended for use by scripts. A single -m uses a backward-compatible format; whereas doubling ( - mm ) uses a newer format
lspci -m
lspci
Displays PCI domain numbers. These numbers normally aren’t displayed.
lspci -D
lspci
Performs a scan in bus-mapping mode; which can reveal devices hidden behind a misconfigured PCI bridge. This is an advanced option that can be used only by root .
lspci -M
lspci
Displays version information.
lspci –version
modprobe
display extra information
modprobe -v
–verbose
modprobe
This option overrides the default configuration directory (/etc/modprobe.d)
modprobe -C STRING
–config
modprobe
This option does everything but actually insert or delete the modules
modprobe -n
–dry-run
useful when combined with -v
modprobe Reverses modprobe 's usual effect; it causes the program to remove the specified module and any on which it depends
modprobe -r
–remove
modprobe force the module loading even if the kernel version doesn't match what the module expects. This action is potentially dangerous
modprobe -f
–force
modprobe shows all of the modules on which the specified module depends
modprobe –show-depends
modprobe
displays a list of available options whose names match the wildcard you specify
modprobe -l STRING
- -list
eg. modprobe -l v* displays all modules whose names begin with v
rmmod
display some extra information about what it’s doing
rmmod -v
–verbose
rmmod forces module removal even if the module is marked as being in use. Naturally; this is a very dangerous option;
rmmod -f
–force
rmmod wait for the module to become unused rather than return an error message if the module is in use. Once the module is no longer being used (say; after a bluetooth device is disconnected); rmmod unloads the module and returns
rmmod -w
–wait
lsusb
display more information
lsusb -v
lsusb
restricts output to the specified bus and device number.
lsusb -s STRING
-s [[ bus ]:][ devnum ]
lsusb
restrict output to a particular vendor and product
lsusb -d STRING
-d [ vendor ]: [ product ]
lsusb
displays information about the device that’s accessible via filename ; which should be a file in the /proc/bus/usb directory tree
lsusb -D STRING
lsusb
displays the device list as a tree so that you can see what devices are connected to specific controllers more easily
lsusb -t
lsusb
displays the version of the lsusb utility
lsusb -V
–version
fdisk
display the current partition table
fdisk -l
fdisk
delete a partition
fdisk d while running
fdisk
display help
fdisk m while running
also ?
fdisk
change the partition type code
fdisk t while running
fdisk
display common partition type codes
fdisk l while running
fdisk
set the bootable flag
fdisk a while running
fdisk
exit
fdisk q while running
fdisk
save changes and exit
fdisk w while running
gdisk
display existing partitions
gdisk print while running
mkfs
sets the reserved-space percentage to NUMBER
mkfs -m NUMBER
tune2fs
Adjust the number of mounts after which the filesystem will be checked by e2fsck
tune2fs -c NUMBER
tune2fs
Adjust the maximal time between two filesystem checks. No suffix or d will interpret the number interval-between-checks as days; m as months; and w as weeks. A value of zero will disable the time-dependent checking.
tune2fs -i NUMBER
tune2fs
converts ext2 to ext3
tune2fs -j
tune2fs
sets the reserved-space blocks to NUMBER
tune2fs -r NUMBER
xfs_admin
enable version 2 log (journal) format
xfs_admin -j
xfs_admin
obtain the filesystem’s label (name)
xfs_admin -l
xfs_admin
obtain the filesystem’s uuid
xfs_admin -u
xfs_admin
set the filesystem’s label (name)
xfs_admin -L STRING
xfs_admin
set the filesystem’s uuid
xfs_admin -U STRING
debugfs
produces superblock information; similar to what dumpe2fs displays
debugfs show_super_stats while running
also stats
debugfs
display the inode data on a file or directory
debugfs stat STRING (while running)
STRING is the name of a file or directorhy
debugfs
undelete a file
debugfs undelete NUMBER STRING (while running)
also undel
NUMBER is the inode number and STRING is the name you want to give i
debugfs
obtain a list of deleted inodes
debugfs lsdel (while running) also list_deleted_inodes
debugfs
extract a file from the filesystem
debugfs write STRING1 STRING2 (while running)
STRING1 is the name of a file in the filesystem that you’re manipulating and STRING2 is a filename on your main Linux system.
debugfs
produces a summary of available commands
debugfs list_requests (while running) also lr; help; or ?
debugfs
exit the program
debugfs quit
fsck
check all of the filesystems marked to be checked in /etc/fstab .
fsck -A
fsck
displays a text-mode progress indicator of the check process
fsck -c
fsck
produces verbose output of the check process
fsck -v
fsck
display what it would normally do without actually doing it
fsck -N
fsck
causes the program to check only the specified filesystem types; even if others are marked to be checked
fsck -t STRING
used with -A
If STRING is prefixed with no ; then all filesystems except the specified type are checked
fsck
passes STRING to the underlying check program
fsck –STRING
df
includes pseudo-filesystems with a size of 0 in the output. These filesystems may include /proc ; /sys ; /proc/bus/usb ; and others
df -a
–all
df
scale and label its units
df -h
–human-readable
df
scale and label its units using powers of 10
df -H
–si
df
scale and label its units using kilobytes
df -k
–kilobytes
df
scale and label its units using megabytes
df -m
–megabytes
df
report on available and used inodes
df -i
–inodes
df
omit network filesystems
df -l
–local
df
display filesystem type
df -T
df
displays only information about filesystems of the specified type
df -t STRING
–type=STRING
df
don’t display information about filesystems of the specified type
df -x STRING
–exclude=STRING
du
report on individual files as well.
du -a
–all
du
add a grand total to the end of its output
du -c
–total
du
scale and label its units;
du -h
–human-readable
du
scale and label its units using powers of 10
du -H
–si
du
scale and label its units using kilobytes
du -k
–kilobytes
du
scale and label its units using megabytes
du -m
–megabytes
du
count the space each hardlink takes (useful if you want to burn to optical storage)
du -l
–count-links
du
limits the report to NUMBER levels
du –max-depth=NUMBER
du
equivalent to –max=depth=0
du -s
–summarize
du
limits the report to the current filesystem. If another filesystem is mounted within the tree that you want summarized; its contents aren’t included in the report
du -x
–one-file-system
mount
mount all of the filesystems listed in the /etc/fstab
mount -a
mount
mount the filesystem read-only
mount -r
mount
produces verbose output
mount -v
mount
mount the filesystem for both read and write
mount -w
also: -o rw
mount
specify the filesystem type
mount -t STRING
mount
mount the filesystem whose label matches STRING
mount -L STRING
mount
mount the filesystem whose UUID matches STRING
mount -U STRING
mount
Causes the default options for this filesystem to be used. It’s used primarily in the /etc/fstab file to ensure that the file includes an options column
mount -o defaults
supported filesystems: all
mount
Causes the loopback device for this mount to be used. Allows you to mount a file as if it were a disk partition. For instance; mount -t vfat -o loop image.img /mnt/image mounts the file image.img as if it were a disk
mount -o loop
supported filesystems: all
mount
Mounts or doesn’t mount the filesystem at boot time or when root issues the mount -a command. The default is auto ; but noauto is appropriate for removable media. Used in /etc/fstab
mount -o auto or noauto
supported filesystems: all
mount
Allows or disallows ordinary users to mount the filesystem. The default is nouser ; but user is often appropriate for removable media. Used in /etc/fstab . When included in this file; user allows users to type mount /mountpoint (where / mountpoint is the assigned mount point) to mount a disk. Only the user who mounted the filesystem may unmount it.
mount -o user or nouser
supported filesystems: all
mount
Similar to user ; except that any user may unmount a filesystem once it’s been mounted.
mount -o users
supported filesystems: all
mount
Similar to user ; except that the user must own the device file. Some distributions; such as Red Hat; assign ownership of some device files (such as /dev/fd0 for the floppy disk) to the console user; so this can be a helpful option
mount -o owner
supported filesystems: all
mount
Changes one or more mount options without explicitly unmounting a partition. To use this option; you issue a mount command on an already-mounted filesystem but with remount along with any options that you want to change. This feature can be used to enable or disable write access to a partition; for example
mount -o remount
supported filesystems: all
mount
Specifies a read-only mount of the filesystem. This is the default for filesystems that include no write access and for some with particularly unreliable write support
mount -o ro
supported filesystems: all
mount
Specifies a read/write mount of the filesystem. This is the default for most read/write filesystems
mount -o rw
supported filesystems: All read/write filesystems
mount
Sets the owner of all files. For instance; uid=1000 sets the owner to whomever has Linux user ID 1000. (Check Linux user IDs in the /etc/passwd file.)
mount -o uid=NUMBER
supported filesystmes: Most filesystems that don’t support Unix-style permissions; such as vfat ; hpfs ; ntfs ; and hfs
mount
Works like uid= value ; but sets the group of all files on the filesystem. You can find group IDs in the /etc/group file
mount -o gid=value
supported filesystems: Most filesystems that don’t support Unix-style permissions; such as vfat ; hpfs ; ntfs ; and hfs
mount
Sets the umask for the permissions on files. value is interpreted in binary as bits to be removed from permissions on files. For instance; umask=027 yields permissions of 750; or –rwxr-x— . Used in conjunction with uid= value and gid= value ; this option lets you control who can access files on FAT; HPFS; and many other foreign filesystems.
mount -o umask=value
supported filesystems: Most filesystems that don’t support Unix-style permissions; such as vfat ; hpfs ; ntfs ; and hfs
mount
Similar to umask ; but sets the umask for directories only; not for files.
mount -o dmask=value
supported filesystems: Most filesystems that don’t support Unix-style permissions; such as vfat ; hpfs ; ntfs ; and hfs
mount
Similar to umask ; but sets the umask for files only; not for directories.
mount -o fmask=value
supported filesystems: Most filesystems that don’t support Unix-style permissions; such as vfat ; hpfs ; ntfs ; and hfs
mount
If code is b or binary ; Linux doesn’t modify the files’ contents. If code is t or text ; Linux auto-converts files between Linux-style and Windows- or Macintosh-style end-of-line characters. If code is a or auto ; Linux applies the conversion unless the file is a known binary file format. It’s usually best to leave this at its default value of binary because file conversions can cause serious problems for some applications and file types.
mount -o conv=code
supported filesystems: Most filesystems used on Microsoft and Apple OSs: msdos ; umsdos ; vfat ; hpfs ; and hfs
mount
Disables Rock Ridge extensions for ISO-9660 CD-ROMs.
mount -o norock
supported filesystems: iso9660
mount
Disables Joliet extensions for ISO-9660 CD-ROMs.
mount -o nojoliet
supported filesystems: iso9660
umount
attempt to unmount all of the partitions listed in /etc/mtab
umount -a
umount
force an unmount operation that might otherwise fail. This feature is sometimes helpful when unmounting NFS mounts shared by servers that have become unreachable
umount -f
umount
if it can’t unmount a filesystem; it should attempt to remount it in read-only mode
umount -r
umount
unmount only partitions of the specified type. You can list multiple filesystem types by separating them with commas.
umount -t STRING
ls append indicator (one of */=>@|) to entries
ls -F --classify / Directory * Executable | Named pipe = Socket @ Symbolic Link
ls
show hidden files (dot)
ls -a
–all
ls
long listing
ls -l
ls
colored listing
ls –color
ls
only list the directory’s name; useful for globbing for directories
ls -d
–directory
ls
display directory contents recursively.
ls -R
–recursive
cp
overwrite any existing files without prompting
cp -f
–force
cp
prompt before overwriting
cp -i
–interactive
cp
preserves ownership and permissions; if possible
cp -p
–preserve
cp
copy recursively
cp -R
–recursive
Although -r also performs a recursive copy; its behavior with files other than ordinary files and directories is unspecified. Most cp implementations use -r as a synonym for -R ; but this behavior isn’t guaranteed
cp
similar to -R ; but it also preserves ownership and copies links as is. The -R option copies the files to which symbolic links point rather than the symbolic links themselves.
cp -a
–archive
cp
copy the file only if the original is newer than the target or if the target doesn’t exist
cp -u
–update
touch
change the access time alone; not the modification time
touch -a
–time=atime
touch
change the modification time alone; not the access time
touch -m
–time=mtime
touch
don’t create the file if it doesn’t exist
touch -c
–no-create
touch
ets the time to the value specified by STRING
touch -t STRING
MMDDhhmm[[CC]YY][.ss]
tar
Changes to directory dir before performing operations
tar C
- -directory
eg. tar -xvzf bigfile.tar.gz -C /folder/subfolder/
tar
Uses the file called file on the computer called host as the archive file
tar f
–file [host:]file
tar
Performs an incremental backup or restore; using file as a list of previously archived files
tar g STRING
–listed- incremental file
tar
Creates or extracts a multi-volume archive
tar M
–multi- volume
tar
Preserves all protection information
tar p
–preserve- permissions
tar
Retains the leading / on filenames
tar P
–absolute- paths
tar
Lists all files read or extracted; when used with –list ; displays file sizes; ownership; and time stamps
tar v
–verbose
tar
Verifies the archive after writing it
tar W
–verify
tar
Compresses an archive with gzip
tar z
–gzip or – ungzip
tar
Compresses an archive with bzip2
tar j
–bzip2
some older versions used I or y
tar
Compresses an archive with xz
tar J
–xz
tar
Creates an archive
tar c
–create
tar
Appends tar files to an archive
tar A
–concatenate
tar
Appends non- tar files to an archive
tar r
–append
tar
Appends files that are newer than those in an archive
tar u
–update
tar
Compares an archive to files on disk
tar d
–diff or –compare
tar
Lists an archive’s contents
tar t
–list
tar
Extracts files from an archive
tar x
–extract or –get
cpio
creates an archive and copies files into it
cpio -o
–create
cpio
extracts data from an existing archive.
cpio -i
–extract
cpio
combines the copy-out and copy-in modes; enabling you to copy a directory tree from one location to another.
cpio -p
–pass-through
cpio
Resets the access time after reading a file so that it doesn’t appear to have been read.
cpio -a
–reset- access-time
cpio
Appends data to an existing archive.
cpio -A
–append
cpio
Uses the contents of filename as a list of files to be extracted in copy-in mode.
cpio -E STRING
–pattern-file=filename
cpio
Uses filename as the cpio archive file; if this parameter is omitted; cpio uses standard input or output.
cpio -F STRING
–file=filename
cpio
Uses a specified format for the archive file. Common values for format include bin (the default; an old binary format); crc (a newer binary format with a checksum); and tar (the format used by tar ).
cpio -H STRING
–format=format
cpio
Uses the filename specified by STRING instead of standard input. (Unlike -F ; this option does not redirect output data.)
cpio -I STRING
cpio
In copy-in mode; extracts files relative to the current directory; even if filenames in the archive contain full directory paths.
cpio –no-absolute-filenames
cpio
Uses the filename specified by STRING instead of standard output. (Unlike -F ; this option does not redirect input data.)
cpio -o STRING
cpio
Displays a table of contents for the input
cpio -t
–list
cpio
Replaces all files without first asking for verification.
cpio -u
–unconditional
cpio
Displays filenames as they’re added to or extracted from the archive. When used with -t ; displays additional listing information (similar to ls -l ).
cpio -v
–verbose
dd
use STRING as the input file
dd if=STRING
dd if=/dev/sda3 of=/dev/dvd
dd
use STRING as the output file
dd of=STRING
dd if=/dev/sda3 of=/dev/dvd
dd
read the filesystem using a block size of NUMBER
1024 seems good
dd bs=NUMBER
dd
read count*bs bytes from the input file
dd count=NUMBER
ln
overwrite any existing files without prompting
ln -f
–force
ln
prompt before overwriting
ln -i
–interactive
ln
attempt to make a hard link to a directory
ln -d
or -F or –directory
usually fails
ln
make a symbolic link
ln -s
–symbolic
mkdir
causes the new directory to have the specified permission mode; expressed as an octal number.
mkdir -m STRING
–mode=mode
mkdir
create parent directories as needed
mkdir -p
–parents
rmdir
don’t display an error message if the directory isn’t empty
rmdir –ignore-fail-on-non-empty
rmdir
delete parent directories recursively
rmdir -p
- -parents
eg. rmdir -p one/two/three
chown
chown -R
–recursive
chmod
set permissions for the owner
chmod u
chmod
set permissions for the group
chmod g
chmod
set permissions for all others (world)
chmod o
chmod
set permissions for ugo
chmod a
chmod
add permissions
chmod +
chmod
remove permissions
chmod -
chmod
set permissions equal to
chmod =
chmod
read permission
chmod r
chmod
write permission
chmod w
chmod
execute permission
chmod x
chmod
execute permission only if it’s already set
chmod X
chmod
SUID or SGID
chmod s
chmod
sticky bit
chmod t
chmod
existing owner’s permissions
chmod u
chmod
existing other permissions
chmod o
umask
display permissions that will not be removed from files/folder symbolically
e.g. u=rwx;g=rx;o=rx
umask -S
newgrp
reinitializes the environment as if the user had just logged in
newgrp -l
chattr
Linux won’t update the access time stamp when you access a file. This can reduce disk input/output; which is particularly helpful for saving battery life on laptops.
chattr [+-]A
chattr
disables write access to the file except for appending data.
chattr [+-]a
chattr
causes the kernel to compress data written to the file automatically and uncompress it when it’s read back.
chattr [+-]c
chattr
cannot be modified: it cannot be deleted or renamed; no link can be created to this file and no data can be written to the file.
chattr [+-]i
chattr
tells the kernel to journal all data written to the file. This improves recoverability of data written to the file after a system crash but can slow performance. This flag has no effect on ext2 filesystems.
chattr [+-]j
chattr
when the file is deleted; the kernel zeros its data blocks
chattr [+-]s
chattr
disables this behavior: small data pieces at a file’s end that don’t fill a complete block are merged with similar pieces of data from other files
chattr [+-]t
quotacheck
create aquota.user and aquota.group files
quotacheck -c
quotacheck
check user quotas
quotacheck -u
quotacheck
check group quotas
quotacheck -g
edquota
sets the soft limit grace period
0 disables it
grace periods are per filesystem, not per user
edquota -t
edquota
edit the quota for the group STRING
edquota -g STRING
quota
display group quotas
quota -g
quota
omits NFS mounts
quota -l
quota
limits output to filesystems on which usage is over the limit
quota -q
find
find files that have the specified permissions
find -perm NUMBER
also symbolically
e.g. -perm g=w
find
find files that have any of the specified permission bits set
find -perm +NUMBER
find
locate files that use NUMBER units of space; rounding up
find -size NUMBER NUMBER is specified in 512k blocks trail with c for bytes trail with k for kibibytes trail with M for Mebibytes
find
locate files larger than NUMBER units of space; rounding up
find -size +NUMBER
find
locate files less than NUMBER units of space; rounding up
find -size -NUMBER
find
locates files whose gid matches GID
find -gid NUMBER
find
locate files whose group matches STRING
find -group STRING
find
locates files whose uid matches UID
find -uid NUMBER
find
locate files whose owner matches STRING
find -user STRING
find
only recuse NUMBER directories
find -maxdepth NUMBER
which
show all matches
which -a
type
shortens the output to builtin ; file ; alias ; or other short identifiers.
type -t
type
provides a complete list; for instance; it provides both the alias expansion and the location of the ultimate executable when provided with an alias name.
type -a
chkconfig
list the services and their applicable runlevels
chkconfig –list
chkconfig
set the STRING1 program to on or off (STRING2) on the runlevels specified in NUMBER with no delimiters
chkconfig –level NUMBER STRING1 STRING2
chkconfig –level 23 nfs-common on
chkconfig
adds the STRING script to those managed by chkconfig
This approach may not work if the script lacks the necessary comment lines with runlevel sequence numbers for chkconfig ‘s benefit
chkconfig –add STRING
shutdown
shutdown now
shutdown now
shutdown
cancel a pending shutdown
shutdown -c
shutdown
reboot
shutdown -r
shutdown
halt
shutdown -H
shutdown
power off
shutdown -P
shutdown
usually powers off; may halt
shutdown -h
systemctl
Displays the current status of all configured units.
systemctl list-units
systemctl
Changes to the default target uni
systemctl default
systemctl
Starts the named unit and stops all others.
systemctl isolate
systemctl isolate rescue.target
go into single user mode
systemctl
Starts the named unit.
systemctl start STRING
systemctl
Stops the named unit.
systemctl stop STRING
systemctl
Causes the named unit to reload its configuration file.
systemctl reload STRING
systemctl
Causes the named unit to shut down and restart.
systemctl restart STRING
systemctl
Displays the status of the named unit. (You can pass a PID value; rather than a name; if you like.)
systemctl status STRING
systemctl
Configures the unit to start when the computer next boots.
systemctl enable STRING
systemctl
Configures the unit not to start when the computer next boots.
systemctl disable STRING
vi commands while running
opens a new line immediately below the current line; moves the cursor to that line; and enters insert mode
vi commands while running o
vi commands while running
copy # lines
vi commands while running #yy
vi commands while running
cut # lines
vi commands while running #dd
vi commands while running
copy from cursor to end of word
vi commands while running yw
vi commands while running
cut from cursor to end of word
vi commands while running dw
vi commands while running
paste
vi commands while running p
vi commands while running
enter text replacement mode
vi commands while running R
vi commands while running
enter insert mode and advance the cursor 1 space
vi commands while running a
vi commands while running
:wq
vi commands while running ZZ
vi commands while running
change case under cursor and advance 1
vi commands while running ~
vi commands while running
undo
vi commands while running u
vi commands while running
inserts a new line immediately below the current one and enters insert mode on that line
vi commands while running o
vi commands while running
search forward for text
vi commands while running /
vi commands while running
search backward for text
vi commands while running ?
vi commands while running
clear from cursor to the end of the word and enter insert mode
vi commands while running cw
vi commands while running
clear line and enter insert mode
vi commands while running cc
vi commands while running
go to line #
vi commands while running #G
vi commands while running
move cursor to top of screen
vi commands while running H
vi commands while running
move cursor to bottom of screen
vi commands while running L
vi commands while running
replace STRING1 with STRING2 globally
vi commands while running :%s/STRING1/STRING2/g
remove g to do the first occurance on each line
to do only lines 3 through 5; replace % with 3,5
vi commands while running
load file STRING for editing
vi commands while running :e STRING
closes the currently open file
vi commands while running
load file STRING on the line after the cursor
vi commands while running :r STRING
vi commands while running
run external command STRING
vi commands while running :!STRING
:!ls runs ls ; enabling you to see what files are present in the current directory