101 Exam Flashcards

(971 cards)

1
Q

Regular File System

A

Method of laying out files and folders on a physical hard disk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Two primary psuedo file system locations

A

/proc

/sys

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Linux Kernel

A
  • Core framework of the OS
  • Handles memory management and hardware device interactions
  • Many third-party kernel modules are device drivers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

uname

A

displays information about current running kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

uname -m

A

prints machine hardware name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

uname -rm

A

brings up kernel release version with hardware name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

uname -a

A

brings up OS, host name of the server, kernel release version, build time of the kernel, machine architecture, cpu type, and the OS label

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

modprobe

A

used to dynamically load and unload kernel modules at runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

modprobe -r

A

used to remove a kernel module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

modprobe (name)

A

used to add a kernel module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

xfs module

A

used by kernel to know how to work with the PC’s file system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

/udev

A

device manager for the Linux kernel, links information on system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

lspci

A
  • displays information on PCI devices attached
  • should the kernel not recognize a device, it will show up here and contain information that can be used to find drivers/modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

lsusb

A

displays information on USB devices attached

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

lsblk

A

lists hard disk and partition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

procfs

A

Information about system hardware and the state of the system is contained in this
‘pseudofilesystem’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

/proc

A
  • Usually where the procfs filesystem is mounted.
    -Within this directory, you will find directories that correspond in label (number) to the
    associated PID (Process ID) of running processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

/proc/mounts

A

file (or link to another file) that contains information on all the
filesystems that are mounted locally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

/proc/interrupts

A

shows information about the interrupts in use in the system

and what they are associated with (the hardware that is using them)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

/proc/ioports

A
one or more addresses that identify a device, and the kernel
module associated with them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

/proc/dma

A
(Direct Memory Access), values used by hardware to access system
memory directly (i.e. without involving the CPU)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

/proc/usb

A

USB device IDs and kernel modules associated with them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

/proc/pci

A

PCI device IDs and kernel modules associated with them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

sysfs

A
  • ‘pseudofilesystem’ that can contain information about system hardware (like procfs)
    -designed to address some of the problems with the procfs method (unstructured data and
    the fact that both hardware and process information was consolidated in the structure)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
