Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

15/07/2020

[bash] Extract all distinct lines from file

Using a combination of cut and uniq, it is possible to extract all distinct lines from a given file:

cut -d\; -f1 file.txt | uniq


It is optionally possible to sort the file as well adding sort to the command:


cut -d\; -f1 file.txt | sort | uniq

[bash] Extract characters before marker from all lines in a file with sed

Using sed, it is possible to quickly extract all characters before a given marker from all lines in a file with:

sed 's/MARKER.*//' file.txt

29/04/2020

[Docker] Move docker directory to different location on NTFS filesystem

The default location of docker files (images, volumes, networks, etc) on most distributions is /var/lib/docker

This can be easily changed with the daemon.json configuration file.

First stop the docker service and make sure it is completely stopped.

You can now edit or create the configuration file under /etc/docker folder. In there, you can specify a new location for the docker files with the graph attribute:

{
   "graph": "/path/to/new/docker_folder"
}



You can then copy ALL the content to the new location or let docker recreate everything from scratch there.

WARNING: if the new location is on a different filesystem you might need to change the storage driver AND existing data might become inaccessible (it will remain on the filesystem though)

To set a new storage driver, set the storage-driver attribute as well (example for NTFS):

{
   "graph": "/path/to/new/docker_folder",
   "storage-driver": "vfs"
}

28/04/2020

[GNOME] Create application shortcut that can be added to favorites

Some applications you install come as archives that you extract in a desired location. However, not all come with an installer that takes care of creating the proper application entries, leaving the task to the user.

You can add a shortcut for any application by creating a file APPLICATION_NAME.desktop under /usr/share/applications and adding this content:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Terminal=false
Categories=OPTIONAL_CATEGORY_LIST

GenericName=APPLICATION_NAME
Comment=OPTIONAL_COMMENT
Name=APPLICATION_NAME
Path=FULL_PATH_TO_APPLICATION_FOLDER
Exec=FULL_PATH_TO_APPLICATION_EXECUTABLE

Icon=OPTIONAL_FULL_PATH_TO_ICON

StartupWMClass=APPLICATION_WM_CLASS


[Linux] Find WM_CLASS value for an application

In order to group application windows together, the WMClass and WMInstance attributes have been specified in the Inter-Client Communication Conventions Manual for X server 11.

Long story short, they are two strings that are used to associate application windows to a specific application, they can be set by the application (WMClass) or the user (WMInstance).

They are very useful especially for those applications that are customizations or based on existing tools, which alone would have a different value (eg Java or Eclipse based apps).

Finding the value for a window is as simple as opening a terminal and running:

xprop

Then clicking on the desired window


25/04/2020

[Linux] Custom keyboard layout QWERTZ to QWERTY

We already saw how to customize a keyboard layout on Windows, now it's the turn of Linux, using XKB for Xorg.

Remapping keys is as simple as editing a text file. You will find all available layouts under /usr/share/X11/xkb/symbols, you can use them as basis for a new layout or directly edit them.

Pick the layout you want to change (maybe make a backup first), then invert the VALUES ONLY of the two lines containing the lower and uppercase z and y, then save.

You will need to restart X server and the changes will be in effect.

15/08/2018

[Ubuntu] Revert kernel back to older version

Intro story: So much luck in a single day.

I always keep only 2 kernel versions after every update, so that I can boot back if something goes wrong. This usually helps, except today I decided to upgrade my Ubuntu from 16.04 to 18.04 since I like spending my nights fixing stuff after unnecessary upgrades, but hey, the future is there.

So I first fully updated my current installation (1st kernel bump), then migrated to the new one (2nd kernel bump) and it turns out I got two 4.15 kernels, with only different minor version.

Double interesting, my wireless card:

02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter

apparently has issues (read: bug) with kernel 4.15 preventing it from working at all (not even connected to the router), and even more interesting, on one version it can actually only connect to websites under google.com domain..

