• 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/65

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;

65 Cards in this Set

  • Front
  • Back
Env variable holding computer's name

set an environment variable manually via dm
$HOSTNAME

$ export HOSTNAME=carson.example.com
find out how environment variables are confi gured by typing
env cmd
Display env variable HOSTNAME with help from grep
$ env | grep HOSTNAME
Env. variable that is your current username

Env. variable that is your current shell
$USER / $USERNAME

$SHELL
Env. variable that prints the working dir

Env. variable that point to you home dir
$PWD

$HOME
Env. variable $PATH
Sets the path for a session, which is a colon-delimited list of dir in which Linux searches for executable programs
Env. variable that holds the location of the users mailbox

Env. variable that hold your current language
$MAIL

$LANG
Env. variable $LD_LIBRARY_PATH desc
$LD_LIBRARY_PATH - Program uses this env. var to indicate dir in which library files may be found
Env. variable $PS1
This is the default prompt in bash. It generally includes variables of its own, such as \u (for the username), \h (for the hostname), and \W (for the current working directory). This value is frequently set in /etc/profile, but it’s often overridden by users.
Env. var $NNTPSERVER
Some Usenet news reader programs use this environment variable to specify the name of the news server system. This value may be set in /etc/profile or in the user’s configuration files.
Env. var $TERM

Env. var $DISPLAY

Env. var $EDITOR
Current terminal type

Identifies the display used by X: Usually is :0.0

Some programs launch the program point by this env. var when the need to call a text editor to use
The PATH variable sometimes includes the current directory indicator (.) why is this a security risk?
The PATH variable sometimes includes the current directory indicator (.) so that programs in the current directory can be run This practice poses a security risk, though, because a miscreant can create a program with the same name as some other program (such as ls) and trick another user into running it by simply leaving it in a directory the victim frequents Even the root user may be victimized this way For this reason, it’s best to omit the
current directory from the PATH variable, especially for the superuser If it’s really needed for ordinary users, put it at the end of the path
run a program in the background by typing
its name and appending an ampersand (&)
To implement an alias, you use the following syntax:

If you want to use an option as the default for your alias, you can use alias
alias alias_name=’commands‘

$ alias ls=’ls --color’
Common bash config files global - login and non login
Login File Location
/etc/profile
/etc/profile.d

Non-Login File Location
/etc/bashrc
/etc/bash.bashrc
Common bash config files user - login and non-login
Login file location
~/.bash_login
~/.profiles
~/.bash_profile

Non-Login file location
~/.bashrc
bash logout scripts location
~/.bash_logout

most disto dont put them in the user home dir
bash configuration file which helps customize your keyboard config
~/.inputrc
Consist of line like this
M-Control-u: universal-argument
above line means Meta-Ctrl-U is mapped to the universal-argument action

meta = ESC
A shell script begins with a line that identifies the shell that’s used to run it, such as the following:
#!/bin/sh

#! - special code that tells the Linux kernel that this is a script and to use the rest of the line as a pathname to the program that’s to interpret the script.
comment character in bash scripts
#

for the #!/bin/sh
the script utility ignores this line
the kernel dosent
Once you are done writing a shell script you should modify it so its executable by using the _______ cmd
chmod +x
+x adds executable permissions

to make my-script exec you should issue
$ chmod a+x my-scirpt
to make my-script exec you should issue
$ chmod a+x my-scirpt
to tell linux to run the script in the current dir you should precede by ____
./
if you want to run an non exec script run called my-script
bash my-sciprt
Simple Script That Launches Three Programs
#!/bin/bash
/usr/bin/xterm &
/usr/bin/xterm &
/usr/bin/kmail &
What if you have an & at the end of a cmd in a script
tells the shell to go on to the next line without waiting for the first line to finish
For instance, users’ home directories appear in the sixth colon-delimited field of the /etc/ passwd file. You can therefore type _____________ to extract this inforamtion
cut -f 6 -d “:” /etc/passwd
variables that are passed to the script are frequently called _____________ and are represented by a _______________ sign followed by number from 0 to 9
parameters
dollar

