Random notes & tips
- Change or disable keyboard beep
- Shutdown
- Leave X and come back
- Vi – Show lines
- Vi – Jump to a line
- Show and change hostname
- Error – database too small: /var/db/locate.database
- Change repository, package mirror
Change or disable keyboard beep
Shutdown
$ doas shutdown -p now
Leave X and come back
You have logged into the X server, but want to quickly jump to a regular terminal? You can type this shortcut with an F key, depending on the number, you will either be dropeed to ttyC0
, ttyC1
, ttyC2
, ttyC3
, ttyC5
or ttyC6
.
Ctrl
+Alt
+{F1,F2,F3,F4,F6}
To go back to the X server, pres Ctrl
+ Alt
+ F5
to go back to your X session, which will be left as it was before.
Also make sure to log out of the other terminal ttys because anyone will be able to switch back to them and you don't want to be logged in when that happens.
Vi – Show lines
To show lines in a file opened in vi
, press Esc
to enter Normal/Command mode and type :set number
.
To make this persistent = show lines by default when you open any file, create a file called .nexrc
in your home directory and put set number
on the first line of it.
$ cd ~
$ touch .nexrc
.nexrc
set number
Vi – Jump to a line
In Normal mode, type :{line_nubmer}
, e.g :20
.
Show and change hostname
Show
To show your hostname, you can conveniently type hostname
into the terminal:
Example output:
Desktop.domain.local
To omit the domain information from the output, type hostname -s
Desktop
Edit
Hostname information is located in /etc/myname
and it's read during the startup. Edit the content of the file to change hostname.
$ doas nvim /etc/myname
This will however propagate on the next reboot, to change the hostname immediately, type:
$ doas hostname new_hostname
$ hostname
new_hostname
Error – database too small: /var/db/locate.database
Locate
is a cool utility that allows you to search through your filesystem quickly thanks to an index database it maintains. It should update this index automatically at midnight (at least on Linux), but sometime you want to do that manually to have an up to date database index immediatelly. Also, if you run into the database too small: /var/db/locate.database
issue, you can fix it with the following command as well:
$ doas /usr/libexec/locate.updatedb
Afterwards, locate
should execute normally.
Change repository, package mirror
Mirror information is located in /etc/installurl
file. Unlike on Linux, where package managers usually offer extensive features like multiple repositories with different priority settings etc., on OpenBSD, there's just a single file with a single URL.
Open the /etc/installurl
file in an editor and put a single URL from this mirror list into the file.
$ doas vi /etc/installurl
There's no need to update repositories like on Linux, it will automatically use the new repository when installing or updating packages, which you can try with pkg_add -u -v