Linux user notes

From Helpful
Jump to: navigation, search
Linux-related notes
Linux user notes

Shell, admin, and both:

Shell - command line and bash notes · shell login - profiles and scripts · Shells and execution ·· find and xargs and parallel · screen and tmux
Linux admin - disk and filesystem · users and permissions · Debugging · security enhanced linux · health and statistics · kernel modules · YP notes · unsorted and muck
Logging and graphing - Logging · RRDtool and munin notes
Network admin - Firewalling and other packet stuff ·


Remote desktops
VNC notes
XDMCP notes




General

Messages/errors

perf interrupt took too long...

perf interrupt took too long (17338 > 5000), lowering kernel.perf_event_max_sample_rate to 25000


tl;dr:

you can ignore this, it's completely benign
it comes from the in-kernel measurement part of perf
it's tuning down the rate it samples, down to minimal impact on this particular hardware (and current load)


Perf, samples various parts of the kernel. See e.g. http://www.brendangregg.com/perf.html on how this can be useful.

Some of the sampling is done in interrupt handlers, and when one such call takes more time than expected, this could imply interrupts might start queueing and bottlenecking. Not even necessarily, but it still takes the safer route and decides to call that interrupt less often from now on, to avoid potentially affecting host performance.

When you use perf, or might ever use it for a "why is my system currently sluggish" checks, you want to leave it on and still have it sample itself at a decent rate.

You will always see the above message, because the default rate at bootup is set higher than most CPUs can handle, so that it scales down to balance for however fast your host is. So it would be weird to not see this at bootup. You'll also probably see it the first time CPUs scale down significantly (often a little later), and sometimes under heavy load.


See also:

GPU-related notes

If you want more recent drivers (and sometimes the more stable ones), you may wish to use the graphics-drivers PPA by doing:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

The newer versions and dependencies will show up alongside.


Failed to initialize NVML: Driver/library version mismatch

dmesg will probably have a little more detail, like:

NVRM: API mismatch: the client has the version 384.130, but
NVRM: this kernel module has the version 384.111.  Please
NVRM: make sure that this kernel module and all NVIDIA driver
NVRM: components have the same version.


If you just ran a package update, then rebooting will typically solve this.


If not, it's probably because you had previously installed some part manually, and a later installed/update conflicts with it. That mix can easily conflict/break on some libraries/symlinks, so (to be sure remove all before...) decide which way to go.


Your system is not currently configured to drive a VGA console
Your system is not currently configured to drive a VGA console on the primary VGA device.
The NVIDIA Linux graphics driver requires the use of a text-mode VGA console.
Use of other console drivers including, but not limited to, vesafb, may result in
corruption and stability problems, and is not supported.


Basically, it has an issue with framebuffer (non-VGA) consoles.

It just seems to be a newer message, for an issue very similar to the one in the next section.


Freeze with GeForce GTX
The problem:

Once X starts up / the GPU gets used, the graphics and/or mouse would be extremely slow (or in some cases not work at all).


The context

Geforce GTX graphics card (a 580 in our case), X windows. Did this in various linux variants (but specifically, sprang up in Ubuntu 12, worked fine in 11).


The diagnosis:

Some bad interaction between the the modeset used for the graphical pre-X boot splash, and the graphics driver used for X.

This is a problem that seems unique to the GTX family (and maybe some relations, and maybe only early models / now-old driver versions).

Not Ubuntu-specific, just a bad combination at bootup (that various ubuntu versions and other linux variants have).


The simple workaround:
Use the
nomodeset
boot option, implying a text mode boot.

You probably want to make this default. On Ubuntu, that means

  • editing /etc/default/grub (look for the "add to all entries" bit, which probably says quiet splash)
  • and running
    update-grub
    .



Fan control

nvidia-settings (also the CLI(verify)) works via an X extension (called NV-CONTROL), meaning there needs to be an X server for the card.

In it, fan control only works when you have CoolBits 4


basic fix

  • edit your xorg.conf to have
    Option "CoolBits" "4"
    in the Device section(s) for your GPU(s)
  • restart X (typically meaning your display manager, e.g.
    sudo service restart lightdm
    )
  • use
    nvidia-settings
    (CLI or GUI)


For headless cards (typical for compute, also on workstations if you have more than one)

  • X server will (pretty sensibly) only launch when there is a monitor,
  • monitors are auto-detected,
  • ...so you have to fake a monitor, for each card that doesn't actually have one.
Note that you don't have to keep X running - there are tricks around that.


See also:


Example: You have

