Debian Notes

Justine Haupt

When installing Debian:

When asked to choose the desktop environment, leave “Debian Desktop Environment” checked and check whatever desktop environment you want. Other things can be checked too, but that’s the main thing. It seems like MATE (for example) has some dependencies that come from the Debian Desktop Environment, and sbelecting MATE (for example) without the other will result in the network connection tool being missing and maybe other oddness.

If after installation the “awesome” WM will be installed, it’s not clear to me whether anything is lost by not including the Debian Desktop Environment, but I would hesitate to ever not include it in case other users want to use GNOME-based desktop environments.

If errors pop up relating to the desktop environment, or some widget needing transparent effects:

A compositing manager might be needed. There is now a default compositing manager built into MATE that can be switched on somewhere through the control panel. Alternatively, install xcompmgr and then run it to see if it fixes the problem. If it does, set to autorun on login.

Switch to xscreensaver:

  1. Install xscreensaver, as well as xscreensaver-gl (adds GL graphics based screensavers), anything xscreensaver related that comes up with the -extra bit in an apt search (adds extra screensavers), and maybe xscreensaver-screensaver-bsod too, which adds the cool BSOD screensaver.
  2. Uninstall the default/installed screensaver. If using mate, this is mate-screensaver, which is removed with apt.
  3. Set the xscreensaver daemon to run automatically after login (go to automatically run something at login section).

Automatically run something after login:

There are many ways to do this. Your desktop environment or window manager may have its own preferred way:

-With the “awesome” WM, include the line awful.util.spawn("command to run") at the end of rc.lua which is in ~/.config/awesome

-A window manager-agnostic method is to put a something.desktop file in the ~/.config/autostart directory (if the directory doesn’t exist create). something.desktop is a launcher file, which appears with a “launcher” icon if using a graphical file browser. For xscreensaver, the command it should execute is xscreensaver -nosplash.

A launcher can be created by right-clicking the desktop and clicking “Create launcher”. The file can then be moved to the above directory. Or just make a new empty file and put this in it:

[Desktop Entry]
Exec=xscreensaver -nosplash

The most important part is Exec=, which is the command that’s actually run by either clicking on the launcher or having it be in that autostart folder.

Manage wallpaper across multiple monitors:

Install nitrogen, then set to autorun with $nitrogen --restore.

To add/create a user:                #adduser jhaupt

To give a user sudo privilidges:        #usermod -aG sudo jhaupt

The -aG option adds the given user to the given group.

Add user to sudoers file without requiring a password:

In the file /etc/sudoers, add this line:


To remove a user:        #userdel jhaupt                

Include -r option to delete user’s home directory and mail spool as well.

Add user to dialout group (mainly needed for USB access directly from programs): 

#adduser jhaupt dialout

To change one’s own password: $passwd

To change another user’s password: #passwd [user]

Packages in the Debian Stable apt repository are not updated except for security updates. On the other hand, Debian Testing always keeps the most up-to-date versions of packages in the repository. To install the most recent version of a program on Stable, install from the “backports” repository, which will install whatever versions that “Testing” is currently using:

In the file /etc/apt/sources.list, add this line (here “Stretch” is the current stable release):

deb stretch-backports main contrib non-free

Run #apt-get update

Backports are turned off by default. To install a program from backports, use this command:

#apt-get -t stretch-backports install somepackage

To list the device name of all connected devices (as in /dev/sda1, etc):

$df -hT

To make a bootable USB stick using an ISO image:

Check the device assignment using df as above, then do:

#dd status=progress if=/PathToISO/ISOfile.iso  of=/dev/[device]

Or use Balena Etcher. The same dd command can be used to put an ISO image on a stick without it being bootable.

To make an ISO image:

Check the device assignment using df as above, then do:

#dd status=progress if=/dev/[device] of=/PathToISO/ISOfile.iso

Machine to machine communication and file transfer on a local network using netcat:

On a given machine, start listening over any port (any port over 1024 without needing su privileges). Here we arbitrarily chose port 1120:

$netcat -l -p 1120

The -l tag says we want to listen and the -p tag specifies the port.

On another machine connected to the same local network, connect to the first machine. If the first machine’s hostname is “3body” we do:

        $netcat 3body 1120

Now we should be able to type messages to the first machine to the other, and back the other way too over the same connection. We can transfer files this way too.

Using nmap to analyse a network:

$nmap -sP          Look for all machines on the network that respond to a ping.


$nmap -sP 192.168.1.*


$nmap -sn

-v option is good in that it just lists all open ports on target

#nmap -p 1-65535 -sV -sS -T4 [target]                Full TCP port scan including service version detection.

