Debian

Table of Contents

1 Power management

  • sudo journalctl | less
  • /etc/systemd/logind.conf
  • dmesg | grep -i 'acpi'
  • /proc/acpi/wakeup

Finally I figure it out!

Install acpitool package. Use acpitool -w to list the wake up events. Use acpitool -W x where x is the number of the output of above command. Try to disable them one by one, and use systemctl suspend to test if the system wake up. In my case, I succeed after disable number 5 (there's really nothing to tell from the list!).

Not sure if it can persist after reboot. It remains to be set how to automatically resume the wifi.

 Device       S-state   Status   Sysfs node
---------------------------------------
1. P0P2         S3    *disabled
2. EC   S4    *disabled  platform:PNP0C09:00
3. HDEF         S3    *disabled  pci:0000:00:1b.0
4. RP01         S3    *disabled  pci:0000:00:1c.0
5. RP02         S3    *disabled  pci:0000:00:1c.1
6. RP03         S3    *disabled  pci:0000:00:1c.2
7. ARPT         S4    *enabled   pci:0000:03:00.0
8. RP05         S3    *disabled  pci:0000:00:1c.4
9. RP06         S3    *enabled   pci:0000:00:1c.5
10. XHC1        S3    *enabled   pci:0000:00:14.0
11. ADP1        S4    *enabled   platform:ACPI0003:00
12. LID0        S4    *disabled  platform:PNP0C0D:00

2 Tmp

change laptop screen brightness:

cat /sys/class/backlight/intel_backlight/max_brightness
cat /sys/class/backlight/intel_backlight/brightness

echo 400 > /sys/class/backlight/intel_backlight/brightness

3 Installation

3.1 VirtualBox Guest addition

It seems need the xinit to be installed.

aptitude install build-essential
aptitude install linux-headers-$(uname -r)
sudo mount /dev/src0 /media/cdrom
cd /media/cdrom
sudo ./VBoxLinuxAdditions.run

Guest addition is needed for clipboard sharing. To enable it, you need: VBoxClient --clipboard.

3.2 dist-upgrade

cp /etc/apt/sources.list{,.bak}
sed -i -e 's/ \(stable\|wheezy\)/ testing/ig' /etc/apt/sources.list
apt-get update
apt-get --download-only dist-upgrade
# Dangerous
apt-get dist-upgrade

netselect-apt to select the fastest source!

4 Startup

Change default desktop environment:

  • GNome: gdm
  • KDE: kdm
  • lxfe: lightdm

Change (three approaches):

  1. edit /etc/X11/default-display-manager: I think we'd better use update-alternative
  2. sudo dpkg-reconfigure gdm
  3. update-alternatives --config x-window-manage

5 Configuration

  • dpkg-reconfigure reconfigure a installed package
  • defconf-show show the current configuration of a package

5.1 update-alternatives

Options:

  • --config: show options and select configuration interactively
  • --display: show the options

Some examples:

  • update-alternatives --config desktop-background

5.2 systemd

  • systemctl disable lightdm This will replace the /etc/rc2.d/S03lightdm with /etc/rc2.d/K01lightdm.

6 Package Management

  • /etc/apt/sources.list
  • /var/cache/apt/archives/

Once installed google-chrome deb file downloaded from google, it will add one file: /etc/apt/sources.list.d/google-chrome.

The original sources.list after a minimal installation:

# deb cdrom:[Debian GNU/Linux 8.5.0 _Jessie_ - Official amd64 NETINST Binary-1 20160604-15:31]/ jessie main
#deb cdrom:[Debian GNU/Linux 8.5.0 _Jessie_ - Official amd64 NETINST Binary-1 20160604-15:31]/ jessie main

deb http://ftp.us.debian.org/debian/ jessie main
deb-src http://ftp.us.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

# jessie-updates, previously known as 'volatile'
deb http://ftp.us.debian.org/debian/ jessie-updates main
deb-src http://ftp.us.debian.org/debian/ jessie-updates main

if some package needs configuration, you can redo the config by:

dpkg-reconfigure <package>

6.1 binary or source

  • deb: binary
  • deb-src: source

6.2 code name

jessie is the current name code for the stable release version of Debian. The next release and the next next release code name are also available.

  • jessie is equal to stable
  • stretch is equal to testing
  • sid is equal to unstable

Sometimes you want to use stable, but with new versions of packages from testing release. This is called, for jessie, the jessie-backports release.

https://backports.debian.org/Instructions/

6.3 source

Another part is the main. If you want some 3rd party contributor packages, add contrib after main. If you further want some non-free packages, add also non-free.

6.4 Upgrade the system: from stable to testing

Follow the following process EXACTLY.

  • First, change the code name stable in sources.list to testing.
  • Then, apt-get update
  • apt-get upgrade
  • apt-get dist-upgrade

Do not use aptitude, it will stuck resolving dependence.

7 Debian boost up scripts

This is based on the following snippets:

list="git xinit xorg"
apt-get update
apt-get install -y $list
cat example.list | xargs sudo apt-get -y install

8 MIME

check the MIME of a file.

file --mime /path/to/file

On debian, the mapping from suffix to MIME type is /etc/mime.types.

Create default application for xdg-open

mkdir ~/.local/share/applications
xdg-mime default firefox.desktop application/pdf

~/.local/share/applications/mimeapps.list

[Default Applications]
application/pdf=firefox-esr.desktop

/usr/share/applications/*.desktop are files define for each application.

9 Trouble shooting

When shutting down, systemd is hindered by a message for a long time: "a stop job is running …"

THIS IS STILL OPEN! NO SOLUTION. The symptoms: If I power of immediately after boot up (before network interface is up), no problem. If I wait for some time and the interface is up, even if I ifdown it, the problem still exists.

https://www.reddit.com/r/archlinux/comments/4bawf7/a_stop_job_is_running_for_session_c2_of_user/

You can add your own rules to a service file like this:

sudo systemctl edit systemd-timesyncd.service

and then pasting this here into the editor that comes up:

[Service]
TimeoutStopSec=1s

It saves a "systemd-timesyncd.service.d/override.conf" file in /etc, does not touch the original files.

After editing, you can check on what systemd sees by doing:

systemctl cat systemd-timesyncd.service
systemctl show systemd-timesyncd.service

9.1 a stop job is running for make remote cups printers available locally

systemctl status cups-browsed.service
systemctl disable cups-browsed.service

10 Man pages

systemd:

  • systemd-system.conf
  • systemd.service

Networking:

  • interfaces

11 Wireless

For a supported wireless card, directly install wicd and run wicd-client -n.

11.1 wireless driver for mac

11.1.1 Debian Installation on mac:

  1. Use DVD because it has dkms package, used for Broadcam wireless chipset.
  2. Clean install Mac OS
  3. Reboot, Cmd-R to boot into recover, partition two more partitions for debian and swap.
  4. Use unetbootin to create Debian USB stick
  5. Install Debian normally, but use the pre-defined partition! Use ext-4 and mount at /

11.1.2 wireless

iwconfig

if the wlan card shows up, it is good, otherwise:

update-pciids # if necessary; run as root, to update PCI database
lspci | grep -E "Atheros|Broadcom" # Finds card

Note: for 4360, there're actually two chipsets: 14E4:4360 and 14E4:43A0, the first one does not have a driver, the second one can use wl (broadcom-sta-dkms). To see which one (http://unix.stackexchange.com/questions/175810/how-to-install-broadcom-bcm4360-on-debian-on-macbook-pro):

lspci -vnn | grep -i net

My macbook shows BCM4360, I installed from outside:

b43-fwcutter
dkms
broadcom-sta-dkms

Install from USB stick needs:

  1. mount
  2. apt-cdrom -m -d /path/to/mount add make sure the mount actually mounted, and the entries in /etc/apt/sources.list correct. When installing, it is still needed to mount to /media/cdrom.

After making the wireless working, put in the sources.list:

deb http://ftp.us.debian.org/debian jessie main
deb-src http://ftp.us.debian.org/debian jessie main

Then run

modprobe -r b44 b43 b43legacy ssb brcmsmac bcma
modprobe wl

Then, config wifi: make sure the iwconfig shows the card information (something with wlan0 xxx).

At this point, just use wicd (available on DVD-2) and you will be fine. The following "manual interface" way is OK for IASTATE wifi because it does not require password, but for a WPA encrypted one, it does not work. In this case, wpa_supplicant is needed, but I didn't make it work. In a word, just use wicd. wicd is a daemon, install and start, make sure you only have lo loopback entry in /etc/network/interfaces.

apt-get install wicd
systemctl restart wicd
ip a
iwconfig
ip link set wlan0 up
# scan wifi
iwlist scan

Add to /etc/network/interfaces: (see also man interfaces, man wireless)

# my wifi device
auto wlan0
iface wlan0 inet dhcp
        wireless-essid [ESSID] (IASTATE)
        wireless-mode [MODE] (Master)

finally, ifup and ifdown toggle the wifi. The auto wlan0 in the config file will start it after boot.

But auto wlan0 will make the boot very slow, so use allow-hotplug wlan0 instead. This will result in a fast boot, while also give you internet. But, after suspension, the network is dead unless ifdown wlan0 && ifup wlan0.

Optionally, NetworkManager service can also be used. The package is network-manager, the front end is network-manager-gnome, but I didn't find a way to invoke it.

11.1.3 Resume wireless after suspend

http://askubuntu.com/questions/761180/wifi-doesnt-work-after-suspend-after-16-04-upgrade

Originally the wifi does not work after suspension. I need to do

ifdown wlan0
ifup wlan0

TODO Now I think this automatic approach might work:

/etc/systemd/system/wifi-resume.service

#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

Author: Hebi Li

Created: 2017-06-14 Wed 22:43

Validate