-
Where can you set variables or PATH to be set at login in a login-shell? 105.1
- /etc/profile (and files in /etc/profile.d)
- or
- ~/.bash_profile | ~/.bash_login | .profile
- p 23
-
Where can you set vars or PATH to be set at login to a non-login shell? 105.1
- /etc/bashrc | /etc/bash.bashrc
- or
- ~/.bashrc
- p23
-
How do you write a shell function to automate tasks? 105.1
- function_name()
- {
- ls $1
- echo $2
- }
- Then can call cmd with args.
- Ex: function_name Myfile, STUPID
- p543
-
Where do you place files that will be copied to new user's home directories? 105.1
- /etc/skel
- Usually used for preference files.
- p.340
-
How do you set PATH? 105.1
- PATH=$PATH:/sharefiles/NewDir:/othershare/OtherDir
- p44
-
How do set an alias? 105.1
- alias mynew1 "cmd -l; nextcmd -P"
- p50
- unalias to remove one.
-
How to remove a variable? 105.1
-
In a BASH Script, how to read input from user? 105.2
-
How to have a variable be an integer in bash? 105.2
-
How's an if statement structured in bash? 105.2
- if condition then
- cmds
- else
- cmds
- fi
- p523
-
How to check if a specified directory exists? 105.2
- if [ -d "$MYNEWPATH" ]; then
- Or use:
- if test -d $MYNEWPATH; then
- p523
-
How to check if a specified file exists? 105.2
- if [ -e "~/Myfile"]; then
- if test -e ~/Myfile; then
- p524
-
How to check if a specified file exists and is a regular one?
105.2
- if [ -f "$MYNEWPATH" ]; then
- or
- if test -f $MYNEWPATH; then
-
How do you compare values? Equal, not equal, <, >?
- For text,
- test "text1" = "text2"
- test "text1" != "text2"
- For numbers:
- test num1 -eq num2
- test num1 -lt num2
- test num2 -gt num2
- p525
-
How to construct a select statement? 105.2
- case $MYVAR in
- val1 | val1a | val1b ) echo "Answer1"
- ;;
- val2 | val2a | val2b ) echo "Answer2"
- ;;
- * ) echo "Default answer."
- ;;
- esac
- p526
-
How to construct a while or until loop? 105.2
- while condition
- do
- script cmds
- done
- p527
-
How does the sequence cmd work? Specify parameters.
- seq a b c
- If a only specified, seq increments by 1 until it reaches a.
- If a and b specified, seq starts from a, increments by 1 until it reaches b.
- If a, b, and c specified, seq starts from a, increments by b, until it reaches c.
- p 528
-
How to do a for-loop? 105.2
- for i in 'seq a b c"
- do
- cmds
- done
- p 528
-
What is cmd substitution and how's it done? 105.2
- It allows a cmd's stdout to be used as cmd line arguments for another cmd. Allow's nesting. Can be done with
- cmd2 $(cmd1 -options)
- p543
-
How to test if a file exists and is owned by a specified group? 105.2
- if [ -G /etc/myfile ]; then
- or
- if test -G /etc/myfile; then
- p524
-
How to test if a file exists and is a symlink? 105.2
- if [ -h /home/myfile ]; then
- if [ -L /home/myfile ]; then
- or
- if test -h /home/myfile; then
- if test -L /home/myfile; then
- p524
-
How to test if specified file is owned by the effective user-id? 105.2
- if [ -O /etc/myfile ]; then
- if test -O /etc/myfile; then
- p525
-
How to check if effective user has read, write, or execute privileges? 105.2
- -r, or -w, or -x in the following:
- if [ -r /etc/myfile ]; then
- if test -x /etc/myfile]; then
- p525
-
Correct way to select a cmd interpreter? 105.2
- #!/bin/bash or specify other cmd interpreter.
- Called hash-bang. She-bang, etc.
- p 518
-
What are special permissions and how do you set them? 105.2
- SUID: 4, SGID: 2, Sticky Bit: 1. Sticky on dirs means user can del files only for which they are owners. In chmod, it's 4th 1st #. E.g., instead of 777, it'd be 4777.
- p415
-
SQL cmd to retrieve info from a table?
105.3
-
SQL cmd to modify info in a table? 105.3
-
SQL cmd to remove info from a table? 105.3
-
SQL cmd to add new data to table? 105.3
-
SQL cmd to make a new table? 105.3
-
SQL cmd to modify an existing table?
-
Cmd to delete an existing table? 105.3
-
Cmd to login to mysql server from client? 105.3
- mysql -h localhost -u root -p
- -p means to prompt for a password.
- p635
-
Command to open a DB in mysql? 105.3
-
mysql cmd to see listing of tables in a DB? 105.3
-
How to create a new mysql table? 105.3
- CREATE TABLE mytable (variable1 VARCHAR(15), variable2 CHAR(12), vardatum DATE);
- p637
-
Cmd to view summary of mysql DB? 105.3
-
How to add a record to a mysql table? 105.3
- INSERT INTO mytable VALUES ('Garbage',"Value","2011-08-29");
- p637
-
How to view records in mysql? 105.3
- SELECT field(s) FROM table [WHERE conditions] [ORDER BY field]
- Ex:
- SELECT first,phone FROM active;
- View two fields only from all records.
- SELECT * FROM active
- View all records.
- p637
-
How to remove records from a mysql table? 105.3
- DELETE FROM active WHERE last='Tracy';
- p637
-
How to modify data on existing mysql record? 105.3
- UPDATE table_name SET column=newvalue WHERE condition
- p638
-
How to sum up a field on a given set of records in a mysql DB? 105.3
SELECT custid,SUM(quantity)AS "Total" FROM active GROUP BY cust id;
-
How do you do a JOIN in mysql? 105.3
- Cross-join is:
- SELECT field1 FROM table1,table2
- p638
-
Location of X11 config files? 106.1
- /etc/X11/xorg.conf (More modern, common)
- /etc/X11/XF86Config
- p.236
-
Describe X font server. 106.1
- Install fonts on server system to:
- /usr/share/X11/fonts or
- /usr/share/fonts
- Types of fonts (and dir's):
- bitmaps /100dpi and /75dpi
- Postscript Type 1 (scalable) /type1
- Truetype (scalable) /truetype
- On server enter: mkfontscale and mkfontdir to make index. Open port 7100. Server is "xfs start"
- Configure clients in /etc/X11/xorg.conf, under Section "Files", enter: FontPath "tcp/server_address:7100"
- p247
-
What is the layout of the X11 configuration file? 6 main sections. 106.1
- Section "Files" Fonts & input device files
- Section "ServerFlags" Optional global flags
- Section "Module" For extensions & font rasterizers
- Section "InputDevice"
- Section "Modes" Defines video modes
- Section "Screen" Binds video board to monitor
- Device "VMware SVGA" must exactly match id under device.
- Subsection "Display"
- Section "Device" 1 section req'd per video adapter.
- Identifier "VMware SVGA"
- Section "ServerLayout" Binds all others together.
- p239
-
Cmd to have X client accept incoming X server connection? 106.1
- xhost +serveripaddress
- p724
-
Settings to set on X server to have video sent to X clent on different system? 106.1
- DISPLAY=X_client_Host_or_IP
- export DISPLAY
- p724
-
2 cmd line cmds to see info on X Windows server and windows? 106.1
- xwininfo - displays window information
- xdpyinfo - displays server information
- p263
-
If in runlevel 3 and want to start X, how would you do so? 106.1
-
Cmds to config X.org? 106.1
- Generic config provided by X:
- Xorg -configure - autodetects all hw and makes /root/xorg.conf.new. To try, X -config /root/xorg.conf.new.
- Graphical utility is xorgcfg
- Some display conig utils:
- system-config-display
- system-config-keyboard
- system-config-mouse
- p243
-
How to enable or display a display mgr? 106.2
- On most, loaded by init script. To start or stop, enter:
- /etc/init.d/xdm start | stop
- OR
- rcxdm start | stop
- Display mgr's are: xdm: gdm: kdm.
- To check which is started, chkconfig xdm -l
- To disable, chkconfig xdm off.
- p250
-
How to change message presented by display mgr? 106.2
- For xdm, edit /etc/X11/xdm/Xresources.
- Modify xlogin* vars.
- p251
-
How to change default color depth for display mgr? 106.2
- In /etc/X11/xdm/Xservers file, locate line:
- :0 local /usr/bin/X -nolisten tcp -br vt7
- add: -bpp 16
- Where 16 is color depth, of 8, 16, or 24.
- p251
-
Steps to configure Remote access to a Display Manager? 106.2
- On host: For xdm or kdm, edit /etc/X11/xdm/Xservers file. Find line:
- :0 local/usr/X11/R6/bin/X -nolisten tcp -br vt7
- Remove the -nolisten part. Save change, restart system.
- On host: For gdm, edit /etc/X11/gdm/gdm.conf and set DisallowTCP = to false.
- If on OpenSUSE, edit /etc/sysconfig/displayanger and set below two to yes:
- DISPLAY_REMOTE_ACCESS="yes"
- DISPLAY_XSERVER_TCP_PORT_6000_OPEN="ye"
- Open port 177 in xdm host's firewall (for xdm Control Protocol XDMCP).
- Open /etc/X11/xdm/Xaccess file (to config access control for XDMCP) on host. Add an entry for each client. Can also do *.mydomain.com. To restrict access, precede a line with a !. p252
-
Describe and name keyboard accessibility options. 106.3
- In AccessX,
- StickyKeys - Locks Ctrl & Shift keys.
- MouseKeys
- SlowKeys - Key must be held to send keystroke.
- ToggleKeys - Audible alert on num & capslock.
- RepeatKeys - Extra time before a key repeats.
- BounceKeys/Delay Keys - Slight delay b/w keystrokes.
- p254
-
Accessibility options for visually impaired users? 106.3
brltty daemon must be loaded for Braille hardware. Orca is a good app for Braille. p261
-
Options for screen readers? 106.3
Orca is a common one, as it can read from the Gnome desktop. Many others, like emacspeak, can only read from text based terminals. p257
-
Options for screen magnifiers? 106.3
- Orca popular (both screen magnifier and reader), Gnome Magnifier, and KDE Magnifier. Can start Orca from shell with orca -e magnifier.
- p257
-
Onscreen keyboard options? 106.3
GOK (Gnome Onscreen Keyboard) and GTkeyboard p254.
-
Cmd to add a user? 107.1
- useradd options username
- -D (no username) to view new user defaults
- -c Incl user's full name
- -e Date acct disable
- -f Days to disable acct after pw expiration.
- -g User's default grp
- -G Add'l groups
- -M Be created w/o home dir
- -m Specifies home dir.
- -p Specify user's encrypted pw. (openssl passwd -crypt)
- -r Specifies a system user
- -s Specify default shell
- -u Specify UID
- ex: useradd -c "Jackie McK" -m -p"q1GXA2Ox" -s "/bin/bash" jmacarthur
- p343
-
Files that specify defaults for new users? 107.1
- /etc/default/useradd
- Specifies Default group, home dir, shell, umask.
- /etc/login.defs
- Specifies UID & GID ranges, p/w min max ages, etc.
- /etc/skel
- p341
-
Cmd to lock accts and change passwords? 107.1
- passwd options username
- -S View acct status
- -l Lock (invalid pw)
- -u Unlock
- -d Removes pw
- -n Sets min days b/w pw changes.
- -x Sets max # days before pw change req'd.
- -w Sets # days warning.
- -i Sets # days after pw expiration before disabling acct.
- p344
-
Cmd to modify user accounts? 107.1
- usermod options userid
- -c Edits user's full name
- -e Sets date of disablement
- -f Sets # days after pw expiration before acct disabled.
- -g Sets default grp
- -G Sets add'l grps
- -l Changes username
- -L Locks acct (disable pw)
- -m Sets home dir
- -p Sets user encrypted p/w. (openssl passwd -crypt)
- -s Default shell
- -u Sets UID
- -U Unlocks acct.
- p345
-
How to delete a user's account? 107.1
- userdel -r username
- -r says to remove the user's home directory.
- p346
-
Where is acct info stored and how is it structured? 107.1
- /etc/passwd
- username:password:UID;GID:Fullname:HomeDir:Defaultsh
- Ex:
- ksander:x:1001:100:Kimberly Sanders:/home/ksanders:/bin/bash
- p337
-
Where are encrypted pw's stored? Structure of file? 107.1
- /etc/shadow
- username:password:Last_Modified:Min_Days:Max_Days
- :Day_Warn:Disabled_Days:Expire
- Note: Last_Modified and Expire are days since 1/1/1970.
- Ex: ksanders:$@#$@#SSFDsdfsdf:15043:0:9999:7:::
- p338
-
Cmd to verify that /etc/passwd and /etc/shadow are in sync?
107.1
-
Where is group info stored? Structure of file 107.1
- /etc/group
- Group:Password:GID:Users
- p348
-
Group pw info stored? 107.1
/etc/gshadow p348
-
Cmd to add groups? 107.1
- groupadd options groupname
- -g Specify GID
- -p Specify password (openssl passwd -crypt)
- -r Specifies is a system group.
- p349
-
Cmd to modify groups? 107.1
- groupmod options groupname
- -g Changes GID
- -p Changes pw (openssl passwd -crypt)
- -A adds user
- -R Removes user.
- Ex: groupmod -A "ktracy,m6soto"
-
Cmd to delete a group? 107.1
-
Cmd to change password aging? 107.1
- chage option user
- -m Min days b/w pw changes
- -M Max days b/w pw changes
- -W Warning days before pw change req'd.
- p660
-
Service to run jobs 1x in future? 107.2
- /etc/init.d/atd
- To allow/deny access:
- /etc/at.allow
- /etc/at.deny
- To schedule job:
- at time
- Diff ways to schedule time.
- Type cmds. Output will be emailed to local acct.
- Ctrl+d
- To view queue, atq. To remove job. atrm job#.
- p500
-
How to specify time for atd? 107.2
- Fixed: HH:MM (am or pm is OK), Noon, Midnight, Teatime (1600), MMDDYY, MM/DD/YY, MM.DD.YY, HH:MM MMDDYY.
- Relative: now, now + value (5 minutes, 2 hours, 3 days), 2 pm today, 2pm tomorrow.
- p500
-
Svc to schedule recurring system jobs?
- /etc/init.d/cron
- Config'd in /etc/crontab
- Scripts run from:
- /etc/cron.hourly
- /etc/cron.daily
- /etc/cron.weekly
- /etc/cron.monthly
- /etc/cron.d
- To config /etc/cron.d intervals,
- Create /etc/cron.d/crontab
- Min Hrs DayofMo Mnth DaysofWk Cmd
- 5 23 * * 1-6 /bin/tar -cvf /media/backup.tar /home
- Backups up at 23:05 every day of every mo on Mon-Sat.
- p502
-
How to restrict access for user scheduled cron jobs? 107.2
- /etc/cron.allow and /etc/cron.deny. By default, only cron.deny is created that blocks guest acct. All others can create crontab scheds. When a cron.allow is created, *only* users listed can make scheds. All others denied. User crontabs stored in /var/spool/cron/
- p504
-
How do users manage their crontabs? 107.2
- crontab options
- -e Edit, or make new. Opens vi.
- -l To list crontab
- -r To remove crontab.
- Uses same format:
- Min Hr DayofMo Month DaysofWk Cmd
- p504
-
What env variables define locale? 107.3
- LC_CTYPE Default char type & encoding
- LC_MESSAGES Config's natural lang msgs
- LC_COLLATE Sorting rules
- LC_NUMERIC # format
- LC_MONETARY Currency format
- LC_TIME Date and time display
- LC_PAPER Default paper size
- LC_NAME Default personal name fmt
- LC_ADDRESS Default address fmt
- LC_TELEPHONE Default phone # fmts
- LC_MEASUREMENT Default meas. units
- LC_ALL Overrides all other LC Env Vars
- LANG Specifies default locale val for all LC-vars
- LANGUAGE Overrides LC_Messages
- p163
-
Whats fmt for LC_CTYPE var? 107.3
- language_territory.codset @modifier.
- Ex:
- en_US.UTF-8
- UTF-8 is known as Unicode.
- p164
-
Order of precedence for Locale env vars? 107.3
- If LC_ALL is defined, it's used. No other LCs used.
- If LC_ALL is undefined, specific LC vars are checked.
- If LC var has null val, then LANG var is used.
- p165.
-
Cmd to check locale settings? 107.3
-
Cmd to set BIOS/hardware clock in Linux? 107.3
- hwclock
- -r or --show (Is default option w/o cmd line options)
- --set --date="9/16/11 08:00:00" (Arg is local time, even if hw clock is set to UTC)
- -s or --hctosys Sets sys time to hwclock time.
- -w or --systohc Sets hwclock time to sys time.
- --utc or --localtime Specifies hwclock is config'd to use either UTC or local time.
- p167/617
-
Settings for hardware clock set to UTC vs local time? 107.3
- In /etc/sysconfig/clock, change as follows:
- HWCLOCK="-u" #for UTC
- HWCLOCK="--localtime" #for local time.
- p107.3
-
Where is timezone info stored? 107.3
- On some (e.g. Ubuntu), it's /etc/timezone
- America/Denver
- On some (e.g. OpenSUSE), it's /etc/sysconfig/clock
- TIMEZONE="America/Boise"
- Can check it by using date cmd.
- Available timezones in /usr/share/zoneinfo.
- p168
-
Cmd to set timezone? 107.3
- Debian based (Ubuntu) use tzconfig. Others (OpenSUSE/Fedora) use tzselect.
- p168.
-
Way to set timezone w/ symbolic link?
- ln -sf /usr/share/zoneinfo/MST /etc/localtime
- Note that -f is "force", which removes an already existing destination file.
- p169
-
Cmd to convert files from one encoding type to another? 107.3
- iconv -f source_encoding -t dest_encoding -o outputfile inputfile
- p166
-
What are some commonly used text encoding schemes? 107.3
- iso8859 (aka latin-9) - designed for Western European languages
- ASCII - English based char encoding
- UTF-8 Unicode - for all languages, worldwide.
- p169.
-
How to set system date and time? 108.1
- date mmddhhmmyyyy
- Had to search net.
-
How to configure ntp? 108.1
- Ensure pkg installed. Then check /etc/nftp.conf file. Ensure following lines exist, as fallback:
- server 127.127.1.0 # local clock (LCL)
- fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
- Then ensure not on insane time (>17 min diff). If it is, run "ntpdate addrOfTimeProv" to do initial sync (ntpd must be stopped!). Newer ntp versions let you specify "etc/init.d/ntp ntptimeset" which does quick sync. Then start daemon. Do "insserv ntp" to have it run on start.
- p621
-
How to check ntpd status/progress? 108.1
- ntpq -p - Shows status of daemon.
- ntptrace - Traces how consumer is receiving time from provider (incl stratum, etc).
- p623
-
Pool of servers? 108.1
- pool.ntp.org
- Roundrobin volunteer servers
- p622
-
Syslog configuration files 108.2
- Logs stored in /var/log. Most svcs config'd to write to /dev/log, which is run by syslogd svc. syslog then looks at /etc/syslog.conf file to determine what to do. Syntax for etc/syslog.conf is:
- facility.priority file
- Facilities are subsystems that provide msgs. All assigned to one: authpriv, cron, daemon, kern (kernel), lpr, mail, news, syslog (for daemon itself), user, uucp, local0-local7 (for self-dev'd applications). Priorities are usually handled by klogd. Priority choices: debug (All info), info, notice, warn, err (Serious), crit alert or emerg (critical). p680
-
Useful/common log files. 108.2
- /var/log/
- boot.log - Log entries from daemons during startup.
- boot.msg - Shows all msgs displayed on screen during boot.
- faillog - Failed auth attempts
- firewall - Firewall log entries
- lastlog - Last login info for users. View w lastlog cmd.
- mail - Msgs from postfix or sendmail.
- messages - Messages from most running processes. One of most useful.
- warn - Warning messages.
- wtmp - List of user's authenticated. View w last cmd.
- xinetd.log -
- p680
-
Log rotation. 108.2
logrotate. Config'd with /etc/logrotate.conf. Contains defaults. Can customize for certain ones with placing config file in /etc/logrotate.d. p682
-
How to manually add entry to log files? 108.2
- logger -p facilility.priority "log_message"
- p684
-
How to create email aliases? 108.3
- Edit /etc/aliases. Add using this format:
- alias: list of actual email addys (separated by commas).
- Then run newaliases cmd to enable them. p631.
-
Config email fwding. 108.3
Create ~/.forward file that contains email addys, delimited by commas. Note that msgs will not be delivered to actual address. p630
-
Commonly available MTAs (Mail Transfer Agents). 108.3
- sendmail - oldest. Non-componentized. Can be hard to config.
- postfix - Popular. Modular.
- qmail - Modular. Componentized. Untrusting components. Proprietary licensing.
- 2 components:
- QMQP (Quick Mail Queing Protocol) - Allows sharing of queues among diff MTAs.
- QMTP (Quick Mail Transport Protocol - Like SMTP but faster.
- exim - Nonmodular. Single executable, but easy to config.
- p628.
-
Cmd to send a mail to a user? 108.2
- mail [recipient]
- Cmds in mail
- t - type msg
- d - del msg
- u - undelete msg
- n - next msg
- e - edit msg
- R - reply msg
- r - reply all
- m - mail new
- q - quit
- mailq - View unread msgs in mailq.
- p631
-
CUPS components and file locations. 108.4
- cupd. Supports printing over IPP on port 631.
- Parts:
- scheduler - Webserver running on port 631.
- filters - Located in /usr/lib/cups/filter. PDLs (page desc langs)
- backends - provide interface from scheduler to hardware. Located in /usr/lib/cups/backend.
- p603
-
Configuring CUPS. 108.4
- Config files located in /etc/cups. Main config is /etc/cups/cupsd.conf
- To add an admin user, "lppasswd -g sys -a root". Accts contained in /etc/cups/passwd.md5.
- Printers defined in /etc/cups/printers.conf. To add click Administration | Printers | Add Printer | etc...
- p609
-
Cmd to print from the cmd line? 108.4
- lp -d printername filename
- Options:
- -n x - Prints x copies
- -m - Emails conf email to my acct when done
- -q - Sets priority of print job
- -o landscape - Prints landscape mode
- -o sides=2 - Prints doublesided.
- p610
-
Cmd line option to view cups print stats?
- lpstat -t. Shows default printer, current print job, and pending.
- p611
-
Cmd to cancel CUPS jobs? 108.4
cancel [jobname]. p612
-
How to set default cups printer? View current settings? 108.4
lpoptions -d printername. Sets for everyone. Individual users can set default by creating ~/.lpoptions and stating "default printername."
-
What is legacy printing mechanism in Linux? 108.4
- lpd (line printer daemon)
- lpr -P printer-name filename To print
- lpc status For printer status
- lpq View pending jobs
- lprm jobnum Cancel pending job.
- p613
-
Where to config DNS servers? 109.1
- /etc/resolv.conf
- search mydomain.com - Used to fill incomplete hostnames.
- nameserver 192.168.1.1 - Actually nameserver
- p580
-
Where to config default gateway? 109.1
- /etc/sysconfig/network/routes
- Line in here is:
- default 192.168.1.1 - -
- p566
-
List common ports. 109.1
- 20 FTP
- 21 FTP
- 22 SSH
- 23 Telnet
- 25 SMTP
- 53 DNS
- 80 HTTP
- 119 NNTP
- 139 NetBIOS Session Svc
- 143 IMAP
- 161 SNMP
- 443 HTTPS
- 465 URL Rendezvous for SSM (Cisco)
- 993 IMAP over SSL
- 995 POP3 over TLS/SSL
- Source: Inet
-
How to manually & automatically configure a network device? 109.2
- Manual:
- ifconfig eth0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
- Auto:
- dhclient eth0
- One time use only
- p572
-
Where/how to config interface permanently? 109.2
- Create/Edit /etc/sysconfig/network/ifcfg-eth0 or /ifcfg-eth-id-00:0c:29:d1:52:d4, on some distribs.
- BOOTPROTO="static" or "dhcp"
- STARTMODE="auto" or manual or onboot. Start @ boot?
- IPADDR="192.168.1.81/24"
- NETMASK="255.255.255.0" Another option, than /24.
- NETWORK="192.168.1.0" Defines net segment
- BROADCAST="192.168.1.255"
- LABEL_0='0' These 3 lines define IPv6 addr
- IP_ADDR0='2607:f0d0:1002:0011:0000:0000:0000:0003'
- PREFIXLEN_0='64'
- p573
-
How to modify the routing table using a cmd? 109.2
- route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.1.254
- To remove, same options, but start with
- route del
- To add default,
- route add default gw 192.168.1.254
- p578
|
|