• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/505

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

505 Cards in this Set

  • Front
  • Back
What does the 'netstat -in' command do?
It shows the state of all configured network interfaces, using numeric values for users, hosts and ports
What command shows the state of all configured network interfaces, using numeric values for hosts?
netstat -i --numeric-hosts
OR
netstat -in
What does the "netstat -a" command do?
The default operation of netstat is to show sockets. The -a argument tells netstat to show "all". It's not very much different to running netstat alone.
What command shows the state of all network sockets?
netstat -a
What command shows statistics for a the TCP protocol?
netstat -st
What does the 'netstat -s' command do?
It shows summary statistics for each network protocol.
What command shows statistics for each network protocol?
netstat -s
What is 'PMTU'?
Path Maximum Transmission Unit.

Explanation: When a host transmits packets across multiple networks to another host the packets will become fragmented if their size is greater than the smallest MTU of any network in the path. Packet fragmentation can result in reduced network performance.

Summary: Path Maximum Transmission Unit is the smallest MTU along an entire network path.
What is SmokePing?
A tool used to monitor network latency using RRDTool to store and display graphs.
What tool is used to monitor network latency using RRDTool to store and display graphs?
SmokePing
What is the file /etc/sysctl.conf used for?
It is a configuration file for setting kernel parameters at runtime (eg: TCP buffer size, swappiness, security).

You can force the kernel to re-read the file using the command:

sysctl -p

You can show all current values using this command:

sysctl -a
What configuration file is used to set kernel parameters (like TCP buffer size, swappiness etc)?
/etc/sysctl.conf
What does the 'sysctl -p' command do?
It loads settings from /etc/sysctl.conf and modifies kernel parameters at runtime. The sysctl command can read or write system configuration.
What command loads settings from /etc/sysctl.conf and modifies kernel parameters at runtime?
sysctl -p
What is the purpose of the pseudo filesystem /proc ?
/proc is the kernel's status repository. It contains pseudo files that show information about the running system.
What does the pseudo file /proc/interrupts contain?
It contains information about IRQ assignments on a running system.
Which pseudo file contains details of the IRQ assignments on a running system?
/proc/interrupts
What does the pseudo file /proc/ioports contain?
It contains information about IO ports on a running system.
What pseudo file contains details of available IO ports on a running system?
/proc/ioports
What does the pseudo file /proc/dma contain?
It contains information about DMA (Direct Memory Access) devices.
What is the pseudo file that contains DMA (Direct Memory Access) device information.
/proc/dma
Briefly describe Cylinder Head Sector (CHS) disk geometry.
IDE disks are formated into 512byte sectors, arranged in concentric circles (each called a cylinder) which is written to by a head. This disk geometry allows for up to 65526 cylinders, 16 heads and 255 sectors / track. Maximum capacity is 137GB
What is LBA (Logical Block Address)?
To overcome the limits of CHS disk geometry, ATA-2 standards implemented the LBA addressing system for disk drives.
What does the 'hdparm -l' command do?
It show hard disk parameters.
What command shows hard disk parameters for /dev/sda?
hdparm -l /dev/sda
What does the following command do?
dmesg | grep -i irq
It shows all interrupts found during boot
What command shows all interrupts found by the kernel during the boot process?
dmesg | grep -i irq
What does the following command do?
dmesg | grep -i dma
It shows DMA capable devices found by the kernel on boot.
What command shows DMA capable devices found during the boot process?
dmesg | grep -i dma
What does the following command do?
dmesg | grep "[hs]d[a-z]"
It shows all hard disks found by the kernel during boot.
What command shows all hard disks found during the boot process?
dmesg | grep "[hs]d[a-z]"
What does the 'lspci' command do?
It lists all PCI devices.
What command lists all PCI devices?
lspci
What is the file /etc/modprobe.conf used for?
It stores the configuration of kernel modules on 2.6+ kernels
Which file stores the configuration of kernel modules on 2.6+ kernels?
/etc/modprobe.conf

Modern systems use a directory called /etc/modprobe.d which contains separate files different device classes.
What does the 'lsmod' command do?
It shows the status of modules in the Kernel.
What command shows the status of modules in the Kernel?
lsmod
What is sndconfig?
Sndconfig is a command written by RedHat for configuring sound devices. It uses isapnp. It does not detect resource conflicts.
What command can be used to configure sound devices?
sndconfig
What /dev file represents the first CD or DVD device?
/dev/scd0 or /dev/sr0
What /dev file represents the first hard disk device?
/dev/sda
What /dev file represents the first tape device?
/dev/st0
What does the 'scsi_info' command do?
Shows the details of the 'real' device that corresponse to /dev/sda.
What command shows the details of the 'real' device that corresponse to /dev/sda?
scsi_info /dev/sda
What are 'SCSI Generic drivers'?
SCSI Generic drivers are generally used to handle devices that aren't covered by sd and st drivers (enclosuires, cd writers, scanners). When sg drivers are used, additional information is available in /proc/scsi/sg. There will also be devices such as /dev/sg0, /dev/sg1 etc, which correspond to other devices such as /dev/sr0
What does the 'sg_map' command do?
It shows the mappings between 'sg' name and device name for SCSI devices.
What command provides a map between 'sg' name and the device name for SCSI devices?
sg_map
What does the 'sginfo' command do?
This command interrogates devices directly using the "SCSI Generic" driver. Because this command talks to the devices, it must be run as root.
What command interrogates devices using the "SCSI Generic" driver?
sginfo

Note: The sginfo command talks to devices directly, so it must be run as root. The scsi_info command doesn't interrogate devices, but reads /proc files to obtain details; it can be executed without root privileges.
How many devices can a USB hub support? What is the total number of devices on a root hub?
A USB hub can support 7 devices [some of which may be hubs]

A root hub supports up to 127 devices in total.
What is the purpose of the 'USB Bus Interface layer'?
The USB Bus Interface layer provides physical, signaling, and packet connectivity between hosts and devices, providing data transfer between the host and devices.
Which USB layer provides physical, signaling and packet connectivity between hosts and devices?
The USB Bus Interface Layer
What is the purpose of the 'USB Device layer'?
The USB Device layer is used by the system software to do generic USB operations with a device over the bus. This allows the host to determine characteristics of the device, including device class, vendor name, device name, power requirements, and many capabilities such as device speed or USB level supported.
Which USB layer is used by the system to do generic operations with devices over the bus (including querying its characteristics and requirements)?
The USB Device Layer
What is the purpose of the 'USB Function layer'?
This USB layer provides additional capabilities that are specific to the device. Matched host and device software layers permit use device-specific functions.
Which USB layer provides additional capabilities that are specific to devices?
The USB Function layer.
What speed do USB 1.0 and 1.1 operate at?
12Mbps
What speed does USB 2.0 operate at?
480Mbps
What does the following command do?
lspci | grep -i usb
It lists all USB controllers on the system, telling you what USB version is supported on each.
What command shows USB controllers?
lspci | grep -i usb

Note: This will tell you if the system supports USB 2 / 3. Devices connected to the USB controllers will not appear. For that you need lsusb.
What does the pseudo file /proc/bus/usb/devices contain?
It contains information about USB root hubs attached to the system.
Which pseudo file shows information about USB devices attached to the system
/proc/bus/usb/devices
What does the 'lsusb -t' command do?
It shows shows a tree view of USB devices.
What command shows a tree view of USB devices
lsusb -t
What does the 'lsusb -v' command do?
It shows verbose information about usb devices.
What command shows verbose information about usb devices?
lsusb -v
What does the 'usbmgr' command do?
It is used to handle hot plugging of USB devices by loading/unloading USB kernel modules when devices connect into or disconnect from a USB hub.
What does the 'hotplug' command do?
It is used to handle hot plugging of USB devices
What commands handle hot plugging of USB devices?
hotplug or usbmgr
What is the IDE drive partition limit?
63 partitions.
What is the SCSI drive partition limit?
15 partitions
What does the pseudo file /proc/ide/sda/geometry contain?
It shows the capacity of the first IDE disk in terms of Cylinders/Heads/Sectors.

The file /proc/ide/sda/capacity shows the capacity in LBA format.
Which pseudo file shows the nomimal geometry of the first SCSI disk?
/proc/ide/sda/geometry
Where is the partition table located?
The MBR (master boot record) holds the partition table and bootstrap code. It's the first 512kb of the active disk.
Where is the MBR located?
On the first sector of the disk
What are the 3 partition types?
1. Primary - only 4 can exist
2. Extended - only 1 can exist. It is a container for logical partitions
3. Logical
Run through the boot process of a Linux system...
1. The BIOS boot code is executed, performing POST and loading the MBR.
2. The MBR boot code find the active partition and loads the first sector (partition boot record)
3. The 'Stage 2 boot loader' proceeds directly to load the kernel.
4. The Linux kernel continues to start the system, referring to /etc/inittab
What is LILO? What configuration file does it use?
LInux LOader is a smart bootloader, once the default on many distros, but has been dropped from many in favour of GRUB.

