Technical Notes: Unix

From Mediawiki-1
Jump to navigation Jump to search

Systems Management

Boot Topics

Disabling selinux

Sometimes it it useful to boot the system without SELinux enabled for temporary administrative work. In this case you may pass selinux=0 option to the kernel (in boot manager).


Grub needs to be installed on the first disk to function as an independent boot loader, for all other configurations grub needs to be chain loaded.

During the bootstrap process the boot loader mounts the first partition as "/" upon startup and looks for the /boot/grub directory. All paths in grub.conf are relative to this "/" directory. THe same partition might be mounted as /boot in the fully booted OS (as is the case on acadia).

After changing grub.conf, which is linked to menu.lst, do NOT run grub-install ! THe bootloader looks for this configuration file in /boot/grub and reads it when starting up (THe docu "info grub" says menu.lst must be present in /boot directory, but trial and error showed it needs to be in /boot/grub)!

The --root-directory argument of grub-install refers to the location (within the running OS) where grub files (the various stages) are written. THe "device" argument specifies where the bootloader code will be installed.

File Systems

Mounting a device

by UUID:

   Determine UUID using 'ls -l /dev/disk/by-uuid
   Add line to fstab file like:
   UUID=3c5d8359-e415-4a39-ac41-da892b413ca8       /media/usb_backup_local3        ext3 user,noauto,rw,nosuid,user_xattr,acl 0 0

by Label:

   Label device or find label: e2label or tune2fs
   Add line to fstab file like: LABEL=local0            /local/0                ext3    defaults        1 2


   dump / restore commands
   rdist -P /usr/bin/ssh -o whole -c /local/3 root@atlas:/media/usb_backup_local3


 setfacl / getfacl
 lsattr / chattr

Misc Commands

 awk '{print s += $6 }'

Performance Management

Disk IO

  • dstat -D hda,hdb,total 5 ... disk IO details


  • vmstat
  • top
  • free ... shows cached memory as well



Required packages (rpm -qa | egrep 'snmp|mbrows')


Printing from Unix to Windows Print Server


Enable Windows support for Unix printing

Here is the XP sequence. Vista is quite similar: Open Control Panel --> Add or remove programs --> Add/remove windows components. Scroll down to "Other Network File & Print Services". iconHighlight that and select "details". Put a check mark in "Print Services for Unix" and OK/Next or whatever.

Now that Unix services are installed, activate them as a service: Open Control Panel --> Administrative Tools --> Services (Local) and findiconTCP/IP print server. It should be set to "Status= started" and "Start type=Automatic". To change settings you double Lclick the line "TCP/IP print server" and adjust appropriately.icon

Setting up a Linux client to print using LPD protocol (alternative to Samba)

Note: the client does NOT use or need Samba for LPD. Open Cups Admin's GUI by entering this address in your browser (or click this link): http://localhost:631 where you can review the existing situation.icon. The GUI differs across the various Suse releases. Find the "add Printer" function, click and fill in a useful name and optionally a location & description.icon

"Continue" on and select "LPD/LPR Host or Printer" as the device type for your CanonBub printericon. Then "continue" and fill in the URI. The server address is DragaXP for dynamic addressing and for fixed addressing - and the exact server queuename is CanonBub. So for dynamic (DHCP) addressing use this address --> lpd://DragaXP/CanonBub and for fixed addressing use this --> lpd:// Next select the modeliconand the printer driver.iconFinally, you can set the default printer and test the connectivity to the Windows server. You should now be printing from Linux_To_Windows via LPDicon

Setting up a Linux client using Samba's SMB/CIFS Protocol (alternative to LPD)

Check that Samba has been configured for cups printing. The [global] entry will contain at least these lines if it has been configured for cups printing. [global] printing = cups printcap name = cups

Open cups admin on http://localhost:631 and execute these steps:

  • Open Printers and Add Printer
  • Enter the name CanonBub. This becomes the queuename. You can fill in the optional Location and Description to suit.
  • In Device type choose Windows Printer via SAMBA from the drop-down list
  • Fixed IP: In Device URI enter smb://workgroup/username:password@, where "username", "password" and "workgroup" are real and give access to the server.
  • Dynamic IP: In Device URI enter smb://workgroup/username:password@DragaXP/CanonBub, where "username", "password" and "workgroup" are real and give access to the server.
  • Choose the printer driver from the cups database on the final screens
  • Execute a Print Test Page and you should be printing from Linux_To_Windows via Samba

Creating Floppy Images

  • /sbin/mkfs.msdos -C floppy.img 1440
  • dd bs=512 count=2880 if=/dev/zero of=imagefile.img
  • cat /dev/fd0 > imagefile.img
  • mount -o loop floppy.img /media/floppy1/

Writing CD's under Linux


The temporary disk area available for preparing and writing CD's is in /scratch. Create a directory in /scratch (usually with the same name as your username, the convention with all Unix temporary areas) and create a subdirectory (say cdrom) to contain the directory tree of data. Then the steps to create a cd are:

  • Copy the required files to the cdrom directory, using scp or ftp if the files are on a remote machine. Note that the directory cdrom itself will not appear on the cd, the top level of the cd will be the contents of cdrom.
  • Copy the required files and directories to the cdrom directory.
  • Use the command mkisofs to create an ISO9660 image file of the directory tree.
  • Write the image file to the blank cd with the command cdrecord.

An example:

 > cd /scratch
 > mkdir n123456
 > cd n123456
 > mkdir cdrom
 > cp -a ~/data ~/programs cdrom
 > cd ..  
 > mkisofs -o cdimage.raw -l -L -R -v cdrom
 > cdrecord -v dev=1,2,0 speed=1 cdimage.raw

Some Notes:

The command mkisofs has many options. The option -l allows long filenames (i.e., not restricted to MSDOS 8.3 format); -L allows files to start with the character . (which is otherwise replaced as an initial character by _); -R enables the ``Rock Ridge extensions to the ISO9660 format; -v selects verbose mode, so that mkisofs outputs progress reports. The options -R and -r are very similar, and one or the other should be used. The essential difference is that -R records the ownership and permissions as with the original files, whereas -r sets ownership to the user root, and essentially world-readable permissions. The dev=... option to cdrecord selects the device to use. On velma, this is 1,2,0, on davey it is 0,3,0. The maximum speed of the CDR on davey is 4, and on velma it is 8 for CDR media and 4 for CDRW media. However the most reliable writing speed is 1. It is possibly best to blank CDRW media that has already been used. This can be done with the command cdrecord -v dev=1,2,0 blank=all


Useful programs:

  • ffmpeg ... convert various video formats (notably, vob->quicktime), the - formats option shows available formats
  • vlc ... universal media player (VideoLAN Client)