The Linux Command Line

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

find Size units: w

2-byte words

ls -l /boot/grub>> ls-output.txt

Append redirected output of the ls -l /boot/grub command to ls-output.txt.

kill -18 or kill -cont

Continue. This will restore a program after a STOP signal.

vmstat #

Continuous display of vmstat with a time delay of # sec.

Vim (Text Deletion Commands) - d0

Deletes from the current cursor location to the beginning of the line.

Vim (Text Deletion Commands) - 3x

Deletes the current character and the next two characters.

Vim (Text Deletion Commands) - x

Deletes the current character.

Vim (Text Deletion Commands) - 5dd

Deletes the current line and the next four lines.

apropos

Display a list of appropriate commands.

locate bin/zip

Display a list of files ending in bin/zip

TAB-TAB

Display a list of possible completions.

whatis

Display a very brief description of a command.

apropos searchterm

Display appropriate commands relevant to searchterm.

Less: h

Display help screen.

rm -v or rm --verbose

Display informative messages as the deletion is performed.

mv -v or mv --verbose

Display informative messages as the move is performed.

ls -ltr

Display long results with most recent files last.

Environment Variable: LANG

Defines the character set and collation order of your language.

rm -r file1 dir1

Delete file1 and dir1 (and its contents)

rm -rf file1 dir1

Delete file1 and dir1 (and its contents). If either file1 or dir1 does not exist, rm will continue without a prompt.

rm file1

Delete file1.

Package management system: Low level tools

Handle tasks such as installing and removing package files (dpkg)

Additions to .bashrc: export HISTSIZE=1000

Increases the size of the command history from the default of 500 lines to 1000 lines.

type

Indicate how a command name is interpreted.

Vim - ~

Indicate that no text exists on that line.

Metacharacters: Multiple ranges: [A-Za-z0-9]

Indicates the ranges A-Z, a-z, and 0-9.

Vim (Moving the Cursor Around) - CTRL-b or PAGE UP

Moves cursor up one page.

How do you access the virtual terminal/console?

Press CTRL-ALT-F1 through CTRL-ALT-F6.

Domain name

Typically a web address linked to an IP address.

Login Shell Session Startup Files: ~/.bash_profile

A user's personal startup file. Can be used to extend or override settings in the global configuration script.

Non-Login Shell Session Startup Files: ~/.bashrc

A user's personal startup file. Can be used to extend or override settings in the global configuration script.

alias foo="cd Documents"

A user-defined command called foo which is equivalent to the command "cd Documents".

What is an alias?

A user-defined command.

Synopsis of cat

cat [OPTION]... [FILE]...

cd dir is the same as typing what command?

cd ./dir

Synopsis of cd

cd [directory]

Synopsis of info

info [OPTION]... [MENU-ITEM...]

When a system starts up, the kernel initiates a few of its own activities and launches a program called _____ (parent process) which runs shell scripts (child process) which start all system _____.

init, services

Synopsis of ls

ls [OPTION]... [FILE]...

Octal File Mode: 4

r--

Octal File Mode: 5

r-x

Synopsis of man

man name

Synopsis of mkdir

mkdir [OPTION ...] DIRECTORY ...

Synopsis of sort

sort [OPTION]... [FILE]... sort [OPTION]... --files0-from=F

Synopsis of which

which [filename]...

zip

zip - Package and compress files.

Synopsis of zip

zip [zipfile [file ...]]

top Information Fields: # users

# users are logged in.

top Information Fields: #%ni

#% of the CPU is being used by nice (low-priority) processes.

top Information Fields: #%sy

#% of the CPU is being used for system (kernel) processes.

top Information Fields: #%us

#% of the CPU is being used for user processes (outside of the kernel itself).