It uses /sbin/lilo to write a stage 1 boot record and create a /boot/map file using the configuration information from /etc/lilo.conf

Any time the config file changes, lilo must be executed again, unlike GRUB which reads the config file during each boot.
What does the 'lilo -u' command do?
It uninstalls lilo and restores previous boot record
What does the 'lilo -R' command do?
It sets lilo to automatically boot the specified system on the next reboot only.
Briefly describe GRUB, where it keeps its configuration, and where it can be installed.
GRand Unified Bootloader is the most common Smart Bootloader. It is installed into the MBR or into a partition boot record. It can be installed on CDs, USB keys or floppy disks.
How do you install GRUB to a floppy disk?
1. Unmount the floppy disk
2. grub-install /dev/fd0

[Note: Unmounting partitions on an IDE or SCSI disk is not necessary as they do not mount the MBR!]
What does the following command do?
tar -jxf file.tar.bz2
Untars a tar file compressed with bzip2.
What command untars a file compressed with bzip2?
tar -jxf file.tgz
What does the following command do?
'tar -zxf file.tgz' do
Untars a tar file that was compressed with gzip.
What command untars a file that has been compressed with gzip?
tar -zxf file.tgz
What command is equivalent to 'zcat'?
gunzip -c
Which command is equivalent to 'gunzip -c'?
zcat

Either command will gunzip a file to stdout.
What do the 'unzip' command do?
It decompresses .zip (PKZIP) files.
What command decompresses .zip (PKZIP) files?
unzip
What does the following command do?
./configure --prefix /opt/new
The configure script it is used to configure source code before compiling. The --prefix option specifies an installation path. [Default path is /usr/local on most distros.]
When compiling source code, what is the function of the config.cache file?
Before compiling the source code, you must run the configure script to specify compile options. The config.cache file stores the configuration for 'make' to use.
After running ./configure in a source code directory which file stores the saved configuration?
config.cache
What are statically linked executables?
These executables contain all the library functions that they need to execute. This makes them larger, but they have no dependencies.
What type of executables contain all the library functions that they need to execute?
Statically linked executables.
What are Dynamically linked executables?
They are small, incomplete programs which require functions from external shared libraries. This enables many programs to share common libraries, saving on disk space and memory.
What type of executables are small incomplete programs which require functions from external shared libraries?
Dynamically linked executables.
What is the binary '/sbin/sln'?
It is a statically linked version of the ln command. It is used when 'ln' fails due to dependency problems.
What does the 'ldd' command do?
It shows all shared libraries required by a program.

Important: ldd is actually a bash script that checks the binary's .interp ELF section to discover which loader it uses, and then runs one of these commands:

LD_TRACE_LOADED_OBJECTS=1 /bin/grep
LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux.so.2 /bin/grep

If a program is not handled by the default loader "ld-linux.so", and doesn't handle the LD_TRACE_LOADED_OBJECTS environment, ldd tries to discover which loader it uses. Unfortunately, it's easy to create a loader that instead executes the program.

If you are unfamiliar with the binary you are running ldd on, be very careful!
What command shows all the shared libraries required by gedit?
ldd /usr/bin/gedit

OR

ldd `which gedit`
Where is Dynamic Library configuration stored?
The dynamic loader uses two configuration files to find executables:

/etc/ld.so.conf
/etc/ld.so.cache

If you change anything in ld.so.conf, you must run ldconfig to regenerate /etc/ld.so.cache
How would you override the default dynamic library configuration for a particular program?
export LD_LIBRARY_PATH=/opt/extra/stuff:/opt/new/stuff
Why would you set the variable LD_LIBRARY_PATH?
To override the default dynamic library configuration before launching a program.
What does the following command do?
apt-get -s install program
It simulates the installation of a program on a Debian system.
What command simulates the installation of a program on a Debian system?
apt-get -s install program

OR

dpkg -i --simulate package.deb
What is the file /etc/apt/sources.list used for?
It stores the APT repository configuration.
Which file stores the APT repository configuration?
/etc/apt/sources.list
What does the 'apt-setup' command do?
It manages APT repositories.

[Note: This is obsolete on Ubuntu, and perhaps on Debian too! However, it may be on the exam still.]
What do the following grep arguments do?

