Posts with the tag System Administration

Setting Up A Log Host for Syslog

Let's suppose you have a device that has remote logging capabilities like the Switch TL-SG3210. In this case you may want to set up a machine on your local network to receive these log messages and store them permanently.

On Linux you have the choice between rsyslog and <a...

Read on

Automatically Update Packages on a Ubuntu or Debian Server

To automatically install updates on Ubuntu / Debian you can install the package cron-apt:

sudo aptitude install cron-apt

In /etc/cron-apt/config you can set up your email address for notifications by setting the value for MAILTO.

resources

...

Read on

Backup saved passwords in Ubuntu

To make a backup of the saved passwords in Ubuntu just make a backup of the folder ~/.gnome2/keyrings/. This is where Gnome stores its password keyrings (named something like somename.keyring).

You can also export all your passwords from the Gnome Keyring using the python module keyring as described in <a...

Read on

Zombie Processes on Linux

Find zombie / defunct processes:

ps -ef | grep -i defunct

Kill them:

sudo ./kill-zombies.sh --admin

where kill-zombies.sh is the following bash script by Markus Gattol:

#! /bin/bash
#
# Zombie processes killing script. Must be run under root.

case "$1" in
--admin)
 ...

Read on

Boot Info Script

T get the boot_info_script, run:

cd ~/Downloads
wget http://sourceforge.net/projects/bootinfoscript/files/bootinfoscript/0.55/boot_info_script055.sh/download -O boot_info_script.sh

To execute the boot_info_script and thus get information about your bootable partitions etc., run:

sudo bash ~/Downloads/boot_info_script.sh

Resources

...

Read on

Upgrade to Ubuntu Maverick using the CD

https://help.ubuntu.com/community/LucidUpgrades#Upgrading%20Using%20the%20Alternate%20CD/DVD

  1. Download the alternate installation CD
  2. Burn and insert it or mount it using sudo mount -o loop ~/Desktop/ubuntu-10.04-alternate-i386.iso /media/cdrom0
  3. Follow the on-screen instructions or run gksu "sh /cdrom/cdromupgrade"
...

Read on

Downgrade a Package

https://help.ubuntu.com/community/DowngradeHowto

using Synaptic: Package → Force Version in Synaptic

preferred using aptitude:

apt-cache showpkg libAppA

which will produce an output similar like this:

Provides:
6.5.1-cvs20060628 - libAppA
6.4.1-0ubuntu8 - libAppA

So you can force a certain...

Read on

Viewing the Changelog of Ubuntu Packages

at the command line using aptitude:

aptitude changelog <packagename>

This only works for officially supported packages, so it won't work for PPAs

alias to see the changelog for all packages that need an update

To see a description of all available updates, I create for myself the following alias in the ~/.bashrc:

<div...

Read on

HowTo generate secure passwords using pwgen

http://wiki.ubuntuusers.de/Shell/pwgen

sudo aptitude install pwgen

pwgen can generate safe passwords for you. It is a command line tool and can be used like this:

pwgen -s -y 8 1

-s means create a secure password, -y means it should contain at least one special character, 8 means it...

Read on

Advanced Usage of ethtool

There exist a comparison of ethtool in linux with the equivalents in solaris command-by-command... It's great!

not available anymore... but here is an archived version: https://web.archive.org/web/20120918092833/http://hub.opensolaris.org/bin/view/Project+brussels/ethtool-dladm-comparison

...

Read on

Remove the 5% root quota of an ext2 / ext3 partition

Usually 5% of the storage of an ext2 or ext3 volume are reserved for the root user. You can use tune2fs to make that space available to other users!

tune2fs -m 0 /dev/sdb1

