home | tech | misc | code | bookmarks (broken) | contact | README


Linux general tips

Forcing ext3 to check next boot

To force ext3 fsck checking in boot time, say in /, add the /forcefsck file, like told here:

# touch /forcefsck

Changing keyboard layout at console

To load keyboard layout at console, just use the command:

# loadkeys <keymap>

Keymaps can be found in keymaps. To change to ABNT2 layout, for instance, type:

# loadkeys br-abnt2

Enabling core dumped on Linux

By default, AFAIK, Linux doesn't create core files when a program suffers core dumped. To enable them, let your shell know that it is allowed to create core files which size is greater than zero, as told in a Linux FAQ entry. For example, in bash:

$ ulimit -c 2000000

The default behaviour is to create a core file named core. But it can yield problems if more than one process is core dumped (they will generate the same core file name, and the first will overwrite the later).

To change the default name, change the kernel.core_pattern option in sysctl. For example, to make it generate core files like in BSD (<process_name>.core), do:

# sysctl kernel.core_pattern='%e.core'

Also see the sysctl documentation to get a full description of this option.

Making filesystem in file

To make a filesystem in a file, like if it were a partition, just follow the following commands (from here):

First, create the file:

$ dd if=/dev/zero of=/tmp/ext2.fs bs=4096 count=$(echo '1024 * 50' | bc)

Then, format it:

$ mkfs.ext2 /tmp/ext2.fs

Finally, mount it as root:

$ sudo mount -o loop /tmp/ext2.fs <mount_point>

Find which package contains a file in Debian and derivated

This site contains interesting forms to find a package that contains a given file. The simplier way is that:

$ dpkg -S filename_pattern

Change default locale and encoding in Ubuntu

Ubuntu, by default, comes with en_US.UTF-8 enabled by default, only, in the installation with the English language. If you want to enable other locales/encodings, follow these steps, as described by this page.

  1. Append the locale and encoding you want to /var/lib/locales/supported.d/local, e.g.: en_US.ISO-8859-1 ISO-8859-1.

  2. Change the default locale and encoding in /etc/default/locale, e. g.: LANG="en_US.ISO-8859-1".

  3. Run, as root:

    # locale-gen --purge
    

Where does GNOME mounts devices?

GNOME (in GNU/Linux distributions like Ubuntu) mounts automatically devices such as USB sticks and remote filesystems. But the mount option does not show the mouting point. This is because it uses gvfs-mount to mount devices. By default, GNOME uses the directory in ~/.gvfs, that do not appear on mount output.

Mount NetBSD partitions under Linux

This is just a small version (for myself) of how to mount ffs partition under linux, in the NetBSD page.

First, verify if ufs module is loaded:

# lsmod | grep ufs

If not, load it. It was necessary under the Ubunbu live CD we are using in this case:

# modprobe ufs

Then, you will able to see NetBSD partitions with the following command:

# sfdisk -l

The output of this command, in my computer, is:

Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1   *      0+  31870   31871- 256003776   a9  NetBSD
/dev/sda2          0       -       0          0    0  Empty
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
/dev/sda5          0+   7648-   7649-  61440120
/dev/sda6       7648+   8158-    510-   4096008
/dev/sda7       8158+   8224-     66-    524664
/dev/sda8       8224+  15873-   7649-  61439584+
/dev/sda9      15873+  18422-   2550-  20480040
/dev/sda10     18422+  31870   13449- 108023359+

See that it lists the NetBSD slice as sda1. NetBSD partitions are sda5, sda7, sda8, sda9, sda10. sda6 is swap.

Finally, to mount it, use the following command:

# mount -t ufs -o ro,ufstype=44bsd /dev/sda5 /mnt/sda5