Metacharacters: [#-#] (bracket expressions)

- Indicates a # range (i.e. 0-9)

Metacharacters: [character-character] (bracket expressions)

- indicates a character range (i.e. [a-c]zip indicates azip, bzip, or czip).

Octal File Mode: 0

---

Octal File Mode: 1

--x

cut Selection Options: -d delim_char

-d delim_char When -f is specified, use delim_char as the field delimiting character. By default, fields must be separated by a single tab character.

sort Options: -t or --field-separator=char

-t --field-separator=char Define the field-separator character. By default fields are separated by spaces or tabs.

Octal File Mode: 2

-w-

What are the file descriptors for the standard input, output, and error file streams?

0, 1, and 2 respectively.

What four things can commands be?

1. Executable programs 2. Shell built-ins 3. A shell function 4. An alias

find Size units: b

512-byte blocks

cd /path/to/dir is what kind of pathname?

An absolute pathname.

Debian style (.deb)

A packaging system

What is Less?

A pager program (allows for easy viewing of long text documents page by page)

File Type Attributes: -

A regular file.

u+x, go=rw

Add execute permission for the owner and set the permissions for the group and others to read and execute.

Text enclosed in double quotes

All special characters are treated as ordinary characters except $ (dollar sign), \ (blackslash), and ` (back tick). Combines several arguments into one argument.

Command substitution

Allows the use of the output of a commands as an expansion.

Vim - Command mode

Almost every key is a command.

Wildcard: *

Any characters.

Mounting

Attach a device to the filesystem tree.

TAB

Autocompletes an (unique) pathname, variable, username, command, or hostname.

What type of characters should be avoided in filenames?

Avoid punctuation characters and spaces.

/boot

Contains the linux kernel, initial RAM disk image (for drivers needed at boot time), and the boot loader.

/usr/lib

Contains the shared libraries for the programs in /usr/bin.

Backslash escape sequence: \b

Backspace.

rm -i or rm --interactive

Before deleting an existing file, prompt the user for confirmation.

rm -i file1

Before deleting file1, prompt the user for confirmation.

mv -i or mv --interactive

Before overwriting an existing file, prompt the user for confirmation.

cp -i or cp --interactive

Before overwriting an existing file, prompt the user.

Backslash escape sequence: \a

Bell ("alert" - causes the computer to beep).

find File Types: b

Block special device file.

fold -w 12 -s

Break the line at the last available space before the line width is reached.

xargs

Build and execute command lines from standard input

make

Builds a program using the instructions in a Makefile.

sort Options: -b or --ignore-leading-blanks

By default, sorting is performed on the entire line, starting with the first character in the line. This option causes sort to ignore leading spaces in lines and calculates sorting based on the first non-whitespace character on the line.

find Size units: c

Bytes

/usr/sbin

Contains system administration programs.

BSD-style ps Column headers: %CPU

CPU usage as a percent.

cancel

Cancel print jobs.

lprm

Cancel print jobs.

Backslash escape sequence: \r

Carriage return.

Metacharacters: ^ (caret) (anchor)

Cause the match to occur only if the regular expression is found at the beginning of the line (i.e. ^zip).

Metacharacters: $ (dollar sign) (anchor)

Cause the match to occur only if the regular expression is found at the end of the line (i.e. zip$).

Additions to .bashrc: export HISTCONTROL=ignoredups

Causes the shell's history recording feature to ignore a command if the same command was just recorded.

chgrp

Change a file's group ownership.

chmod

Change a file's mode. Can only be used by the file's owner or superuser.

chown

Change a file's owner. Requires superuser privileges.

passwd

Change a user's password.

touch

Change file times

cd

Change the directory (to home directory).

cd -

Change the directory to the previous working directory.

find File Types: c

Character special device file.

POSIX Character Classes: [:xdigit:]

Characters used to express hexadecimal numbers. In ASCII, equivalent to: [0-9A-Fa-f]

Cursor Movement: CTRL-L

Clear the screen and move the cursor to the top left corner. The clear command does the same thing.

clear

Clear the screen.

sort file1.txt file2.txt file3.txt > final_sorted_list.txt

Combine three text files into a single sorted file.

ps: CMD

Command

diff

Compare files line by line

comm

Compares two sorted text files and displays the lines that are unique to each one and the lines they have in common. The first column contains lines unique to the first file argument; the second column, the lines unique to the second file argument; the third column contains the lines shared by both files.

gzip foo.txt

Compress foo.txt to foo.txt.gz

gzip

Compress or expand files.

cat

Concatenate (join) files. Read one or more files and copies them to standard output.

/sbin

Contains "system" binaries.

top Information Fields: hh:mm:ss

Current time of the day.

gzip Options: -d or --decompress or --uncompress

Decompress a file.

join

Data from multiple tables with a shared key field is combined.

dpkg

Debian Package Manager, an installation and packaging tool.

echo "$(cal)"

Displays the calendar formatted correctly (with delimiters) w/o highlighting the current date.

echo $(cal)

Displays the calendar with each text string separated

date

Displays the current date, time, and timezone.

jobs

Displays the current list of jobs.

ls -l "two words.txt"

Displays the long list format of two words.txt.

ls -l two\ words.txt

Displays the long list format of two words.txt.

echo ~username

Displays the name of the home directory of username.

ls -l /bin/usr 2> /dev/null

Dispose of the error message of the ls -l /bin/usr command.

Operator: /

Division (results are integers, regardless if remainders exist).

vim file1 file2 file3...

Edit multiple files at the same time in vim.

echo -e

Enables interpretation of escape sequences.

Dependency resolution

Ensures that when a package is installed, all of its dependencies are installed as well.

Vim - ESC

Enter command mode

Vim - i

Enter insert mode

sudo su

Gain access to superuser privileges

help

Get concise and accurate help for shell builtins.

Package maintainer

Gets software in source code from an upstream provider (the author of the program), compiles it, and creates the package metadata and any necessary installation scripts.

find Size units: G

Gigabytes (units of 1073741824 bytes)

Vim (Global Search-and-Replace Syntax) - g

Global (substitution is performed on every instance of the search string in each line). If g is omitted, only the first instance of the search string on each line is replaced.

find Numeric Argument: +

Greater than

How do you automatically copy text?

Highlight the text in question.

Processes

How Linux organizes the different programs waiting for their turn at the CPU.

Login Shell Session Startup Files: ~/.profile

If neither ~/.bash_profile nor ~/.bash_login is found, bash attempts to read this file.

uniq Options -i

Ignore case during the line comparisons.

uniq Options: -f n

Ignore n leading fields in each line. Fields are separated by whitespace as they are in sort; however, unlike sort, uniq has no option for setting an alternate field separator.

ls -l -h or ls -l --human-readable

In long format listings, display file sizes in human-readable format rather than in bytes.

cat < lazy_dog.txt

Input the text of lazy_dog.txt into the cat command which outputs the text on the screen.

Interpreter

Inputs the program file and reads and executes each instruction contained within it. Each source code instruction is translated every time it is carried out.

Vim (Inserting an Entire File into Another) - r file

Insert an entire file at the cursor location.

Vim - Insert mode

Insert text.

aspell

Interactive spell checker

What is a parent directory?

It is the directory directly above.

cat movie.mpeg.0* > movie.mpeg

Join mpeg files movie.mpeg.001, movie.mpeg.002, movie.mpeg.003, ... into movie.mpeg.

find Tests: -iname pattern

Like the -name test but case insensitive.

find Tests: -type c

Match files of type c.

find Logical Operators: -and

Match if the tests on both sides of the operator are true. May be shortened to -a. Note that when no operator is present, -and is implied by default.

find Size units: M

Megabytes (units of 1048576 bytes)

BSD-style ps Column headers: %MEM

Memory usage as a percent.

Operator: %

Modulo (remainder).

mount

Mount a filesystem. Display a list of the filesystems currently mounted.

Cursor Movement: ALT-B

Move cursor backward one word.

Operator: *

Multiplication

top Information Fields: top

Name of the program.

Backslash escape sequence: \n

Newline.

apt-get

Package handling utility.

How do you paste automatically copied text?

Press the middle mouse button.

lpr

Print files

Less: q

Quit Less.

Process State: R

Running. The process is running or ready to run.

Vim - :ZZ

Save the current file and exit vim.

uniq Options: -s n

Skip (ignore) the leading n characters of each line.

Vim (Replace Confirmation Keys) - n

Skip this instance of the pattern.

sort Options: -r or --reverse

Sort in reverse order. Results are in descending rather than ascending order.

kill -15 or kill -term

Terminate a program.

POSIX Character Classes: [:alpha:]

The alphabetic characters. In ASCII, equivalent to: [A-Za-z].

POSIX Character Classes: [:alnum:]

The alphanumeric characters. In ASCII, equivalent to: [A-Za-z0-9]

ps: TIME

The amount of cpu time consumed by the process.

Environment Variable: PWD

The current working directory.

/root

The home directory for the root account.

What are arguments in commands?

The items upon which the command acts.

POSIX Character Classes: [:lower:]

The lowercase letters.

Pathname expansion

The mechanism by which wildcards work.

Environment Variable: PAGER

The name of the program to be used for paging output. This is often set to /usr/bin/less

POSIX Character Classes: [:digit:]

The numerals zero through nine.

Environment Variable: HOME

The pathname of your home directory.

Environment Variable: OLD_PWD

The previous working directory.

POSIX Character Classes: [:print:]

The printable characters. All the characters in [:graph:] plus the space character.

What are scripts?

They are programs that the system uses.

What do configuration files do?

They contain system settings.

What do options in commands do?

They modify the behavior of the commands.

Vim - u

Undo.

Parameter Expansion

Used to work with variables.

BSD-style ps Column headers: USER

User ID. This is the owner of the process.

ping address

Verify connection to address

ping -c # address

Verify connection to address # times

diff -c file1.txt file2.txt

View the differences between file1.txt and file2.txt in context format.

diff -u

View the differences between files in unified format

Vim (Switching between files) - buffers

View the list of files being edited. Each file has its own buffer #.

kill -28 or kill -winch

Windows change. This is a signal sent by the system when a window changes size. Some programs, like top and less, will respond to this signal by redrawing themselves to fit the new window dimensions.

Are filenames with a period hidden by default?

Yes.

Can multiple short options be strung together?

Yes.

Environment Variable: USER

Your username

Metacharacters: [^characters] (bracket expressions)

^ indicates that the remaining characters are taken to be a set of characters that must not be present at the given character position (i.e. [^bg]zip lists results containing the string "zip" preceded by any character except "b" or "g". Loses its special meaning if its not the first character.

echo a{A{1,2},B{3,4}}b

aA1b, aA2b, aB3b, aB4b

Synopsis of bg

bg [JOBSPEC]

Synopsis of bzip2

bzip2 [OPTION]... [name]...

Synopsis of cal

cal [options] [[month] year]

Synopsis of chgrp

chgrp [OPTION]... GROUP FILE... chgrp [OPTION]... --reference=RFILE FILE...

Synopsis of chmod

chmod [-R] mode file ...

Synopsis of chown

chown [OPTION]... [OWNER][:[GROUP]] FILE... chown [OPTION]... --reference=RFILE FILE...

Synopsis of comm

comm [OPTION]... FILE1 FILE2

What is the form a command is written in?

command -options arguments and/or --options for long options

What is the form multiple commands on one line are written in?

command1; command2; command3

Synopsis of cp

cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE...

Synopsis of df

df [OPTION]... [FILE]...

Synopsis of diff

diff file1 file2

Synopsis of dpkg

dpkg [option...] action

Data stored in the _____ is used by programs to determine facts about our configuration.

environment.

Synopsis of fg

fg [JOBSPEC]

Synopsis of find

find [path...] [expression]

Synopsis of fold

fold [OPTION]... [FILE]...

Synopsis of free

free [options]

Synopsis of grep

grep [OPTIONS] PATTERN [FILE...]

Synopsis of gzip

gzip [OPTION]... [name...]

Synopsis of jobs

jobs [options] [JOBSPEC]

Synopsis of join

join [options] file1 file2

Synopsis of kill

kill [options] <pid> [...]

Synopsis of killall

kill name ...

Synopsis of ln

ln [-fs] source_file target_file ln [-fs] source_file ... target_dir

Synopsis of locate

locate [OPTION]... PATTERN...

Synopsis of mv

mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE...

Synopsis of nl

nl [OPTION]... [FILE]...

Non-login shells inherit the environment from their _____ _____, usually a login shell.

parent process

Synopsis of passwd

passwd [options] [LOGIN]

Synopsis of paste

paste [OPTION]... [FILE]...

Synopsis of ping

ping [-c count] host

Synopsis of printenv

printenv [OPTION]... [VARIABLE]...

Synopsis of ps

ps [options]

Synopsis of rm

rm [OPTION]... FILE...

Octal File Mode: 6

rw-

Octal File Mode: 7

rwx

Synopsis of shutdown

shutdown [options] time (min)

Login and non-login shell sessions read a different set of _____ _____

startup files .

What are abbreviations for standard input, standard output, and standard error?

stdin, stdout, and stderr.

Synopsis of tail

tail [OPTION]... [FILE]...

Synopsis of unzip

unzip file[.zip] [file(s) ...]

Synopsis of type

type [name]...

Synopsis of umask

umask [-S] [mask]

Synopsis of uniq

uniq [OPTION]... [INPUT [OUTPUT]]

Synopsis of uniq .

uniq [OPTION]... [INPUT [OUTPUT]]

Synopsis of vmstat

vmstat [options] [delay [count]]

Synopsis of wc

wc [OPTION]... [FILE]... wc [OPTION]... --files0-from=F

Synopsis of wget

wget [option]... [URL]...

Synopsis of whatis

whatis [name]...

top Information Fields: #%id

#% of the CPU is idle.

top Information Fields: #%wa

#% of the CPU is waiting for I/O

Octal File Mode: 3

-wx

Name three reasons to launch a graphical program from the command line

1. Might not be listed on the window's manager's menu. 2. See error messages. 3. Use cli options

bzip2

A block sorting file compressor.

File Type Attributes: b

A block special file. This file type refers to a device that handles data in blocks, such as a hard drive or CD-ROM drive.

File Type Attributes: c

A character special file. This file type refers to a device that handles data as a stream of bytes, such as a terminal or modem.

Metacharacter

A character that has a special meaning (instead of a literal meaning) to a computer program, such as a shell interpreter.

Operator

A character that represents an action.

Environment Variable: PATH

A colon-separated list of directories that are searched when you enter the name of an executable program.

What is BASH (Bourne Again Shell)?

A common shell program from the GNU Project found on almost all Linux distributions.

Package File

A compressed collection of files that compromise a software package. It may contain programs, data files that support the programs, metadata about the package, and pre- and post-installation scripts that perform configuration tasks before and after package installation.

Process State: Z

A defunct or "zombie" process. This is a child process that has terminated, but has not been cleaned up by its parent.

File Type Attributes: d

A directory.

drwxrwx---

A directory. The owner and the members of the owner group may enter the directory and create, rename, and remove files within the directory.

What is a symbolic link?

A file that references other files.

kill -1 2425 or kill -HUP 2425

A foreground program with PID 2425 running on the terminal will be sent a signal to terminate and the shell indicates that a process received a hangup signal.

Login Shell Session Startup Files: /etc/profile

A global configuration script that applies to all users.

Non-Login Shell Session Startup Files: /etc/bash.bashrc

A global configuration script that applies to all users.

xload

A graphical program that draws a graph showing system load over time.

Processor State: <

A high-priority (not nice) process.

Uniform Resource Identifier (URI)

A label that identifies an abstract or physical resource.

Hostname

A label that is used to identify the device in various forms of electronic communication such as the World Wide Web, e-mail or Usenet.

Vim

A lightweight, fast text editor.

diff Context-Format Change Indicators: +

A line added. This line will appear in the second file but not in the first file.

diff Context-Format Change Indicators: !

A line changed. The two versions of the line will be displayed, each in its respective section of the change group.

diff Context-Format Change Indicators: -

A line deleted. This line will appear in the first file but not in the second file.

diff Context-Format Change Indicators: (none)

A line shown for context. It does not indicate a difference between the two files.

Processor State: N

A low-priority (nice) process.

Package Management

A method of installing and maintaining software on the system.

What is an info page?

A more comprehensive alternative to man pages displayed with a reader program (a program that displays info in a website-like manner).

IP (Internet Protocol) address

A number assigned to a device participating in a network that uses the Internet Protocol for communication

ps: PID (Process Identifier)

A number assigned to a process.

What is a relative pathname?

A pathname that begins from the current working directory and uses . (dot) and .. (dot dot) to represent relative positions in the filesystem. . (dot) refers to the working directory and .. (dot dot) refers to the working directory's parent directory.

What is an absolute pathname?

A pathname that begins with the root directory and follows the tree branch by branch until the path to the desired directory or file is completed.

What is a manual (man) page?

A piece of documentation for executable programs displayed with Less.

What is the terminal emulator?

A program that gives access to the shell.

What is the shell?

A program that takes keyboard commands and passes them to the operating system to carry out.

Linker

A program used to form the connections between the output of the compiler and the libraries that the compiled program requires.

Vim (Global Search-and-Replace Syntax) - c

A prompt asking for confirmation for each substitution.

-rwx------

A regular file that is readable, writable, and executable by the file's owner. No one else has any access.

-rwxr-xr-x

A regular file that is readable, writable, and executable by the file's owner. The file may be read and executed by everybody else.

cd ./dir is what kind of pathname?

A relative pathname.

What is a pathname?

A route taken along the filesystem to get to the desired directory.

Library

A shared collection of routines that different programs can use.

Repository

A storage location from which software packages may be retrieved and installed on a computer.

lrwxrwxrwx

A symbolic link with dummy values. The real permissions are kept with the actual file pointed to by the symbolic link.

File Type Attributes: l

A symbolic link. The remaining file attributes are rwxrwxrwx and are dummy values. The real file attributes are those of the file the symbolic link points to.

+x

Add execute permission for the owner, group, and world. Same as a+x.

chmod u+rw

Add read and write permission for the owner.

Operator: +

Addition

paste

Adds one or more columns of text to a file

File descriptor

An abstract indicator used to access a file or other input/output resource, such as a pipe or network connection.

History Expansion

An expansion for items in the history list by using the ! character.

>>

An operator that appends redirected output to a file instead of overwriting the file.

<

An operator that changes the source of stdin from the keyboard to a file.

>

An operator that redirects standard output from the screen to a file.

./configure

Analyze the build environment to produce a Makefile.

Wildcard: [:alpha:]

Any alphabetic character.

Wildcard: [:alnum:]

Any alphanumeric character.

Wildcard: [characters]

Any character that is a member of the set characters.

Wildcard: [[:class:]]

Any character that is a member of the specified class.

Wildcard: [!characters]

Any character that is not a member of the set characters.

Wildcard: BACKUP.[0-9][0-9][0-9]

Any file beginning with BACKUP. followed by exactly three numerals.

Wildcard: Data???

Any file beginning with Data followed by exactly three characters.

Wildcard: [[:upper:]]*

Any file beginning with an uppercase letter.

Wildcard: b*.txt

Any file beginning with b followed by any characters and ending with .txt.

Wildcard: [abc]*

Any file beginning with either a, b, or c.

Wildcard: g*

Any file beginning with g.

Wildcard: *[[:lower:]123]

Any file ending with a lowercase letter or the numerals 1, 2, or 3.

Wildcard: [![:digit:]]*

Any file not beginning with a numeral.

Wildcard: [:lower:]

Any lowercase letter.

Wildcard: [:digit:]

Any numeral.

Wildchard: ?

Any single character.

Wildcard: [:upper:]

Any uppercase letter.

ls -F or ls --classify

Append an indicator name to the end of each listed name (i.e. a forward slash if the name is a directory).

tar Modes: r

Append specified pathnames to the end of an archive.

patch

Apply a diff file to an original

cd ~username

Change the working directory to the home directory of username.

chown [owner] [[:group]] file...

Changes a file' s owner to owner and group owner to group

cd .

Changes directory to working directory.

chown bob:admins foo.txt

Changes the file's owner to bob and group owner to admins.

chown bob: foo.txt

Changes the file's owner to bob and group owner to the login group of user bob.

Vim (Global Search-and-Replace Syntax) - :%s/Line/line/gc

Changes the word Line to line for the entire file (asks for confirmation for each substitution).

cd dir

Changes to a directory called "dir" in the working directory.

cd ..

Changes to the working directory's parent directory.

Makefile

Configuration file that instructs the make program exactly how to build the program.

/dev

Contains a list of device nodes (the devices the kernel understands).

.bash_history

Contains a list of previously used commands.

/lost+found

Contains a partial recovery from a filesystem corruption event.

/proc

Contains a virtual filesystem maintained by the Linux kernel and provides a picture of how the kernel sees the computer.

/etc

Contains all of the system-wide configuration files and a collection of shell scripts that start each of the system services at boot time.

/usr

Contains all the programs and support files used by regular users.

/usr/share

Contains all the shared data used by programs in /usr/bin.

/bin

Contains binaries (programs) that must be present for the system to boot and run.

/opt

Contains commercial software products that may be installed on the system.

/var

Contains data that is likely to change.

/usr/share/doc

Contains documentation of packages installed on the system.

/var/log

Contains log files (records of various system activity).

/media

Contains mount points for removable media such as USB drives, CD-ROMS, etc. that are mounted automatically at insertion.

/usr/local

Contains programs that are not included with the distribution but are intended for system-wide use are installed.

/lib

Contains shared library files used by the core system programs.

/tmp

Contains temporary, transient files created by various programs.

/usr/bin

Contains the executable programs installed by your Linux distribution.

pr

Convert text files for printing

Text Editing: ALT-L

Convert the characters from the cursor location to the end of the word to lowercase.

Text Editing: ALT-U

Convert the characters from the cursor location to the end of the word to uppercase.

Vim (Copying (Yanking) Commands) - y20G

Copes from the current line to the 20th line of the file.

Vim (Copying (Yanking) Commands) - y0

Copies from the current cursor location to the beginning of the line.

Vim (Copying (Yanking) Commands) - y$

Copies from the current cursor location to the end of the current line.

Vim (Copying (Yanking) Commands) - y^

Copies from the current cursor location to the first non-whitespace character in the line.

Vim (Copying (Yanking) Commands) - yG

Copies from the current line to the end of the file.

Vim (Copying (Yanking) Commands) - yW

Copies the current cursor location to the beginning of the next word.

Vim (Copying (Yanking) Commands) - 5yy

Copies the current line and the next four lines.

Vim (Copying (Yanking) Commands) - yy

Copies the current line.

cp -r dir1 dir2

Copy a directory (recursively) into dir2.

cp sourcefile destfile

Copy a file named sourcefile to destfile.

cp dir1/* dir2

Copy all the files in dir1 into dir2.

cp

Copy files and directories.

cp file1 file2 dir

Copy files to a directory.

cp -a or cp --archive

Copy the files and directories and all of their attributes, including ownerships and permissions.

find ~ | wc -l

Counts the number of files in the home directory.

tar czf playground.tgz playground

Create a gzipped archive that contains playground.

ln file link

Create a hard link for the file data file.

ln fun fun-hard

Create a hard link named fun for the fun data file.

ln

Create a hard link.

ln -s file* symlink

Create a symbolic link named symlink for file*

ln -s

Create a symbolic link.

zip -r playground.zip playground

Create a zip file called playground.zip that contains playground.

alias

Create an alias for a command.

tar Modes: c

Create an archive from a list of files and/or directories.

tar cf playground.tar playground

Create an archive that contains playground.

mkdir dir1 dir2 dir3

Create directories dir1, dir2, and dir3

mkdir

Create directories.

vim foo.txt

Create foo.txt using vim.

mkdir -p dir1/dir2

Create nested directories.

ln -s ../fun dir1/funsym

Created a symbolic link named funsym in dir1 for the fun file*.

ls /bin /usr/bin | sort | less

Creates a combined list of all the executable programs in /bin and /usr/bin, put them in sorted order, and then view the list with less.

ls /bin /usr/bin | sort | uniq | less

Creates a combined list of all the executable programs in /bin and /usr/bin, put them in sorted order, removes duplicated lines, and then view the list with less.

ls /bin /usr/bin | sort | uniq | grep zip | less

Creates a combined list of all the executable programs in /bin and /usr/bin, put them in sorted order, removes duplicated lines, print lines with zip, and then view the list with less.

find ~ -type f -name '*.BAK' -delete

Delete files that have the file extension ".BAK" (which is often used to designate backup files) in the home directory (and its subdirectories)

Text Editing: CTRL-D

Delete the character at the cursor location.

Predefined find Actions: -delete

Delete the matching file

Vim (Text Deletion Commands) - dW

Deletes from the current cursor location to the beginning of the next word.

Vim (Text Deletion Commands) - d$

Deletes from the current cursor location to the end of the current line.

Vim (Text Deletion Commands) - d^

Deletes from the current cursor location to the first non-whitespace character in the line.

Vim (Text Deletion Commands) - d20G

Deletes from the current line to the 20th line of the file.

Vim (Text Deletion Commands) - dG

Deletes from the current line to the end of the file.

Vim (Text Deletion Commands) - d

Deletes the current character and places it in a paste buffer.

Vim (Text Deletion Commands) - dd

Deletes the current line.

find File Types: d

Directory.

info

Display a command's info page.

man

Display a command's manual page.

apt-cache show package_name

Display a description of the package.

dpkg -l or dpkg --list

Display a list of all the packages installed on the system.

locate zip | grep bin

Display a list of files with zip and bin in the name.

file

Display brief description of a file* content and filetype.

ls -l -d or ls -l --directory

Display details about the directory rather than its contents.

stat

Display file or file system status

cp -v or cp --verbose

Display informative messages as the copy is performed

cat -A

Display non-printing characters in the output.

ls -l

Display results of the directory's contents in a long format.

top

Display tasks.

free

Display the amount of free memory.

cat ls-output.txt

Display the contents of ls-output.txt.

history

Display the contents of the history list.

pwd

Display the name of the current working directory.

ls -r

Display the results in reverse alphabetical order (ls normally displays results in alphabetical order).

gzip Options: -h or --help

Display usage information.

id

Display user identity.

gzip Options: -v or --verbose

Display verbose messages while compressing.

dpkg --search file_name

Display what package installed file_name

dpkg -s package_name or dpkg --status package_name

Display whether a specified package is installed.

which

Display which executable program will be executed.

dpkg --search /usr/bin/emacs24-x

Display which package installed emacs24-x

cal

Displays a calendar of the current month.

--help

Displays a description of the command's supported syntax and options.

xlogo

Displays a program with the X windows system logo.

history | grep /usr/bin

Displays previous commands used to list /usr/bin.

Scripting/Interpreted Language

Do not require compiling but are executed directly by a special program called an interpreter.

wget http://linuxcommand.org/index.php

Download http://linuxcommand.org/index.php

tload

Draws a graph showing system load over time in the terminal.

sudo

Execute a command as another user.

History: CTRL-O

Execute the current item in the history list and advance to the next one.

Vim - :q

Exit vim.

!#

Expands !# into the contents of the !#th line in the history list.

Operator: **

Exponentiation.

export

Export environment to subsequently executed programs.

cut

Extract a section of text from a line and output the extracted section to standard output.

tar Modes: x

Extract an archive.

cut Selection Options: -f field_list

Extract one or more fields from the line as defined by field_list. The list may contain one or more fields or field ranges separated by commas.

unzip

Extract the contents of a zip file.

tar xf playground.tar

Extract the contents of playground.tar

cut Selection Options: --complement

Extract the entire line of text, except for those portions specified by -c and/or -f.

cut Selection Options: -c char_list

Extract the portion of the line defined by char_list. The list may consist of one or more comma-separated numerical ranges.

Permission Attributes: r

Files: Allows a file to be opened and read. Directories: Allows a directory's contents to be listed if the executable attribute is also set.

File Type Attributes: x

Files: Allows a file to be treated as a program and executed. Program files written in scripting languages must also be set as readable to be executed. Directories: Allows a directory to be entered e.g. cd directory.

File Type Attributes: w

Files: Allows a file to be written to or truncated but not deleted or renamed. Directories: Allows files within a directory to be created, deleted, and renamed if the execute attribute is also set.

command1 | filter | command2

Filter takes the input from command1, changes it, then outputs it. The output is the input for command2 which outputs even more results.

grep -i '^..j.r$' /usr/share/dict/words

Find all the words in the dictionary file that are five letters long and have a j in the third position and an r in the last position while ignoring case.

locate

Find files by name.

grep Options: -h or --no-filename

For multi-file searches, suppress the output of filenames. May also be specified --no-filename.

gzip Options: -f or --force

Force compression even if a compressed version of the original file already exists.

Vim - :q!

Force quit vim.

a2ps

Format files for printing on a Postscript printer

History: ALT-N

Forward search, non-incremental.

chmod -g

Group owner.

find Logical Operators: ( )

Groups tests and operators together to form larger expressions. Since the parentheses characters have special meaning to the shell, escape them with a backlash character

tar Modes: z

Gzip the archive (extensions .tgz or .tar.gz)

gzip Options: -r or --recursive

If one or more arguments on the command line are directories, recursively compress files contained within them.

Login Shell Session Startup Files: ~/.bash_login

If ~/.bash_profile is not found, bash attempts to read this script.

grep -i

Ignore case sensitivity when performing the search.

grep Options: -i or --ignore-case

Ignore case. Do not distinguish between upper and lower case characters. May also be specified --ignore-case.

rm -f or rm --force

Ignore nonexistent files and do not prompt. Overrides the --interactive option.

How are files organized in a hierarchical directory structure?

In a singled root tree-like pattern of directories (folders).

POSIX Character Classes: [:blank:]

Includes the space and tab characters.

dpkg -i package_file or dpkg --install package_file

Install package_file w/o dependency resolution.

apt-get install package_name

Install package_name with dependency resolution.

make install

Install the final product in a system directory (usually usr/local/bin) for use.

ftp

Internet file transfer program

kill -2 or kill -int

Interrupt (terminates) a program. Performs the same function as CTRL-C in the terminal.

CTRL-C

Interrupts (terminates) a program.

grep Options: -v or --invert-match

Invert match. Normally, grep prints lines that contain a match. This option causes grep to print every line that does not contain a match.

Escaping character

Invokes an alternative interpretation on subsequent characters in a character sequence such as \ (backlash).

What does pressing the up-arrow key in the terminal do?

It brings up previously executed commands.

What is the current working directory?

It is the directory in use.

What does pressing the down-arrow key in the terminal do?

It makes the previous command disappear.

What does pressing the left and right arrow keys in the terminal do?

It positions the cursor on the current line.

Vim (Joining Lines Commands) - J

Joins the line below with the line above.

kill -9 or kill -kill

Kernel immediately terminates the process and cannot be ignored (the process doesn't get an opportunity to clean up or save its work).

killall xlogo

Kill all instances of xlogo.

killall -u username

Kill all processes running on username.

killall

Kill processes by name.

Cut and Paste (Kill and Yank) Text: ALT-L

Kill text from the cursor location to the beginning of the current word. If the cursor is at the beginning of a word, kill the previous word.

Cut and Paste (Kill and Yank) Text: ALT-D

Kill text from the cursor location to the end of the current word.

Cut and Paste (Kill and Yank) Text: CTRL-U

Kill text from the cursor location to the end of the current word.

Cut and Paste (Kill and Yank) Text: CTRL-K

Kill text from the cursor location to the end of the line.

find Size units: k

Kilobytes (units of 1024 bytes)

find Numeric Argument: -

Less than

grep Options: -L or --files-without-match

Like the -l option, but print only the names of files that do not contain matches.

jobs .

List active jobs.

ls -a or ls --all

List all files, even those that begin with a period (i.e. hidden).

ps x

List all of our processes.

ps aux

List all processes belonging to every user.

gzip Options: -l or --list

List compression statistics for each file compressed.

echo /usr/*/share

List directories which have the /usr/*/share pattern such as /usr/local/share.

ls

List directory contents.

echo *s

List the contents of a directory ending with s.

echo [[:upper:]]*

List the contents of a directory starting with an uppercase letter.

unzip Options: -l

List the contents of a zip file.

tar Modes: t

List the contents of an archive.

echo *

Lists the contents of a directory (like ls) without coloring scheme.

find ~ \( -type f -not -perm 0600 \) -or \( -type d -not -perm 0700 \)

Look for all the files with permissions that are not 0600 and the directories with permissions that are not 0700.

ind ~ -type f -name "*.JPG" -size +1M

Look for all the regular files that match the wildcard pattern "*.JPG" and are larger than one megabyte

sort Options: -f or --ignore-case

Makes sorting case insensitive.

Metacharacters: [characters] (bracket expressions)

Match a single character from a specified set of characters (i.e. [bg]zip indicates bzip or gzip)

Metacharacters: . (dot) (the any character)

Match any character (i.e. .zip).

find Tests: -empty

Match empty files and directories.

find Tests: -nouser

Match file and directories that do not belong to a valid user. This can be used to find files belonging to deleted accounts or to detect activity by attackers.

find Tests: -group name

Match file or directories belonging to group. group may be expressed as either a group name or as a numeric group ID.

find Tests: -nogroup

Match files and directories that do not belong to a valid group.

find Tests: -newer file

Match files and directories whose contents were modified more recently than the specified file. This is very useful when writing shell scripts that perform file backups. Each time you make a backup, update a file (such as a log), and then use find to determine which files have changed since the last update.

find Tests: -name pattern

Match files and directories with the specified wildcard pattern.

find Tests: -size n or -size +n or -size -n

Match files greater than, less than, or size n.

find Tests: -user name

Match files or directories belonging to user name. The user may be expressed by a username or by a numeric user ID.

find Tests: -perm mode

Match files or directories that have permissions set to the specified mode. mode may be expressed by either octal or symbolic notation.

find Tests: -cmin n or -cmin +n or -cmin -n

Match files or directories whose content or attributes were last modified exactly n minutes ago. To specify less than n minutes ago, use -n and to specify more than n minutes ago, use +n.

find Tests: -ctime n or -ctime +n or -ctime -n

Match files or directories whose contents or attributes were last modified greater than, less than, or n*24 hours ago

find Tests: -cnewer file

Match files or directories whose contents or attributes were last modified more recently than those of file.

find Tests: -mmin n or -mmin +n or -mmin -n

Match files or directories whose contents were last modified greater than, less than, or n minutes ago.

find Tests: -mtime n

Match files or directories whose contents were last modified greater than, less than, or n*24 hours ago.

find Tests: -inum n

Match files with inode number n. This is helpful for finding all the hard links to a particular inode.

find Logical Operators: -or

Match if a test on either side of the operator is true. May be shortened to -o.

find Logical Operators: -not

Match if the test following the operator is false. May be abbreviated with an exclamation point (!).

Cursor Movement: CTRL-B

Move cursor backward one character; same as the left arrow key.

Cursor Movement: CTRL-F

Move cursor forward one character; some as the right arrow key.

Cursor Movement: ALT-F

Move cursor forward one word.

Cursor Movement: CTRL-A

Move cursor to the beginning of the line.

Cursor Movement: CTRL-E

Move cursor to the end of the line.

mv dir1 dir2

Move dir1 (and its contents) into dir2.

mv file1 file2 dir1

Move file1 and file2 into dir1.

mv file1 file2

Move file1 to file2.

mv -i file1 file2

Move file1 to file2. If file2 exists, the user is prompted before it is overwritten.

History: ALT-<

Move to the beginning (top) of the history list.

Less: g

Move to the beginning of the text file.

Less: G

Move to the end of the text file.

History: CTRL-N

Move to the next history entry. Same action as the down arrow.

History: CTRL-P

Move to the previous history entry. Same action as the up arrow.

mv

Move/rename files and directories.

Vim (Moving the Cursor Around) - j or down arrow

Moves cursor down one line.

Vim (Moving the Cursor Around) - CTRL-f or PAGE DOWN

Moves cursor down one page.

Vim (Moving the Cursor Around) - h or left arrow

Moves cursor left one character.

Vim (Moving the Cursor Around) - l or right arrow

Moves cursor right one character.

#-SHIFT-g

Moves cursor to line #

Vim (Moving the Cursor Around) - 0 (zero)

Moves cursor to the beginning of the current line.

Vim (Moving the Cursor Around) - w

Moves cursor to the beginning of the next word or punctuation character.

Vim (Moving the Cursor Around) - W

Moves cursor to the beginning of the next word, ignoring punctuation characters.

Vim (Moving the Cursor Around) - b

Moves cursor to the beginning of the previous word or punctuation character.

Vim (Moving the Cursor Around) - B

Moves cursor to the beginning of the previous word, ignoring punctuation characters.

Vim (Moving the Cursor Around) - $

Moves cursor to the end of the current line.

Vim (Moving the Cursor Around) - ^

Moves cursor to the first non-whitespace character on the current line.

Vim (Moving the Cursor Around) - G

Moves cursor to the last line of the file.

Vim (Moving the Cursor Around) - k or up arrow

Moves cursor up one line.

Vim (Searching Within a Line) - f[character] ENTER ;

Moves the cursor to the next occurrence character.

Are filenames not case sensitive?

No.

wget

Non-interactive network downloader

Where does output go to and input come from normally?

Normally, output goes to the screen and input comes from the keyboard

ls -l two words.txt

Not a valid command due to the space in the filename.

nl

Number lines

cat -n

Number lines in the output.

Non-login shell session

Occurs when we launch a terminal session in the GUI.

Filter: uniq

Omit duplicated lines.

Signals

One of several ways that the OS communicates with programs.

Delimiter

One or more characters that separates text strings such as unquoted spaces, tabs, and newlines.

Login shell session

One which prompts for a username and password.

uniq Options: -d

Only output repeated lines, rather than unique lines.

uniq Options: -u

Only output unique lines. This is the default.

Vim (Opening Additional Files for Editing) - e file

Open an additional file for editing.

Vim (Line Opening Keys) - O

Open the line above the current line.

Vim (Line Opening Keys) - o

Open the line below the current line.

ssh

OpenSSH SSH client (remote login program)

/home

Ordinary users can only write files here (protects the system from errant user activity).

uniq Options: -c

Output a list of duplicate lines preceded by the number of times the line occurs.

Predefined find Actions: -print

Output the full pathname of the matching file to standard output. This is the default action if no other action is specified.

pstree

Outputs a process list arranged in a tree-like pattern showing the parent/child relationships between processes.

vmstat

Outputs a snapshot of a system resource usage including memory, swap, and disk I/O.

Vim (Pasting Commands) - p

Paste the contents of the buffer after the cursor.

Vim (Pasting Commands) - P

Paste the contents of the buffer before the cursor.

patch < diff_file

Patch a file using a diff file.

Package management system: High level tools

Perform metadata searching and dependency resolution (apt-get)

Predefined find Actions: -ls

Perform the equivalent of ls -dils on the matching file. Output is sent to standard output.

Vim (Replace Confirmation Keys) - a

Perform the substitution on this and all subsequent instances of the pattern.

Vim (Replace Confirmation Keys) - y

Perform the substitution.

Vim (Replace Confirmation Keys) - l

Perform this substitution and then quit. Short for last.

sort Options: -n or --numeric-sort

Performs sorting based on the numeric evaluation of a string. Using this option allows sorting to be performed on numeric values rather than alphabetic values.

umask 0000 > foo.txt

Permissions set for foo.txt: -rw-rw-rw-

chmod 777 foo.txt

Permissions set for foo.txt: -rwxrwxrwx

command1 | command2

Pipe the stdout of command1 into the stdin of command2.

| (pipe operator)

Pipe the stdout of one command into the stdin of another.

ls -l /usr/bin | less

Pipe the stdout of the ls -l /usr/bin command into the stdin of the less program.

bg

Place a job in the background (immune from keyboard input and termination.

fg

Place a job in the foreground.

program &

Place a program in the background. Displays a job control number (jobspec) and PID.

grep Options: -n or --line-number

Prefix each matching line with the number of the line within the file.

diff -Naur -r old_file new_file > diff_file

Prepare a diff file. -r is mandatory for directories.

Lossless compression

Preserves all the data contained in the original.

echo '$USER $((2+2)) $(cal)'

Print $USER $((2+2)) $(cal).

echo Five divided by two equals $((5/2))

Print Five divided by two equals 2 (ignoring remainder).

find ~ -type d

Print a list of all the directories in the home directory.

find ~

Print a list of all the files in the home directory

lp

Print files (System V)

find ~ -type f -and -name '*.BAK' -and -print

Print files that have the file extensions ".BAK" in the home directory.

head

Print first (10) lines of a file.

tail

Print last (10) lines of a file.

wc ls-output.txt

Print line, word, and byte counts of ls-output.txt.

wc

Print line, word, and byte counts.

Filter: grep

Print lines matching a pattern.

grep -v

Print lines not matching the pattern.

netstat

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

printenv .

Print part or all of the environment.

head -n 5 ls-output.txt

Print the first five lines of ls-output.txt.

tail -n 5 ls-output.txt

Print the last five lines of ls-output.txt.

grep Options: -l or --files-with-matches

Print the name of each file that contains a match instead of the lines themselves.

grep Options: -c or --count

Print the number of matches (or non-matches if the -v option is also specified) instead of the lines themselves.

traceroute

Print the route packets trace to a network host

echo "this is a test"

Print this is a test (with the spaces).

echo with $((5%2)) left over.

Print with 1 left over.

echo $((2+2))

Prints 4.

echo $(((5**2)) * 3))

Prints 75.

echo Number_{1..3}

Prints Number_1, Number_2, Number_3

echo {Z..X}

Prints Z Y X.

printenv

Prints a list of all available variables.

mkdir {2009..2010}-0{1..3}

Prints directories 2009-01, 2009-02, 2009-03, 2010-01,2010-02, 2010-03.

echo $USER

Prints the current username.

echo $(ls)

Prints the output of the ls command

printenv variable

Prints the value of a specific variable.

echo this is a test

Prints this is a test.

Data compression

Process of removing redundancy from data.

Compiling

Process of translating source code (human-readable code) into machine language (binary).

Dependency

Programs usually rely on other software (such as shared libraries) to function.

Environment Variable: PS1

Prompt String 1. This defines the contents of your shell prompt.

Predefined find Actions: -quit

Quit once a match has been made.

Vim (Replace Confirmation Keys) - q or ESC

Quit substituting.

kill -3 or kill -quit

Quit.

Multitasking

Rapidly switching from one executing program to another.

CTRL-D on stdin

Reach end-of-file (EOF).

tee

Reads stdin and copies it to both stdout (allowing data to continue down the pipeline) and to one or more files.

Extended regular expressions (ERE)

Recognizes the following Metacharacters: BRE and ( ) { } ? + |

Basic regular expressions (BRE)

Recognizes the following metacharacters: ^ $ . [ ] *

script

Records an entire shell session and store it in a file

cp -r or cp --recursive

Recursively copy directories and their contents (required when copying directories).

rm -r or rm --recursive

Recursively delete directories.

zip Options: -r

Recursively zip directories

I/O redirection

Redirect the input and output of commands to and from files.

ls -l /usr/bin> ls-output.txt

Redirect the results of the ls -l /usr/bin command to ls-output.txt.

ls -l /bin/usr 2> ls-error.txt

Redirects error of the ls -l /bin/usr command to ls-error.txt.

ls -l /bin/usr &> ls-output.txt

Redirects output and error of the ls -l /bin/usr command to ls-output.txt.

ps: TTY (teletype)

Refers to the controlling terminal for the process.

top Information Fields: load average:

Refers to the number of processes that are in a runnable state and are sharing the CPU. Three values are shown: the first is the average for the last 60 seconds, the next the previous 5 minutes, and finally the previous 15 minutes.

find File Types: f

Regular file

rsync

Remote file and directory synchronization.

chmod u-x

Remove execute permission from the owner.

rm

Remove files and directories.

dpkg -p package_file or dpkg --purge package_file

Remove package file and configuration files.

dpkg -r package_file or dpkg --remove package_file

Remove package_file w/o removing configuration files.

apt-get purge package_name

Remove package_name and configuration files.

apt-get remove package_name

Remove package_name w/o removing configuration files.

Lossy compression

Removes data as the compression is performed, to allow more compression to be applied

History Expansion: !#

Repeat history list item number.

History Expansion: !?string

Repeat last history list item containing string.

History Expansion: !string

Repeat last history list item starting with string.

History Expansion: !!

Repeat the last command. It is the same as pressing the up arrow and ENTER.

ps

Report a snapshot of current processes

uniq -d

Report duplicated lines.

df

Report file system disk space usage

BSD-style ps Column headers: RSS

Resident Set Size. The amount of physical memory (RAM) the process is using in kilobytes.

History: CTRL-R

Reverse incremental search. Searches incrementally from the current command line up the history list.

History: ALT-P

Reverse search, non-incremental. With this key, type the search string and press ENTER before the search is performed.

su

Run a shell as another user.

Less: Page Up or b

Scroll back one page.

Vim (Replace Confirmation Keys) - CTRL-e, CTRL-y

Scroll down and scroll up respectively. Useful for viewing the context of the proposed substitution.

Less: Down Arrow

Scroll down one line.

Less: Page Down or Spacebar.

Scroll forward one page.

Less: Up Arrow

Scroll up one line.

find

Search for files in a directory hierarchy by a variety of attributes.

Vim (Searching the Entire File) - /[characters] ENTER n

Search for the next instance of characters.

Less: n

Search for the next occurrence of the previous search.

Less: /characters

Search forward to the next occurrence of characters.

grep -r

Search through all files in the directory.

grep bzip dirlist*.txt

Searches all of the listed files for the string bzip

kill -11 or kill -segv

Segmentation violation. This signal is sent if a program makes illegal use of memory; that is, it tried to write somewhere it was not allowed to.

kill

Send a signal to a process.

kill [-signal] PID or kill [-signal] jobspec

Send a signal to a specific process. If no signal is specified, then the TERM (Terminate) signal is sent by default. Must be the owner of a process to send a kill command.

ping

Send an ICMP ECHO_REQUEST to network hosts allowing the network connection to be verified.

bg %#

Send job # to the background.

fg %#

Send job # to the foreground.

killall [-u user] [-signal] name...

Send signals to multiple processes matching a specified program or username. Requires superuser privileges.

sort Options: -o or --output=file

Send sorted output to file rather than standard output.

Daemon programs

Services/programs that run in the background w/o an user interface.

gzip Options: -number (1-9)

Set amount of compression. Number is an integer in the range of 1 (fastest, least compression) to 9 (slowest, most compression). The values 1 and 9 may also be expressed as --fast and --best, respectively. The default value is 6.

set

Set shell options. Displays both shell and environment variables.

umask

Set the default file permissions.

go=rw

Set the group owner and anyone besides the owner to have read and write permission. If either the group or world previously had execute permissions, remove them.

What two basic types of data does the shell store in the environment?

Shell variables (bits of data placed there by the bash) and environmental variables (everything else).

ps: STAT

Short for Process state

chmod -a

Short for all; the combination of u, g, and o.

chmod -o

Short for others but means world.

chmod -u

Short for user but means the file or directory owner.

lpq

Show printer queue status information

lpstat

Show printer status information.

top Information Fields: Mem

Shows how physical RAM is being used.

top Information Fields: Swap

Shows how swap space (virtual memory) is being used.

shutdown

Shutdown or reboot the system.

find Tests: -samefile name

Similar to the -inum test. Matches files that share the same inode number as file name.

Mount point

Simply a directory on the filesystem tree for mounting devices or files.

Process State: S

Sleeping. The process is not running; rather, it is waiting for an event, such as a keystroke or network packet.

sort Options: -k or --key=field1[,field2]

Sort based on a key field located from field1 to field2 rather than the entire line.

Filter: sort

Sort lines of text files.

ls -t

Sort results by modification time (most recent files first).

ls -S

Sort results by size (biggest files first).

Vim (Global Search-and-Replace Syntax) - s

Specifies the operation. In this case, substitution (search and replace).

Environment Variable: TZ

Specifies the time zone

fold -w 12 file.txt

Specifiy a line width of 12 characters

tar Modes: f

Specify the name of the tar archive

Vim (Global Search-and-Replace Syntax) - 1,5

Specify the range of lines from line 1 to line 5.

Vim (Global Search-and-Replace Syntax) - 1,$

Specify the range of lines from line 1 to the last line.

Vim (Global Search-and-Replace Syntax) - %

Specify the range of lines from the first line to the last line.

Vim (Global Search-and-Replace Syntax) - :

Starts an ex command (in command mode).

CTRL+Z

Stop a foreground process w/o terminating it.

xlogo CTRL+Z

Stop xlogo

kill -19 or kill -stop

Stop. This signal causes a process to pause w/o terminating. Cannot be ignored.

Process State: T

Stopped. Process has been instructed to stop.

sed

Stream editor for filtering and transforming text

Operator: -

Subtraction

cat -s

Suppress the output of multiple blank lines.

Text enclosed in single quotes

Suppresses all special characters.

sleep 10; echo -e "Time's up\a"

Suspend the computer after 10 minutes. Print Time's up and follow with a beep.

Vim (Switching between files) - N

Switch back to the previous file.

Vim (Switching between files) - n

Switch from one file to the next.

Vim (Switching between files) - buffer #

Switch to the file in buffer #.

find File Types: l

Symbolic link

Regular expressions

Symbolic notations used to identify patterns in text.

Backslash escape sequence: \t

Tab.

Filter

Takes inputs, changes it somehow, then outputs it.

tar

Tape archiving utility.

kill -20 or kill -tstp

Terminal stop. Performs the same function when CTRL-Z is pressed. Unlike the STOP signal, the TSTP signal is received by the program but the program may choose to ignore it.

gzip Options: -t or --test

Test the integrity of a compressed file.

POSIX Character Classes: [:cntrl:]

The ASCII control codes. Includes the ASCII characters 0 through 31 and 127.

Access rights to files are defined in terms of read, write, and execution access for what three types of people?

The file's owner, file's group owner, and everybody else

What is the root directory?

The first directory in the filesystem. It contains files and subdirectories, which contain more files and subdirectories, and so on.

Environment Variable: EDITOR

The name of the program to be used for text editing.

Environment Variable: Display

The name of your display if you are running a graphical environment. Usually this is :O; meaning the first display generated by the X server.

Environment Variable: SHELL

The name of your shell program.

Environment Variable: TERM

The name of your terminal type.

Archiving

The process of gathering up many files and bundling them together into a single large file.

POSIX Character Classes: [:punct:]

The punctuation characters. In ASCII, equivalent to: [-!"#$%&'()*+,./:;<=>?@[\\\]_`{|}~]

