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