Linux: Difference between revisions

From indicium
Jump to navigation Jump to search
Stefan (talk | contribs)
Line 31: Line 31:
'''Option 1''', using package manager:
'''Option 1''', using package manager:
  sudo apt-get install --reinstall nvidia-driver
  sudo apt-get install --reinstall nvidia-driver
or if your graphics card is not supported by the latest drivers (they will tell you):
sudo apt-get install --reinstall nvidia-legacy-390xx-driver


'''Option 2''', using latest official NVidia driver:
'''Option 2''', using latest official NVidia driver:

Revision as of 11:59, 29 August 2019

Debugging Linux applications

LDD

Linux LDD is just a wrapper for:

LD_TRACE_LOADED_OBJECTS=1 <cmd>

Core dumps

To check core dump handler:

cat /proc/sys/kernel/core_pattern
|/usr/sbin/coredump-handler %h_%t_%p.core

Valgrind

valgrind --trace-children=yes --leak-check=full --show-leak-kinds=all <binary>

Configuring Linux

Graphics drivers

Disable Nvidia drivers and enable Intel embedded HD graphics driver
sudo apt-get purge nvidia-*
dpkg --list | grep nvidia

Make sure the list of nvidia packages is empty

sudo apt-get install --reinstall xserver-xorg-video-intel libgl1-mesa-glx libgl1-mesa-dri mesa-utils xserver-xorg-core
sudo dpkg-reconfigure xserver-xorg
sudo update-alternatives --remove gl_conf /usr/lib/nvidia-current/ld.so.conf
reboot
Disable Nvidia drivers and enable nouveau drivers
sudo apt-get purge nvidia-*
dpkg --list | grep nvidia

Make sure the list of nvidia packages is empty

sudo apt-get install --reinstall xserver-xorg-video-nouveau
Disable nouveau drivers and enable Nvidia drivers

Option 1, using package manager:

sudo apt-get install --reinstall nvidia-driver

or if your graphics card is not supported by the latest drivers (they will tell you):

sudo apt-get install --reinstall nvidia-legacy-390xx-driver

Option 2, using latest official NVidia driver:

  • Go to [1] and download the latest Linux driver for your system.
  • Switch to console mode (Ctrl+Alt+F1), kill any Xorg process (or mask/stop them with systemctl if you run systemd)
  • Run the NVidia installer as root
systemctl mask gdm
systemctl stop gdm
killall Xorg
sudo ./NVIDIA-<driver-version-name>.run

Switch default compiler

(cc --version;c++ --version;gcc --version;g++ --version) | grep Debian
 cc (Debian 6.1.1-11) 6.1.1 20160802
 c++ (Debian 6.1.1-11) 6.1.1 20160802
 gcc (Debian 6.1.1-11) 6.1.1 20160802
 g++ (Debian 6.1.1-11) 6.1.1 20160802

sudo apt-get install gcc-4.9 g++-4.9

gcc-4.9 --version
 gcc-4.9 (Debian 4.9.3-14) 4.9.3

g++-4.9 --version
 g++-4.9 (Debian 4.9.3-14) 4.9.3

gcc-5 --version
 gcc-5 (Debian 5.4.1-1) 5.4.1 20160803

g++-5 --version
 g++-5 (Debian 5.4.1-1) 5.4.1 20160803

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

(cc --version;c++ --version;gcc --version;g++ --version) | grep Debian
 cc (Debian 4.9.3-14) 4.9.3
 c++ (Debian 4.9.3-14) 4.9.3
 gcc (Debian 4.9.3-14) 4.9.3
 g++ (Debian 4.9.3-14) 4.9.3

To go back:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Console is not filling the screen completely

This may be due to that the console thinks it is connected to a different display device than it actually is. This can be fixed by adding kernel command line parameters to disable that specific video mode.

ls /sys/class/drm
card0@  card0-DisplayPort-1@  card0-DisplayPort-2@  card0-DisplayPort-3@  card0-HDMI Type A-1@  card0-HDMI Type A-2@  card0-LVDS-1@  card0-SVIDEO-1@  card0-VGA-1@  controlD64@  version

Now check the different "modes" and "connected" and "enabled" nodes under each device to figure out which needs to be disabled. Then add to your kernel command line things such as

video=LVDS-1:d video=SVIDEO-1:d video=TV-1:d

More information: https://bbs.archlinux.org/viewtopic.php?id=94990

udev

udev rules

Some sample udev rules which might come handy:

KERNEL=="tty*", GROUP="dialout", MODE="0660"
SUBSYSTEM=="gpio", GROUP:="gpio", MODE:="0660"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="XXXXXXXX", SYMLINK+="ftdiserial2usb"

udev debugging

Command to reload udev rules:

sudo udevadm control --reload-rules && udevadm trigger

Command to test udev rules:

udevadm test --action=add /class/gpio

Screen

How to make the scrollback work in screen? Add the following to your .screenrc file:

termcapinfo xterm ti@:te@

Linux performance

http://www.brendangregg.com/