grep -Hr "whatever" /*

grep -hr "whatever" /*
-H prints the file name
-h suppresses printing of the file name.

The default behaviour depends on the input that grep was searching. For example, if you tell grep to search a number of files, it will automatically print the filename beside each line matched.
What does the 'apt-cdrom add' command do?
It adds a CDROM to your APT repository list.
What command adds a CDROM to your APT repository list?
apt-cdrom add
What does the 'apt-get update' command do?
It retrieves a list of all available packages from each repository configured on a Debian system
What command retrieves a list of all available packages on a Debian system?
apt-get update
What does the 'apt-get remove' command do?
It removes a package from a Debian system.
What command removes a package on a Debian system?
apt-get remove program

or

dpkg -r package.deb
What does the 'apt-config' command do?
It's used to display APT configuration (Stored in /etc/apt/apt.conf or /etc/apt/apt.conf.d/) and to make config changes.
What command can be used to display APT configuration (Stored in /etc/apt/apt.conf or /etc/apt/apt.conf.d/) or to make config changes?
apt-config
What does the 'dpkg --info' command do?
It examines a Debian .deb package file.
What command examines a Debian .deb package file?
dpkg --info
What does the 'dpkg --contents' command do?
It displays the contents of a Debian .deb package file.
What command displays the contents of a Debian .deb package file?
dpkg --contents package.deb
What does the 'dpkg -s' command do?
It displays the status of a Debian .deb package.
What command displays the status of a Debian .deb package?
dpkg -s package.deb
What does the 'dpkg -L' command do?
It displays all files that were installed by a Debian .deb package.
What command displays all files installed by a Debian .deb package?
dpkg -L package.deb
What does the 'dpkg -S' command do?
It finds out which Debian package installed a particular file.
What command finds out which Debian package owns a file?
dpkg -S /usr/bin/program

[Hint: Search packages for owner]
What do the following commands do?
dpkg --get-selections
dpkg --set-selections
They are used to get or set package selections on a Debian system.
What does the 'dpkg-reconfigure' command do?
It reconfigures a package which has already been installed onto a Debian system.
What command reconfigures a package which has already been installed onto a Debian system?
dpkg-reconfigure program
What does the 'dselect' command do?
It is an ncurses-based program used to manage packages on Debian based systems.
What ncurses-based program is used to manage packages on Debian based systems?
dselect
What does the following command do?
apt-get dselect-upgrade
It applies package selections set through dselect.
What command applies package selections set through dselect?
apt-get dselect-upgrade
What does the 'apt-cache search' command do?
It searches the Debian repositories for a program
What command searches the Debian repositories for a program?
apt-cache search
What does the 'rpm -ivh' command do?
It installs an RPM package, giving verbose output and showing a progress bar made out of '#' characters.
What command installs an RPM package?
rpm -i package.rpm

Typically, this will be issued with 'v' for verbose output and 'h' to show installation progress with a 'hash' progress bar.
What does the 'rpm -Uvh' command do?
It upgrades an RPM package, displaying verbose output and uninstallation progress using 'hashes'
What command upgrades an RPM package?
rpm -Uvh package.rpm
What does the 'rpm -e' command do?
It uninstalls an RPM package.
What command is used to uninstall RPM package?
rpm -e program
What does the 'rpm -i --force' command do?
It forcibly installs an RPM package ignoring dependency problems or other controls.
What command forcibly installs an RPM package, even if it has already been installed?
rpm -i --force

Note that this will still fail to install if dependencies are not met!!
What does the 'rpm -e --nodeps' command do?
It forcibly removes an RPM package, ignoring dependency problems.
What command forcibly removes an RPM package, ignoring dependency problems?
rpm -e --nodeps
What does the 'rpm -qi' command do?
It queries the RPM database for a program and display information about it.
What command queries the RPM database for a program and display information about it?
rpm -qi program
What does the 'rpm -qa' command do?
It queries the RPM database and lists all installed packages.
What command queries the RPM database and list all installed packages?
rpm -qa
What does the 'rpm -ql' command do?
It list the files installed by a particular RPM package.
What command queries display files installed by a particular RPM package?
rpm -ql program
What does the 'rpm -qlc' command do?
It lists configurations files installed by an RPM package.
What command displays configuration files installed by an RPM package?
rpm -qlc package.rpm
What does the 'rpm -qpi' command do?
It Queries a Package file and shows Information about it.
What command displays information about an RPM package?
rpm -qpi
What does the 'rpm -qf' command do?
It tells you which RPM package owns a file.
What command finds out which RPM package owns a file?
rpm -qf /usr/bin/program
What does the following command do:

rpm -qR program
It lists the dependencies required by the installed "program". To list the dependencies of a package, use 'rpm -qpR package.rpm'.
What command finds out which dependencies are required by an RPM package?
rpm -qR package.rpm
What does the 'rpm --checksig' command do?
It verifies the integrity of an RPM file.
What command verifies the integrity of an RPM file?
rpm --checksig package.rpm
What does the 'rpm -V' command do?
It verifies an installed RPM. (Do not reference the package file, but the application name)
What command verifies a program after it has been installed via RPM package?
rpm -V program

(You don't run the command against the RPM file)
What does the 'rpm --showrc' command do?
It displays the RPM configuration file (rpmrc).
What command displays the RPM configuration file (rpmrc)?
rpm --showrc
What is the IO address and IRQ of COM 1 (ttyS0)
3f8, IRQ 4
What is the IO address and IRQ of COM 2 (ttyS1)
2f8, IRQ 3
What is the IO address and IRQ of COM 3 (ttyS2)
3e8, IRQ 4
What is the IO address and IRQ of COM 4 (ttyS3)
2e8, IRQ 3
What is the IO address and IRQ of LP0 (LPT1)?
378-37f, IRQ 7
What is the IO address and IRQ of LP1 (LPT2)?
278-27f, IRQ 5
To set up a connection to your ISP via your modem, what settings should you configure?
Configure the dialer, PPP settings and ppd daemon.
Which modem speed may be too high if your computer doesn't have a 16550 UART?
11520. You should use 56700 instead.
What does 'isapnp' require in order to detect your sound card?
OSS sound modules for your kernel
What does the 'sndconfig' utility use to detect sound cards?
isapnp
What are the bus width and throughput of SCSI-1?
8bit
5MB/s
What are the bus width and throughput of 'Wide SCSI'?
16bit
10MB/s

[Same clock speed as SCSI 1 and 2, but the wider bus enables faster bitrates]
What are the bus width and throughput of Fast SCSI
8bit
10MB/s

[SCSI-2, or Fast SCSI, has 2x clock speed of SCSI-1]
What are the bus width and throughput of Fast Wide SCSI
16bit
20MB/s

[SCSI-2, or Fast SCSI, has 2x clock speed of SCSI-1. The wider bus doubles the throughput again.]
What are the bus width and throughput of 'Ultra SCSI'?
8bit
20MB/s

[SCSI-3, or Ultra SCSI, has 4x clock speed of SCSI-2]
What are the bus width and throughput of 'Ultra Wide SCSI' (aka SCSI 3)?
16bit
40MB/s

[SCSI-3, or Ultra SCSI, has 4x clock speed of SCSI-1. The wider bus doubles the throughput again.]
What are the bus width and throughput of 'Ultra2 SCSI'?
8bit
40MB/s

[SCSI-3 SPI2, or Ultra2 SCSI, has 8x clock speed of SCSI-1.]
What are the bus width and throughput of 'Wide Ultra2'?
16bit
80MB/s

[SCSI-3 SPI2, or Ultra2 SCSI, has 8x clock speed of SCSI-1. The wider bus doubles the throughput again.]
Describe the kernel USB drivers
Host controller: usb-ohci.o, and usb-uhci.o, uhci.o and ehci-hcd.o

Class: hid.o, usb-storage.0, acm.o, printer.o and audio.o

Other: rio500.0, pwc.o and misc vendor-specific drivers.
Why might you wish to put /usr on a separate partition?
This allows you to share it read-only via NFS, so that other systems can use it. This was popular back when storage spaces was limited.
Which command is equivalent to 'gzip -d'?
gunzip
Which command is equivalent to 'gunzip'?
gzip -d
What is the variable '$PS1' used for?
It contains the BASH prompt.
What is the BASH prompt variable?
$PS1
When setting the prompt variable in BASH, what represents the current user?
\u
When setting the prompt variable in BASH, what represents the hostname?
\h

Here's the lot...
* \a : an ASCII bell character (07)
* \d : the date in "Weekday Month Date" format (e.g., "Tue May 26")
* \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
* \e : an ASCII escape character (033)
* \h : the hostname up to the first '.'
* \H : the hostname
* \j : the number of jobs currently managed by the shell
* \l : the basename of the shell’s terminal device name
* \n : newline
* \r : carriage return
* \s : the name of the shell, the basename of $0 (the portion following the final slash)
* \t : the current time in 24-hour HH:MM:SS format
* \T : the current time in 12-hour HH:MM:SS format
* \@ : the current time in 12-hour am/pm format
* \A : the current time in 24-hour HH:MM format
* \u : the username of the current user
* \v : the version of bash (e.g., 2.00)
* \V : the rel
When setting the prompt variable in BASH, what represents the basename of the current working directory?
\W
How would you display the 2nd column of a CSV file using the 'cut' command?
cut -d, -f2 file.csv
What does the 'expand' command do?
expand -i /var/log/file
It converts the initial tabs on each line into into spaces.
What does the 'join' command do?
The join command is like a database join. If two text files contain one identical columns (eg, column 1 in both files is a sequence of numbers), then both files can be joined at this field with the following command:

join -j 1 file1.txt file2.txt
What does the 'nl' command do?
This command numbers each line in a file
What command numbers each line in a file?
nl

NOTE: You can also use awk:

awk '{ print NR" "$0 }'
What does the 'od' command do?
"'Octal dump' is mostly used to examine the byte code of binary files
What command can be used to examine the byte code of a binary file or input stream?
od (Octal Dump)
What does the 'paste' command do?
This command takes files as arguments, and pastes corresponding lines from each file in columns, specifying a delimeter.

For example, if file1.txt contains ascending numbers and file2.txt contains ascending letters, the output of 'paste -d, file1.txt file2.txt' would be:

1,A
2,B
3,C
4,D

...etc
What does the 'sort' command do?
It sorts a file or stdin.

sort -n - numerical sort -f - ignore case
sort -r - reverse sort order
sort -k 5,10 - sort lines 5 to 10

[Note that the -t argument may be necessary to tell 'sort' what delimiter to use between fields]
split -2 /var/log/file splitfiles_
It splits the file /var/log/file every 2 lines and outputs to multiple files beginning 'splitfiles_'
What command splits a file every 2 lines into multiple files beginning 'splitfiles_'
split -2 /var/log/file splitfile_
Which command should you use to translate characters in a file from lower case to upper case?
There are two ways:

cat file | tr a-z A-Z
cat file | tr '[:lower:]' '[:upper:]'
The file /tmp/file contains the following:
1 2 3 4
56 7 8 9 10

How would you use the 'tr' command to remove all repeated spaces in the file?
cat file | tr -s '[:blank:]'
What does this command do:
cat file | tr -s '[:blank:]'
It reads a file and ignores all duplicate blank lines.

[-s is --squeeze-repeats]
What does the 'unexpand' command do?
Unexpand replaces spaces with tabs (seems to be the opposite of what it should do!)
What command replaces spaces with tabs (which are 8 spaces by default)?
unexpand
What does the 'uniq -u' command do?
Shows unique lines in a file or standard input
What command shows unique lines in a file or standard input?
uniq -u

NOTE: The default action of uniq is to remove duplicates.
What does the 'uniq -d' command do?
Shows non-unique lines in a file or standard input
What command shows non-unique lines in a file or standard input?
uniq -d
What does the 'wc' command do?
It counts the words in a file.
What command counts the words in a file
wc file
What would the following command do?
find / -type f | xargs -n 1 grep -H linux
First, it finds all files in the root directory.

These file names are piped to xargs, which takes a maximum of one argument per line to pass to grep.

grep -H searches each file for the word 'linux', which uses "-H" to display the name of each file it finds it in.

xargs syntax:
xargs [options] [command] [arguments]

Typically, arguments are piped from standard input.
How would you go about configuring an ISA pnp card?
isapnp requires a configuration file to be created with pnpdump.

pnpdump >/etc/isapnp.conf
isapnp /etc/isapnp.conf
What command shows all environment variables that are currently set?
env
What does the 'env' command do?
It displays all environment variables that are currently set
What's the difference between info and man?
Man pages are flat. Info uses hypertext to help organise documents.
What command reformats paragraphs within a text file?
fmt
What does the 'fmt' command do?
It reformats paragraphs within a text file
What is the difference between grep and egrep?
grep uses basic regular expressions by default, whereas egrep uses extended regular expressions by default.
What does this command do?

tail -f /var/log/messages
It displays the last few lines of /var/log/messages, and continues to monitor the file, updating the screen every time a new line is added.
What command displays the last few lines of a file and continues to monitor it, displaying new lines as they're added?
tail -f file
What does the 'renice' command do?
Renice alters the priority or running processes.

20 - idle
0 - realtime
What does the 'nice' command do?
Nice allows you to run a command while specifying its priority. For example:

nice 0 amarok

This would launch amarok with 'realtime' priority.
What does the 'uptime' command do?
It displays the amount of time the system has been running, and also three load averages: the past minute, the past 5 minutes and the past 15 minutes.
What does the 'uname' command do?
It displays:
Hardware platform
Processor type
Kernel name, version
Hostname
OS name
What command kills a process by name?
killall [processname]

OR

pkill [processname or part thereof]
Traditionally, the linux kernel must reside below which cylinder?
1024th cylinder. However, newer versions of GRUB and LILO will work from any part of the disk if the BIOS supports it.
What are the major fdisk commands?
d delete a partition
l list known partition types
n add a new partition
p print the partition table
v verify the partition table
q quit without waving
w write the table and exit
How does linux burn optical media?
It uses mkisofs to create an ISO-9660 filesystem, and cdrecord to burn it to the media.
Which command is used to create a filesystem?
mkfs
On which partitions type(s) can the Linux kernel reside?
It can reside on primary or logical partitions. Extended partitions are placeholders for more logical partitions.
What is the default install location for software installed from source?
/usr/local/
How can you prevent filesystem checks after a power failure?
Use a journaled filesystem like JFS, XFS, EXT3, EXT4 or ReiserFS.
Where should you install GRUB or LILO if you want to be able to restore it using DOS fdisk after installing Windows?
You must install it to the partition's boot sector, not to the MBR.
What is the function of the 'sticky bit'
The sticky bit is set on directories to ensure that only the a file's owner may delete it.
What does the 'umask' command do?
It shows the numeric value being subtracted from the default permissions of newly created files and folders. For example:

umask = 0022

This means the default permission is x755:

-rwxr-xr-x
The following python command prints text to screen. What will it look like?

print ("I", "have", "lice")
I have lice

By default, python prints each value using a space as a separator. You can change this behaviour by specifying end=""

print (end="_" "Here", "I", "am")

Here_I_am
What does the 'edquota' command do?
It edits disk quota information.
What command edits disk quota information?
edquota
What is a 'hard link'
A hard link is a filename that points to the inode of another file. Think about data recover, and the purpose of the file table; if you have two file table entries pointing to a single inode, then deleting one has no effect on the other. Changing the file content does, of course.
Here is an example of what you would see after creating a hard link and a soft link:

HOST1:# touch original_file
HOST1:# ln original_file hardlink
HOST1:# ln -s softlink

Now, displaying the inode with the ls command (short date, no user or group):

HOST1:# ls -lAgG --time-style iso
total 0
-rw-r--r-- 2 0 11-29 16:08 hardlink
-rw-r--r-- 2 0 11-29 16:08 original_file
lrwxrwxrwx 1 13 11-29 16:11 softlink -> original_file
What is a 'symbolic link'?
A symbolic link points to another file by its entry in the file table, rather than to the inode on the disk. If you remove the original file, its entry in the file table is removed (though the inode is not necessarily wiped) and the symbolic link no longer works.
What modes does vi have?
Command mode
Insert Mode
Ex Mode (used to enter external commands)
Which file directs the boot process after the kernel has loaded?
/etc/inittab OR files in /etc/event.d/
What does the 'dmesg' command do?
It allows you to examine the 'kernel ring buffer' after the kernel has loaded. Essentially, this is a log of kernel events recorded during boot.
What does the 'runlevel' command do?
It shows the computer's current runlevel. It can also be used with the --set option to set the runlevel.
What command can show or change the current runlevel?
runlevel
What option must be set in the /etc/ssh/sshd_config file to enable X tunneling?
X11Forwarding yes
What program does Linux use to convert PostScript into non-PostScript formats?
Ghostscript
What is the role of a filter in a Linux printing system?
A filter identifies the file type and passed it through the appropriate programs to convert it into something the printer understands.
What command displays information about the print queue?
lpq
What does the 'lpq' command do?
It displays information about print queues.
What does the 'mpage' utility do?
It prints several pages onto one PostScript page to save on paper.
What types of network printer can CUPS print to?
IPP, LPD and SMB/CIFS
What does the 'lpr' command do?
It submits a print job.
What command is used to submit a print job?
lpr
What are the main XDMCP servers in Linux?
XDM, KDM and GDM
What does the 'lprm' command do?
It removes a print job from a print queue.
What command removes a print job from a print queue?
lprm
What option do you pass to the lpr command to specify a printer
lpr -Plexmark
What factors does X use to compute the refresh rate?
The monitor's maximum horizontal and vertical refresh rates and the resolution.
Why would you set the LC_ALL variable?
To change the locale for a single program.
How would you override the locale for a single program?
export LC_ALL
What does the 'chage' command do?
It changes a user's password expiration information.
What command changes a user's password expirey information?
chage
What command locates all files belonging to a particular user?
find / -uid 502
Which file records group memberships?
/etc/group
What command lets you create a user cron job?
crontab
What does the 'crontab' command do?
It allows you to maintain cron jobs for individual users.
What does the command 'userdel -r raff' do?
It deletes the user 'raff' and removes the user's home directory.
What command removes a user and deletes their home drive?
userdel -r username
How would you prevent a user from using crontab?
Add the user to /etc/cron.deny
What does klogd do?
It intercepts and logs kernel messages from the overall system log daemon.
What command(s) can identify slow or unreliable routers between you and another system?
traceroute and tracepath
Which server runs on port 53?
DNS
Which port does DNS use?
53
What is the difference between UDP and TCP?
UDP is connectionless, and it has no packet-level error checking. This reduced overhead makes it much faster than TCP. It is useful for improving the performance of online gaming, video streaming etc, where 100% of the transmitted data may not necessarily be required.
Why is telnet generally avoided?
Telnet isn't encrypted, and is therefore insecure. SSH is recommended for remote shell access.
Which file would you edit to have postmaster email delivered to you?
Depending on the distribution, it may be either of these:
/etc/mail/aliases
/etc/aliases
Where would you set global BASH options for all users?
Any of these:
/etc/bashrc
/etc/bash.bashrc
/etc/profile
How can you check if an SMTP email has been sent?
Type mailq to view the message queue.
What does the 'newaliases' command do?
It forces the mail server to read the /etc/aliases or /etc/mail/aliases file after it has been changed.
After you make a change to the /etc/aliases or /etc/mail/aliases file what command should you run for the changes to take effect?
newaliases
What is the difference between .profile and .bashrc?
.profile is only executed in login shells, whereas .bashrc files launch for any bash shell.
What does /etc/nologin do?
It prevents non-root users from logging into shells. It can contain a message the will be shown to users if they try to connect.
What is inetd?
It's a "superserver" that launches other servers on demand. It uses the /etc/inetd.conf for its configuration.

inetd differs from xinetd in that it uses TCP Wrappers, whereas xinetd is much more powerful and configurable, with its own built-in access controls, limits and logging features.
What advantages does xinetd have over inetd?
inetd must use TCP wrappers (i.e. /etc/hosts.allowed and /etc/hosts.denied) for security, but xinetd has security features built in.
What utility uses /etc/hosts.allow and /etc/hosts.deny?
TCP Wrappers use these files for access control. (The main user of TCP Wrappers is inetd, thought some other programs use it). To find out if a program supports TCP Wrappers, use this command:

ldd /usr/bin/program | grep libwrap
What utility manages ssh logins, enabling you to use a single passphrase instead of typing a password for each connection?
ssh-agent
What file holds ssh information about all known hosts for all users
/etc/ssh/ssh_known_hosts
Monitoring progress: If you wished to draw a rotating line on the screen during a process, how would you echo to the same character space onscreen?
echo \b\c

In order to use the backslash characters on echo in bash, you have to use the '-e' option. This is not the default on many distros!
System account information such as user ID and group ID is stored in which file?
/etc/passwd
What does the 'tee' command do?
It takes standard input, and redirects output to the screen and to a file.

Example: If you needed to echo a new line to a file owned by root, the following command would fail:

sudo echo "Newline" > /etc/newfile

While 'echo' is executed with root privileges, the redirect happens outside of 'sudo'. The correct command is:

echo "Newline" | sudo tee /etc/newfile
What does the 'unset' command do?
It is used to remove a shell variable; it is the opposite of set.
What would this command do?
mkdir /tmp/bar || echo "oops"
It would try to create the /tmp/bar folder. If it fails, it will echo "oops". || is an 'OR' logical operator.
What is the default signal for the kill command?
SIGTERM

Though SIGTERM is the default, it can be specified by using either of these commands:

kill -TERM process
kill -15 process

This type of kill signal can be blocked if the process cannot be cleanly killed.
What is SIGTERM?
Sigterm is the default 'signal' for the kill command. It sends a 'kill' command to the process. The process itself then tries to terminate. However, this does not always work, as the process may block the request or fail to terminate.

Though SIGTERM is the default, it can be specified by using either of these commands:

kill -TERM process
kill -15 process
What is SIGKILL?
SIGKILL is a signal for the 'kill' command. It does not send a 'kill' command to the process, but to the kernel. As such, it cannot be blocked.

SIGKILL can be specified by using either of these commands:

kill -KILL process
kill -9 process
What does the 'pkill' command do?
The 'pkill' command works in exactly the same way as the 'kill' command, except that it can be passed process names instead of PID numbers. For example, the following commands would forcibly kill the firefox process:

pkill -9 firefox
pkill -KILL firefox
Which redirector is used to direct the standard error to a file?
2>
How would you alter the priority of a running process?
You could use the 'renice' or 'top' commands.
What commands can be used to create an ext2 filesystem?
mke2fs
mkfs.ext2

(mkfs.ext2 is a link to mke2fs)
What command would you use to check an ext2 or ext3 filesystem?
You could use the following commands:

e2fsck
fsck.ext2
fsck.ext3
What command would you use to check an ext4 filesystem?
fsck.ext4
What's the bash history file called?
~/.bash_history
What's the default BASH history size?
500 lines
What is the name of the variable that controls BASH history size?
$HISTSIZE
What does "!!" do in BASH?
It executes the previous command
What would "!ssh" do in BASH?
It would execute the last command that started with 'ssh'.
What would "!123" do in BASH?
It would execute the 123rd command in the BASH history.
What does "!$" represent in BASH?
It represents the last argument of the previous command.
What would "!23:p" do in BASH?
It would print the 23rd command in the BASH history
What to the following BASH history modifiers do?

!$:h
!$:t
!$:r
!$:e
!!:p
!!:s/balls/walls/g
!$:h - 'head', shows the path but not the filename
!$:t - 'tail', shows the filename but not the path
!$:r - shows the full path, but removes the file extension
!$:e - 'end'; just shows the file extension
!!:p - prints the command but doesn't execute it.
!!:s/john/harry - repeats the command, replacing the first instance of "john" with "harry"
!!:s/hda/sda/g - repeats the command, globally replacing "hda" with "sda"
What would the following BASH history shortcut do?

!!:gs/hda/sda
It would repeat the previous command, replacing all instances of 'hda' with 'sda'.
What would the following BASH history command do?

!!:s/one/two
It would repeat the previous command, replacing the first instance of 'one' with 'two'. This is equivalent to:

^one^two
What would the following BASH history command do?

^tzr^tar
It would repeat the previous command, replacing the first instance of 'tzr' with 'tar'. This is equivalent to:

!!:s/tzr/tar
Which CTRL key is used to go to the start of the BASH command line?
CTRL + a
Which CTRL key is used to go to the end of a BASH command line?
CTRL + e
Which CTRL key is used to clear the BASH screen?
CTRL + l
Which keystrokes can be used in BASH when cursor keys do not work?
Readline
CTRL + p = Previous (up)
CTRL + n = Next (down)
CTRL + b = Back one character
ALT + b = Back one word
CTRL + f = Forward one character
ALT + f = Forward one word
CTRL + a = Home
CTRL + e = End
CTRL + w = Delete previous word
ALT + w = Delete next word


For a complete 'readline' cheat sheet:
http://www.bigsmoke.us/readline/shortcuts
Which CTRL keys are used to search the BASH history?
CTRL + r = Reverse search

[Once you have found the command, ENTER to execute, CTRL + j to edit it.]
Describe the two ways in which you can substitute a command for a variable or value in a BASH command.
`command`
$(command)

Examples:
profile =`ls .mozilla/firefox/ | grep default`
rcsize = $(wc -l ~/.bashrc)
How would you find and delete all .zip files in a folder and its subfolders?
There are several methods:

The first method you could use is the built-in 'exec' option that the 'find' command provides:

find /folder -iname "*.zip" -exec rm "{}" \;

The second option is to use the 'xargs' command along with 'find':

find /folder -iname "*.zip" | xargs rm *

The third option is only possible with newer versions of find:

find /folder -iname "*.zip" -delete
What regular expression would you used with grep to find all lines in a file beginning with "http" or "ftp"?
grep -E "^(ht|f)tp" file

OR

egrep "^(ht|f)tp" file

^ represents the start of the line

Braces () let you search for strings using the OR logical operators, represented by a | pipe.

"egrep" and "grep -E" argument use extended regular expression.

Note: -e just allows you to specify multiple 'regular' regular expressions.
How can your script tell if it's in an interactive BASH shell?
The variable "$-" will contain the letter i.
How would you redirect command output to several different files?
In your BASH script, you can direct output to named file descriptors:

echo option $OPTSTR >&5

From the command line, you can tell your script which file this descriptor should write to like this:

$ command 5> output
Explain the difference between these commands:

$ somecmd >my.file 2>&1
$ somecmd 2>&1 >my.file
This may appear counter-intuitive, so pay attention!

In the first case, standard out is redirected to a file (my.file), and then standard error is redirected to "the place that standard out is directed", which means that all output appears in my.file.

However, in the second command, standard error is redirected to standard out (which at that point is connected to the screen), after which standard out is redirected to my.file. Thus, standard output appears in my.file while standard error appears onscreen.
What does this command do:
$ set -o noclobber
It unsets the noclobber option. This tells BASH to be more careful about overwriting files that already exist.

Note: To undo, use this command:
$ set +o noclobber

You can override noclobber by redirecting like this:

echo "whatever" >| /tmp/file
How would you achieve the same result as this without the cat command:

cat /tmp/file | wc
wc < /tmp/file

Note: cat is overused, but can improve the readability of 'long' commands by placing the cat /tmp/filename at the beginning.
What is a 'here-document'?
If you wish to place data inside a simple script, you can use what is called a 'here-document'. Example script called "ext":

# here is a "here" document
#
grep $1 <<EOF
mike x.123
joe x.234
sue x.555
pete x.818
sara x.822
bill x.919
EOF

Command: ext joe
Result: joe x.234
How can you ask for BASH user input?
read -p "Enter some text" VARIABLE

Note: If you want to prompt, but hide input (as with a password prompt) use:

read -s -p "Enter password" PASSWORD
What is BASH script exit status?
$? represents the exit variable. This can be set to a particular value on exit, depending on whether or not the command was successful.

For example:

if [ $value -le 10 ]; then
exit 5
fi

By default, a zero value means 'success', and a non-zero value means 'failure'.
How would you show the last two lines of a text file?
tail -2 textfile

While this works, it's less confusing to use:

tail -n 2 textfile
How would you show a text file, but skip the first 4 lines?
tail -n +4 textfile

Note: This has changed! It is documented in many places like this:

tail +4 filename


...but this will attempt to 'tail' the text file, and also a file named "+4".

Note also that the syntax of tail to show the last 4 lines should also be formatted in this way for simplicity:

tail -n 4 filename
How can you run several commands at once?
Separate the commands with ampersands:

/usr/bin/runme &
/etc/init.d/restart &
/control/scripts/update

Note: If you want to run commands consecutively, use semi-colons.
How can you run several commands consecutively?
If you only want to run the next command if the previous one succeeds:

./configure && make && make install

If you want to run all commands regardless of whether or not the previous one fails:

touch ~dir ; cd ~dir ; cp file ~
How can you use the output of a command, and redirect it to a file simultaneously?
Use the 'tee' command to T-joint the output:

find ~ -type f | tee list.txt | grep -i ".doc"
You ping a host and redirect output to a file. However, the error message still appears onscreen. How do you overcome this? Why does it happen?
Explanation: Ping is behaving properly! Every Unix process typically has three open file descriptors:
0> STDIN
1> STDOUT (shorthand is > )
2> STDERROR

Many programs stick to this standard, so if you wish to capture STDOUT and STDERR to a single file, you must specify this:

ping hostname > logfile 2> logfile

OR:
ping $host > logfile 2>&1

[In the alternative, the order of the redirects is important!]
How would you use the output of a command inside another command?
BASH has a command substitution feature that can be called by using back ticks or $().

Example:
rm `ls | grep bak`
rm $(ls | grep bak)

The $() method is recommended.
You have written a script that generates screen output. You would like to enable this script to direct its output to multiple files. How would you accomplish this?
Inside the script, you should echo output to numbered file descriptors:

echo $VALUE >&4
echo $ERROR >&5

When the script is executed, these file descriptors can be used like this:

runscript 4> values 5> errors
How would you ping a host, directing output and errors to a file, while also viewing them onscreen?
ping host 2>&1 | tee logfile
How would you save STDERR and STDOUT to separate output files, while displaying STDERR onscreen?
This is a trick question. If you wished to save both to separate files and show STDOUT onscreen, it would be easy direct STDERR to a file, and pipe into tee to split the STDOUT onto screen and to a file. However, there is no way to put STDERR through a pipe! You must swap STDERR and STDOUT before piping into tee. This can be achieved through an intermediate file descriptor:

command 3>&1 1>std.out 2>&3 | tee std.err

Create file descriptor 3 pointing at STDOUT. This allows it out through the pipe.

Direct standard out into a file.

Direct standard error into file descriptor 3 (buffered).
What does the 'free' command do?
It displays the amount of free and used memory in the system.
What command displays free and used memory in the system?
free
What does the 'nohup' command do?
It is used to run a command that is immune to the HUP (hangup) signal. This means that the command will continue to run after the user logs out. Output doesn't go to tty, but to a file called nohup.out.
When a command is running, what happens when you press CTRL + z?
The command is paused and sent to the background as a 'job' so you can have control of the terminal.

You can unpause a background job with the command 'bg'.

You can bring a background job to the foreground using the command 'fg'.

You can list jobs with the 'jobs' command.
What does the 'jobs' command do?
It is used to display a list of jobs that have been pushed into the background. (Look up BASH job control)
What does the 'bg' command do?
When you pause a BASH job and push it into the background with CTRL + z, the bg command leaves it in the background but resumes the job. This gives you interactive control over the shell (though you will get STDOUT from the background command on the screen!). To bring the job back to the foreground, use 'fg'.
What does the 'updatedb' command do?
It updates (or creates) a database of files for the 'locate' command. [This is usually executed by cron on a daily basis.] Locate is much faster than find because it doesn't have to search the file table, but looks inside a database.
What does the 'locate' command do?
It is used to find files. It works much quicker than the 'find' command because it queries the 'mlocate' database rather than the filesystem.
What does the 'which' command do?
It is used specifically for locating commands.
What does the 'whereis' command do?
It is used to find binary, source and man page of a command.
What port number does IMAP use?
143
What service uses port 143?
IMAP
How would you configure visudo to edit the /etc/sudoers file in an editor other than vi?
export EDITOR=/usr/bin/gedit
What would you add to the /etc/sudoers file to give the group "admins" the ability to run any command with sudo without needing a password?
%admins ALL=(ALL) NOPASSWD: ALL

The general format of sudoers is:
user host=(user you can run as) command
How many command line arguments to useradd can you remember?
-c comment
-d home directory
-D Don't create, just use these as default values
-g Set the primary group
-G Add the user to a comma-delimited list of groups
-m Create a home directory using /etc/skel
-M Do not create a home directory
-p Password
-s Shell
-u
How would you restrict user logins based on time, date etc?
You could use enable the pam_limits module and configure the /etc/security/limits.conf file:

* soft core 0
* hard rss 10000
@student hard nproc 20
@faculty soft nproc 20
@faculty hard nproc 50
ftp hard nproc 0
@student - maxlogins
How would you sniff packets on the eth0 interface, ignoring SSH packets?
tcpdump -i eth0 not port 22
How would you install an RPM to a different Linux installation on another partition?
rpm -i --root /mnt/other
How would you extract files from an rpm package?
rpm2cpio package.rpm | cpio -ivd

The cpio command line arguments are:
-i extract
-v verbose
-d create directories

NOTE: To view the files, use "cpio -vt". This allows you to specify individual files to extract, if you don't want all of them.
How would you extract files from a deb package?
You can use dpkg to extract files:

dpkg -X package.deb

Also, since debian packages are 'ar' archives that contain three files, you can use this command:

$ ar -vx package.deb
x - debian-binary
x - control.tar.gz
x - data.tar.gz

The files can be extracted from the data.tar.gz using this command:

tar -xvzf data.tar.gz
How would you remove a Debian package, including configuration files?
dpkg -P package

OR

dpkg --purge package
How do you find out which package owns a file on a Debian system?
dpkg -S /opt/filename

OR

dpkg --search /opt/filename
How do you show information about a package installed on a Debian system?
dpkg -p package

OR

dpkg --print-avail package

Note: This information can be useful when creating your own packages with checkinstall.
How do you list the files in a Debian package?
The following command list files owned by an installed package:

dpkg -L package.deb

OR

dpkg --listfiles package.deb

However, the following command shows the contents of a package file (i.e. not installed):

dpkg -c package.deb
How would you list unmet dependencies of a package on a Debian system?
apt-cache unmet package_name
How would you capture 5 packets from the source 192.168.2.105 on interface "eth0", ignoring port 22?
tcpdump -i eth0 -c 5 src 192.168.2.105 and not port 22
What does this "tcpdump -e" do?
It displays source and destination MAC address and the ethertype.
How would you capture verbose packets to the file /tmp/tcpdump.cap, originating from the network 10.30.123.0, going to the destination address 10.30.122.50.
tcpdump -VV -w /tmp/tcpdump.cap src net 10.30.123.0 and dst host 10.30.122.50
How you you show all of the processes that are listening on a particular port?
netstat -l -p --numeric-ports

By default, netstat shows open sockets.
-l shows sockets that are being listened to
-p shows process IDs

NOTE: the "-n" option shows hosts, ports and users numerically. Each one can be specified 'longhand' without affecting the others.

OR

lsof -iTCP -sTCP:LISTEN

lsof lists open files, but this includes pseudo files. (In *nix, everything is a file!)

-i lists network "files"
-iTCP particularly lists TCP connections
-sTCP:LISTEN only shows TCP connections that are listening.
What are the six types of information that netstat can show? What command line arguments are used to show them?
The type of information shown by netstat is controlled by the first argument:

(none) Open sockets
-r Kernel routing tables
-g Multicast group memberships
-i Network interfaces
-M Masquerade connections
-s Statistics for each protocol
How would you direct the microphone input to the speakers on your other PC?
dd if=/dev/dsp | ssh username@host dd of=/dev/dsp

You could probably use netcat either.
How would you create a 250MB RAM disk at /mnt/ramdisk
mount -t tmpfs -o size=250m tmpfs /mnt/ramdisk
How would you show which programs are listening on which tcp ports?
netstat -tlnp

-t causes netstat to only list information about TCP sockets.
-l causes netstat to only list information about listening sockets.
-n causes netstat not to do reverse lookups on the IPs.
-p causes netstat to print the PID and name of the program to which the socket belongs (requires root).
How do you find out who is using a file?
lsof /pathto/file
How do you find out which files are opened by a particular user?
lsof -u user
How do you show open files used by bash?
lsof -c bash
How do you show open files used by bash as the root user?
lsof -a -c bash -u root

The -a option works like "and", combining the other options.
How do you show open files used by the process ID 2123?
lsof -p 2123
How would you list all open network connections?
lsof -i

OR

netstat
How would you show all TCP connections?
lsof -i tcp

OR

netstat -at
How would you show all TCP network connections used by the user "raff"?
lsof -a -u raff -i tcp
What does the lsof option "-t" do?
It forces lsof to produce terse output with process identifiers only. This is useful when you want to pass the results to 'kill'. For example, this command would kill all processes that have UDP connections open:

kill -9 `lsof -t -i udp`
How would you use netcat to copy a file from one computer to another?
# On computer A with IP 192.168.1.10
$ cat file | nc -l -p 6666

# On computer B
$ nc 192.168.1.10 6666 > file
How would you remotely access BASH without using rsh, ssh or telnet?
#On a computer with IP 10.30.1.2
nc -l -p 12345 -e /bin/bash

#To connect to the 'BASH server', execute this command:

nc 10.30.1.2 12345
What would this awk command do?

awk 'NF { print $0 "\n" }' /filname
If the first argument in awk has a non-zero value, awk will execute the remainder of the command. If it is zero, it will not.

NF specifies the number of fields in a line. If the line is:

Good morning sunshine

...then the value of NF is 3. However, if the line is blank, the number will be zero, and awk will not proceed.

This command will remove all duplicate empty lines in the file.
What would this awk command do?

awk 'BEGIN { ORS="\n\n" }; 1' /filename
BEGIN has special significance in awk. It is only executed once, before awk processes any lines. In this case, it sets the "Output Record Separator" to two new lines.

The next command is "1". Simply put, "1" is always true, therefore awk will print each line.

This command prints all lines of a file on a single line. The output record separator is normally a new line, but we set it to be a space.
What would this awk command do?

awk '{ print FNR "\t" $0 }' /filename
FNR is the "File Line Number". This command will print each line number, a tab, and then the line, like the "nl" command.
What would this awk command do?

awk '{ print NR "\t" $0 }'
NR is "line number", which differs from FNR in that it doesn't get reset if awk processes multiple files.

This command is useful if you wishe to process multiple files and number each line. Again, this is like "cat file1 file2 file3 | nl", but it's more flexible (because it's awk!).
What would this awk command do?

awk 'NF { $0=++a " :" $0 }; { print }' /filename
NF is the number of fields in the line. If this is zero, the proceeding command will not be executed.

Variables come into existence automatically in awk, so "++a" will create and/or automatically increment "a".

So the first command will convert $0 into 'a :$0' provided that the line isn't blank.

The next command simply prints each line.

This command numbers every non-blank line.
What would this awk command do?

awk '{ total = total + NF }; END { print total+0 }'
NF is the number of fields in a line.

Variables come into existence automatically in awk, so "total" gets incremented by the number of words in each line.

END has a special significance in awk. It is only execute once, after awk has processed all lines.

This command works like "wc".
What would this awk command do?

awk '{ print $NF }'
NF is the number of fields in a line.

This command prints the last field from each line.
What would this awk command do?

awk 'NF > 4'
Every awk program contains "pattern {action}" statements. If a pattern is missing, it is assumed to be "1", which will execute the action. If the action is missing, it is assumed to be "{ print }".

NF is the number of fields in a line.

This awk command is the same as:

awk 'NF > 4 {print}'

It will print each line that has more than four fields.
What would this awk command do?

awk '$NF > 4'
Every awk program contains a "pattern {action}" statement. IF a pattern is missing, it is assumed to be "1", which will execute the action. If the action is missing, it is assumed to be "{print}"

NF is the number of fields in a line.

This awk command is the same as:

awk '$NF > 4 {print}'

It will print each line where the last field is a number larger than 4.
ldapsearch produces the following:

DN: cn=winxp1,dc=domain,ou=dept,o=com
update=21
user=paddy

DN: cn=winxp2,dc=domain,ou=dept,o=com
update=22
user=john

DN: cn=winxp3,dc=domain,ou=dept,o=com
update=15
user=philip

Problem: You wish to use awk to display the user and update on a single lines like this:

user: paddy,update: 21
user: john,update: 22
user: philip,update: 15
NOTE: There are several ways, one that uses 'getline'; we will use a better method

awk ' BEGIN {RS="\n\n";FS="\n";OFS=","};{print $1,$2}'

In the BEGIN statement awk is told that:
- each RS (record separator) is a blank line.
- each FS (field separator) is a new line.
- The OFS (output field separator) is a comma.


With the new values, awk reads each 'record' as a series of new lines until it hits a blank one. Out of each record, it prints values $2 and $3, separated by commas.
What sed command would you used to delete all lines containing "Arse"?
sed '/Arse/d'

OR

sed '/Arse/!p;d'
What sed command would you used to delete all lines that don't contain "SPUDS"
sed '/SPUDS/!d'
What would this sed command do?

sed 's/\([Dd]ie\) or \([Dd]o\)/\2 or \1/'
\( \) remembers a pattern in the 'hold buffer'
[Dd]ie represents "die" or "Die"
\2 prints the 2nd remembered pattern

This command will perform the following conversions, if found:

die or do > do or die
Die or do > do or Die
die or Do > Do or die
Die or Do > Do or Die
Using sed, how would you surround every instance of the word "hint" in parenthesis?
sed 's/hint/(&)/g'

s/search/replace/g - global search and replace
& - represents the search pattern
You have a text file containing the poem "The Daffodils", but you don't like the verse that begins "Continuous as the stars that shine". How would you used sed to remove it?
sed '/^Continuous/,/bay.$/d' poem.txt

OR

sed '/^Continuous/,/bay.$/!p;d' poem.txt
Using sed, you would you remove all lines containing the word "Arse"?
sed '/Arse/d'
Using sed, you would you show only the lines that contain the word "excellent"?
sed '/excellent/!d'

OR

sed '/excellent/p;d'
You have a text file that contains a list of files. Using sed, how would you produce a script that can rename all of the files, adding .old to each one?
sed '/.*/mv & &.old' > /tmp/script
Using sed, how would you capitalize the name "Paul" in an entire text file?
sed 's/\&lt;paul /> /directory/file