Using nethogs to monitor which processes on a PC are sending/receiving the most network traffic:

        # nethogs

Using netstat to analyze a network (installed via net-tools):

        Continuously report on network connections (very cool): $netstat -c

Special IP addresses:

192.168.0.X        Local area network        Local private network        Loopback address

Using “ip”, which supercedes ifconfig:

        List all network devices with local ip addresses:        $ip a  or $ip addr

        List all network devices without ips: $ip link

To shut down a network device:         #ip link set wlan0 down

To turn it back on:         #ip link set wlan0 up

Using dhclient to release and renew and ip address:

To release one’s IP addrewss: sudo dhclient -v -r

...Which also shuts down dhclient, so do #dhcient [device name] as shown below to bring it back up.

Bring up a network connection from the command line:

For example, this might be needed to recover a system that only has shell access.

  1. Bring up the desired network interface using ip as shown above.
  2. Run #dhclient [device name]

Display the signal strength of a wifi network continuously in the terminal:

Connect to the network of interest and then run $watch -n 1 "cat /proc/net/wireless"

For a more readable display run $watch -n 1 "awk 'NR==3 {print \"WiFi Signal Strength = \" \$3 \"00 %\"}''' /proc/net/wireless"

A significant limitation is that you must be able to connect to the network first (i.e., know the password). Explore /proc/net/ files to see if there’s an alternative.

See what USB devices are connected:

Show names of devices:        $lsusb

Show connect/disconnect history of devices including mount location(e.g.  /dev/ttyACM0):        $dmesg

Another way to see what ports are mounted where is to do something like $ls /dev/ttyUSB*, unplug the device of interest, then plug it back in and rerun that command.