# lspci  | grep VGA
02:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
03:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)

And you stuck a monitor only on the first.

Find /etc/X11/xorg.conf. If it doesn't exist, e.g. use nvidia-setting to write one, from what it's got already (which will be the ones with monitors).

nvidia-settings will also list the thing you need to put in BusID for new Device sections (if you use lspci for that, note that it shows hex whereas xorg.conf wants decimal


The first gets an X server because you have a monitor, so you only need to add the CoolBits 4 line

Section "Device"
   Identifier     "Device0"
   Driver         "nvidia"
   VendorName     "NVIDIA Corporation"
   BoardName      "GeForce GTX 1080 Ti"
   BusID          "PCI:2:0:0"
   Option         "Coolbits" "4"
EndSection

The other is headless, so you need to fake a monitor, to get an X server, to get fan control, roughly with:

Section "Device"
   Identifier     "Device1"
   Driver         "nvidia"
   VendorName     "NVIDIA Corporation"
   BusID          "PCI:3:0:0"
   Option         "Coolbits" "4"
EndSection
Section "Screen"
   Identifier     "Screen1"
   Device         "Device1"
   Monitor        "Monitor1"
   DefaultDepth    24
   SubSection     "Display"
       Depth       24
   EndSubSection
   Option         "ConnectedMonitor" "CRT"
   Option         "TwinView" "0"
   Option         "Stereo" "0"
   Option         "metamodes" "nvidia-auto-select +0+0"
EndSection
Section "Monitor"
   Identifier     "Monitor1"
   VendorName     "Unknown"
   ModelName      "CRT-N"
   HorizSync       28.0 - 33.0
   VertRefresh     43.0 - 72.0
   Option         "DPMS"
EndSection

(I'm fairly sure there are lines in there that are not required and/or do nothing, this is copy-paste from elsewhere)

Also make it relevant by, in Section ServerLayout, where you already had a

Screen      0  "Screen0" 0 0

Adding:

Screen      1  "Screen1" 



nvidia-settings CLI
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)


For example, to force the fan to highish speed (90%)

DISPLAY=:0 nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=90"

DISPLAY=:0 is useful when SSHing in, and possible in scripts. Without that, it'll complain it "Failed to connect to Mir"


CUDA versions
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)


When you can, use the metapackages (cuda-6-5, cuda-7-0, cuda-7-5, etc.).

Less headache in the long run, also because all the parts (cuda-*-version packages) are pulled in as dependencies and removable when you remove the metapackage.


Keep in mind that recent CUDA versions will depend on recent nvidia drivers, and possibly opencl wrapper, which have to be installed relatively manually or at least specifically named.

TODO: verify the following list:

  • CUDA 9.0
  • CUDA 8.0 required nvidia driver ~367
  • CUDA 7.5 required nvidia driver ~352
  • CUDA 7.0 required nvidia driver ~346
  • CUDA 6.5 required nvidia driver ~340
  • CUDA 5.5 required nvidia driver ~319
  • CUDA 5.0 required nvidia driver ~304


The currently installed/active CUDA is essentially what's there in PATH and LD_LIBRARY_PATH. The easiest way to see is probably:

nvcc -V    #from nvidia-cuda-toolkit

e.g.

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2013 NVIDIA Corporation
Built on Wed_Jul_17_18:36:13_PDT_2013
Cuda compilation tools, release 5.5, V5.5.0

means 5.5


CUDA is designed to be backwards compatible, so a newer system CUDA in your system should support applications that use older CUDA libraries.

Some applications still manage to break this, though.


You can install multiple CUDA versions. Keep in mind that you would need to separate their environments. You would probably have one of them active by default.

I wanted cuda7.5 for just one program, which (after install did not tie it into the system) ended up working something like:

function myappname() {
  export CUDA_HOME=/usr/local/cuda-7.5
  export PATH=$PATH:$CUDA_HOME/bin
  export LD_LIBRARY_PATH=$PATH:$CUDA_HOME/lib64
  `which myappname`
}

GNOME / Unity notes

Check out shortcuts in system Settings → Keyboard → Shortcuts tab

I didn't know about opening a terminal via CtrlAltT


AltTab switches between apps

and hold for windows of that app