\&lt; represents the first letter of a word
\u forces upper case
What is SIGTERM?
SIGTERM is the default 'signal' for the 'kill' command. It sends a 'kill' command to the process rather than to the kernel. The process ends itself. This can be blocked or may fail if the process has hung.

SIGTERM can be specified by using either of these commands:

kill process
pkill processname
pkill -15 processname
What does this sed command do?

sed 'N;s/\n //;P;D'
Let's break it down:

N read another line (embedded)
s/\n // removes a newline if it starts with a space
P prints up to embedded line
D deletes up to embedded line

This command appends the next line to the current one with "N" command. If the appended line starts with a " ", the newline and " " get removed. If the substitution fails, P prints out the pattern space up to the newline character and D deletes the contents of pattern space up to the newline character.
In BASH, how would you easily split a string variable into separate values?
Let's say string="one two three four"

user@host$ set -- $string
user@host$ echo $1
one
user@host$ echo $3
three
user@host$ shift
user@host$ echo $1
two
user@host$ echo $@
two three
You're using BASH to echo "newline\n", but it does not escape the new line character. How do you get around this?
echo -e "newline\n"
How do you extract files from a Debian package?
Debian packages are 'ar' archives that always contain 3 files: debian-binary, control.tar.gz, and data.tar.gz. To extract...