Anyway, quick fix was to revert back my kernel, here is how for future me to remember:
  1. go to http://kernel.ubuntu.com/~kernel-ppa/mainline/ and download in the same folder: linux-headers-VERSION-generic-XXX_SYSTEM.deb, linux-headers-VERSION_all.deb, linux-image-VERSION-generic-XXX_SYSTEM.deb for your system, eg I have 64 bit system and got amd64 files
  2. install them by going into the folder where you downloaded them, make sure there are only those three .deb files and run: sudo dpkg -i *.deb
  3. restart the system, then press SHIFT at boot to enter the GRUB choices, then check from the top line (number 0) to the line of your kernel version. If your installation has the "Advanced" menu entry and does not display all kernels, go there and do the same counting. We need this to set a default GRUB entry to always boot in this kernel
  4. edit /etc/default/grub and change the value of GRUB_DEFAULT to the number you counted OR to (exactly as shown) "1>N" if you have the "Advanced" menu option. This means you want to boot into the Nth entry (starting from 0) under the "Advanced" menu. Also set GRUB_TIMEOUT to some value in seconds that's more than 1, to have some time to block the boot process in case of mistakes
  5. run sudo update-grub and you are set
Note that this is a TEMPORARY fix, you would not want to have a fully updated system run on an older version of the kernel, mainly because some obscure dependency or feature might be missing/not working, therefore check back periodically to see if your issue has been addressed and try the latest kernel version out!


24/05/2014

[Debian] Run Wireshark as non-root user

Wireshark by default enables only the root user to capture network traffic; the idea is that as a root user you'll capture and store the traffic and as non-root user you'll perform any analysis you need. This unfortunately does not allow you to perform a "live capture" where you can work on the data while it is freshly captured from your network interface.

To enable non-root users to run a live capture too, simply dpkg-reconfigure it:

sudo apt-get install wireshark
sudo dpkg-reconfigure wireshark-common

When prompted to allow non-root user to perform restricted operations, say Yes.

Then logout and login again and you should be set. If not, add your user to the wireshark group:

sudo usermod -a -G wireshark $USER

[Debian] Test APT changes without altering the system

The APT package manager allows you to test the changes a command would perform without altering the system. To do that, simply add --dry-run to the desired command (usually an install or remove one).

Eg:

apt-get install SOMEPACKAGE --dry-run

Will show you what dependencies will be installed alongside the specified package but no actual installation will take place.

10/05/2014

[Debian] Set up wireless networking on a Lenovo T430 laptop

On a Lenovo T430 running Debian Wheezy and MATE desktop environment, the wireless networking was not working good even after installing the non-free drivers and Wicd, so you can install GNOME's good ol' network-manager instead.

[Debian] Install MATE desktop environment

Now that GNOME 2 is dead in favour of the not-so-good GNOME 3, users are still able to experience their solid and favourite desktop experience with MATE.

Installing it is really simple; this guide will describe how to add it to Debian Wheezy (stable release).

[Debian] Install package and its dependencies using dpkg

When installing a package with dpkg:

dpkg -i package.deb

its dependencies will not be automatically installed. To solve this, run:

apt-get -f install

after the dpkg installation

04/04/2009

Install Debian

This is the Debian Etch/Lenny/Sid installation guide I made. WARNING: Some parts of this guide are for the internet installation mode, if you don't have a lan/usb internet connection, download the full CDs - at least the first one -, since otherwise the installer won't work. Questa è la guida all'installazione di Debian Etch/Lenny/Sid che ho creato. ATTENZIONE: Alcune parti di questa guida riguardano l'installazione via internet, se non avete una connessione lan/usb, scaricate i CD - o almeno il primo -, poichè altrimenti l'installer non funzionerà.