Alt` (backtick) switches between windows of the same application

actually just initially fixed on the same app, you can shift to

You may also like https://extensions.gnome.org/extension/38/windows-alt-tab/


Ctrl Alt numpad - send to corner (similar to Win-arrow on windows)

of which Ctrl-alt-5 also works out as Maximize

F11 fullscreen Ctrl Win Maximize


Remove "Show desktop" from alt tab, a.k.a. "I don't randomly want all my windows minimized"

if you have unity tweak tool or compizconfig (or can install either), look at [1]

Package manager notes

Apt notes

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

shorter forms

Many of us are used to:

apt-cache search openmpi
apt-get install openmpi-bin

There is also a shorter form:

apt search openmpi
apt install openmpi-bin 


specific-package stuff

update specific package

...and dependencies (only?(verify) when versions say it must.

apt-get install --only-upgrade packagename


which versions of a package can I install?

sudo apt-cache showpkg packagename

That is, for which are there packages - dependencies of everything you have may effectively force a minimum version.


reinstall already-installed package package

apt-get install --reinstall packagename


Repositories

Add PPA

Remove repository/PPA

Messages

“The following packages have been kept back"

'Kept back' means a new package must be installed to be able to upgrade this one, and it won't do so fully automatically.


If it's just one or two cases, then you can probably figure out the dependency, decide it's okay, and install it explicitly:

apt-get install package-name depdency-name


If it's during a large-scale (e.g. distro) upgrade and the official distro update utility isn't helpful, you can force the issue via:

sudo apt-get dist-upgrade

...though keep in mind this is the somewhat careless version of the above.


Inspection

Files in a package

Files belonging to an installed package: -L / --listfiles

dpkg -L libraw-bin

dlocate libraw-bin


Files belonging to a downloaded-but-not-installed deb package:

dpkg -c /var/cache/apt/archives/libraw-bin_0.15.4-1_amd64.deb

apt-file update
apt-file list libraw-bin

Files belonging to a non-installed package you'll need a browser for (and a choice of version, here wheezy)

http://packages.debian.org/wheezy/all/libraw-bin/filelist


Tell me more about a package

apt-cache show libraw-bin

apt show libraw-bin


What package does this file belong to?

dpkg -S /usr/bin/shutter
dpkg -S indicator-multiload

apt-file search /usr/bin/shutter
apt-file search indicator-multiload

dlocate /usr/bin/shutter
dlocate indicator-multiload


Version information

Figure out which matching packages are installed

dpkg -l *nvidia* | grep ^i


apt-show-versions python
aptitude versions python-matplotlib


List of manually installed packages

No direct way, but a few decent approximations.


Apt logs its command history, so the following is a start (half of this is just formatting one package name per line)

(zcat /var/log/apt/history.log.*.gz ; cat /var/log/apt/history.log) | sed 's/apt-get install //p' | tr ' ' '\n' | sort -u

Note that this does not reflect the current state of the system, when any package led to uninstall of another, or you manually removed things. Also it doesn't mention what wildcards resolved to.


All packages, minus those in the initial install, minus things installed as dependencies. This still leaves in some updates.

zcat /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u > initial

# Installed things
apt-mark showmanual | sort -u > manualmostly
apt-mark showauto | sort -u > auto

cat initial auto | sort -u > boring

# Print entries unique to the first file:
comm -23 manualmostly boring 

Props to / based on http://unix.stackexchange.com/questions/3595/list-explicitly-installed-packages/3624 and http://askubuntu.com/questions/32007/how-to-find-manually-installed-packages


You may also care about residual-config, roughtly stuff that gets left over after a distribution upgrade.

dpkg -l | grep '^rc' | awk '{print $2}' > residual

Yum notes

Yum command cheat sheet


Repositories

These are mostly just individual files in
/etc/yum.repos.d/
.


Add

In a few cases the distro itself knows about them, e.g:

sudo yum install epel-release
In other cases it's basically just adding a .repo file in
/etc/yum.repos.d/
,

e.g. when installing subversion


Remove

You could just remove the .repo from /etc/yum.repos.d/

Or disable, via
yum-config-manager --disable reponame


List

yum repolist


https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-managing_yum_repositories


Distro-specific

Ubuntu notes

Releases and their names

Releases are usually referred to as the first part of their codename, e.g. lucid, precise, trusty, xenial

Names:

  • Ubuntu 10.04 - Lucid Lynx (LTS)
  • Ubuntu 10.10 - Maverick Meerkat
  • Ubuntu 11.04 - Natty Narwhal
  • Ubuntu 11.10 - Oneiric Ocelot
  • Ubuntu 12.04 - Precise Pangolin (LTS)
  • Ubuntu 12.10 - Quantal Quetzal
  • Ubuntu 13.04 - Raring Ringtail
  • Ubuntu 13.10 - Saucy Salamander
  • Ubuntu 14.04 - Trusty Tahr (LTS)
  • Ubuntu 14.10 - Utopic Unicorn
  • Ubuntu 15.04 - Vivid Vervet
  • Ubuntu 15.10 - Wily Werewolf
  • Ubuntu 16.04 - Xenial Xerus (LTS)
  • Ubuntu 16.10 - Yakkety Yak
  • Ubuntu 17.04 - Zesty Zapus
  • Ubuntu 17.10 - Artful Aardvark
  • Ubuntu 18.04 - Bionic Beaver (LTS)


You can figure out which you are using using:

cat /etc/issue

LTS refers to Long Time Support releases, meaning that they will be supported three (for desktops) or five (for servers) years instead of two.

See also


http://www.techotopia.com/index.php/Ubuntu_Linux_Essentials

Window manager behaviour

You can send windows to a specific part of the screen with CtrlAltkeypad


Additional (proprietary) drivers

Used to be called jockey up to Ubuntu 12, with a CLI variant called
jockey-text
.


Now the GUI part is called "Additional drivers", the CLI part is
ubuntu-drivers
, but note that it does not itself install specific drivers.

It does mention their package names, though, so it's mostly an apt-get install away.

Alternatives

To list all things registered here (most with just one option):

ls /var/lib/alternatives /etc/alternatives

Some also have:

update-alternatives --get-selections


Perhaps the best introduction is editor, i.e. /usr/bin/editor. On my system this is currently symlinked to nano:

/usr/bin/editor -> /etc/alternatives/editor -> /bin/nano

The config is:

# sudo update-alternatives --config editor
There are 5 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path               Priority   Status
------------------------------------------------------------
* 0            /bin/nano           40        auto mode
  1            /bin/ed            -100       manual mode
  2            /bin/nano           40        manual mode
  3            /usr/bin/emacs24    0         manual mode
  4            /usr/bin/mcedit     25        manual mode
  5            /usr/bin/vim.tiny   10        manual mode


The auto versus manual difference is roughly that

in auto mode, it's based on priority. The above is in auto mode.
in manual mode, it's based on you choosing one.

It's not that nano is available in both modes, it's that the priorities mean that (with my current set of packages) nano is currently auto mode's choice.


See also:

On updates

Automatic updates can be thought of as two parts:

  • update knowledge of packages from the repositories
  • notice what to do with these changes (automatic install, notifications, etc. There may be more than one piece of software doing this)



Disable updates / notifications

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)


Things relating to the update system include:

  • automatic background
    apt-get update
  • the sources that update pulls from
  • checks whether the current state has any packages that can be updated
  • the various notifiers and updater utilities that exist
  • "new version of ubuntu" check


You may wish to tackle the update notification rather than the repository update, because chances are something (or you) will run apt-get update anyway, after which you'll get notifications again.


There is more than one utility that can be saying this, and they can be hooked in in different ways (mostly changes over time).


update-notifier is apparently the thing that launches update-manager according to the settings mentioned above.

The most certain, but also overkill way is to remove these (
apt-get remove update-notifier update-manager
).

but this removes more features than you probably want.



your options seem to be
  • avoid update-notifier from being started
look at /etc/xdg/autostart - chances are there's a update-notifier.desktop in there.
  • ask update-notifier to be silent (verify)
Under GNOME (and as of this writing), you can use
dconf-editor
and in dconf under com, ubuntu, update-notifier
Check no-show-notifications (
gsettings set com.ubuntu.update-notifier no-show-notifications true
)
and/or uncheck auto-launch, if present (
gsettings set com.ubuntu.update-notifier auto-launch false
)
auto_launch may be outdated, though?(verify)
These things may have been in different places before

TODO: complete this


Unattended upgrades

https://help.ubuntu.com/community/AutomaticSecurityUpdates


See also

(need to read these myself)

http://blog.tenstral.net/2015/09/update-notifications-in-debian-jessie.html

http://askubuntu.com/questions/773874/disable-gnome-softwares-notification-bubble-notify-osd-for-available-updates

https://www.garron.me/en/linux/turn-off-stop-ubuntu-automatic-update.html

Cleaning up space

RHEL / Fedora / Centos notes

Services

Redhat seems to have also done the path of sysv to upstart to systemd.

So see Init systems and service management

Repositories

Extra ones you may care about

  • EPEL (Extra Packages for Enterprise Linux) [2]
for things like node.js, munin, ganglia, mono, mediawiki, torque
Aims to provide a full stack of and recent PHP stuff.
  • RPM Fusion [4]

See #Yum notes