Find a file:         $find  . -name nameoffile*        (Note the dot, which signifies a search within the current directory. The star at the end has the normal UNIX meaning. 

Mount a remote file system using sshfs: $sshfs user@host:[directory] [mountpoint]

        To close connection once opened: #umount [mountpoint]

After sshing into a remote computer, to run a GUI program that will display on the remote computer’s screen:         $export DISPLAY=:0         (Run before any other commands)

Install vmware player:        #sh [vmwareplayerinstallscript].bundle

Launch vmware player directly into the guest operating system:

$vmplayer -M /home/jhaupt/VM/Windows\ 7\ x64/Windows\ 7\ x64.vmx

(Here, it’s the .vmx file located in ~/VM/Windows/)

To get MATE to NOT display the Computer icon (or other icons):

Run $dconf-editor, go to org > mate > caja > desktop, and turn off those visibilities.

dconf-editor can access a lot of configuration settings that aren’t otherwise accessible.

Change computer’s hostname:

Easy way: Use nmtui

Or on Raspbian, do it through raspi-config.

To do it manually:

  1. Edit the file “hostname” in the /etc directory. The file contains a single entry, which is the hostname.

  1. Edit the file “hosts” in the /etc directory. Change every occurrence of the hostname.

  1. Reboot.

If mouse cursor is stuck in “drag and drop” mode, as though left clicks are inverted:

The touchscreen may be giving whacky signals. Try disabling it with xinput:

Run $xinput. This will list all the input devices. Find the number associated with the touchscreen. As of this writing mine was 13. Then disable it with $xinput disable 13

To assign a particular icon to all files of the same type (NOTE, this didn’t fully work the first time I tried it):

This is based on MIME types, which are like identification cards for files. To start, we need to see if a MIME type for the particular filetype in question already exists. To do this run:

 $grep 'py' /etc/mime.types 

In this example we’re looking for files with a .py extension. This returns two outputs, one with the extensions pyc and pyo, and the other with the extension ‘py’, which is the one we want. It looks like this:

text/x-python                                   py

Note the left part of this output, the part that says “text/x-python”.

Find the icon you want to use and put it someplace sensible, like /usr/share/pixmaps or /usr/share/icons, if it’s not already there. It MUST be an svg file. Rename (or copy and rename, if it’s already in use on the system) the icon to be the left part of the output above but with any slashes replaced with a hyphen. For example, “text/x-python” becomes “text-x-python”, and the filename is “text-x-python.svg”.

Now, from the directory where the renamed file is placed, run these commands:

#cp text-x-python.svg /usr/share/icons/gnome/scalable/mimetypes
#gtk-update-icon-cache /usr/share/icons/gnome/ -f

To reinstall something that won’t run because files have been deleted but which apt-get won’t reinstall because it thinks it’s already installed correctly:

        #apt-get --reinstall install [package]

Make a file executable. That is, make it so it can be run from the command line just by typing .[filename]. The shebang at the top of the file will determine how it’s run.

$chmod u+x [file]

Change permissions to let anyone read, write or execute a file:

$chmod 777 [file]

Create a symbolic link:        #ln -s  [file to be referenced] [virtual file]

Install a .deb file:        #dpkg -i [deb file]

Convert one type of install file to another (e.g. .rpm tp .deb) using “alien”: #alien -d [rpm file]

This produces a .deb file from a .rpm file. It can convert in other directions. Use -h to see all possibilities.

Display/overlay text on a screen:  $conky -t “text”

Conky can do a lot of things. Use -h to see options, like positioning text and changing font.

Login automatically (turn on “autologin”):

The login GUI is called the Display Manager. Debian uses the lightdm display manager to handle the “greeter”, the login screen, after which the desktop environment gets launched. To see where the config files for lightdm are, run $/usr/sbin/lightdm --show-config.

That will probably show that one of the config files is /etc/lightdm/lighdm.conf.  In that file (or whichever comes up), uncomment the lines
autologin-user=  and autologin-user-timeout=0, adding the username we want to login automatically for the former one. Also be sure that autologin-session= is set to the preferred desktop environment. (E.g. autologin-session=mate).

Related: This will likely make a keyring password prompt come up when starting Chrome. Tried a bunch of things to turn this off and failed..

Change the login greeter (display manager):

As mentioned above, the GUI login interface is strangely called the display manager. A list of Debian-supported display managers is here: Probably all of them can be installed with apt. Upon installation of a new one you may be prompted to change which one is used at start time. Otherwise use #dpkg-reconfigure [name of display manager] to switch.

Changing settings in a more advanced way then the desktop environment’s Control Center allows:

$gsettings is the key to all of the GNOME-based settings you didn’t know you needed.

Categories of settings are grouped into “schemas”. Specific settings within each schema are called “keys”.


Too see a list of all the schemas: $gsettings list-schemas

To see all of the keys within a schema: $gsettings list-keys [schema]

To see the value of a key: $gsettings get [schema] [key]

To set the value of a key (usually true or false): $gsettings set [schema] [key] [value]

Can be combined with BASH commands.

To search within the keys of a given schema: $gsettings list-keys org.mate.power-manager | grep lock

NOTE: It’s useful to use more than one terminal at once to list schemas or keys in one and type get or set commands in the other.


Make a command/script executable globally (run from any directory):


        There are a few ways to do this.

-We can create an alias in the .bashrc file so that the desired command is aliased to the full path. This looks like alias arduino=’/opt/arduino-1.8.9/arduino’


-We could also create a symbolic link from the actual executable file doing something like #ln -s [path to executable] /usr/bin/[executable name]

-We can export the directory where the executable command lies to the path variable using a command like $export PATH=$PATH:/home/jhaupt/bin. This will make all executable files in the /home/jhaupt/bin directory be runnable from anywhere in the system.

This needs to be set to run automatically when starting up. It could be added to .bashrc file or to rc.lua if using the “awesome” desktop manager.

Record mouse location/coordinates to a text file:

$while true; do xdotool getmouselocation | sed -e 's/ screen:0 window:[^ ]*//g' >> coordinates.txt; done

To open that with Octave, use octave:> data = importdata('coordinates.txt')

To address specific digits from data, use octave:> data{linenum}(colnum). Note the curly brackets first, then parentheses.

To update a system:

Refresh sources:        #apt update

Update all installed packages:                #apt upgrade 

Update (patch) the distribution or upgrade to latest stable (depends on sources.list):        #apt dist-upgrade

To upgrade to a new version of the system, do the same steps but with the sources in sources.list pointing to the new version.

Recap: The function of apt-get upgrade and apt-get dist-upgrade depends on which sources are used. If it’s the sources for the current version of Debian, this will accomplish a system update. If it’s the sources for the next version of Debian, this will accomplish a version upgrade.

To make a file executable:         $chmod u+x myfile        The shebang at the top of the file will tell the computer how to run it (e.g. shell script? Python?, etc). Otherwise this might be determined by the file extension, if present.

Using PuTTY to connect to an Arduino serial console (but there’s no reason not to use ‘screen’ instead)

-The default serial speed (9600), data bits (8), stop bits (1), parity (NONE) and flow control (XON/XOFF) are good, so no need to go to the settings under Connection > Serial.

-Naturally we’ll connect to device /dev/ttyUSB0 (or whatever) instead of ttyS0.

-Under the “Terminal” settings, we can optionally set “Local echo” to “Force on” to see any characters we send.

-Also under “Terminal” settings, keeping “Local line editing” set to “Auto” should be OK, but if in doubt we can set to “Force off”.

-Under “Terminal” > “Keyboard” settings, set “The function keys and keypad” to either “Linux” or “Xterm R6”.

To send a string, type what you want to send, then instead of pressing the Enter key, press Ctrl+J. Ctrl+J is PuTTY’s shortcut for Line Feed, which in combination with the other settings above has the effect of replacing the Enter key for sending strings.

To make life easier, enter all those settings and then under "Session" highlight "Default Settings" under "Load, save, or delete a stored session" and then click Save. Or save it as a new name.

To make life easier still, now bypass the PuTTY Configuration GUI altogether by running $putty -serial /dev/ttyUSB0 -sercfg 9600 to start the serial terminal directly.

To make life EVEN easier, add something like alias puttyarduino='putty -serial /dev/ttyUSB0 -sercfg 9600' to your .bashrc file, logout and login, and forever and always bring up the PuTTY terminal with $ puttyarduino.

Installing and configuring the “awesome” wm:

        -Install with apt

        -Log out and log back in, selecting awesome as the wm

        -The default location of the configuration files is /etc/xdg/awesome/ . This should be moved to ~/.config/awesome and edited from there.

        -At the very least we want to have a theme.lua config file in our home directory too, to do things like set the wallpaper. In rc.lua find the “beautiful.init(....” line and edit it to be:


-And create that directory and file, and copy some starting point theme into it (google “awesome defualt theme”).

Using screen for an RS232 terminal:

        -To connect to a device on ttyUSB0:  $screen /dev/ttyUSB0

        -For Arduino, use “Ctrl+J” instead of “Return” to send commands (see explanation below).

-For Arduino, the default serial speed (9600), data bits (8), stop bits (1), parity (NONE) and flow control (XON/XOFF) , so no need to do anything special.

        -To connect with a different baud rate (e.g. 4800), just do $screen /dev/ttyUSB0 4800


        -NOWHERE on the internet have I found this information, but Ctrl+J sends the Line Feed character. This doesn’t seem to be documented screen’s man page. Also, I can’t find it spelled out explicitly anywhere but pressing the RETURN/ENTER key on the keyboard sends the Carriage Return character alone. I confirmed this with an FTDI console cable and a logic analyzer. Sheesh.

        -To close the connection, do Ctrl+A followed by K. Some systems may require Ctrl for the K as well. In general, screen commands are all done after first doing Ctrl+A.

Handling high-DPI displays (tested in “awesome” window manager)

  1. We want to use the .Xresources file to configure the DPI. This files is not present by default, so we create it in the home directory. The line to include in the file to set the DPI is Xft.dpi: 144

  1. The system needs to know to include configuration settings within the .Xresources at start time, and the command xrdb -merge ~/.Xresources will do that. This command needs to be run automatically at start. With “awesome”, the easiest thing is to add awful.util.spawn("xrdb -merge ~/.Xresources")  to the end of ~/.config/awesome/rc.lua

Important note: The order of the above awful.util.spawn line in rc.lua may be important. For the purpose of testing different DPI settings, if after restarting awesome nothing happens, try running $xrdb -merge ~/.Xresources in a terminal and THEN restart Awesome.

Other useful tidbits:

-To see DPI of current screen configuration: $xdpyinfo | grep -B 2 resolution

-To see physical screen size and resolution of display: $xrandr | grep -w connected

This method STILL doesn’t seem to fix DPI across every program. Luckily, some programs allow font to be specified separately from the system settings, like PuTTY.

Change the color of the prompt, or make it multicolored

If we do this in the terminal it will make each section of the prompt have a different color. The parts that change the color is the 5 instances of the two numbers followed by “m”. Mess with that to see what does what:

$ export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h\[\033[01;36m\]:\$\[\033[00m\] '

To make the change permanent add this line (minus the “export”) in the part of the .bashrc file where there’s the PS1= bit. In mine, there are three such bits close to each other, ad the one that changes the prompt looks like this:

if [ "$color_prompt" = yes ]; then

        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h\[\033[01;36m\]:\$\[\033[00m\] '


Turn off the system bell

$xset b off        Will turn it off for programs run from the BASH shell.

-Add to .bashrc to make permanent for anything launched from a BASH terminal.

The state of the Function key is reversed/toggled.

 I think this is somewhat computer-specific, but on my laptop (perhaps all), pressing Fn + Esc will toggle the default-state. So if usually you need to press Fn to use the F keys and you want it to bet the other way around, doing this should fix it. On desktops the combination might be Fn + NumLock.

Using github:

To download files from a repository: $git clone [url.git]

To upload (push) files to a repository:


        If the name of the local repository (directory) is identical to the remote repository (the github URL), from within that directory do

        $ git add .                        to stage all the files in the local directory

        $ git commit -m "a comment about the changes"

        $ git push origin master                 to push (upload and overwrite) the changes