Created at:

Modified at:

Linux general tips

Forcing ext3 to check next boot

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

# touch /forcefsck

Easy way to force or disable fsck at boot time with Debian?

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. For example, in bash::

    $ ulimit -c 2000000

A Linux FAQ entry

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:

sysctl documentation

Making filesystem in file

To make a filesystem in a file, like if it were a partition, just follow the following commands.

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

    $ dpkg -S filename_pattern

Find which package contains a file in Debian Linux

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:

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

how to mount ffs partition under linux

NetBSD

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

Change Ubuntu DNS servers

(2022-11-08)

Using Ubuntu GNU/Linux 22.04.1 LTS.

1. Open /etc/netplan/00-installer-config.yaml.

2. Locate the part regarding nameservers addresses and edit them. Save and close the file.

3. Run netplan apply command.

Change DNS server in Ubuntu Command Line

Error: Failed to download metadata for repo 'remi-modular'

(2023-06-26)

(Using Rocky Linux 9.2, but it may also be valid for CentOS, AlmaLinux or RedHat).

On Rocky Linux, if you are having this problem when trying to install a dnf module with dnf module install php:remi-8.0, maybe you should first execute:

# dnf module reset php

List content of a given package in CentOS, RockyLinux and AlmaLinux

(2023-06-29)

To list the content of a given installed package, i.e., what files it installs, run:

$ rpm -qi --filebypkg packagename