Changes between Version 17 and Version 18 of Internal/OpenFlow/miscUnix
- Timestamp:
- Aug 28, 2012, 7:35:02 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Internal/OpenFlow/miscUnix
v17 v18 1 = *Nix related tidbits. ..=2 This is a page on various tools and techniques related to *nix administration, programming, disaster recovery - basically, odds and ends that come in handy once every so often.1 = *Nix related tidbits. = 2 This is a page on various tools and techniques related to administration, programming, disaster recovery - basically, odds and ends that come in handy once every so often on a UNIX-like system. 3 3 Anything based on a link is reiterated just for completeness, and just in case a link dies. 4 4 5 This page is a compilation of things done with Ubuntu and FreeBSD; however, general practices doapply to any UNIX-like OS, though syntax will inevitably be different.5 This page is a compilation of things done with Ubuntu and FreeBSD; however, general practices should apply to any UNIX-like OS, though syntax will inevitably be different. 6 6 7 7 [#shell Shell-based] Command-line tools. So far, this section includes: 8 * extundelete - forfile system recovery9 * cdrecord - for burningISO's10 * process I/O redirection ( gdb)11 * fixing garbled text ( gcc)8 * `extundelete` - Linux file system recovery 9 * `cdrecord` - burning bootable ISO's 10 * process I/O redirection (`gdb`) 11 * fixing garbled text (`gcc`) 12 12 [#net Network] Various networking-related things. 13 13 * Disabling SSH timeout 14 14 * NAT boxes 15 * with `ufw` 16 * with `pf` 17 [#print Printing] quick CUPS setup [[BR]] 15 * with `ufw` (Linux) 16 * with `pf` (*BSD) 17 [#print Quick Printing] Printing under *nix, relatively quickly 18 * CUPS 19 * `lpd` 18 20 [#fortune one-liners] miscellaneous single-sentence tips. [[BR]] 19 21 ---- … … 179 181 180 182 == NAT boxes. == 183 NAT boxes are handy if you want to build a gateway. First and foremost, you need to enable IP packet forwarding on your to-be-NAT box. [[BR]] 184 On Linux, the command 185 {{{ 186 sudo sysctl -e net.ipv4.ip_forward=1 187 }}} 188 at the shell enables it. For persistence, add the following line to /etc/default/ufw: 189 {{{ 190 net.ipv4.ip_forward=1 191 }}} 192 193 [[BR]] 194 Similarly for FreeBSD (assuming you have `sudo` installed), 195 {{{ 196 sudo sysctl net.inet.ip.forwarding=1 197 }}} 198 enables it, and the following line in /etc/sysctl.conf makes it persistent: 199 {{{ 200 net.inet.ip.forwarding=1 201 }}} 202 181 203 === with `ufw` === 182 204 source: https://nowhere.dk/articles/tip_nat_with_ubuntus_ufw_firewall … … 187 209 {{{ 188 210 DEFAULT_FORWARD_POLICY="ACCEPT" 189 }}}190 and /etc/ufw/sysctl.conf :191 {{{192 net.ipv4.ip_forward=1193 211 }}} 194 212 2. set up IP masquerading in `ufw` … … 230 248 sudo pfctl -e -f /etc/pf.conf 231 249 }}} 232 If it throws errors, make sure that the kernel module (pf.ko or something similar) is loaded. Also, don't forget that IP forwarding is enabled:233 {{{ 234 sudo sysctl net.inet.ip.forwarding=1 235 }}} 236 ---- 237 == Printing setup with CUPS. == #print250 If it throws errors, make sure that the kernel module (pf.ko or something similar) is loaded. 251 252 ---- 253 == Quick Printing Setup. == #print 254 This section contains info that should let you get up and printing from a network printer relatively quickly. 255 === with CUPS === 238 256 * ref: http://linuxcourse.rutgers.edu/howto/cups_printing.html 239 257 CUPS stands for Common UNIX Printing System, and is fairly standard as a means to print from UNIX and UNIX-like things. We'll describe the steps needed for quick CUPS printing setup (bare-bones) in Ubuntu 11.04 … … 248 266 tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 249 267 }}} 250 If you see it, point your browser to localhost:631. You should get a shiny-white welcome page. Yes, it was made by Apple. 268 If you see it, point your browser to localhost:631. You should get a shiny-white welcome page. Yes, it was made by Apple. 269 251 270 3. Add your printer from the Administration tab -> Add Printer. It will ask for the root user and password (OK if you are on sudoers). You will be asked to provide info on the printer, and choose the drivers. 252 271 [[BR]] 253 If all goes well, you will be able to see the printer's status with `lpstat`.272 If all goes well, you will be able to see the printer's status with `lpstat`. 254 273 {{{ 255 274 $ lpstat -p -d … … 257 276 no system default destination 258 277 }}} 259 If you want to print, you can do so by invoking `lp`:278 If you want to print, you can do so by invoking `lp`: 260 279 {{{ 261 280 $ lp -o sides=two-sided-long-edge -d Phaser_5500DT [filename] 281 }}} 282 283 === with `lpd` === 284 * ref: http://www.wonkity.com/~wblock/docs/html/lpdprinting.html 285 `lpd` comes packaged with FreeBSD, and is therefore extensively covered in its handbook. The above link lets you get going relatively quickly; here parts of the link are repeated. 286 287 1. (1) set up the spool directory (where printed files go temporarily), with (2) modified perms to keep jobs private: 288 {{{ 289 mkdir /var/spool/lpd/lp (1) 290 chown daemon:daemon /var/spool/lpd/lp 291 chmod 770 /var/spool/lpd/lp (2) 292 }}} 293 2. enable `lpd`. Add the following to /etc/rc.conf: 294 {{{ 295 lpd_enable="YES" 296 }}} 297 to make `lpd` start at boot-up. "lpd" at the shell as root will also start it. 298 299 3. edit /etc/printcap : 300 {{{ 301 lp:\ 302 :lp=9100@192.168.200.32:\ 303 :sh:\ 304 :mx#0:\ 305 :sd=/var/spool/lpd/lp:\ 306 :lf=/var/log/lpd-errs: 307 }}} 308 * lp : the printer (port@machine IP), specifically Phaser_5500DT (the WINLAB printer in the large cubicle room) 309 * sh : suppress page header 310 * mx : maximum file size set to 0 (unlimited) 311 * sd : spool directory 312 * lf : file for error logging 313 [[BR]] 314 You can test if your setup works by piping a text string to `lpr`: 315 {{{ 316 printf "printer test page\r\n\f" | lpr 317 }}} 318 You also may have to do some extra work to print certain file formats. The WINLAB printer doesn't support direct printing of PDFs, so a quick work-around is to (1) convert, and (2) print it as a Postscript file: 319 {{{ 320 pdf2ps /tmp/myfile.pdf /tmp/myfile.ps (1) 321 lpr /tmp/myfile.ps (2) 262 322 }}} 263 323 ---- … … 271 331 ---- 272 332 [[BR]] 333