ar xv package.deb
tar zxvf data.tar.gz

NOTE: You can modify the contents, tar it back up again and use "ar -r package.deb data.tar.gz" to repackage the data.

You can also use "dpkg-deb -x" and "dpkg-deb -b" to extract or build the .deb package.
What does this command do?

kill -HUP 123
It sends the HUP signal to process 123. This is the same as kill -1, but it's safer because mistyping kill -1 could kill process ID 1.

HUP is the 'hang up' signal. If you send this to many services, they do not terminate, they just reload their configuration.
What does this command do?

set c a b
It sets the following variable values:

$1 = c
$2 = a
$3 = b
If you have a variable $var="one two three", what would the following command do?

set -- $var
It would 'unset all positional parameters' resulting in the following values being set:

$1 = one
$2 = two
$3 = three
$# = 3
You have a file that is named "-example.txt", and you are trying to delete it. You get the following message:

rm -example.txt
rm: invalid option -- e
Try `rm --help' for more information.

Why can you not delete the file? How do you get around this?
When BASH reads the '-' it assumes that '-example.txt' is an option to the rm command, not an argument.

You can work around this in two ways:

rm ./-example.txt

(The filename no longer starts with a '-')

rm -- -example.txt

(The '--' can be used to sign the end of command options)
How do you convert a ext2 file system to an ext3 file system?
Run the following command as root:

/sbin/tune2fs -j /dev/sd?
How can you tell if a program (for example, sendmail) supports TCP Wrappers?
ldd `which sendmail` | grep libwrap
What would this command do?

ldd `which sendmail` | grep libwrap
It checks to see which shared library dependencies are used by sendmail, and then searches the results to see if libwrap is included. This would tell you whether or not sendmail supports TCP Wrappers!
List all the Posix character classes and their meanings...
[CHAR*] in SET2, copies of CHAR until length of SET1

[CHAR*REPEAT] REPEAT copies of CHAR, REPEAT octal if starting with 0

[:alnum:] all letters and digits

[:alpha:] all letters

[:blank:] all horizontal whitespace

[:cntrl:] all control characters

[:digit:] all digits

[:graph:] all printable characters, not including space

[:lower:] all lower case letters

[:print:] all printable characters, including space

[:punct:] all punctuation characters

[:space:] all horizontal or vertical whitespace

[:upper:] all upper case letters

[:xdigit:] all hexadecimal digits

[=CHAR=] all characters which are equivalent to CHAR
What is the file /etc/yp.conf used for?
It is the NIS binding configuration file, read by ypbind on startup or when it receives a SIGHUP.
Which file contains NIS binding configuration?
/etc/yp.conf
What does the 'sysctl -a' command do?
It displays all kernel parameters currently set.
On a GRUB2 system that only has a single OS installed, how do you prevent the system from booting the OS?
Hold down the SHIFT key.
The following is a sample /etc/inittab:

ca::ctrlaltdel:/sbin/shutdown -r -t 4 now
kb::kbrequest:/bin/echo "Keyboard Request -- edit /etc/inittab to let this work."
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
sh:12345:powerfail:/sbin/shutdown -h now THE POWER IS FAILING
#
1:2345:respawn:/sbin/mingetty --noclear tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

What does each field represent?
They are:
ID number:runlevels:action:process

Actions can be:
respawn
wait
once
boot
bootwait
off
ondemand
initdefault
sysinit
powerwait
powerfail
powerokwait
powerfailnow
ctrlaltdel
kbrequest

What are the types of USB Host Controllers?
OHCI - open host controller interface [USB1.1 low and full speed] used by most vendors

UHCI - universal host controller interface [USB1.1 low and full speed] - proprietary mainly used by Intel and VIA.

EHCI - enhanced host controller interface [USB2 high speed only - relies on OHCI or UHCI to handle low or full speed]

xHCI - extended host controller interface [USB3 - supports all speeds and makes OHCI/UHCI/EHCI redundant]
What command would remove all unused kernel modules?
rmmod -a
Before adding a new module with "insmod", what command would you used to find information about the module?
modinfo

-a show author
-d show description
-p show parameters used by module

example:
modinfo -a /lib/modules/2.6.5-smp/misc/zftape.o

(c) 1998 Mr Bloggs
mr.bloggs@linux.net
What command would you use to find out which kernel modules are available for use?
There are two methods:

modprobe -l [args]

find /lib/modules/ -exec basename {} \;

NOTE: The arguments to "modprobe -l" don't seem to work in Ubuntu. The book, "LPI Certification in a nutshell" claims that it works, but it doesn't. This may be distribution-specific.
How do you force a disk check on the next reboot?
sudo touch /forcefsck
shutdown -rF now
After removing an network manager from a PC or server, how would you make sure interface eth0 is enabled for DHCP on boot?
Edit the file /etc/network/interfaces and add the lines:

auth eth0
iface eth0 inet dhcp
Explain the following arguments for the cp command:

-f
-i
-b
-u
-P
-L
-d
-f overwrite without prompt
-i interactively prompt to overwrite
-b create backups of existing files
-u update existing files
-P don't follow links, dereference the original and copy the link
-L follow links and reference the original file
-d follow links and make a new link to the original file

[CONFIRM]
What's the best way to remember the COM port memory addresses?
Addresses either start with a 2 or 3.
COM number matches odd with odd, even with even.
Start with COM2 = 2F8
Alphabetically reversed (F first two, E second two)

COM1 = 3F8
COM2 = 2F8
COM3 = 3E8
COM4 = 2E7

The IRQ is the number +1

COM1 = IRQ4
COM2 = IRQ3
COM3 = IRQ4
COM4 = IRQ3
Which envionment variable determines the search path for man pages?
MANPATH
How would you make a file suid?
chmod u+s
OR
chmod 4755

OK, ignore the last three digits, as these set the usual rwx on the file. The 1st digit can be used to setuid, setgid or set the sticky bit. Because file ownership works "user", "group", "others", you setuid by setting the first digit to "4", representing 'user' in octal.

ugo
421
How would you set the sticky bit?
In the world of 'user', 'group', 'other', the sticky bit is stored in the 'other' section. It looks like this:

-rwxr-xr-t

You can set it like this:
chmod o+t
OR
chmod 1755 foo

NOTE: The letter s was already used by suid, so sticky got the next letter!
NOTE2: The same octal field is used to perform setuid and setgid.
How could you get the physical SCSI address of /dev/sda ?
scsiinfo /dev/sda
Which command would you use to check the signature of a rpm package?
rpm --checksig package.rpm
How do you reconfigure a debian package?
dpkg-reconfigure
What is the definition of a daemon
It is a process that has no controlling terminal
Who can set negative nice values? What do they mean?
Only root can give negative nice values. Negative values (from -20 to -1) give higher priority.
What are the partition IDs for SWAP and Linux
82 = Linux
83 = SWAP
Why might you run out of inodes?
Too many directories, cross-linked files or small files. (Don't know the 'correct' answer.)

You can count inodes with the command:
df -i
What program can be used to configure the X11 server?
xf86config
or
XF86Setup
In vi 'command mode' how would you move the cursor 7 spaces left
7h
In vi 'command mode' how would you move the cursor 7 spaces down
7j
In vi 'command mode' how would you move the cursor 7 spaces right
7l
In vi 'command mode' how would you move the cursor 7 spaces right?
7l
Using the setserial command, how would you set the speed to 56k?
setserial /dev/ttyS0 spd_hi
Using the setserial command, how would you set the speed to 115k?
setserial /dev/ttyS0 spd_vhi
Using the setserial command, how would you set the speed to 230k?
setserial /dev/ttyS0 spd_shi
If you set umask to 027, what permissions will the files be?
640.
Confused? Read this:
http://teaching.idallen.com/dat2330/04f/notes/umask.txt

The default mode of a directory is 777, while the default mode of a file is 666. The umask applies to the default value.
http://www.linux-praxis.de/lpisim/lpi101sim/next.php3

http://www.ibm.com/developerworks/linux/tutorials/l-lpic1101/index.html
whatever
How do you check the current lilo configuration
lilo -q
How do you run lilo with a configuration file other than /etc/lilo.conf?
lilo -C config_file
When do you need to run the lilo command?
The lilo command installs a two-stage boot loader. It must be executed any time your boot options (eg kernel, config) change.
Recap on the options you know for the command:
dpkg
-S search for files installed by package
-L list files in package
-s show status of package
-i install package
-r remove package
--purge remove package and config files
--configure configures an unpacked package
How would you convert a .deb package to .rpm format
alien --to-rpm package.deb
How would you convert an .rpm package to .deb format
alien -r package.rpm
When setting the bash prompt, what does \W represent?
The basename of the working directory.
What does it mean to 'export' a variable?
A shell variable is not available outside the shell unless it is exported to the environment, becoming an environment variable. All child processes and shells can access exported environment variables.
How do you view man pages for a system call named bind?
man 2 bind

1 = user programs
2 = system calls
3 = library calls
4 = special files (usually in /dev)
5 = file formats
6 = games
7 = misc
8 = system admin
How would you find out which man pages were available for mkfifo?
man -wa mkfifo

-w show location, don't print the man pages
-a by default man shows the first available page and exits, but -a shows all pages.
'ps' command refresher
-a non-daemon processes owned by all users
-f full format, showing arguments to the processes
-l long format including PID, priority etc
-u user format, with usernames and process times
-w wide format
-x include daemons
How would you show a process tree with PIDs included
pstree -p
How would you take 5 process snapshots, one every second, and output to a file?
top -bi -n 5 -d 1 > file

-b batch mode
-i ignore idle processes (interesting only)
-n number of times to run
-d delay (sec)
Which file shows the paramerets that were passed to the kernel during boot?
/proc/cmdline
Which dpkg argument scans for partially installed packages and suggests how to fix them?
dpkg -C
or
dpkg --audit
How would you send a USR1 signal to all Apache httpd processes?
The USR1 signal asks Apache to stop allowing new connections, wait for the current ones to die, reread the config files, re-open its log files, and restart the server, allowing for relatively smooth in-production changes.

You can do this with the command:

apachectl -k graceful

You can also do it with the kill command:

kill -s USR1 [pid]
Which signal will be sent to a process when you press Ctrl+c on a terminal?
SIGINT

Note: Ctrl + \ or Ctrl + Y will send the SIGQUIT signal
Which directory is the YUM repository in?
/etc/yum.repos.d
How would you convert a DOS file to Unix using tr?
Tell tr to remove the carriage return:

tr -d '\r' < DOS_file > UNIX_file
Where are man files usually located?
/usr/share/man
Where would you normally find documentation for installed programs?
/usr/share/doc/
If you install grub using --root-directory=/custom-grub, where will the menu.lst file be created?
/custom-grub/boot/menu.lst

Grub treats /custom-grub as / and then creates a sub-directory 'boot' into which it places the menu.lst file.
What is the numerical equivalent to SIGHUP
1
What is the difference between S and K symlinks in /etc/init.d/rc*.d/?
Each runlevel has its own rc folder folder in /etc/init.d/ and each of these folders contain symlinks to service files that are located in /etc/init.d.

S symlinks are placed inside any runlevel that the service should be started, and K symlinks should be placed at runlevels where the service should be killed.

There should never be an S and K symlink for a service inside the same runlevel directory.
research the whole "cat <<" thing
whenever
What does the shopt command do?
If executed without arguments, shopt displays modifiable shell options.

Other arguments:

-s set
-u unset
What is the source command used for?
It can read and execute commands from non-executable files.
What does this command do?

mke2fs -j /dev/sda1
mke2fs is the ext-specific version of mkfs, which has additional options for that particular filesystem.

The -j option instructs mke2fs to add a journal, thus creating an ext3 filesystem
Which Linux filesystem cannot dynamically creat inodes?
ext2/3.

Other linux filesystems such as Reiser and xfs can create inodes dynamically, but ext2/3 have their allocation set during creation.
How could you prevent non-root users from logging into a system
create the file /etc/nologin
Which "apt-get" option switch will cause "half-installed" packages to complete the installation process?
apt-get -f
OR
apt-get --fix-broken
When you use apt-get to install a package, in which directory does the downloaded package get stored?
/var/cache/apt/archives
On a Debian or Ubuntu system, which directory is used to store information about what packages are installed or available, and about what updates are available? (Enter the entire path.)
/var/lib/dpkg
With dpkg, how do you ensure that you don't overwrite a newer version of the same package?
dpkg -R package.deb
http://www.studystack.com/flashcard-146269
more flashcards
http://www.proprofs.com/flashcards/cardshowall.php?title=lpi-101-flash-cards
more flashcards
How could you monitor the amount of free inodes on /dev/hda3 ?
df -i /dev/hda3
How would you find out what type of quota is active for user "mcfoo"
repquota mcfoo

(The default action of repquota is -u which reports user quotas)
In vi command mode, what does ZZ do?
This will exit vi, saving changes if there are any
What program is used to tune the screen settings after installing X11?
xvidtune
http://www.linux-praxis.de/lpisim/lpi102sim/index.html
102 exam
What command will load a kernel module along with all necessary dependencies?
modprobe
You wish to load a module, but you don't know which options can be used. How do you find out?
modinfo
When submitting a print job using lpr, how do you print 5 copies?
lpr -5 -Pprinter /tmp/file
Which file contains the welcome message being displayed by getty before the login?
/etc/issue
How do you check if the file /tmp/foo exists and is owned by the user.
test -O /tmp/foo
What would this command do?
userdel -r foo
It removes the user 'foo' and deletes his home directory.
In the latest versions of Linux, what two utilities have replaced the "scsi_info" utility that used to be in older versions of Linux?
sginfo & lsscsi
On a modern Linux system, which program monitors for hotplug events?
udev
http://www.proprofs.com/flashcards/cardshowall.php?title=lpi-101-flash-cards
more flashcards
http://www.penguintutor.com/cgi-bin/quiz/index.pl
practise exams