su -l user

The resulting shell session is a login session for the specified user (i.e. the user's environment is loaded and the working directory is changed to the user's home directory.)

/

The root directory, where everything begins.

POSIX Character Classes: [:word:]

The same as [:alnum:], with the addition of the underscore (_) character.

Vim (Global Search-and-Replace Syntax) - /Line/line

The search pattern and the replacement text.

POSIX Character Classes: [:upper:]

The uppercase characters

POSIX Character Classes: [:graph:]

The visible characters. In ASCII, it includes characters 33 through 126.

POSIX Character Classes: [:space:]

The whitespace characters including space, tab, carriage return, newline, vertical tab, and form feed. In ASCII, equivalent to: [ \t\r\n\v\f]

What is the shell prompt?

The window that appears when the terminal emulator is launched.

What do wildcards do?

They select filenames based on a pattern of characters.

top Information Fields: Tasks:

This summarizes the number of processes and their various process states.

BSD-style ps Column headers: START

Time when the process started. For values over 24 hours, a date is used.

tr

Translate or delete characters

Text Editing: CTRL-T

Transpose (exchange) the character at the cursor location with the one preceding it.

Text Editing: ALT-T

Transpose the word at the cursor location with the one preceding it.

sort Options: -m or --merge

Treat each argument as the name of a presorted file. Merge multiple files into a single sorted result without performing any additional sorting.

