Commands - Reverse Flashcards
print the working directory
pwd
print the working directory
pwd
display text from stdin
echo STRING
times how long COMMAND takes to execute
Three times are displayed: totalexecution time (aka real time); user CPU time; and system CPU time
time COMMAND
displays a wide variety of options relating to bash shell operation
These options are formatted much like environment variables; but they aren’t the same things. You can pass various options to set to have it affect a wide range of shell operations.
set
terminates any shell
Login shells are shell programs that are launched automatically when you initiate a text-mode login as opposed to those that run in xterm windows or other terminal emulators
exit
terminates only login shells
Login shells are shell programs that are launched automatically when you initiate a text-mode login as opposed to those that run in xterm windows or other terminal emulators
logout
tells you how a command you enter will be interpreted—as a built-in command; an external command; an alias; and so on
type COMMAND
displays all of the commands in the history
typically the latest 500 commands
history
display and execute the last command in your shell history
!!
execute command NUMBER from the history
!NUMBER
a directory list to search when you’re entering command or program names
$PATH
display environment variables
env
unset an environment variable
unset VARNAME
the shell prompt
$PS1
display the manual for COMMAND
man COMMAND
hypertext formatted manual
info COMMAND
a built in manual for built in commands
help COMMAND
Creates a new file containing standard output. If the specified file exists; it’s overwritten. No file descriptor necessary.
>
Appends standard output to the existing file. If the specified file doesn’t exist; it’s created. No file descriptor necessary.
> >
Creates a new file containing standard error. If the specified file exists; it’s overwritten. File descriptor necessary.
2>
Appends standard error to the existing file. If the specified file doesn’t exist; it’s created. File descriptor necessary.
2»
Creates a new file containing both standard output and standard error. If the specified file exists; it’s overwritten. No file descriptors necessary.
&>
Sends the contents of the specified file to be used as standard input. No file descriptor necessary.
Accepts text on the following lines as standard input. No file descriptor necessary.
<
Causes the specified file to be used for both standard input and standard output. No file descriptor necessary.
<>
link stdout from COMMAND1 to stdin of COMMAND2
COMMAND1 | COMMAND2
display stdin on stdout and save it to the specified files
tee
run command once for every word passed to it on standard input
find / -user Christine | xargs -d “” \ n”” rm
xargs [ options ] [ command [ initial-arguments ]]
a separate command whose results are substituted on the command line
rm ` find . / -user Christine `
COMMAND
a separate command whose results are substituted on the command line
rm $(find ./ -user Christine)
$(COMMAND)
concatenate files and print on the standard output
cat
concatenate files and print on the standard output in reverse line order
tac
For each pair of input lines with identical join fields; write a line to standard output. The default join field is the first; delimited by blanks.
Fields are typically space-separated entries on a line
join
Write lines consisting of the sequentially corresponding lines from each FILE; separated by TABs; to standard output
paste
Convert tabs in each FILE to spaces; writing to standard output.
assumes a tab stop every eight characters
expand
dump files in octal and other formats
od
sort lines of text files
sort
Output pieces of FILE to PREFIXaa; PREFIXab; …; default size is 1000 lines; and default PREFIX is ‘x’.
split -l 2 listing1.1.txt numbers
split
Translate; squeeze; and/or delete characters from standard input; writing to standard output tr BCJ bc < listing1.1.txt B is replaced with b C is replaced with c J is replaced with c
tr [ options ] SET1 [ SET2 ]
unexpand - convert spaces to tabs
defaults to 8
unexpand
report or omit repeated lines
uniq
Reformat each paragraph in the FILE(s); writing to standard output.
(default of 75 columns)
fmt
number lines of files (non empty)
the similar to ““cat -b”” by default
nl
Paginate or columnate FILE(s) for printing
defaults to 80 columns
pr
Print the first 10 lines of each FILE to standard output. With more than one FILE; precede each with a header giving the file name.
head
Print the last 10 lines of each FILE to standard output. With more than one FILE; precede each with a header giving the file name.
tail
Less is a program similar to more (1); but it has many more features.
less
Print selected parts of lines from each FILE to standard output.
cut
Print newline; word; and byte counts for each FILE; and a total line if more than one FILE is specified. A word is a non-zero-length sequence of characters delimited by white space.
wc
searches for PATTERN in each FILE
grep
stream editor for filtering and transforming text
sed [ options ] -f script-file [ input-file ]
sed [ options ] script-text [ input-file ]
sed
RPM Package Manager
rpm
converts the .rpm file specified as a single argument to a cpio archive on standard out. If a ‘-‘ argument is given; an rpm stream is read from standard in.
rpm2cpio
copy files to and from archives
find ./my-work | cpio -o > /media/usb/my-work.cpio
cpio -i < /media/usb/my-work.cpio
cpio
a repository based rpm manage
used by: Red Hat; CentOS; Fedora; and some other RPM-based distributions
not usd by: SUSE and Mandriva;
yum
yumdownloader is a program for downloading RPMs from Yum repositories
yumdownloader
a gui frontend for yum
also yumex
kyum
a gui frontend for yum
also kyum
yumex
debian’s equivelant of rpm
dpkg
a high-level interactive package browser. Using it; you can select packages to install on your system from the APT archives defined in /etc/apt/sources.list ; review the packages that are already installed on your system; uninstall packages; and upgrade packages.
dselect
debian’s equivelant of yum
apt-get
apt-cache performs a variety of operations on APT’s package cache. apt-cache does not manipulate the state of the system but does provide operations to search and generate interesting output from the package metadata. The metadata is acquired and updated via the ‘update’ command of e.g. apt-get; so that it can be outdated if the last update is too long ago; but in exchange apt-cache works independently of the availability of the configured sources (e.g. offline).
apt-cache
a text based debian package manager with an optional interactive mode that is similar to dselect
aptitude
a X gui program similar to dselect or aptitude
synaptic
reconfigures packages after they have already been installed. Pass it the names of a package or packages to reconfigure. It will ask configuration questions; much like when the package was first installed.
dpkg-reconfigure
converts between Red Hat rpm; Debian deb; Stampede slp; Slackware tgz; Solaris pkg; and tarballs
requires that you have appropriate package manager software installed—for instance; both RPM and Debian—to convert between these formats
When converting from a tarball; alien copies the files directly as they had been in the tarball; so alien works only if the original tarball has files that should be installed off the root ( / ) directory of the system
alien
This environment variable specifies additional directories the system is to search for libraries
Does not require ldconfig for changes to take effect
$LD_LIBRARY_PATH
prints the shared objects (shared libraries) required by each program or shared object specified on the command line.
ldd
usually called without any options
updates caches and links used by the system for locating libraries—that is; it reads /etc/ld.so.conf and implements any changes in that file or in the directories to which it refers
ldconfig
Print certain system information. With no OPTION; same as -s
node(host) name; kernel name; kernel version; kernel release; machine; processor; hardware platform; os name
uname
ps displays information about a selection of the active processes.
ps
provides a dynamic real-time view of a running system
top
displays the total amount of free and used physical and swap memory in the system; as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo. T
free
gives a one line display of the following information. The current time; how long the system has been running; how many users are currently logged on; and the system load averages for the past 1; 5; and 15 minutes
the same information displayed in the header of w
uptime
displays minimal information about the processes associated with the current session
jobs
looks through the currently running processes and lists the process IDs which match the selection criteria to stdout.
pgrep -u root cron
pgrep
move the specified job to the background, or start the first background process if it is stopped
bg
bring the specified job to the foreground
fg
Run COMMAND with an adjusted niceness (defaults to 10); which affects process scheduling. With no COMMAND; print the current niceness.
nice
renice alters the scheduling priority of one or more running processes.
renice 7 16580 -u pdavison tbaker
renice
send a signal to a process
The default signal for kill is TERM.
used to stop programs
kill
Run COMMAND; ignoring hangup signals
nohup
kill processes by name
killall vi
killall
allows you to kill one or more processes based on usernames; user IDs; group IDs; and other features as well as using a matching regular expression
pkill
a utility for querying and configuring PCI devices.
setpci
utility for displaying information about PCI buses in the system and devices connected to them
lspci
a trivial program which nicely formats the contents of the /proc/modules (kernel modules)
lsmod
a trivial program to insert a module into the kernel. Most users will want to use modprobe(8) instead; which is more clever and can handle module dependencies. e.g. insmod /lib/modules/3.16.6/kernel/drivers/bluetooth/bluetooth.ko
insmod
intelligently adds or removes a module from the Linux kernel e.g. modprobe bluetooth
modprobe
a trivial program to remove a module (when module unloading support is provided) from the kernel. Most users will want to use modprobe(8) with the -r option instead.
rmmod
a utility for displaying information about USB buses in the system and the devices connected to them
lsusb
initialize a disk or partition for use by LVM
pvcreate
create a volume group (for LVM)
vgcreate
create a logical volume in an existing volume group (for LVM)
lvcreate
scan (all disks) for Logical Volumes (for LVM)
lvscan
a dialog-driven program for creation and manipulation of partition tables. It understands GPT; MBR; Sun; SGI and BSD partition tables.
the book says this tool can’t do GPT even though it can
e.g. fdisk /dev/hda
fdisk
GPT fdisk (aka gdisk) is a text-mode menu-driven program for creation and manipulation of partition tables
gdisk
build a Linux filesystem
deprecated in favour of filesystem specific mkfs. utils
mkfs -t ext3 /dev/sda6
mkfs
sets up a Linux swap area on a device or in a file
mkswap /dev/sda7
mkswap
used to specify devices on which paging and swapping are to take place
/dev/sda7
swapon
dump ext2/ext3/ext4 filesystem information
prints the super block and blocks group information for the filesystem present on device
dumpe2fs
like dumpe2fs but for xfs; displays filesystem info
xfs_info
copies the filesystem’s metadata (filenames; file sizes; and so on) to a file
xfs_metadump
enables you to change many of the filesystem parameters that are reported by dumpe2fs
adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
tune2fs
check and repair a Linux filesystem
fsck
xfs equivelant to tune2fs
xfs_admin -L av_data /dev/sda7
xfs_admin
display the label and UUID of any partition’s filesystem
blkid
provides the abilities of dumpe2fs ; tune2fs ; and many of Linux’s normal file-manipulation tools all rolled into one
an interactive file system debugger. It can be used to examine and change the state of an ext2; ext3; or ext4 file system
e.g. debugfs /dev/sda11
debugfs
xfs equivelant to debugfs; only for experts
xfs_db
report file system disk space usage
df
estimate file space usage
du
mount a filesystem
mount /dev/sdb7 /mnt/shared
mount
unmount file systems
umount
list directory contents
ls
make a copy
cp
move (rename) files
mv
remove files or directories
rm
Update the access and modification times of each FILE to the current time
touch
an archiving utility
tar
compress or expand files; oldest least compression
gzip
a block-sorting file compressor; improved over gzip
bzip2
Compress or decompress .xz and .lzma files newest and best compression compared to gzip and bzip2
xz
Copy a file; converting and formatting according to the operands.
very low level
dd
make links between files
ln [options] source link
you can’t make hard links to directories
ln