$0 stands for the name of the script
$1 for the first parameter
shift command expl
shifts the parameter variables, so that what would ordinarily be $2 becomes $1, what would be $3 becomes $2, and so on Adding a number, as in shift 3, shifts the assignments by that number of units The shift command does not alter the $0 variable
using variable create a script that
creates an account
changes the account’s password (you’ll be prompted to enter the password when you run the script)
creates a directory in the /shared directory tree corresponding to the account,
sets a symbolic link to that directory from the new user’s home directory
adjusts ownership and permissions in a way that may be useful, depending on your system’s ownership and permissions policies.
#!/bin/sh
useradd -m $1
passwd $1
mkdir -p /shared/$1
chown $1.users /shared/$1
chmod 775 /shared/$1
ln -s /shared/$1 /home/$1/shared
chown $1.users /home/$1/shared

2, you need type only three things: the script name with the desired username and the password (twice).

mkuser ajones
declare variable in a script
ping="/bin/ping"
ip=`route -n | grep UG | tr -s “ “ | cut -f 2 -d “ “`

when you’re assigning a value to a variable from the output of a command, that command should be enclosed in back-quote characters (`),
script with user interaction for entering variable
#!/bin/sh
echo -n “Enter a username: “
read name
useradd -m $name
bash script conditional statement if expl
The if keyword’s conditional expression appears in brackets after the if keyword and can take many forms.
bash if statment primary expressions
if [-f file]
if [-s file]
if [ STRING1 == STRING2 ]
-f - True if FILE exists and is a regular file.
-s - True if FILE exists and has a size greater than zero.
[ STRING1 == STRING2 ] True if the strings are equal. "=" may be used instead o
bash if statment primary expressions
if [-a file]
if [-d file]
if [ -x file]
[ -a FILE ] True if FILE exists.
[ -d FILE ] True if FILE exists and is a directory.
[ -x FILE ] True if FILE exists and is executable.
Conditionals may be combined together with the logical and (&&) or logical or (||) operators. When conditionals are combined with &&, both sides of the operator must be ____________ for the condition as a whole to be true
When || is used, if either side of the operator is true, the condition as a whole is __________
true

true
script to exit if the file /tmp/tempstuff is present and is larger than 0 bytes
if [ -s /tmp/tempstuff ]
then
echo “/tmp/tempstuff found; aborting!”
exit
fi

fi (if backward) marks the end of the if block
An alternative form for a conditional expression uses the test keyword rather than square brackets around the conditional
if test -s /tmp/tempstuff
You can also test a command’s return value by using the command as the condition
if [ command ]
then
additional-commands
fi

in this example additional-commands will be run only if command completes successfully
Conditional expressions may be expanded by use of the ___________ clause
else

if [ conditional-expression ]
then
commands
else
other-commands
fi
What do you do if more than two outcomes are possible—for instance, if a user may
provide any one of four possible inputs?
case word in
pattern1) command(s) ;;
pattern2) command(s) ;;
...
esac

word is a variable

each patter is a value
Script That Executes a Command on Every Matching File in a Directory
#!/bin/bash
for d in `ls *.wav` ; do
aplay $d
done

aplay command is a basic audio file player
seq command
can be useful in creating for loops
This command generates a list of numbers starting from its first argument and continuing to its last one. For instance, typing seq 1 10 generates 10 lines, each with a number between
You can use a for loop beginning for x in `seq 1 10` to have the loop execute 10 times, with the value of x incrementing with each iteration.
while loop
while [ condition ]
do
commands
done

The until loop is similar in form, but it continues execution for as long as its condition
is false—that is, until the condition becomes true.
function is a part of a script that performs a specific sub-task and that can be called by name from other parts of the script. How you define func?
myfn() {
commands
}

keyword function may optionally precede the function name
demonstrates the use of functions in a simple program that copies a file but aborts with an error message if the target file already exists. This script accepts a target and a destination filename and must pass those filenames
to the functions
#/bin/bash
doit() {
cp $1 $2
}

function check() {
if [ -s $2 ]
then
echo “Target file exists! Exiting!”
exit
fi
}
check $1 $2
doit $1 $2
The mail server holds incoming messages for each user, typically in a file in
/var/spool/mail
what folders howl mail for the user benf
/var/spool/mail/benf
mail spool def
Some e‑mail servers store incoming mail in subdirectories of the users’ home directories, though. This incoming mail file or directory is referred to as the user’s mail spool.
sendmail prog
sendmail program was for many years the dominant e‑mail server package on the Internet
Postfix prog
Postfix was designed as a modular replacement for sendmail.
Uses multiple programs each with its own specific task
Exim prog
is a monolithic server, like sendmail, it has a much simpler configuration file format and so is easier to configure. A few Linux distributions use Exim as the default e‑mail server.
qmail prog
Like Postfix and Exim, qmail is easier to configure than sendmail. It’s not the standard e‑mail server in any Linux distribution because its license is a bit strange and complicates qmail distribution with Linux; however, many system administrators like qmail enough that they replace their distributions’ standard e‑mail
servers with qmail.
You can learn which e‑mail server your Linux distribution runs in several ways. The two most reliable are to use ps
$ ps ax |grep send
31129 pts/2 R+ 0:00 grep send
$ ps ax | grep post
7778 ? Ss 0:45 /usr/lib/postfix/master
31132 pts/2 S+ 0:00 grep post
Pull mail servers
Two pull mail protocols, POP and IMAP, are popular. If a Linux system should function as a mail server from which users can read their e‑mail remotely, chances are you’ll install a POP or an IMAP server package, such as Cyrus IMAP or Dovecot.
Fetchmail prog
If you run a small site that relies on an external ISP for e‑mail delivery, chances are the ISP supports only POP or IMAP. If you want to use a variety of e‑mail clients, you may want to run your own SMTP server, and perhaps your own POP or IMAP server, to deliver mail locally. To do this, you need a program that pulls mail using POP or IMAP and then injects it into a local SMTP mail queue. This is the job of Fetchmail
nail cmd
some linux distro ship with the nail cmd which is similar to mail but supports more features
mail program is intended to be used on the command line to send or receive messages.
The basic syntax for mail
mail [-v] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr
mail [-v] [-f [name] | -u user]

$ mail -s “Meeting reminder” -c benf@example.com sallyg@example.com
Remember the meeting at 4:00 today!
This line, if included in a script, sends the contents of /tmp/alert.txt to benf@example.com with the specified subject.
mail -s “Automated alert!” < /tmp/alert.txt benf@example.com
main tool to help in e‑mail queue management
mailq program is the main tool to help in e-mail queue management without any options, shows the contents of the e‑mail queue on all systems:
$ mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
5B42F963F* 440 Sat Aug 23 13:58:19 sally@example.com
benf@luna.edu
-- 0 Kbytes in 1 Request.
you want to clear the mail queue immediately what cmd will you use
sendmail -q
postmaster account usage
all e‑mail servers are supposed to maintain an account called postmaster. E‑mail to this account should be read by somebody who’s responsible for maintaining the system. One way to do this is to set
up an alias linking the postmaster name to the name of a real account. You can do this by editing the aliases file, which usually resides in /etc or sometimes in /etc/mail
aliases file format
used in email server to set up email forwarding

comment line #

name: addr1[,addr2[,...]]

a typical config includes a few map aliases to root.
Reading emails through root is not advisable
CMD to learn what databases are defined in you mysql

CMD to see all tables in a DB called test
SHOW DATABASE;

cmds are terminated by semicolons
------------------------------------------------
USE test;
SHOW TABLES;
CMD to create a DB called test in mysql
CREATE DATABASE test;