Process State: D

Uninterruptible Sleep. Process is waiting for I/O such as a disk drive.

apt-get update

Update packages.

top Information Fields: h:mm

Uptime (the amount of time since the machine was last booted).

Arithmetic expansion

Use the form $((expression)) to perform mathematical operations. Only supports integers.

Brace expansion

Used to create multiple text strings from a pattern containing braces. It may contain either a comma-separated list of strings or a range of integers or single characters.

tail -f /var/log/messages

View the progress of log files as they are being written in real-time. Press CTRL+C to end the command.

BSD-style ps Column headers: VSZ

Virtual memory size.

cp -u or cp --update

When copying files from one directory to another, copy only files that either don't exist or are newer than the existing corresponding files in the destination directory.

uniq

When given a sorted file (including standard input), it removes any duplicate lines and sends the results to standard output.

mv -u or mv --update

When moving files from one directory to another, move only files that either don't exist in the destination directory or are newer than the existing corresponding files in the destination directory.

Expansion

When something is entered into the terminal, some text is "expanded" into something else before the shell acts upon it.

fold

Wrap each line at a specified length.

Vim - :w file

Write file to hard disk.

gzip Options: -c

Write output to standard output and keep original files. May also be specified with --stdout and --to-stdout.

ls | tee ls.txt | grep zip