Only do this for non-system partitions (as you might need the "root quota" to recover from full...

Read on

Solve Boot Problems: The Kernel Did Not Find the Root Partition Using its UUID

On startup the system hung because the root UUID was not found. http://ubuntuforums.org/showthread.php?p=9020811#post9020811

So when I ran sudo blkid — executed from a live cd — it didn't show the root partition (all other partitions UUIDs were listed).

But tune2fs showed me its UUID

sudo tune2fs -l /dev/sda2

So I tried...

Read on

Find out To What Package a File Belongs & What Files Belong to a Package

http://wiki.ubuntuusers.de/apt-get#Zuordnung-von-Paketen-und-Dateien
http://www.debian.org/doc/manuals/apt-howto/ch-search.de.html#s-apt-file

dpkg -S

Find out the files that belong to an installed package.

dpkg -S packagename

apt-file

sudo apt-file update
apt-file search filename

Works like dpkg -S but also shows not installed packages that contain the file.

apt-file list packagename
...

Read on

Restore Grub2

http://wiki.ubuntuusers.de/Grub_2#GRUB-2-wiederherstellen
After an installation of Windows 7, Grub2 would not start any more as Windows overwrote the boot loader section. So i did the following:

  1. Boot the Ubuntu Live CD.
  2. Find out correct disc and mount the root partition:

    sudo fdisk -l
    sudo mount /dev/sda2 /mnt
    
  3. If you have a separate boot partition...

Read on

gpointing-device-settings – Manage Synaptic Touchpads on Linux

gpointing-device-settings lets you manage your Synaptic touchpads etc. (gsynaptics is deprecated, use gpointing-device-settings instead):

sudo apt-get update && sudo apt-get install gpointing-device-settings
...

Read on

Speed up your Ubuntu karmic system

http://www.n00bsonubuntu.com/tips/improvebootinternetkarmic

  • enable preload: sudo apt-get install -y preload (more: http://wiki.ubuntuusers.de/tuning#Preload. Change settings using sudo gedit /etc/preload.conf and display the log file using sudo cat /var/log/preload.log. A more extensive state file can be accessed on: /var/lib/preload/preload.state.)
  • disable Pango smoothing on Firefox export MOZ_DISABLE_PANGO=1. Put this in your ~/.bash_profile or ~/.bashrc.
  • start...

Read on

Delete Wine Launcher Files from Gnome Menu

To delete a launcher for an installed Windows program via Wine just remove it from the directory ~/.local/share/applications/wine/Programs.

...

Read on

Convert mbox to Maildir

A link collection for howtos to convert mail stored in the mbox format to the Maildir format:

Perl Scripts

Combinations of Scripts

Read on

Write the system status to a logfile every hour

It may happen that your system is slow for some reason, it may fail completely, be under an attack, it can even have a troyan and you do not even know. I found a script recently which integrates into your system via a daily cronjob. It uses logrotate. So it...

Read on

Have a look at your MBR using `dd`, `hexdump` and `file`

With two little tools (dd and hexdump) you can use your command line to inspect / investigate the master boot record of a hard disk.

The command is

sudo dd if=/dev/sda bs=512 count=1 | hexdump -C

where /dev/sda is the hard disk you want to inspect.

So here I provide an example...

Read on

Read and Redirect Local System Mail to `/var/mail/USERNAME`

Read Local Emails Using Evolution

  1. Start Evolution
  2. Edit → Preferences → Add
    (replace "USERNAME" with your login user name):
  3. Name: USERNAME@localhost
  4. Fullname: USERNAME
  5. Server type: Local Delivery
  6. Path: /var/mail/USERNAME
  7. Sending Mail: sendmail

Read Local Emails Using mutt

http://wiki.ubuntuusers.de/Mutt

start Mutt using

mutt

you will end in the mbox dir /var/mail/USERNAME. After reading the messages, they are...

Read on

Synchronize Directories using Unison

Unison is a great tool to keep directories and files synchronized. It is extremely simple to use once you figure out how to do the setup and it can be done automatically (via a cronjob).

I show you here how to do it:

If you are not sure if used Unison before,...

Read on

Little tricks to speed up Ubuntu 9.10 karmic koala

Tips found on: http://www.n00bsonubuntu.com/tips/improvebootinternetkarmic
If you want to know how those tricks work, have a look at the link above!

  • enable preload: sudo apt-get install -y preload
    Find detailed information on preload here.
  • disable Pango smoothing on Firefox export MOZ_DISABLE_PANGO=1. Put this in your ~/.bash_profile or ~/.bashrc.
  • start Firefox and...

Read on

Workaround for problems with constantly changing resolv.conf

When you don't want other software (like network manager) to mess with your DNS server settings, make /etc/resolv.conf immutable:

sudo chattr +i /etc/resolv.conf

It can be undone like this:

sudo chattr -i /etc/resolv.conf

resources

http://ubuntuforums.org/showthread.php?t=435525

...

Read on

Set Up HRZ Printers (Hochschulrechenzentrum Universität Frankfurt - Studentendruck)

http://www.studentendruck.uni-frankfurt.de/org/hrz/services/druck/follow_me_druck/studierende/index.html

cd ~/Downloads/
wget ftp://ftp.rz.uni-frankfurt.de/pub/_Linux/Druckertreiber/Ricoh_MPC3500/Ricoh-Aficio_MP_C3500_PS.ppd
wget ftp://ftp.rz.uni-frankfurt.de/pub/_Linux/Druckertreiber/Ricoh_MP3350/Ricoh-Aficio_MP_3350_PS.ppd
sudo cp Ricoh-Aficio_MP_C3500_PS.ppd /etc/cups/ppd
sudo cp Ricoh-Aficio_MP_3350_PS.ppd /etc/cups/ppd
GEHEIM='HRZ-LOGIN:HRZ-PASSWORT'
sudo lpadmin -p schwarzweiss_hrz -v smb://${GEHEIM}@ntsamba1.server.uni-frankfurt.de/schwarzweiss -P /etc/cups/ppd/Ricoh-Aficio_MP_3350_PS.ppd -E
lpq -P schwarzweiss_hrz
sudo lpadmin -p farbe_hrz -v smb://${GEHEIM}@ntsamba1.server.uni-frankfurt.de/farbe -P /etc/cups/ppd/Ricoh-Aficio_MP_C3500_PS.ppd -E
lpq -P farbe_hrz
...

Read on

Upgrade to grub2 on Ubuntu karmic

http://grub.enbug.org/Grub2LiveCdInstallGuide
http://everflux.de/ubuntu-jaunty-zu-karmic-koala-update-1390/
http://wiki.ubuntuusers.de/Grub_2
http://wiki.ubuntuusers.de/GRUB_2/Konfiguration

After your system was upgraded from Ubuntu jaunty 9.04 to karmic 9.10 you still have grub1.5 on your HDD. To replace it with grub2 do

sudo apt-get install grub2
sudo upgrade-from-grub-legacy
...

Read on

Uninstall Mathematica on Ubuntu Linux

Basically, you have to:

  • delete the folders /usr/local/Wolfram and /usr/share/Mathematica.
  • remove a number of links in /usr/local/bin: mathematica mcc Mathematica math MathKernel.
  • in your home directory you can remove the folder ~/.Mathematica

The following commands do that all:

sudo rm -rf /usr/local/Wolfram
sudo rm -rf /usr/share/Mathematica
cd /usr/local/bin
sudo rm mathematica mcc Mathematica math MathKernel
rm -rf...

Read on

Run Script Triggered by Kernel Upgrade

http://www.tuxyturvy.com/blog/index.php?/archives/48-Automating-VMware-modules-reinstall-after-Linux-kernel-upgrades.html
http://www.debianhelp.co.uk/boot.htm (← about the debian /ubuntu startup process)

myTool is what you want to set up after a kernel upgrade

#!/bin/bash
if [ ! -e /lib/modules/`uname -r`/misc/.myTool_installed ]; then
        /usr/bin/vmware-config.pl --default
 ...

Read on

The screen command - A versatile tool

With screen you can run an SSH command without interrupting the execution when the connection is lost. In case of a connection loss, all you have to do is to reconnected to the SSH host again when a connection is available and attach to the former screen session again.

Install screen:

<div...

Read on

Delete old & unused Kernels

You could also use the "System Clean Up Tool": https://wiki.ubuntu.com/SystemCleanUpTool

List all installed kernels:

dpkg --list | grep linux-image

Then remove the kernel(s) you don't need anymore. e.g.:

sudo aptitude remove linux-image-2.6.28-11-generic

This automatically removes all kernel modules depending on this kernel image and the kernel headers. It also...

Read on

Renaming Network Interfaces (When Changing Network Cards)

When I inserted a new network card into my Linux computer, the new network interface was named with an incremented number at the end. I didn't want that as my network setup (firewall rules etc.) were set up for the former name. So I had to change the configuration to rename...

Read on

OpenJDK and Sun Java on Ubuntu 9.04

https://help.ubuntu.com/community/Java

install openjdk:

sudo aptitude install openjdk-6-jre

install sun java v6

sudo aptitude install sun-java6-bin

Choosing the default Java to use

Just installing new Java flavours does not change the default Java pointed to by /usr/bin/java. You must explicitly set this:

to see the current configuration and possibilities:

sudo update-java-alternatives -l

to...

Read on

strace - Watch File Access of any Executable

To trace files that a certain software opens, run:
strace -e trace=open -o my_progam.log my_program
# Or include access as well:
strace -e trace=open,access my_program
# Log a CDROM autorun:
strace -o out.txt -f ./cdrom/autorun
# Analyze log file for operations setting a SUID bit:
grep '...

Read on

Find out UUID of your Partitions

Run blkid:

blkid
    /dev/sda1: UUID=”1c9e4ae2-0ddc-4e3c-8758-4cdd6c90407a” SEC_TYPE=”ext2″ TYPE=”ext3″
    /dev/sda5: UUID=”a647ea33-74ee-4123-84bf-7edc32e2e39b” TYPE=”swap”
...

Read on

Recover Linux Account when You Forgot the Password

http://www.ubuntugeek.com/howtorecover-your-username-and-passwordfix-grub-21-error-in-ubuntu.html

If you have a Linux machine and forgot the password you set during the installation process or if one of your friends gave you his old computer including a Linux installation without giving providing you his user name and password you can use this tutorial to help you...

Read on

CLI for the NetworkManager

NetworkManager has a DBUS API, so other applications can use DBUS to communicate with it and change its settings. I found three different ways to do this on the command line using a CLI (command line interface):

nmcli (NetworkManagerCmdline)

As of 2010-12-18 the most actively maintained project is nmcli: http://fedoraproject.org/wiki/Features/NetworkManagerCmdline.

Compare nmcli...

Read on

Autostart on Ubuntu

Xorg Server Autostart:

Check xinit(1) man page for further details.
System wide autostart: /etc/X11/xinit/xinitrc
User specific autostart: ~/.xinitrc

Gnome

http://wiki.ubuntuusers.de/Autostart

Gnome user specific:
System → Einstellungen → Sitzungen → Startprogramm

Gnome system wide:
Create a file e.g. MyProgram.desktop in the directory /etc/xdg/autostart:

[Desktop Entry]
Encoding=UTF-8
Name=MyProgram
Exec=command to be executed
<span...

Read on

Use smartmontools to monitor S.M.A.R.T. status of your HDDs

The S.M.A.R.T. status is not a perfect measure of your hdd health but it can sometimes provide pre-failure notification. Here is how to check the S.M.A.R.T. status on Ubuntu:

Install the smartmontools using:

sudo aptitude install smartmontools

To display all the S.M.A.R.T. information for an IDE drive, run

sudo smartctl...

Read on

Shutdown System Automatically Later

You might want to have some entertainment while falling asleep...

To shutdown the system in 30 minutes time:

sudo shutdown -P +30

cancel shutdown during that time:

sudo shutdown -c
...

Read on

Delete Downloaded Packages After Installation (Clean Package Cache)

If you're out of hard disk space on the root partition then set up you system to delete packages after installing:

sudo synaptic

Settings → Preferences → Files → Delete downloaded packages after installation, also click Delete Cached Package Files.

delete package files after installation using command line

On the command line...

Read on

Uninstall the Proprietary Nvidia Driver

For my Nvidia Geforce 8600 GT in order to uninstall the driver I have to run the following command and restart:

sudo aptitude remove nvidia-glx-180
...

Read on

Ubuntu's Automatic File System Checks

http://wiki.ubuntuusers.de/Dateisystemcheck

Fix errors automatically on startup

sudo gedit /etc/default/rcS

and change FSCKFIX=no to FSCKFIX=yes

Force a check of all ext3 partitions on next startup

sudo touch /forcefsck

View results of previous filesystem checks

less /var/log/fsck/checkroot
less /var/log/fsck/checkfs
...

Read on

Empty Gnome Trash using Terminal

I connected my old notebook hard disk to my desktop computer (as the HDD was exchanged). To expunge the trash folder I did:

cd /media/disk/home/philipp/.local/share/Trash/info/
ls
rm -rf *
cd /media/disk/home/philipp/.local/share/Trash/files/
ls
rm -rf *
...

Read on

No Beep on Reboot

http://ubuntuforums.org/showthread.php?t=1177256

sudo gedit /etc/modprobe.d/blacklist.conf

Then add those two lines to the blacklist and click save:

#Stop PC speaker
blacklist pcspkr
...

Read on

Share Internet Connection

http://ph.ubuntuforums.com/showthread.php?t=335465

install needed packages:

sudo aptitude install dnsmasq ipmasq dhcp3-server

configure network/interfaces

auto lo
iface lo inet loopback
auto eth0
auto eth1
iface eth1 inet static
  address 192.168.0.1
  netmask 255.255.255.0
  broadcast 192.168.0.255
  wireless-mode master
  wireless-essid HDFredistribution

dhcp

Change in /etc/default/dhcp3-server the line INTERFACES="" to INTERFACES="eth1"

In /etc/dhcp3/dhcpd.conf comment out the...

Read on

Add GUI for lm-sensors to the Panel

http://wiki.ubuntu-forum.de/index.php/Lm-sensors (German)

sudo apt-get install sensors-applet

Right click on the panel → Add to Panel → Hardware Sensors Monitor

...

Read on

Raising Skinny Elephants is Utterly Boring (or: if all else fails)

The magic key codes on Linux systems:

press Alt + SysRQ ("print") +

  • R keyboard → raw mode
  • S sync disc
  • E terminate all processes
  • I kill all processes
  • U remout all filesystems read-only
  • reboot

That works almost all the time. Even after problematic errors.

...

Read on

Set up Port-Knocking

The installation of the port knocking daemon is quite simple:

sudo apt-get install knockd

To start the knockd daemon automatically: uncomment START_KNOCKD=1 in /etc/default/knockd.

Configuration:

Edit the config file /etc/knockd.conf:

[options]
   logfile = /var/log/knockd.log
[openSSH]
   sequence    = <span...

Read on

Display Contents of .deb Packages Using deb-gview

You can display the contents of a .deb package with the program deb-gview. To install run:

sudo aptitude install deb-gview

To have a look at the contents of the package garmin-upload-tools_1.2.0_all.deb run:

deb-gview garmin-upload-tools_1.2.0_all.deb
...

Read on

Chroot SFTP users

OpenSSH supports jailing SFTP users to a directory (using chroot) just by changing its configuration file:

Basically you add the users you want to jail to a linux user group (sftp) and add the following lines to /etc/ssh/sshd_config:

### Comment out the following line:
#Subsystem sftp /usr/lib/openssh/sftp-server
### and replace with:
Subsystem sftp...

Read on

Short Of Disk Space - Find Large Files & Clear Caches

When your hard disk is getting full you might want to know why and what files are the largest. This post describes how to find that out and clean up using the disk usage analyser, package cache cleaning and a fast way to list big files on the terminal using...

Read on

Check Logfiles of Cron Daemon

check if cron runs the scripts as it should

cat /var/log/syslog

example output:

Jun 21 20:31:01 lion /USR/SBIN/CRON[8702]: (philipp) CMD (~philipp/sync.sh)

From the cron manpage:

  • cron logs its action to the syslog facility ’cron’, and logging may be controlled using the standard syslogd(8) facility. So if syslogd is available it is...

Read on