Thursday, May 4, 2017
Commandline auto-login in Ubuntu 16.04
This works in Ubuntu and Raspbian, it probably works in any systemd distro.
mkdir -p /etc/systemd/system/getty@tty1.service.d/
Create a file at /etc/systemd/system/getty@tty1.service.d/autologin.conf with contents:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I \$TERM
Replace USERNAME with the actual username to login.
You can now reboot and test this.
If you want to start something on startup, then create a file /etc/profile.d/10-runthing.sh with contents like:
if [ "$(tty)" = "/dev/tty1" ]; then
THING
fi
Replace THING with the command to run. You could run tmux so you never forget. You could compile DOSBox so it runs on the framebuffer and you appear to have a DOS computer, which is why I wanted to do this.
Wednesday, November 13, 2013
how does mke2fs decide automatic check mount count?
However, the number seems to vary depending on the filesystem. How is this value calculated? I used the source of e2fsprogs-1.42.8 and the cscope source code tool to find this out.
Sunday, August 5, 2012
how to persist ethtool settings across reboot
For example, ethtool -g ethX reads the size of the ring buffer on the NIC, and ethtool -G ethx rx A tx B changes it. Use man ethtool to discover more settings.
But these options don't persist across reboot, so how do you make sure your settings are kept permanent?
You can enter the ethtool commands in /etc/rc.local (or your distribution's equivalent) where commands are run after the current runlevel completes, but this isn't ideal. Network services may have started during the runlevel and ethtool commands tend to interrupt network traffic. It would be more preferable to have the commands applied as the interface is brought up.
The network service in CentOS has the ability to do this. The script /etc/sysconfig/network-scripts/ifup-post checks for the existence of /sbin/ifup-local, and if it exists, runs it with the interface name as a parameter (eg: /sbin/ifup-local eth0)
We can create this file with touch /sbin/ifup-local make it executable with chmod +x /sbin/ifup-local set its SELinux context with chcon --reference /sbin/ifup /sbin/ifup-local and then open it in an editor.
A simple script to apply the same settings to all interfaces would be something like:
#!/bin/bash if [ -n "$1" ]; then /sbin/ethtool -G $1 rx 4096 tx 4096 /sbin/ethtool -K $1 tso on gso on fiKeep in mind this will attempt to apply settings to ALL interfaces, even the loopback.
If we have different interfaces we want to apply different settings to, or want to skip the loopback, we can make a case statement:
#!/bin/bash case "$1" in eth0) /sbin/ethtool -G $1 rx 16384 tx 16384 /sbin/ethtool -K $1 gso on gro on ;; eth1) /sbin/ethtool -G $1 rx 64 tx 64 /sbin/ethtool -K $1 tso on gso on /sbin/ip link set $1 txqueuelen 0 ;; esac exit 0Now ethtool settings are applied to interfaces as they start, all potential interruptions to network communication are done as the interface is brought up, and your server can continue to boot with full network capabilities.
Saturday, August 4, 2012
kvm virtual machine won't start
However, upon returning the guests to service, one of them would not start up. Typing virsh start I got the helpful error message
Error restoring domain: cannot send monitor command
Connection reset by peer
Why was this one VM broken but the others were fine?
I played around with virsh autostart and virsh autostart --disable but that had no effect, nor did a reboot of the hypervisor.
After some searching around, it turns out libvirt has the capability to keep "managed save states" of guests, kinda like a sleep mode or snapshot, to save you fully powering a guest OS off.
For some reason, a managed save for this one guest had been created, perhaps it had not shut down properly, or perhaps there's an errorr in libvirt. I could view the saved state with
# virsh list --all --managed-save
Id Name State
----------------------------------
- guest1 shut off
- guest2 saved
Now a virsh managedsave-remove guest2 returned it to the "shut off" state, and I could start it properly with virsh start as per usual.
Monday, May 25, 2009
how to monitor dmesg in real time
Some distros allow you to
tail -f /var/log/dmesghowever this file stops being written in Ubuntu after boot, so that's not so useful.
I then found the watch command, which executes a command every 2 seconds (configurable if you like). Just watching dmesg fills my terminal output from the start, which is less than useful, so I use tail to shrink it down a bit. The command:
watch "dmesg | tail -20"does exactly what I was after.
Wednesday, November 26, 2008
compositing without compiz
despite this approach, proper window transparency is a useful feature. i spend most of my work day going between a terminal and configuration files, so it is good to have a semi-transparent terminal in front, and the file i'm working on behind, that i can read off (yes, two monitors would be more useful). how can we get this effect, without all the other useless cruft?
enter xcompmgr. this useful app handles compositing, without replacing the existing window manager. install it with sudo apt-get install xcompmgr, and run with just xcompmgr
start up a gnome-terminal (or stjerm), and set transparency to about 80%. move that window over some other windows or icons, and enjoy actual proper window transparency!
xcompmgr can also do drop shadows, and combined with transset, can be setup to make your windows transparent too. i'm not so into this, but there's a good summary on urukrama's openbox guide
Friday, November 21, 2008
stjerm - a lightweight dropdown terminal
it's quite lightweight, built with gtk2, and even supports tabs. it's available in ubuntu intrepid with just sudo apt-get install stjerm, or source is here at googlecode
to launch it, run it at least with the option stjerm -k f12, and hit the F12 key to hide and show the terminal. a man stjerm will show all options, and you can save your setup in ~/.Xdefaults, here's mine:
stjerm.key: f12
stjerm.mod: control
stjerm.background: #000000
stjerm.foreground: #44ddff
stjerm.opacity: 80
stjerm.lines: 50000
stjerm.width: 1024
stjerm.height: 768
to get stjerm running in ubuntu hardy or debian, install the build dependencies and tools (sudo apt-get install automake libvte-dev libgtk2.0-dev), and follow the installation guide in the stjerm wiki to compile and install
Thursday, November 20, 2008
basic debian package maintenance
i've been looking at how to tidy my pc up a bit lately, and this is more or less what i came up with, with a bit of help from deborphan, which tells you libraries/packages that are installed but have no dependencies. install it with sudo apt-get install deborphan
firstly, run deborphan to see what lone libraries you have installed. you can also append --guess-data to try guessing data files, and --guess-all too. there are more options in the man page, such as the -e (exclude) and -A (add to exclude list) switches, useful if you have some independent packages installed that you need (like my libmotif3 for the citrix client)
if you're happy with that list, nest the program in apt-get with sudo apt-get purge `deborphan` (the backquotes will use the output of deborphan as the input for apt-get). once these packages have been removed, run deborphan again, and see if you've uncovered any deeper nested depends. if you're really keen, you can script it like so:
#!/bin/sh
while [ -n "`deborphan`" ]; do
deborphan
echo
apt-get purge `deborphan`
done
at times, apt-get will know that it doesn't need packages anymore either, and will tell you so when you run it. you can get rid of these packages with the sudo apt-get autoremove command
your system will also build up an apt cache of packages, especially as upgrades happen over time. you can clear these out with sudo apt-get autoclean, which removes packages that are out of date, or just sudo apt-get clean, which removes everything except the lockfile from the apt cache
so in summary:
sudo apt-get autoremove
deborphan
sudo apt-get purge `deborphan` till you have no packages
sudo apt-get clean
Monday, October 20, 2008
Split rar files
One way of getting around this is compressing the file, in the hope that it gets small enough. If this still doesn't work, where does that leave you?
Using rar on the commandline, you are able to split files easily and quickly, for copying off to other sources.
First, install rar with sudo apt-get install rar
Usage is as easy as rar a -m5 -v500M archive.rar file.ext
rar starts the command
the a switch tells it to "add to archive"
-m5 is the compression level (0 don't compress, 3 default, 5 best compression but takes longest)
-v500M specifies volume size to 500Mb, you can also use something like -v512k for 512kbyte volumes, or -v5b for 5 byte volumes
You name your resulting archive with the name archive.rar (or whatever you'd like)
And the file you intend to compress with file.ext
You can also specify a folder as the target, just add a -R before the archive name to recurse subdirectories
To uncompress, right click on the first part01.rar file and choose Extract, or type rar x archive.part01.rar at the commandline
Tuesday, October 7, 2008
Screenshots at the commandline
But how to make a screenshot without X, when just working in the console?
Everything in the console is displayed in the framebuffer, and fbgrab enables you to make a screenshot of this.
Usage is easy, just:
fbgrab filename.png