Linux

Contents

Manual software installation

There is a convention for manually installed software to put it in /opt . (See Linux FHS)

The following steps are recommended to maintain such a setup:

  1. Obtain a .zip of the software distribution
  2. Unzip it to /opt/<publisher>/<app name>-<version>    (The publisher directory is optional)
  3. Setup symbolic links for other apps to reference (so they don't break when you upgrade)

Example

$ curl -sL https://ihmc.us.tar.gz -o app.tar.gz
$ tar -xvzf app.tar.gz
# mv app-v2/ /opt/.
# rm /opt/app-v2
# ln -s /opt/app-v2/ /opt/app
# ln -s /opt/app/bin/app.sh /usr/local/bin/app

Environment Variables

To set environment variables for terminals, use export VAR_NAME=value in ~/.bashrc.

To set environment variables for GUI desktop launchers, use export VAR_NAME=value in ~/.profile.

To temporarily set environment variables, run export VAR_NAME=value  just before you run your program.

Desktop entries

freedesktop.org has defined a file format standard for creating shortcut launchers that work in both GNOME and KDE. See the full spec here. However, a good overview can be found on the Arch Wiki page.

A sample intellij-idea-ce.desktop  in /usr/share/applications :

[Desktop Entry]
Version=2019.2.1
Type=Application
Name=IntelliJ IDEA Community
Comment=Intelligent Java IDE
Exec="/opt/intellij-idea-ce/bin/idea.sh" %f
Icon=/opt/intellij-idea-ce/bin/idea.png
Comment=Intellij Idea IDE (community version) with Intellij JDK
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-idea-ce

Scroll in a Terminal / Console

SHIFT + Page Up and SHIFT + Page Down are the correct keys to operate on the linux (virtual) console

Passwordless sudo

Sometimes it's easier if embedded systems don't ask for a password everytime you need to use sudo commands. To achieve this, one option follows.

# visudo

Adjust the following section to add "NOPASSWD: " before the "ALL".

/etc/sudoers.tmp
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) NOPASSWD: ALL

SFTP from Dolphin File Browser

fish://server

Diagnosing System Crashes

Rebooting elegantly

If your system completely hangs, there are some ways to try and either get it back or reboot the machine more safely/elegantly.

You can set the kernel flag sysrq_always_enabled=1 to enable this functionality. If using GRUB, you can add this like so:

/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="<other args you might have here> sysrq_always_enabled=1"

Then, you would update your GRUB config and reboot:

Update GRUB on Ubuntu
# update-grub

This enables you to type in the magic Alt and SysRq (which is the Print Screen key) + REISUB slowly pressed key sequence key sequence. (See full description here: https://blog.kember.net/posts/2008-04-reisub-the-gentle-linux-restart/)

  • R: Switch the keyboard from raw mode to XLATE mode
  • E: Send the SIGTERM signal to all processes except init
  • I: Send the SIGKILL signal to all processes except init
  • S: Sync all mounted filesystems
  • U: Remount all mounted filesystems in read-only mode
  • B: Immediately reboot the system, without unmounting partitions or syncing

Browsing the previous system log

When you've rebooted, you can look through previous boots' system logs like so, listing the previous boots available, and selecting one with -b .

# journalctl --list-boots
# journalctl -b -1