-->IN ENGLISH:

  1. First, we need to download and burn an installation "businesscard" .iso image. Take it from here.
  2. Place it into your cd-drive and reboot your system.
  3. DON'T PRESS ENTER, but press F1 then F3, and type expertgui to install using the gui installer, or expert, then press enter.
  4. Follow all the steps until you are prompted to choose between : "Stable" (Etch), "Testing" (Lenny) or "Unstable" (Sid).
  5. Keep going until you're asked on which type of installation you want. Choose only "Base system" - and "Laptop" if you need it -but don't select "Desktop environment" too - unless you want to have the WHOLE gnome installation (not recommended, why would this guide be here for otherwise?) -.
  6. When it's installed, you'll be in shell login mode. And you'll need to install the Xserver, the login manager, and the desktop - if you want them of course -.
  7. Login and go in root: su
  8. Type: apt-get install xserver-xorg-core xorg to install the xserver and configure it when it's installed.
  9. Now install the login manager you want: apt-get install gdm if you want gnome (recommended) or kdm if you want kde. Install the login manager for the desktop you want. So if you want gnome install gdm, otherwise install kdm for kde.
  10. Finally, install the desktop environment you want: apt-get install gnome-core for a minimal gnome installation - recommended, light but very very minimal. You'll have to install all the software you want later manually -, if you want all you'll just have to choose also "Desktop environment" at point 5, but again.. why would this guide be here for? Anyway, if you decide to install the whole gnome just type: apt-get install gnome. If you want kde replace gnome with kde in the code lines.
  11. Now reboot your system and login. If the graphical login doesn't start, try: dpkg-reconfigure xserver-xorg
  12. Ok, now you're done. You'll find a base Debian system running and you can start to install the software you need
  13. Just one more thing: if you want to use sudo add this line in the /etc/sudoers file (from root nano /etc/sudoers): yourusername ALL = (ALL) ALL

-->IN ITALIANO:

  1. Scaricate e masterizzate un'immagine .iso "businesscard" da qui.
  2. Inseritela nel lettore e riavviate.
  3. NON PREMETE INVIO, ma F1 quindi F3, e digitate expertgui per installare usando la gui, oppure expert ,quindi premete invio
  4. Seguite i passi finchè non vi sarà chiesto di scegliere tra: "Stable" (Etch), "Testing" (Lenny) o "Unstable" (Sid).
  5. Continuate finchè non vi sarà chiesto che tipo di installazione volete. Scegliete solamente "Sistema base" - e "Computer portatile" se necessario - ma non selezionate anche "Ambiente desktop" - a meno che non vogliate l'installazione COMPLETA di gnome (non consigliato, a che servirebbe questa guida altrimenti?)-.
  6. Quando è installato, vi ritrovere in modalità di login shell. E dovrete installare Xserver, il login manager, ed il desktop - sempre se li volete -.
  7. Loggate ed andate in root: su
  8. Digitate: apt-get install xserver-xorg-core xorg per installare xserver e configurarlo al termine.
  9. Adesso installate il login manager desiderato: apt-get install gdm se volete gnome (consigliato) o kdm se volete kde. Installate il login manager per il desktop che volete, quindi gdm per gnome altrimenti kdm per kde.
  10. Infine, installate l'ambiete desktop desiderato: apt-get install gnome-core per un'installazione minimale di gnome - consigliato, ma davvero minimale. Dovrete installare tutto il software che volete in seguito manualmente -, se volete tutto basta scegliere anche "Ambiente desktop" al punto 5, ma di nuovo.. cosa ci sta a fare questa guida? Comunque, se decidete di installare tutto gnome digitate: apt-get install gnome. Se volete kde sostituite gnome con kde nelle righe di codice.
  11. Adesso riavviate e loggate. Se non dovesse partire l'ambiente grafico, digitate: dpkg-reconfigure xserver-xorg
  12. Ok, adesso avete finito. Avrete un sistema base Debian e potrete iniziare ad installare il software desiderato.
  13. Un'ultima cosa: se volete usare sudo, aggiungete queste righe in /etc/sudoers (da root nano /etc/sudoers): vostrousername ALL = (ALL) ALL

Enable automount on Debian

To enable the auto mount feature, just type in a terminal: sudo apt-get install gnome-volume-manager pmount Expecting more steps? Sorry to inform you that it's all done. :)

Per abilitare l'auto mount, digitate in un terminale: sudo apt-get install gnome-volume-manager pmount Vi aspettavate altri passi? Spiacente di informarvi che è tutto fatto. :)