Write the directory listing to the file ls.txt before grep filters the pipeline's contents.

ls | tee file

Write the output of the ls command to the screen and to file.

Cut and Paste (Kill and Yank) Text: CTRL-Y

Yank text from the kill-ring (buffer) and insert it at the cursor location.

Synopsis of alias

alias [name=['command']]

Synopsis of apropos

apropos keyword

Synopsis of cut

cut [OPTION]... [FILE]...

Synopsis of date

date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

Synopsis of head

head [OPTION]... [FILE]...

Synopsis of help

help name

Synopsis of id

id [OPTION]... [USER]

Synopsis of patch

patch [options] [originalfile [patchfile]]

Synopsis of pstree

pstree [pid, user]

Synopsis of pwd

pwd [OPTION]...

Synopsis of script

script [options] [file]

On startup, the bash reads configuration scripts called _____ _____ which define the default environment shared by all users.

startup files.

Synopsis of su

su [options] [username]

Synopsis of sudo

sudo command

Synopsis of tar

tar [options] [pathname ...]

Synopsis of tee

tee [OPTION]... [FILE]...


संबंधित स्टडी सेट्स

Tutorial 9 Quiz - Getting Started with JavaScript

View Set

APUSH Chapter 7 Notes (1793-1815)

View Set

HEALTH ASSESSMENT PRACTICE QUESTIONS

View Set

Section 7, Unit 3: Subprime Lending, Predatory Lending, and Mortgage Fraud

View Set

Unit 3- marine provinces and marine sediments

View Set

English IV: Lesson Three (Test Nine)

View Set

Quizfrågor kapitel 3 från canvas

View Set