Linux and Unix Notes

Changing default file association

If changing it in rightclick->properties does not help, or you are dealing with a GTK association in KDE, run

xdg-mime query default somemimetype

Or look look under /usr/share/applications/ and /home/alex/.local/share/applications/. Grep for your MimeType and run

xdg-mime default someapp.desktop somemimetype

Sudo alias

I actually have alias please=sudo. Every time I forget 'sudo', I think "ah ah ah, you didn't say the magic word!".
Might be better to do
alias please="sudo \$(history 2 | head -n1 | sed s/'^ *[0-9]*\*\? *'//)"

Controlling baloo search

Database location - .local/share/baloo/index
To stop or start
balooctl stop
To see the statistics
balooctl status
To see what it's doing right now
balooctl monitor

Graphical LSOF or glsof

ProcessMon is a great tool for windows for finding out all kinds of stuff about running processes. Getting a list of current open files and folders helped me many times. Now, for Linux, there is lsof. While I am untroubled by the command line, the sheer number of command line options for lsof is just overwhelming. So I looked at the graphical lsof, or GLSOF. Glsof is two separate utilities (Queries & FileMonitor) fronting lsof, both written in Java.

Linux TOP commands

  • iotop - (disk i/o)- Ever wondered why your hard drive is thrashing when all you are doing is reading a wikipedia page? Run this top and it will tell you what program is the offender.
  • powertop (power consumption) - Laptop battery is draining awfully fast? This top is great at telling what is causing the most CPU wakeups, causing it to waste precious energy.
  • iftop (network load) - give it an interface name and you got a quick glance at why your network light is blinking furiously. It won't tell you which app is doing it but it will tell you where on the internet it is going the most.
  • top (cpu,mem,swap) - well, this little guy needs no explanation. It's the father of all top commands, displaying cpu and memory usage statistics per process.
  • htop (cpu,mem,swap) - is top's big bretheren. It gives you bar-graphs of CPU, memory and swap, you can scroll through the processes and manipulate them in the ''<em>''curses''</em>'' interface.
  • ntop (network) - a very heavy weight network monitor and analyzer. It runs in the background and displays a lot of network statistics via a local web interface
  • kerneltop, latencytop (kernel) - tops for kernel activity monitoring.
  • xrestop (gui) - x11 utilization monitor
  • atop - (cpu,memory,i/o,network) -  this one tops it all. It's got it all, network, memory, cpu... consider it top, iftop, and iotop combined in one place. And it does get a bit crowded in there. With a help of the kernel patch atop can correlate hardware resources to the processes, something only things like lsof and clever scripting can do.

And BTW all these tops, including atop's kernel patch, are in the Ubuntu repositories, ready to be apt-get'ten. (or apt-gotten, if you so desire)

Configuring Getting Things Gnome on KDE

Shortcut to create a new item:

  • Go to System Settings > Shortcuts
  • Create a New Global Shortcut > Command/URL.
  • Go to the Action tab and enter /usr/bin/gtg_new_task
  • Go to the Trigger tab and click on a keyboard shortcut.

Configure the new task window to be centered and in focus:

  • Open the gtg new task window
  • In System settings go to "Configure window behavior -> Window-specific"
  • Click New -> Detect window properties and click on the new task window
  • Set Placement -> Force -> centered
  • Set Keep above -> Force -> Check
  • Set Accept focus -> Force -> Check
  • Set Focus stealing prevention -> Force -> None (!)

A tool for managing startup items aka autoruns for Linux

It is called bum, also known as the Boot-Up Manager
Get it from the ubuntu repo:
apt-get install bum

Gnome or Nautilus trash folder location

/home/<username>/.local/share/Trash
for a mounted disk it is in .Trash-000x


Wayland vs Mir vs X11

Xorg is the current de facto standard display server on Linux, basically what pushes and blends pixels from the different desktop applications onto your screen. The clients use the X11 protocol to speak with Xorg.

Despite still being perfectly usable, it was designed several decades ago when most of the stuff was being rendered on the server side. So basically all window elements, buttons, fonts, etc. were being allocated and rendered by the Xorg server, while clients were just sending "commands" to tell Xorg what to draw and where.

Today this model has almost completely disappeared. Almost everything is done client-side and clients just push pixmaps (so pictures of their window) to the display server and a window manager will blend them and send the final image to the server. So most of what the Xorg server was made for is not being used anymore, and the X server is noadays just a pointless middleman that slows down operations for nothing. Xorg is also inherently insecure with all applications being able to listen to all the input and snoop on other client windows.

So since the best solution would certainly involve breaking the core X11 protocol, it was better to make something from scratch that wouldn't have to carry the old Xorg and X11 cruft, and thus Wayland was born.

Wayland basically makes the display server and window manager into one single entity called a compositor. What the compositor does is take pixmaps from windows, blend them together and display the final image and that's it. No more useless entity in the middle which means way less IPC and copies which leads to much better performance and less overhead. The compositor also takes care of redirecting input to the correct clients which makes it vastly more secure than in the X11 world. A Wayland compositor also doesn't need a "2D driver" like Xorg does (DDX) at the moment since everything is done client-side and it only reuses the DRM/KMS drivers for displaying the result image.

(Mir is more or less the same than Wayland, except with some internal differences (API vs protocol) and for now Ubuntu/Unity 8 specific.)

Linux performance monitoring

dstat
also

iostat
vmstat (virtual memory)

Network:

iperf (client/server for true network bandwith, bits/sec)
iftop (per connection, uses pcap, default bits/sec)
nethogs (per process traffic, default bytes/sec)
ifstat (same as dstat, just for network)

for other network monitoring tools look here:
http://www.binarytides.com/linux-commands-monitor-network/

@TechnicalNotes @LinuxandUnix