/sys
- Where the 'sysfs' filesystem is mounted -Within this directory, you will directories that correspond to system hardware and kernel modules associated with the system (physical or virtual) -process data (PID) does NOT exist in this method
26
/dev
-contains device data (using the information from /sys or sysfs) - Devices added or removed on a live system will engage the udev system which will detect and configure it and then make it available for use (often called 'hotplug' or 'hotswap')
27
D-Bus
-send data messages between applications udev utilizes dbus to notify user and the system when new hardware is attached -Allows desktop applications to send messages to other applications and/or receive messages from the Linux kernel
28
lsmod
- displays a listing of all currently loaded kernel modules | - Will not load a driver if missing
29
lscpu
displays information on processors on a system
30
lscpu -a (--all)
will display offline and online CPUs
31
lscpu -b (--online)
only online CPU information
32
lscpu -c (--offline)
only offline CPU information
33
lscpu -e (--extended)
display information in a more readable format
34
lscpu -p (--parse)
provides the information displayed in a comma delimited form (that can be logged and used by other applications for reporting)
35
lsscsi
- displays information on any SCSI devices detected | - some distros will display SATA devices connected
36
lsscsi -c (--classic)
output is the same as running cat /proc/scsi/scsi
37
lsscsi -d (--device)
provides additional 'major/minor' device numbers behind each detected device
38
lsscsi -g (--generic)
generic SCSI device file name (sg)
39
lsscsi -l (--long)
additional information for each device
40
lsscsi -s (--size)
print the disk size in a more readable format
41
lsscsi -v (-vv or -vvv)
controls the level of detail (verbosity)
42
lsdev
Shows all the devices that are recognized by the running system kernel
43
lsraid
• Displays any RAID (Redundant Array of Inexpensive Disks) on your system • not installed on most systems, unavailable outside of some RAID drivers/configuration software
44
lsusb -t
- tells you which device is attached to which controller | - displayed in a tree view
45
lsusb -s
shows the specified bus and device number information
46
lsusb -d [vendor]
show only devices with the indicated vendor and product ID
47
lsusb -v
verbose device output
48
lsblk -a (--all)
list empty devices as well (off by default)
49
lsblk -d (--nodeps)
print only top level device information
50
lsblk -e (--exclude)
exclude the indicated devices (one or more, comma separated)
51
lsblk -f (--fs)
include information on filesystems
52
lsblk -i (--ascii)
use ASCH characters for tree view
53
lsblk -l (--list)
output list format
54
Pseudo File System
- Does not exit on a physical hard disk - pseudo - "fake" or "not real" - only exists in RAM while system is running - cleared upon a reboot
55
dri
- Direct Rendering Interface | - pertains to the video cards attached to the system
56
lspci -k
lists out which components of the hardware are being used with which particular kernel modules
57
lspci -v (or -vv or -vvv)
be verbose and list more detailed information about all devices
58
General boot order 1
Power on
59
General boot order 2
BIOS loads ( modern systems includes EFI)
60
General boot order 3
BIOS find and hands off to the primary (or chosen) disks 'boot sector'
61
General boot order 4
Boot sector provides the MBR (Master Boot Record), within the first 512 bytes of the active (or first, depending on installation) drive (can be any type of hard drive)
62
General boot order 5
Boot loader is executed
63
General boot order 13
Modules indicated within the init scripts are loaded
64
General boot order 14
root filesystem is checked
65
General boot order 15
remaining filesystems are mounted
66
General boot order 16
network devices are started
67
General boot order 17
remote filesystems are mounted (if configured)
68
General boot order 18
init process re-reads /etc/inittab and changes to the default runlevel indicated and executes the appropriate scripts
69
General boot order 19
runlevel scripts executed in numeric order (#service for the runlevel indicated in /etc/ inittab)
70
General boot order 20
tty sessions are loaded as listed in /etc/inittab
71
General boot order 21
Login prompt is displayed, system is ready for login
72
General boot order 12
/etc/inittab is read and the appropriate runlevel script(s) are run
73
General boot order 11
The init program is loaded (and becomes the first PID - /sbin/init)
74
General boot order 10
root filesystem is mounted
75
General boot order 9
Device initialization, module loading, and the initial RAM disk (initrd) is loaded
76
General boot order 8
linux kernel is read and executed
77
General boot order 7
USER INPUT STEP depending on boot loader configuration, the user may be able to choose from a menu of potential boot types/kernel versions or allow the default to proceed
78
General boot order 6
LILO/GRUB/GRUB2 boot loader begins
79
sysvinit
- older system and service management - init script driven - written by Miquelvan Smoorenburg
80
init (initialization)
- based off of the system V init used in UNIX systems - services start one after the other - static. does not natively respond to changes on a system
81
inittab: wait
process specified will be started once when the runlevel is entered, and init will wait for its termination.
82
Red Hat init script
/etc/rc.d/
83
Debian init script
/etc/init.d
84
/etc/init.d/rc
script that orchestrates how the runlevel scripts run and what occurs when a runlevel changes
85
upstart (background)
- first developed for Ubuntu in 2006 by Scott Remnant - started in Ubuntu 6.10 - Eventually used in Red Hat 6, Debian, and Fedora 9
86
upstart
- offers asynchronous starting of services - decreasing boot up times - works off real-time events - stops and starts services, and monitors their availability - considered easily extensible - not used by most distros - dynamic. can respond to changes on the system - supports all sysvinit methods but not systemd methods
87
init Runlevel 3
- Multi-user mode but with networking. | - most linux servers are set up to run at this level by default.
88
init Runlevel 2
- Multi-user with no networking | - No remote file systems mounted
89
init Runlevel 6
- Reboot | - where init stops services and restarts the system.
90
init Runlevel 5
Multi-user but with networking and GUI. | Older Linux webstations set to run on this by default.
91
init Runlevel 4
typically not used but available should a system administrator want to set up a custom run level environment.
92
init Runlevel 1
- single user mode - only root user allowed to log in. - primarily used for maintenance tasks and repair functionality
93
init Runlevel 0
- halt or shutdown level | - where init runs scripts that stop services and powers off the system.
94
systemd
- removed the need for shell scripts - replaces the functionality of scripts with compiled C code - still compatible with older System V scripts - default on most modern distros - designed to replace sysvinit method - fewer dependencies - service prioritization and precedence - reduces start up time
95
Unit File Locations: | /usr/lib/systemd/system
- the 'units' installed | - provided by package installations (do not edit these unit files)
96
Unit File Locations: | /etc/systemd/system
units that have priority over other units and are controlled by sysadmin
97
Unit File Locations: | /run/systemd/system
units created at runtime and may have priority over non-runtime (or installed) units
98
systemctl
primary command for controlling service start/stop/restart/status
99
system-analyze
display performance information on system bootup, allows for | trace/debugging information
100
logind
replaces consolekit, supports X Windows managers
101
consoled
console daemon, replaces virtual terminals
102
journald
logging system, uses binary logs (although it can be replaced by other logging daemons)
103
networkd
network support daemon
104
.service
system service
105
.swap
swap device or file
106
.socket
IPC socket
107
.target
unit (one or a group of)
108
.snapshot
saved state instance of the systemd manager
109
.slice
units grouped together in a hierarchy used to manage processes
110
.timer
timer
111
.mount
mount point on the file system (local or remote)
112
.automount
automount point on the filesystem
113
.scope
externally created process
114
.path
file or directory on file system
115
.device
device in use by the system kernel
116
systemd runlevel 0
- poweroff.target | - shutdown the system
117
systemd runlevel 1
- rescue.target | - single user/rescue shell
118
systemd runlevel 2,3 and 4
- multi-user.target | - non-graphical, but full network, multi-user
119
systemd runlevel 5
- graphical.target | - full graphical desktop, multi-user
120
systemd runlevel 6
- reboot.target | - reboot
121
Service target dependencies
• Method of indicating dependencies between units or groups of units on the system
122
Service target dependencies - requires
• Only after the requirement is met, will any other 'wanted' units be started
123
Service target dependencies - wants
Only executed upon completion of 'requires' units
124
systemd boot process changes
- /etc/inittab is not read (and is no longer in use) - 'default.target' is started (which is linked to the current 'default' target - multiuser, graphical, etc) - A tree of 'requires' and 'wants' is then followed throughout the process
125
runlevel (command)
displays the current runlevel (and the previous, if available)
126
systemctl get-default
displays the current default runlevel target
127
systemctl set-default [new.target]
- Will set the default runlevel target to the indicated value - Creates a link from 'default.target' to the indicated target
128
systemctl list-units --type=target
list all the active system targets
129
systemctl isolate [runlevel.target]
Allows you to set the runlevel of the system without changing the default
130
Components of the Unit File
-unit files follow the INI style format first seen in MS-DOS
131
lspci -m (-mm)
displays the PCI device information in a more "easily parseable" format
132
lspci -vm
nicely formatted listing of all PCI hardware on the system
133
lspci -t
displays a tree view of the PCI devices on the system
134
lspci -tvm
associate the device names with the IDs in a tree view
135
PCI
- Peripheral Component Interconnect | - PCI device is any piece of computer hardware that plugs directly into a PCI slot on a computer
136
Commands to view output from kernel ring buffer
- dmesg - legacy command | - journalctl -k viewed within the systemd journal
137
/sbin/init
binary used to bring up the rest of the system and start services
138
Boot order overview
- BIOS - Boot sector (w/ Boot loader) - Kernel - Initial RAM disk - Device initialization
139
upstart: Task
will do what is requested and will return to a waiting state once finished
140
upstart: Service
Will not stop by itself
141
upstart: Job state
condition at one point in time
142
upstart: Waiting
initial state of a job
143
upstart: Starting
job itself is about to start
144
upstart: Stopping
interim state where job has processed a section of it's configuration known as prestop
145
upstart: Killed
where job is actually stopped
146
upstart: Post-stop
where job has completely stopped and goes in waiting state
147
upstart: Respawning
- occurs when something goes wrong when job is running and quits unexpectedly - upstart will attempt to respawn a job up to 10 times at 5 second intervals
148
sysvinit: change runlevel
- telinit or init (followed by runlevel) - must be root user - telinit is legacy command
149
sysvinit: pull default runlevel
cat/etc/inittab
150
sysvinit: change runlevel during restart
- press any key during boot process - press "a" in GRUB menu - type run level number to use
151
reboot (command)
reboot system
152
shutdown -h
halt the system (shut it down)
153
shutdown -r [specifictime]
reboot system at the time given
154
shutdown -P
power off (if ACPI is available)
155
shutdown -C
cancel shutdown
156
shutdown -k [message]
broadcasts a 'wall' message to logged in users
157
halt -f (--force)
does not shutdown, only halts
158
halt -p (--poweroff)
power off after shutdown (if ACPI is available)
159
halt -w (--wtmp-only)
only LOGS the shutdown but does not perform the shutdown | or reboot
160
halt --verbose
displays more information for troubleshooting
161
systemd Target
- target is a unit that syncs up other units when the computer boots or changes states - other units associate themselves with a target for an operating environment
162
multi-user.target
- multi-user system - similar to runlevel 3 - provides a command line shell with networking and the ability to host multiple user log ins
163
graphical.target
- multi-user system with a desktop environment. similar to runlevel 5 - "picture text"
164
rescue.target
- pulls in basic system and file system mounts and provides a rescue shell - there to provide an isolated environment for the root user to perform repairs on the system. - similar to runlevel 1
165
basic.target
basic system. used during the boot process before another
166
sysinit.target
system initialization
167
systemctl list-unit-files -t target
show all unit files for available targets
168
systemctl list-units -t target
show all loaded and active unit files
169
systemctl get-default
list out the default target
170
systemctl set-default [new.target]
change the default target to a different target
171
systemctl isolate [runlevel.target]
will change the running state of the system from the current target to a different target
172
systemctl rescue
- almost identical to the System V init single-user mode | - allows the root user to repair the system
173
systemctl reboot
- will run the reboot target | - same thing as just typing reboot at the prompt
174
systemctl poweroff
- isolates the system to poweroff.target | - same as typing poweroff at the prompt
175
systemctl halt
halt. do not power off
176
systemctl poweroff
halt and power off (if ACPI is available)
177
wall
- allows you to broadcast a message to all logged in users. - limited to 20 lines of text - will appear on every terminal overwriting or interrupting terminal text - terminate with CTRL+D
178
reboot commands
- reboot - telinit 6 - shutdown -r now - systemctl isolate reboot.target
179
Shutdown commands
- poweroff - telinit 0 - shutdown -h+1 - systemctl isolate poweroff.target
180
ACPI
-Advanced Configuration and Power Interface -registers system events (pressing power button or closing laptop lid)
181
mount (command)
list out every partition and every mount point currently in use on the system
182
block device
hard disk or anything that takes a large amount of data and writes it and blocks sizes to a location
183
single disk installation
linux installed on a single physical disk, consisting of one or more partitions
184
multi-disk installation
linux installed on multiple physical disks, each consisting of on or more partitions
185
dev/sda
first physical SATA disk on a system
186
dev/sda2
first physical disk, second partition
187
dev/hdc2
third IDE drive, second partition
188
dev/scd0
- first CDROM drive | - CDROM doesn't have partitions
189
Linux filesystem layout
- everything is a file - any folder (few exceptions) can be mounted on any drive/partition - shared development system with constrained disk space
190
/
- 'root' filesystem is mounted on a device/partition and contains all other folders - bottom of the directory tree
191
/var
- log files, shared files/directories, runtime information, binary data files - generally set up on a separate partition
192
/home
user's home directory, where personal files are stored
193
/boot
-boot loader configuration and kernel files are contained here
194
/opt
- generally third party applications are installed here | - enterprise environments make use of this location
195
swap
- temporary storage that acts like RAM - when a percentage of RAM is full, kernel will move less used data to swap - much slower than using a dedicated partition
196
Swap size
older 'rules' ranged from 1.5x to 2x of avail RAM | -today should use no less than 50% of avail
197
LVM (Logical Volume Manager)
- Allows the creation of 'groups of disks' or partitions that can be assembled into a filesystem. - can be used for nearly any mount point except /boot - flexibility - allows for resizing of volumes - snapshots- allows for 'point in time' copies of your logical volume
198
VG (Volume Group)
- combination of one or more PV to create a pool of avail storage - Contains all of your physical volumes
199
LV (Logical Volumes)
- Volume group is carved into individual components that can be used for specific functions - like a partition
200
pvs (command)
lists out the physical volumes in an LVM group
201
vgs (command)
lists out the volume groups within an LVM group
202
lvs (command)
lists out the logical volumes within an LVM group
203
PV (Physical Volume)
- basic starting point of storage | - corresponds to a disk or partition
204
Swap - Partition
dedicated partition formatted specifically as swap space
205
Swap - files
created file that is used on a filesystem as swap space for the system
206
grub-install [device]
- command used to install GRUB to the specified device - typically done from a live CD/USB where GRUB is installed on a new disk - can be identified by drive path /dev/hda or /dev/hd0
207
grub (command)
-invokes GRUB shell environment and prompt
208
help (command)
print the help listing for GRUB, or get more info on a command
209
GRUB: find (command)
search for a file in all partitions and list the devices the file is on
210
GRUB: quit (command)
exit grub shell
211
MBR (Master Boot Record)
- traditionally supported only 26 total partitions | - partition size limited to 2TB
212
GPT (GUID Partition Table)
- supports 128 partitions - partition size up to ZB range - Needs UEFI to boot and asks as BIOS
213
UEFI (United Extensible Firmware Interface)
- replacement for traditional BIOS, can act in legacy BIOS mode - requires 64bit OS - prevents unauthorized
214
grub2-editenv list
view the default boot entry for the grub configuration file
215
grub2-mkconfig
- creates or updates a /boot/grub2/grub.cfg file based on entries from the /etc/default/grub file - used to generate the GRUB configuration file menu
216
update-grub
- can be used to update a GRUB2 configuration after changes to /etc/default/grub have been made - same results as running grub-mkconfig -o /boot/grub/grub.cfg
217
GRUB Legacy: [A] key
append options to the kernel boot line
218
GRUB Legacy: [C] key
open up the GRUB command lilne
219
GRUB Legacy: [ESC] key
escapes out of any GRUB menu
220
GRUB Legacy: Arrow Keys
used to highlight an option in the GRUB menu
221
RHGB
Red Hat Graphical Boot
222
Setup (command)(hd0)
used to reinstall GRUB
223
GRUB2: [E] key
used to edit GRUB menu item
224
GRUB2: [Esc] key
go to previous menu item
225
GRUB2: Ctrl+x or F10
boots a selection or modified line
226
GRUB (legacy) /boot
- 'boot volume' for GRUB - kernel and related files are stored here - kernel config file - kernel initrd (ramdisk) file - default boot message - system map file
227
/boot/grub
-Legacy GRUB configuration directory
228
menu.lst/grub.conf
GRUB options and builds the menu of choices displayed on boot
229
GRUB Legacy menu list: | deftault=[#]
determines the menu option that will be started if nothing else is chosen
230
GRUB Legacy menu list: | timeout=[#]
the amount of time, in seconds, you have to choose another option
231
GRUB Legacy menu list: | title [description]
text based description of the menu entry
232
GRUB Legacy menu list: | root [(hd#,#)]
hard drive device number and partition of the root drive (where the kernel is)
233
GRUB Legacy menu list: | initrd [/boot/initrd#.img]
path to the initial RAM disk image for the chosen menu entry
234
GRUB2: /boot
- 'boot' volume for GRUB2 - kernel config file - kernel initrd (ramdisk) file - default boot message - system map file
235
GRUB2: /boot/grub
- compatibility with GRUB directory | - sometimes will contain splash image for the boot menu
236
/boot/grub2/grub.cfg
-combination of a number of files when the grub2-mkconfig utility is used
237
/boot/grub2/fonts
default and custom font for the GRUB2 menu
238
/boot/grub2/themes
themes for the GRUB2 graphical menu
239
/etc/grub.d
-numbered files that, when the grub2-mkconfig utility is run, all are concatenated to make the /boot/grub2/grub.cfg (menu) file
240
/etc/deftault/grub
file containing the GRUB2 specific configurations
241
grub2-install
installs GRUB2 to the indicated location
242
APT - Advanced Package Tool
-installs applications and their dependencies -remove applications -updates and upgrades packages -reads /etc/apt/sources.list directs installation and uninstallation of packages to dpkg
243
/etc/apt/sources.list
configuration file that lists out repository locations for packages
244
apt-get update (command)
updates the local apt cache with a listing of packages that can be updated/upgraded and installed
245
apt-get upgrade (command)
upgrades the packages that have updates available
246
apt-get install (package name)
installs a package from the repositories in the sources.list file
247
apt-get remove (package name)
removes package from the system but any config files that came with the package will be left behind
248
apt-get purge (package name) | 0r dpkg --purge
removes the package from the system and any associated configuration files
249
apt-get dist-upgrade
upgrades all packages on the system up to the next release of the distro
250
apt-get download (-d) (package name)
- downloads the package and places in /var/cache/apt/archives - does not install it
251
Shared Library
- files containing functionality that other applications can use - files can end in a '.so' extension - for 'shared object'
252
Shared Libraries are found here
-/lib -/usr/lib (32 bit) -/usr/lib64 (64 bit) /usr/local/lib -/usr/share
253
Two types of library files
- dynamic - ends in.so | - statically linked - ends in .a
254
ldd
prints out shared object library dependencies
255
ldconfig
- configures dynamic linker run-time bindings | - creates a cache based on library directories and can show you what is cached
256
/etc/ld.so.conf
configuration file that points to directories and other configuration files that hold references to library directory locations
257
LD_LIBRARY_PATH
Legacy environment variable that points to a path where library files can be read from
258
Shared Libraries: Soft links
where specific library versions are linked to a more generic name
259
Static linking
- application contains a full copy of the library that is used - application will have exact library version it expects with known interfaces - size is a disadvantage
260
Dynamic linking
- application uses the library externally using 'stubs', the library is installed on the OS itself but not installed with the app - size is an advantage
261
ld.so
any time an app needs to use a shared library, the ld.so is called -known as 'dynamic linker'
262
Repository
remote location that you can download and install packages from using any of the package management tools
263
/etc/apt/sources.list.d
- files that define one or more remote repository locations for package download and installation - each may contain lines for both packages and another for package resources
264
apt-get
Package manager that can install, reinstall or remove packages and all their dependencies at the same time
265
apt-cache
allows you to interact with the cache of available packages from all configured repositories
266
apt-cache search [value]
search for packages matching the indicated value
267
apt-cache show [packagename]
show available information about the indicated package
268
apt-cache showpkg [packagename]
additional technical information about the package
269
aptitude and synaptic
- similar to apt and uses it in the background | - has a graphical front end
270
dpkg package
- application or utility - default configuration files - how and where to install files - listing of dependencies the package requires - apt handles the dependencies
271
dpkg --info [packagename] or | dpkg -I (capital i)
displays package contents
272
dpkg --status [packagename]
abbreviated display of the --info option
273
dpkg -l [packagename or partial name]
lists out package(s) that match the string provided
274
dpkg -i (--install) [packagename]
- will install the indicated package name | - fail if there are missing dependencies
275
dpkg -L (--listfile) [packagename]
list all files that were installed with the indicated package
276
dpkg -r (--remove) [packagename]
removes the package's files but any configuration files and directories will be left alone
277
dpkg -P (--purge) [packagename]
removes the package's files AND and configuration files and directories associated with it
278
dpkg -S (--search) [filename]
search for the indicated installed file within the package database for all mentions of the file or string
279
dpkg-reconfigure [packagename]
allows for modification of a package by re-running the application's configuration tool
280
dpkg --force-reinstreq [packagename]
allows you to force the removal of a package marked as requiring install
281
dpkg --force-depends [packagename]
used with -i to force the install of a package with missing dependencies
282
dpkg --force-conflicts [packagename]
- used with -i to force install a package with conflicting dependencies - forcing installations may leave system unusable
283
yum (Yellowdog Updater, Modified)
- originally used for Yellowdog Linux distro - handles RPM package dependencies - installs, upgrades, removes packages - RHEL, CentOS, Scientific LINUX
284
yum setup
- global yum config options are set in /etc/yum.conf | - reads repository information from /etc/yum.repos.d/
285
zypper
-RPM package manager for SUSE Linux
286
zypper repos (command)
will list out the individual repositories that zypper uses for install and upgrade of packages
287
zypper install vim (command)
will install the vim package
288
DNF - Dandified yum
- used in Fedora - future replacement for yum in Red Hat - uses same command syntax as yum
289
yum update/upgrade
will read the configured repositories and local cache, and upgrade all installed system apps
290
yum search
searches the yum repositories for specified package
291
yum info
lists information about a specified package
292
yum clean all
cleans up all of yum's cache information and it's local database file
293
basurl line within the repo file
web address that indicates where packages are downloaded from
294
yum install [packagename]
- installs a specified package and all of its dependencies | - -downloadonly will just download the indicated package
295
yum remove
uninstalls a package and leaves dependencies behind
296
yum autoremove
-uninstalls a package and its dependencies
297
yum whatprovides
find out what package provides a specified file name
298
yum reinstall
reinstalls a specified package
299
/etc/yum.conf
default yum config file. may contain some repository definitions
300
/etc/yum.repos.d
individual '*.repo' files containing the location and options for remote repositories
301
/var/log/yum.log
default yum transaction log file
302
yum --enablerepo [reponame]
enable a disabled repo for the current transaction only
303
/var/cache/yum/[architecture]/[version]/base/packages
directory the package will be downloaded to
304
-y on a yum command
will skip affirmation step
305
yumdownloader
allows you to download a package only, but provides additional functionality
306
yumdownloader --source
download only source RPM
307
yumdownloader --urls
display the URL of the files without downloading
308
yumdownloader --destdir
allows you to indicate the directory to store the package download
309
yumdownloader --resolve
includes any dependencies
310
.rpm package
- application or utility - default config files - how and where to install the files that come with the package - listing of dependencies the package requires
311
rpm -qpi
- displays information on a package | - same as yuminfo
312
rpm -qpl
list files in a package
313
rpm -qa or yum list installed
lists out all installed packages
314
rpm -i
installs a specified package
315
rpm -U
upgrades an installed package
316
rpm -e
uninstalls a package
317
rpm -Va
verify all installed package
318
rpm2cpio
converts a .rpm file into a cpio archive file
319
/var/lib/rpm
RPM database directory
320
rpm --rebuilddb
- rebuilds the local RPM database in the /var/lib/rpm directory - only performed by root
321
rpm -q [packagename]
shows all packages meeting the indicated values that are installed
322
rpm -qi [packagename]
-detailed information about an installed package
323
rpm -ql [packagename]
listing of all files in the package
324
rpm -qip [package.rpm]
- show the appropriate details about a file NOT installed as named - will show information on a package before install
325
rpm --changelog [packagename]
display the changelog for the indicated package
326
rpm -qc [packagename]
display all configuration files for the indicated package
327
rpm -qRp [package.rpm]
show the requirements of the indicated rpm file
328
rpm -qf
will show the package that the indicated file dependency belongs to
329
rpm -K
validate for the indicated package
330
rpm --import
import the indicated keyfile from the package maintainer
331
rpm -v
print verbose information
332
rpm -h (--hash)
during activity, print a 'status' bar using hash '#' character
333
rpm --force
option added during install or removal to force install/removal
334
rpm --replacefiles
option added during install, that replaces duplicate files
335
rpm -V
verify the integrity of a package
336
rpm -Va
verify ALL installed packages
337
rpm -Vac
verify ALL installed package config files on the system
338
rpm -F (--freshen)
will ONLY upgrade the indicated package if it's already installed
339
rpm -e (--erase)
erases the indicated package name
340
Virtual Machine
- emulation of a specific OS - share same physical hardware - isolated from hardware and communicates through Hypervisor
341
VM/Hypervisor Examples
- KVM - QEMU - VMWare - Xen - VirtualBox
342
Full virtualization
guest system is not aware that it is a virtual machine
343
paravirtualization
- guest system is aware that it is a virtual machine, uses guest drivers - VMs perform better with guest drivers
344
dbus-uuidgen or dbus-uuidgen --get
ensures that each running kernel interacts with a system that has a unique ID
345
cloud-init (command)
- used to ensure user data is completely new - creates new SSH keys - sets system's default locale - sets system's host name - sets up mount points
346
Cloud Virtual Machines
- AWS - Azure - Rackspace
347
Container
- isolated set of packages, libraries and/or applications that are independent from their surroundings - use shared OS - more resource efficient
348
Machine container
shares a kernel and file system with the host computer
349
Application container
- shares everything but the application files and library files the application needs - useful on a web server
350
Container example
- Docker - nspawn (systemd) - LXD - OpenShift
351
Linux Shell
- bash is default - csh - C programming style syntax - ksh - KornShell includes elements of Bash and C - zsh - Z Shell includes elements of Bash and Korn
352
Environment Variable
settings that dictate common functionality and locations
353
env
command that displays environment variables except shell settings
354
echo
versatile command that can be used to print the value of a variable
355
set
displays shell settings or shell variables for the session
356
unset
removes a variable or custom bash function
357
shopt
displays shell options and their current settings
358
set -x
turns on debugging with the bash shell
359
set +x
turns off debugging
360
shopt -s (option)
to set or enable option
361
export (command)
used to export a variable to the current shell and any new shells started from the current shell
362
which (command)
-shows the full path of (shell) commands
363
type (command)
determines if something is a function, file, alias, built-in or keyword
364
"weak" quotes
double quotes will expand variables, but characters used for path substitutions or pattern matching will not be expanded
365
'strong quotes'
inside strong or single quotes. nothing is interpreted
366
history (command)
shows most recently used commands
367
.bash_history
file located in user's home directory that contains the previously run commands
368
HISTFILESIZE
- environment variable that determines how many lines the bash_history file will contain - default is 500
369
Man page - Section 1
executable programs or shell commands
370
Man page - Section 2
System calls - functions provided by the kernel
371
Man page - Section 3
Library calls - functions within program libraries
372
Man page - Section 4
special files - typically found in /dev
373
Man page - Section 5
file formats and conventions
374
Man page - Section 6
games
375
Man page - Section 7
miscellaneous terms and conventions
376
Man page - Section 8
system admin commands
377
Man page - Section 9
kernel routines
378
man -k or | apropos
used to search man pages for a key word
379
man [section number]
pulls up a specific section of a man page
380
less
read-only text view
381
head
bring up first 10 lines of a file
382
tail
last 10 lines of a file
383
zcat
view gzip compressed text file
384
bzcat
view bunzip2 compressed text file
385
xzcat
view XZ compressed text file
386
nl (file)
prints the number of lines in a file
387
od
- octal dump command | - print out file in octal or other formats
388
md5sum
calculates and checks a file's hash based on MD5
389
sha256sum
calculates and checks file's hash based on SHA-2 hash using 256 bits
390
sha512sum
calculates and checks file's hash based on SHA-2 hash using 512 bits
391
/etc/bashrc
- sourced script and is executed each time user logs in or they execute a non-login session - umask set for the whole system within this file
392
~/.bash_profile
- sourced script and is executed each time user logs in but only affects the environment for the user logging in - typically used to set environment variable specific to user
393
~/.bashrc
- usually called by the ~/.bash_profile' script - will source /etc/bashrc file - used to customize shell prompt, keyboard shortcuts - umask set for individual user here
394
~/.bash_logout
executed when the logout or exit commands are executed
395
'non-login' session
- when the root or other user uses su to become another user | - does not load full environment by default
396
~ (character)
user home directory
397
\ (character)
escape character
398
Special character: $
identifies a variable
399
? (character)
single character 'wildcard'
400
* (character)
0 to n 'wildcards'
401
& (character)
send process to background returning the use of the shell to the user
402
&& (character)
execute second command only if first is successful
403
|| (character)
execute second command only if first is unsuccessful
404
; (character)
execute multiple commands on the same line
405
command exit 0
success
406
command exit 1 or higher
failure
407
set -o (option)
turns option on
408
set +o (option)
turns option OFF
409
/etc/profile
- where PATH environment variable is initially set | - source script executed each time a user logs in
410
HISTCMD
index of the current command
411
HISTCONTROL set to ignorespace
command preceded by a blank space will not be recorded in history file
412
HISTCONTROL set to ignoredups
two consecutive lines that are a duplicate will have one ignored
413
sed (command)
- 'stream editor' command | - commonly used to alter text in a file or replace words
414
sort (command)
used to sort and/or merge lines of a file
415
uniq (command)
removes consecutive duplicate lines of a file
416
tr (command)
used to translate or swap characters in a file
417
cut (command)
extracts columns or fields of data from a file
418
paste (command)
merge lines of files
419
split
- command used to split a file into individual pieces | - each piece contains up to 1,000 lines by default
420
sort -k [#] [filename]
- sort at the start of the second delimited field | - delimiter by default is a space or tab
421
sort -n [filename]
sort the file numerically
422
nl -ba [filename]
will number all lines, even if the line is empty
423
wc -l
number of lines
424
wc -w
number of words
425
wc -c
number of characters in bytes
426
expand
- changes tabs in a file to a specific number of spaces | - default is 8
427
expand -t [#]
converts tabs to # of spaces indicated
428
cut -c [#][-#] [filename]
will display only the column or range of column from the indicated filename
429
cut -d [delimiter]
- set the delimiter to use when dealing with fields | - default is TAB`
430
cut -f [field] [filename]
identify the field numbers identified by delimiter to display from the indicated filename
431
join
combines two files together but removes redundant fields
432
join -t [character]
use the indicated character as the field separator
433
uniq -u [filename]
print ONLY the unique lines in the file
434
uniq -d [filename]
print an example of each line that is duplicated in a file
435
uniq -D [filename]
print ALL instances of duplicate lines in a file
436
head -n [#][filename]
display number of lines, beginning at the top, of the indicated file
437
tail -n [#][filename]
display number of lines, beginning at the bottom, of the indicated file
438
tail -f [filename]
to follow a file as new entries are created
439
split -a [#]
when the split file(s) are created named them 'x#'
440
split -b [#][b/k/m]
new file(s) contain the indicated number of bytes/kilobytes/megabytes
441
split - [#]
new file(s) contain the indicated number of lines of bytes
442
split -l [#]
new file(s) contain the indicated number of lines
443
cat
display a file, top to bottom,
444
tac
same as cat, but in reverse by listing file bottom to top
445
od -a
display 'named' binary file
446
od -d
decimal format
447
od -f
floating point format
448
od -o
octal format
449
od -x
hexadecimal format
450
pr (command)
- used to 'format' a source file or other text only files to be printed - adds a header with the date of the 'job', file, and pagination (page number) at the top
451
pr -- columns=[#]
format text data in the file into the indicated number of columns for printing
452
pr -- columns -a[#] (--across)
print columns across instead of down
453
pr -d (--double-space)
double space the line output
454
pr -h (--header) [text]
- customizes the header text | - replaces the filename with the indicated text
455
pr -t (--omit-header)
omits the header from the output
456
fmt
- used to format files for printing - limited to wrapping longer lines of output - commonly used with pr utility
457
fmt -[#]
desired width to break each line at
458
fmt -s
split long lines over 50 characters without filling
459
fmt -40 mytext.txt | pr --columns=2
-split each line at 40 characters and prepare a printing with header in two neat columns
460
tr 'A' 'a' < myfile.txt
translates all uppercase A to lowercase a
461
[:upper:][:lower:] < [filename]
converts all uppercase to lowercase
462
sed s/
substitutes what comes next
463
g at the end of sed (command)
replaces ALL instances of the first value with the second
464
sed 's/a/A/g' filename.txt
replace every instance of lowercase 'a' with uppercase 'A'
465
-e in sed (command)
used to chain multiple filters together instead of using ';'
466
sed -n (--quiet
- suppresses the printing of 'pattern space' | - can prevent lines from appearing multiple times
467
more (command)
allows paginate paging through text files one screen at a time
468
more -d
prompt to 'space to continue' or 'q to quit' at each screen
469
more -num [#]
- specify the screen size in lines | - default is 50 or the size of the terminal
470
more -p
clear the screen before starting the first screen display
471
less (space key)
moves to next full screen
472
less (d key[#])
scrolls through the next number of lines indicated
473
less (b key[#])
scrolls backwards through the next number of lines indiciated
474
touch
- create a file | - modify file's time stamp
475
file (command)
-used to determine file type
476
rmdir
- remove directory command | - will not delete directory with any content
477
dd (command)
- copies and converts files | - used to create files of arbitrary size and to back up disk drives
478
tar
-wraps up files and folders into an archive file
479
gzip
creates .gz compressed files
480
gunzip
extracts .gz compressed files
481
bzip2
- command that creates .bz2 compressed files | - better compression utility in terms of size
482
bunzip2
command that extracts .bz2 compressed files
483
xz
- command that creates .xz compressed files | - newer compression utility for files and directories
484
unxz
command that extracts .xz compressed files
485
ls -l
-long listing containing permissions, owner, size and date
486
ls -a
list files including 'hidden' files
487
ls -d
list just the directory without the files
488
ls -i
display the inode numbers for the files or directories
489
ls -h
'human-readable' format to filesizes and details
490
cd ~ | cd
home directory
491
cd .
current directory
492
cd ..
moves up one directory
493
makedir -p
make all directories in the indicated path if they do not already exist
494
globbing
wildcard or list character that makes one or more files based on an indicated pattern
495
touch -t [date][filename]
sets the date/time as indicated for the file
496
touch -r [referencefile][filename]
applies the indicated date/time in the 'reference'file to the 'filename'
497
stat (command)
displays a file or file system status
498
stat -f (--file-system)
display the file system status instead of file status
499
stat -t (--terse)
display the information in terse short form
500
cp -d
- do not follow symbolic links | - just copy the link
501
cp -f
-force overwrite if the file already exists
502
cp -i
ask before overwriting an existing file
503
cp -l
create a hard link to the original
504
cp -s
create a symbolic link to the original
505
cp -r (or -R)
recursively apply any options to other directories or subdirectories
506
cp -x
do not include any files/directories from other filesystems
507
mv -i
- check to see whether the destination already exists | - will prompt to overwrite
508
mv -u
do not overwrite the destination file or directory if it is newer than the original
509
mv -f
- do not prompt for directory entry changes | - often the default
510
rmdir -p
removes all directories in a path as long as they are all empty
511
rmdir --ignore-fail-on-non-empty
allows the removal of directories that do have files
512
rm -r
recursively remove files and subdirectories
513
rm -f
do not prompt for confirmation on deletion
514
rm -i
prompt for every file/directory to be removed
515
dd: if
image file or device used as input
516
dd: of
image file or device used as output
517
dd if=/dev/sda of =/dev/sdb
will back up the full /dev/sda disk to /dev/sdb
518
find (command)
- method for 'finding files' based on name or type | - can be costly of CPU and IO performance
519
find [starting path]
where to begin the search
520
find -[options]
what type of 'thing' to find
521
tar -c
create the archive
522
tar -t
displays the contents of the archive
523
tar -x
extract the content of the archive
524
tar -f
name of the file to create
525
tar -j
- compress/uncompress with bzip2 | - best compression method
526
tar -z
- compress/uncompress with gzip | - most commonly used method
527
tar -v
verbose messages
528
tar -cvjf mybackup.tar.bz2 /home/user
- creates a file called mybackup.tar.bz2 in current directory containing files from /home/user - compressed with bzip2
529
cpio (command)
used by receiving input from a file or another command and sends the files to either standard output or a file
530
cpio -o (--create)
runs in copy-out mode
531
cpio -0 [archivefile]
creates the indicated file instead of using standard output
532
cpio -d (--make-directories)
make leading directories if needed
533
cpio -i (--extract)
extracts the content in copy-in mode
534
cpio -I [archivefile]
use the archive file indicated rather than standard input from a command or file
535
cpio -v
verbose messages
536
gzip and gzip2 -r
recursive, include all files and directories
537
gzip /home/user/myfile.txt
-would compress the /home/user/myfile.txt file, leaving /home/user/myfile.txt.gz in its place
538
xz -z (--compress)
compress the file indicated
539
xz -d
decompress the file indicated
540
find (directory) -name
find files based on their name
541
find (directory) -ctime
- find files based on the time they were last changed | - default is by day
542
find . -ctime -1
locate files that have been changed within current directory from the last 24 hours
543
find (directory) -newer (file)
locate files whose timestamp is newer than the selected file
544
file (directory) -empty -type f
locate empty files
545
file (directory) -atime (file)
locate files based on their access time
546
find (directory) -empty -type f -exec rm -f {} \;
find and remove empty files within current directory without prompting
547
file (directory) -exec [command] {} \;
will act on the results of the find command
548
[abc]
- matches any one of the characters in the list | - case sensitive
549
[^abc]
- matches any one character except those in the list | - case sensitive
550
[0-9]
matches a range of numbers
551
Standard Output
- bucket where all the output goes - >, >> - stdout - 1
552
Standard Input
- usually comes from keyboard entries - files and standard output from other commands can provide input to another command - stdin - 0
553
Standard Error
- usually written to the screen - stderr - 2
554
Find option: group
files/directories belonging to the specified group
555
Find option: user
files/directories belonging to the specified user
556
Find option: iname
files/directories whose names match the indicated name
557
Find option: mtime
files/directories matching the indicated modification time
558
/dev/null
- stderr is commonly redirected to a logging file or special device here - allows you to clean up errors from the normal standard output
559
Redirecting Standard Error: find / -iname "*.sh" 2> /dev/null
-will display the results of the found matches without displaying error messages related to permissions
560
Chaining Redirects: | sort < listfile | nl
redirect the 'listfile' as an input stream to the sort command, piping that output to the nl command to add line numbers
561
Special combination: | find / -iname "*.sh" > /dev/null 2>&1
redirects standard error to standard output and the whole output stream is redirected to /dev/null
562
tee (command)
- accepts a standard input stream and sends one identical output stream to an indicated file - used to capture the output of an app but to also show the results on the screen
563
find / -name "*.sh" | tee visibleresults.txt
- find all files ending in .sh from root partition, piping those results as an input stream to tee - output sent to screen and visibleresults.txt file
564
xargs (command)
takes an input stream of another command and feeds to another command as indicated
565
find / -name "*.sh" | xargs ls -al > myresults.txt
- find all files ending in .sh and xargs will take the output and feed to the ls -al command. - will then display the details of each file and redirect to myresults.txt
566
ps (command)
lists process status of each running process on the system
567
process
set of instructions loaded into memory
568
ps -u (user name)
pull up processes running under a specific user
569
ps -e
pull up every process running on the system for all users
570
ps -eH
pull up running processes in a hierarchy view
571
ps -e --forest
provides a full format listing which includes showing all arguments that a command is using while it is running
572
Kill process from top command
Press (k) key, type in PID and hit enter
573
top (command)
real-time monitoring of processes running on a system
574
man signal
man pages for various signal states of running processes
575
uptime (command)
view how long system has been up, how many users logged in, and CPU load average by last minute, last 5 minute, and last 15 minutes
576
Load Average
average number of process that are either in a runnable or uninterruptable state
577
free (command)
view used and available memory and swap space
578
pgrep (command)
find process information based on process name
579
kill (command)
send a signal to a process based on PID
580
pkill (command)
send a signal to a process based on process name
581
pkill -x (name of process)
used to only kill the exact name of a process given
582
ps -a
display all running processes
583
ps -x
display processes without an associated tty (terminal)
584
ps aux
- show all processes by any user, displaying the process owner and processes not tied to a terminal - same as ps -ef
585
pstree (command)
show a tree view hierarchical ASCII display of running processes
586
pstree -A
display the tree using ASCII characters
587
pstree -a
display the processes including any parameters used
588
pstree -p
show PIDs
589
free -b
displays the memory in bytes
590
free -k
displays the memory in kilobytes
591
free -m
displays the memory in megabytes
592
free -g
displays the memory in gigabytes
593
free -h
displays in 'human-readable' format
594
free -c (#) -s (#)
number of times to display the output and how many seconds between each output
595
free -t
display a line showing each column totals
596
free -l
display low and high memory statistics
597
kill -1 (PID)
shutdown and restart the process
598
kill -15 (PID)
terminate process
599
kill -9(PID)
kill/stop/end/dump right now
600
killall (command)
kills all instances of the named process
601
pkill -signal (#)
send the signal number to the matched process
602
pkill -t
match the indicated terminal/tty
603
pkill -U
match the user ID
604
pgrep -u root, apache httpd
will display any httpd process owned by root OR apache
605
pgrep -u root apache
will display only processes owned by root AND apache
606
watch (command)
- runs a command at specified intervals | - used to monitor a command's output
607
screen (command)
- terminal window manager that allows you to run commands in an isolated session - processes can run after logging out
608
tmux (command)
- terminal window manager similar to screen with extra features - -processes can run after logging out
609
watch date
-displays current date and refreshes every 2 seconds by default
610
watch date -n 5
changes refresh period to every 5 seconds
611
screen: ctrl+a d
detach from screen session
612
screen -r (session number)
attach to specific screen session
613
screen -r
reattach to current screen session
614
screen -ls
view active screen sessions
615
End screen and tmux sessions
type "exit"
616
tmux: ctrl+b d
detach from tmux session
617
tmux ls
view active tmux sessions
618
tmux attach-session -t(session number)
reattach to selected tmux session
619
nohup (command)
command preceded by nohup receives signal 1 so that should a terminal window close, the process will still run as long as the login session is not terminated
620
bg (command)
sends a job to the background while it keeps running
621
fg (command)
brings a job that is in the background to the foreground
622
jobs (command)
displays a listing of jobs that are in the background
623
jobs display: [#]-
indicates the previous job or next to last job to be operated on
624
jobs display: [#]+
indicates the current job
625
priority
scheduling and priorities are what Linux uses to run multiple things on a single machine in a 'multi-tasking like' manner
626
priority range
- default is 0 - any user can start processes with priorities 0 to 19 - only root can start priorities from 0 to -20 - only root can bring a priority number lower
627
screen: ctrl+a c
open a new session
628
screen: ctrl+a p
move back to previous session
629
screen: ctrl+a n
move to next session
630
screen: ctrl+a "
display a list of available sessions
631
screen: ctrl+a x
- lock the screen | - password prompt twice to unlock
632
nice (command)
used to define a new nice level before an application is started
633
watch -n 3 date &
-generate date every 3 seconds and place in the background
634
nice -n 5 watch -n 3 date &
- generate date every 3 seconds and place in the background | - priority level 5
635
renice -n -1 (PID)
changes current priority to -1
636
renice a process within top
hit "r" key then type PID and number to change to
637
renice (command)
used to change the nice level of an application that is already running
638
top d [#]]
run and update the processes display every '#' of seconds
639
top i
show only active processes
640
top -b
run in batch mode
641
top -c [#]
run '#' of updates and exit
642
top -b -n 5 > output.txt
will run top in batch mode and update 5 times, then write results to output.txt
643
top: spacebar
immediate update
644
top: h key
displays help screen
645
top: i key
display or ignore inactive processes
646
top: R key
sort process IDs from high to low
647
grep (command)
used to find strings and phrases in files, streams and directories
648
grep -c
count of matches found only
649
grep -C [#]
encloses the string match with '#' of lines of context
650
grep -E [ext. regex]
use the indicated extended regular expression for finding a match
651
grep -F [fixed regex]
use the indicated fixed regular expression for finding a match
652
grep -H
displays the filename of each matching string or phrase
653
grep -h
prevents the filename from being displayed
654
grep -i
ignore case
655
grep -l
show only the filename, not the matched string/phrase
656
grep -L
show only filenames that do NOT contain a match
657
grep -w
match only lines containing the whole string or phrase
658
grep -x
show only exact whole line matches to the entire string or phrase
659
grep -v
show only those lines in a file that do NOT match the string or phrase
660
find / -name "*.sh" -exec grep -iH "modprobe" {} \;
find any file, recursively, starting in root and ending in .sh. grep would ignore case and display the file name matching content from files containing the word 'modprobe'
661
egrep (command)
-grep command without having to specify -E
662
egrep '(bin|bash)' /etc/passwd
would display any lines containing either 'bin' or 'bash
663
fgrep (command)
- grep command without having to specify the -F | - allows for use of a file that contains one or more items to search for
664
fgrep -f [itemfile]
use the indicated file as a list of items to search for in the file
665
fgrep -f itemfile.txt searchfile.txt
will use the items in itemfile.txt as search parameters for all lines in the searchfile.txt and display the matches
666
regex: .
match any single character
667
regex: ?
match an optional item, but only once
668
regex: *
match from '0 to n' characters in a string
669
regex: +
item MUST be matched at least once but can be matched more
670
regex: {#}
match '#' of times
671
regex: {#,}
match '#' of times, or more
672
regex: {#,#}
-match between the first and second number | {3,10} would match between 3 and 10 times
673
regex: \< and ^
words that start with what comes after
674
regex: \> and $
words that end with what comes after
675
regex: [aA]
words that contain either 'a' or 'A'
676
grep "d[iou]g textfile.txt
return words that start with 'd' and end with 'g' and have i, o, or u
677
regex: [^o]
words that do NOT contain the letter
678
grep "d[^o]g" textfile.txt
return words that start with 'd and end 'g' and have any letter except 'o'
679
sed (command)
stream editor command can operate on files using regular expressions
680
vimtutor
tutorial system for vim
681
vi/vim
- text editor available in Linux | - navigated by command mode, insert mode, ex mode (used for search/replace)
682
/etc/vimrc
global vim configuration file
683
/home/user/.vimrc
-user specific configuration for vim
684
Vim Command Mode: :number/nonumber :nu/no nu
turn line numbers on the display on/off
685
Vim: bottom of screen
-contains the full path to the file, number of lines, size of the file, current line and column and current cursor position
686
Vim: i
invokes insert mode
687
Vim: I
move to the beginning of the current line and invoke 'insert mode'
688
Vim: a
place cursor one character to the right of the current position and invoke 'insert mode'
689
Vim: A
move cursor to the end of the current line and invoke 'insert mode'
690
Vim: o
insert a new line under the current line, place the cursor in the first position on the new line in 'insert mode'
691
Vim: O
insert a new line above the current line, place the cursor in the first position of the new line in 'insert mode'
692
Vim: cw
change the word at the current position
693
Vim: cc
change the line at the current position
694
Vim: c$
change from the current position at the end of the line
695
Vim: r
replace the character at the current position
696
Vim: R
replace text on the same line until you escape the 'insert mode' or until you reach end of line
697
Vim: x
delete the character after the cursor
698
Vim: X
delete the character before the cursor
699
Vim: dw
delete the word after the cursor
700
Vim: dd
delete the entire line the cursor is on
701
Vim: D
delete the text from the current cursor to the end of the line
702
Vim: dL
delete the text from the current cursor to the end of the current screen
703
Vim: dG
delete the text from the current cursor to the end of the file
704
Vim: d^
delete all text from the beginning of line to the current cursor
705
Vim: u
undo the last operation/change
706
Vim: yy
- copy the current line to the buffer | - also called yank
707
Vim: yw
copy the current cursor to end of current word
708
Vim: p
paste the contents of the buffer after the cursor
709
Vim: P
paste the contents of the buffer before the cursor
710
Vim :e!
undo ALL changes since the last time the file was saved
711
Vim :w
write/save the file
712
Vim :q
quit the editor
713
Vim :q!
quit without saving
714
Vim :x
shortcut for save and exit
715
Vim: ZZ
shortcut for save and exit
716
Vim navigation: h
one character left
717
Vim navigation: j
one line down
718
Vim navigation: k
one line up
719
Vim navigation: l
one character right
720
Vim: ctl-u
move back one half page
721
Vim: ctl-b
move back one page
722
Vim: ctl-d
move forward one half page
723
Vim: ctl-f
move forward one page
724
Vim: ctl-G
show the name of the file, lines and position in % of the total file length
725
Vim - Searching
- must be in command mode - "/" search from cursor forward - "?" search from cursor back - "N" to move forward
726
Vim - Replacing
- must be in command mode - sed-like syntax - "s" substitute in current line - "%s" substitute in entire file - "g" will replace all occurrences
727
:s/Mar/Apr/g
will replace Mar with Apr for all occurrences in the file
728
Vim - :![cmd]
run the indicated command on the command line
729
General order of preparing hard drive for use
- Physical install or allocation for VM - partition the device - format the partition created with the chosen filesystem type - create a system mount point - mount the device/partition - add /etc/fstab if intended to be persistent
730
IDE devices
/dev/hda then partition like /dev/hda1
731
SATA/SCSI devices
/dev/sda then partition like /dev/sda1
732
fdisk (command)
- legacy command used to create partitions of the MBR (DOS) type - 2TB partition size limit - no ability to edit GUID drives
733
parted (command)
- modern command used to create partitions of MBR or GPT types - default unit is MB
734
Partition ID 83(00)
standard Linux filesystems
735
Partition ID 82(00)
Linux swap partitions
736
Partition ID 8e(00)
Linux LVM Volumes
737
gdisk (command)
- command in the style of 'fdisk' that can be used to create GPT partitions on disks - capable of creating/modifying GUID tables
738
/etc/fstab
- Filesystem table file - single line mount config for local filesystems that are to be mounted on boot - what computer uses upon boot to locate where filesystems are
739
tools used to create swap partitions
- fdisk - gdisk - parted
740
mkswap (command)
used to format partition to be used as swap space
741
swapon (command)
enables swap partition or file
742
swapoff (command)
disables swap partition or file
743
2 ways to set up swap
- swap file: impacts performance | - swap partition: less performance hit
744
Primary partition
- partition that is independent of any extended and logical partition - Numbered 1 through 4
745
Extended partition
- only one of these per drive | - like a 'container' for logical partitions
746
Logical partition
- partition within an extended partition - usually needed when there is a need for more than four partitions - Numbered 5 through n
747
Swap partition
partition that is specifically formatted an dedicated to virtual memory in support of system memory exhaustion
748
fdisk and gdisk Interactive options: p
display disk/partition summary
749
fdisk and gdisk Interactive options: n
- create a new partition - p to make primary partition - l to make logical partition - each partition defaulted as 83(00) type
750
fdisk and gdisk Interactive options: t
change partition type
751
fdisk Interactive options: w
write partition to disk
752
Partition ID 85(00)
Linux extended
753
Partition ID fd(00)
Linux RAID
754
parted -l [device]
list A LOT of information about the indicated device and partitions
755
parted interactive option: help
list commands available
756
parted interactive option: mkpart [volume name] [begin] [end]
-create partition with the indicated volume name at the beginning value and ending at the end value
757
Superblock
- portion of the disk that can be read and contain filesystem information - typically stored on disk in first sector - first backup block for 'ext' filesystems
758
Inode
- associated with every file and directory - contains info about the file except the filename - includes a list of blocks that make up the file - number of inodes cannot be changed after filesystem creation
759
ls -i /var/log/messages
will display the inode of the /var/log/messages file
760
df -i
show the inodes that are available, used and free on the mounted filesystems
761
filesystem type: ext2
Linux extended filesystem (legacy)
762
filesystem type: ext3
Linux extended filesystem with journaling
763
filesystem type: ext4
- Linux extended filesystem with journaling | - performance enhancements over ext3
764
filesystem type: ReiserFS
one of the first filesystems to introduce journaling and offer dynamic resizing capabilities
765
filesystem type: btrfs
builds on ReiserFS features while adding additional admin features while increasing performance
766
filesystem type: iso9660
filesystem specific to CD-ROM
767
filesystem type: udf
filesystem specific to DVD
768
filesystem type: vfat
older DOS partition type
769
Formatting a drive
process of preparing the size and structures on a partition and applying the filesystem type indicated
770
mkfs (command)
-creates a new file system on a partition
771
mkfs -t [fstype] [device/partition]
creates the indicated filesystem type on the chosen disk partition
772
mkfs -b [#]
- creates the filesystem with the indicated block size | - default - 4096
773
mkfs -m {#]
percentage of space reserved for 'root' user
774
mkfs -L [label]
set the partition volume label
775
mkfs -O
additional options
776
mkfs -t ext4 -b 8192 -m 10 -L LargeData -O sparse_super /dev/sde4
create an 'ext4' partition, with a block size of '8192', reserving 10% for root use and using the 'sparse_super' option
777
mkfs. [fstype]
equivalent command for each filesystem type to format the indicated partition
778
mkfs.ext3 /dev/sda3
will create the ext3 filesystem on the /dev/sda3 partition
779
mke2fs
equivalent command for making an ext2/3/4 filesystem
780
mkraid
creates a RAID array set from the indicated disks
781
mknod
create 'special' files
782
mkisofs
create ISO filesystem for burning CD-ROM
783
File Allocation Table
- Linux can use Virtual File Allocation Table which allows for long file names - EFI boot partitions need to use a FAT partition
784
exFAT - Extended File System
- allows for files larger than 2GB in size | - primarily used for external disk drives, thumb drives
785
ls -la /dev/(disk)/by-uuid/
displays the partition's universally unique identifier (UUID)
786
df (command)
disk free command that shows the available disk space on a file system
787
df -h
human readable format of disk free space
788
du (command)
command that displays the amount of disk space in use
789
du -a
write counts for all files and not just directories
790
du -c
produce a grand total
791
du -h
print sizes in a readable format (K/M/G/TB)
792
du -s
display only a summary for any argument
793
du -sh /home/user/.bash*
provides a human readable summary of each file matching .bash* within the /home/user directory
794
df -a
include all filesystems including 'dummy' filesystems
795
df --direct
show stats for a file instead of a mount
796
df --total
print a grand total
797
df -l
include only local file systems
798
df -t
limit listing to the indicated type
799
df -lh --total
shows a human readable listing of all local filesystems including a total line at the bottom
800
debugfs
- filesystem debugger | - can show a vast amount of information about the indicated partition
801
debugfs /dev/sdb1
will show a lot of information about any selected file or folder on the indicated drive
802
debugs: ?
show available commands
803
debugs: cd [path]
change to the indicated path
804
debugs: features
display the filesystem features
805
debugs: logdump
display journal contents
806
debugs: ls
shows contents of current directory
807
debugs: pwd
shows working directory
808
debugs: open
open a filesystem for debugging
809
debugs: stats
show stats for the filesystem
810
debugs: undelete
- undeletes a file | - MUST be used immediately after deleting a file
811
debugs: quit
exit
812
fsck (command)
- file system check - invoked in command line - configured in /etc/fstab - devices must be unmounted before running check
813
e2fsck (command)
- file system check utility for ext2, ext3, and ext4 file systems - can be used to replay the file system's journal
814
e2fsck -f
force a check to rerun even if report comes back clean
815
e2fsck -p
automatically repair anything it finds without prompting
816
reiserfsck (command)
check 'ReiserFS' filesystem types
817
dosfsck (command)
check DOS filesystem types
818
fsck -A
fsck will iterate through the /etc/fstab file and check all filesystems
819
fsck -C
display hash/mark progress bar
820
fsck -N
dry run, makes no changes but displays what would have been done
821
fsck -V
verbose output
822
fsck -a
-does not prompt for confirmation
823
fsck order of events
- check inodes, blocks, sizes - check directory structure - check directory connectivity - check file/directory reference counts - check group summary info
824
tune2fs (command)
-utility used to adjust parameters on an ext2, ext3, and ext4 file system
825
tune2fs -c [#]
set the maximum number of times a filesystem can be mounted for an fsck to happen automatically
826
tune2fs -e [option]
modifies the behavior of the filesystem with the indicated option
827
tune2fs -g [groupname]
add the indicated group as potential users of the reserved space on a filesystem
828
xfsprogs
tools and utilities for XFS filesystems
829
xfs_check
XFS filesystem equivalent to fsck for checking filesystem
830
xfs_repair
XFS filesystem equivalent to fsck for repairing filesystem
831
xfs_metadump
creates debugging information that can be used by a third party to aid in recover of an XFS filesystem when the repair has failed
832
xfs_growfs
used to grow an XFS filesystem
833
xfs_fsr
- reorganizes data stored in blocks in an XFS file system. | - similar to running a defrag utility on a Windows file system
834
xfs_db
utility used to debug an XFS file system
835
/media
'parent' directory that is often used for 'removable' filesystems (CDs/DVDs)
836
/mnt
'parent' directory that is often used for mounting disk/partitions that are NOT part of the filesystem install
837
blkid (command)
- used to obtain the UUID for the local disk partitions | - will also display disk labels
838
mount -a
mount all filesystems in /etc/fstab
839
mount -f
fake mount all filesystems in /etc/fstab
840
mount -r
mount the indicated filesystem in read only mode
841
mount -o [option]
specify one or more options that are outside the defaults
842
mount -w
mounts in writeable mode
843
unmount (command)
- unmounts the indicated filesystem | - filesystem can only be unmounted if not in use
844
unmount /mnt/data
unmounts the /mnt/data directory from whatever device was mounted there
845
unmount -f
-attempt to forcibly unmount the filesystem even if in use
846
fuser (command)
if unmount indicates a filesystem is in use, this will tell which user is using it
847
fuser -m [mount]
determine who is using the indicated mount
848
Contents of /etc/fstab columns
- device - mount point - filesystem - options - dump - fsck
849
Octal Permission: 4
Read
850
Octal Permission: 2
Write
851
Octal Permission: 1
Execute
852
Octal Permission: 0
No permission
853
UUID
User ID for each user
854
GID
Group ID for each user group
855
symbolic permissions
permissions outlined as rwx
856
numeric permissions
permissions outlined numerically
857
Character before permissions: --
normal file
858
Character before permissions: l
symlink
859
Character before permissions: b
block device, hard drive, disk drive
860
Character before permissions: c
character device- monitor, keyboards, mice
861
Character before permissions: d
directory
862
chmod
used to change permissions for files and directories
863
ex: chmod 755 myscript.sh
set the permissions as 'user read/write/execute', 'group read/execute' and 'other read/execute'
864
ex: chmod g=rx myscript.sh | or g+r-w+x
set permissions as group read/execute
865
chmod -r
allows you to apply permissions to an entire directory structure
866
ex: chmod 744 -R /home/user/data/*
Sets permissions for the all the files and directories within /home/user/data but does NOT change the permissions of the /home/user/data directory itself
867
chmod -c
report which files were changed
868
chmod -v
show all files
869
chmod -h
change only symbolic links, not the original
870
chmod -f
ignore/don't display error messages
871
chown
- change ownership of a file or directory | - . and : are symbolically equivalent
872
chgrp
change the group ownership of a file or folder
873
SUID
- Set User ID - permits a user to access/run a program as if they were the OWNER - 4 value - u+s symbolic notation - files with an 's' in the place of 'x' within user column
874
Sticky Bit
- permission has a 't' in place of an 'x' in the other's column - only allows the creator of a file to remove the file - g+s symbolic notation
875
SGID
- Set group id bit - files and folder's with the s in place of the 'x' within the group column have this set - assigns group ownership to files - a+t symbolic notation
876
umask (command)
- shows the current umask settings and default value for the user - can be used to set a new umask value for the current shell session
877
umask value
subtract the umask value from the default permission to get the current permission value
878
Default (no umask) permissions: files
rw-rw-rw (666)
879
Default (no umask) permissions: directories
rwxrwxrwx(777)
880
dpkg-reconfigure tzdata
command used to reconfigure time zone data on an Ubuntu system
881
symbolic link
- shortcut from one file to another - small file containing its own inode and path to the original file - permissions cannot be modified
882
ln (command)
used to create hard or symbolic link
883
ln -s
creates symbolic link
884
ex: ln -s myscript.sh yourscript.sh
creates a symbolic lnk called yourscript.sh pointing to myscript.sh
885
ex: ln myscript.sh yourscript.sh
Creates a hard link (default) called 'yourscript.sh' point to the data in the inode pointed to by 'myscript.sh'
886
ls -i [filename]
can be used to find all inodes/links for a file
887
Filesystem Hierarchy Standard (FHS)
- Defines the directory structure and contents in Unix-like operating systems - data integrity is preserved - standard is maintained by the Linux foundation
888
Linux Directory structure
-all files and directories appear under 'root' directory
889
/bin
- contains executable programs that the user can run | - LS, CD, PWD commands reside here
890
/etc
host-specific configuration files, no binaries
891
/etc/opt
config files for packages stored in /opt
892
/etc/sgml
config files for software that processes SGML
893
/etc/X11
config files for X Windows
894
/etc/XML
config files for software that processes XML
895
/run
run-time variable data, information about the running system since last boot
896
/sbin
essential system binaries
897
/srv
reserved for server applications
898
/tmp
- temp files | - not preserved between reboots
899
/usr
contains its own set of the directory tree that closely mirrors root
900
/usr/bin
non-essential command binary for all users
901
/usr/include
standard include files
902
/usr/local
tertiary hierarchy for local data, specific to host
903
/usr/sbin
non-essential system binaries
904
/usr/share
architecture independent shared data
905
/usr/src
source code
906
/usr/X11R6
older X Windows configuration
907
/var/lib
state information
908
/var/lock
lock files that keep track of resources in use
909
/var/log
log files
910
/var/mail
mailbox files
911
/var/opt
variable data from add-on packages stored in /opt
912
/var/run
run-time variable data
913
/var/spool
spool for tasks waiting to be processed
914
/var/tmp
Temporary files to be preserved between restarts
915
SIGHUP signal
1
916
/etc/default/grub
where you can make manual changes to GRUB2
917
du -sh
human readable summary of space being used in current directory
918
du -h --max-depth=[#] [directory]
-provides a summary of usage by the specified number of files/folders within the directory
919
du --inode
list inode usage information instead of block usage
920
top: 'u' key
pulls up processes for a user after typing in the user name
921
Commands that will show you full path to an application
- type -P | - which
922
/dev/sdd3
third partition on the fourth SATA disk
923
less: to scroll down
- Down arrow - Page Dn key - 'j' key
924
less: to scroll up
- Up arrow - Page Up - 'k' key
925
less: to search
type in desired text
926
/var/log/secure
- will create a new entry when someone logs into the system | - only readable by root
927
Parse a file containing regular expressions
grep -E -f [filename] | egrep -f [filename]
928
pgrep -a
list the full command line as well as the process ID
929
tmux (command)
- modern terminal window manager like 'screen' with extra features - process will stay running after logging out
930
apt autoremove
-used to remove packages that were auto installed for packages no longer needed
931
locate (command)
- searches local database of files and folders looking for items that match - database needs to be updated to keep track of changes
932
updatedb (command)
updates the database that the locate command uses
933
whereis (command)
command locates binary, source, and/or manual pages for a command
934
locate -i
ignore case on the file being searched for
935
/etc/updatedb.conf
- configuration file for the updatedb command | - contains full or partial filenames to ignore or 'prune' from database updates
936
which -a [command]
display all matches in the PATH, in the order they would run/appear
937
whereis -b
searches for binaries
938
whereis -m
searches for manual entries/man pages
939
whereis -s
locates the source of a specified command name
940
whereis -u
unusual or undocumented entries
941
type -a
lists all variants of the indicated command
942
find -perm -[####]
find matching files by indicated permission
943
uniqu -c
will list the amount of times a line appears consecutively in a file
944
uniq --group
show all items, separating groups with an empty line
945
sort -u
will remove any duplicate lines in a file
946
`example: | cat list.csv | tr ',' ':'
-Print out the file with colons replacing commas
947
example: | cat list.csv | tr -d ','
Print out the file without showing the commas
948
/etc/mke2fs.conf
configuration file used by mke2fs command when creating ext file systems
949
xfs_db: frag
will check on the filesystem's fragmentation
950
xfs_db: freesp
will show how much free space is on the particular device
951
find . -atime -2
-pulls list of files accessed in the last 48 hours
952
touch -m [filename]
change modification time
953
locate -A [option1] [option2]
used to locate patterns that match all options
954
locate -c
count the number of files that match the given pattern
955
dpkg --get-selections
to list out every package installed on a Debian system
956
dpkg-query -S [pathname]
to find out which package owns a specific file
957
apt-file
utility used for searching for searching for files inside packages
958
fdisk -l /dev/sda
command used to locate the boot partition
959
ssh-keygen
used to generate a public and private SSH key pair when accessing remote, cloud-based systems
960
ssh-copy-id
used to copy a system's public SSH key to a remote system to facilitate remote authentication
961
ldconfig -v
display the library version numbers, name of each directory and the links that are created
962
ldd -u (--unused)
prints the unused dependencies if they exist
963
Location of menu entries for GRUB
GRUB: /boot/grub/grub.cfg | GRUB Legacy: /boot/grub/menu.lst
964
locate -e
print only entries that pull existing files at the time the command is run
965
/var/lib/dbus/machine-id
- location of dbus id | - symbolically linked to /etc/machine-id
966
unset -f (name of function)
used to remove a function
967
shopt -u (option)
to disable an option
968
Non-Special Characters in Basic Regular Expressions
- ? - + - { } - | - () - Must be escaped with \
969
Reach runlevel 1 (SysV)
telinit 1, s, or S
970
- kill -l | - man 7 signal
method of pulling up kill signals
971
Most common kill signals
- 1 Sighup - 9 Sigkill - 15 Sigterm