major shells:
sh, the original Borne Shell (note: in linux "sh" will cause the bash
shell to emulate the original bash shell, but ash (Almquist shell)
resembles the original sh more closely, prompt = $)
ksh, Korn shell ($)
csh, C shell (%)
bash, Borne Again shell (probably the most popular shell, $)
zsh, Z shell (Korn, $)
tcsh, Freely available C shell (%)
pdksh, Public-domain Korn shell ($)
the prompt for root is #
changing the prompt can be done by changing the PS1 variable (PS1 =
Prompt String 1)
the current paths set can be displayed by using: echo $PATH
additions to the PATH variable can be made like so: PATH=$PATH:<new
dir(s)>
starting from scratch...: PATH=<dir(s)>
making changes permanent: export PATH
remove a variable: unset <variable>
other environmental variables:
HOME = current user's home directory
DISPLAY = X Windows output
LANG = default language
LD_LIBRARY_PATH = for specifiying the paths of system libraries
MAIL = path to user's mailbox
PRINTER = default printer
PS1=[\u@\h \W]\$ <---- look this up
shells for each user are specified in /etc/passwd
grep <username> /etc/passwd, displays entry for a specific user
quick way to list all usernames: cat /etc/passwd | cut -d: -f1
to see what shell you are using: echo $SHELL
to see what shells are available: ls /bin/*sh
you can also use: cat /etc/shells (a listing of the system's shells)
keystrokes in shell:
Ctrl-H = backspace
Ctrl-Z = suspend current job
Ctrl-D = exit current shell (same as issueing a exit command). can also
be used to delete a single character at the cursor's current position
(like Delete key)
Ctrl-Y = paste text (yank)
Ctrl-R = search history of typed commands by typing a few keys
(example: type c for chmod, cat, etc). To exit search hit an arrow key
Alt-D = delete current word
Ctrl-U = clear current line
Ctrl-L = clears the screen
Ctrl-C = sends INT signal to running process, causes process to
terminate
Ctrl-K = delete text from cursor's current location to end of line
(kill)
Ctrl-E = move to the end of the line (End key)
Ctrl-A = move to the beginning of the line (Home key)
Ctrl-F = move cursor forward/right one character (Right arrow key)
Ctrl-B =
move cursor back/left one character (Left arrow key)
Ctrl-P = previous command/line in history file (Up arrow key)
Ctrl-N = next command/line in history file (Down arrow key)
filename completion:
by typing a few characters of a filename and hitting the TAB key the shell will attempt to complete the filename.
if the characters entered aren't unique enough, as in more than one
file starts with the letter "c" then both files will be listed.
then you can attempt to make your filename entry a little more unique and try TAB again to get the completion to function.
entering commands:
repeating last command
for bash and csh shells: !!
!# = repeats command on line number # in history file
!-# = repeats command on line number equal to current position in
history file minus #
!<string> = repeats most recent command that begins with value
equal to <string>
!?<string> = repeats most recent command that contains value
equal to <string>
^<string1>^<string2> = repeats last command but substitute
<string1> with the value of <string2>
also using the up arrow and down arrow you can sort thru previously
entered commands
adding an & to the end of a command will cause the process to be ran in the background
for korn shells: r
entering multiple commands at once can be done by adding a semi-colon
in between each command
for example: <command1>;<command2>;<command3>
&& between commands may also be used
a \ used at the end of a command will create a line break and give you an additional line to continue typing the command
I/O redirection:
standard input - stdin (0)
standard output - stdout (1)
standard error - stderr (2)
> redirect output (assumed to be stdout unless specified)
< redirect input
>> append output to existing data
2>[filename], redirects stderr to file
>[filename] 2>&1, send stdout and stderr to same location
(file)
2>[filename] 1>&2, send stdout and stderr to same location
(file)
> [filename]
creates a new file if it does not already exist or clear an existing
file
wildcards:
* = match any amount of characters or 0 characters
? = match any single character
[1-9] = match characters 1 thru 9
[a-z] or [A-Z] = match all characters of the alphabet
[23] = match characters 2 or 3
[Ee] = match characters E or e
[!a] = match all characters but exclude "a"
^d = match d only at the start of a line
permissions:
other (o)
group (g)
user (u)
-rwxrwxrwx
read (r) - access contents of file, list contents of directory (4)
write (w) - change contents of file, change files in directory (2)
execute (x) - run a file, enter a directory (1)
flags:
set user id - when program is executed it is ran with permissions of the owner
set group id - when program is executed it is ran with permissions of the group
sticky bit - user can only delete files if the files belong to him or if user has explicit write permission to them.
inode information:
inode #
file type
permissions
timestamps
pointers to data blocks
count of links