Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. 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/02/2015

[CentOS 7] Chrome use system theme fix

After installing Google Chrome on CentOS 7 with the default theme enabled, you may notice that it will display the mouse pointer in the default Xorg theme instead of blending in with the system.

A workaround is to edit the /usr/share/icons/default/index.theme file by changing

Inherits=dmz-aa

to

Inherits=Adwaita

13/02/2015

[CentOS] Detect Windows installation and update GRUB

After installing CentOS on your wannabe dual-boot machine, you realize with horror that for very important and critical reasons, your system does not have a dual boot menu and it's not able to recognize and read the Windows partition.

The solution is luckily very simple:

yum install epel-release
yum install ntfs-3g

This will allow the system to correctly manage NTFS filesystems.

grub2-mkconfig -o /boot/grub2/grub.cfg

This will update GRUB so that it shows the dual boot options now that it's able to recognize the Windows partition.

grub2-set-default X

This is optional and it's used to set the X kernel/OS as default when starting the system. You can find the number by reading the file /boot/grub2/grub.cfg

05/04/2014

[CentOS] Install Oracle XE

Unlike on Windows, installing Oracle XE on CentOS requires some more steps after the actual RPM installation.

After you download the zip file, extract it and install the RPM, browse to the Disk1 directory under the folder where you extracted everything into.

Now run as root

/etc/init.d/oracle-xe configure

to configure and start the database.

The installation process creates a /u01 folder, inside it, under app/oracle/product/VERSION_NUMBER/xe/bin you'll find the oracle_env.sh script which sets some environment variables used by Oracle for you.

To have it permanently set those variables for your user, add this line to your .bash_profile (found under your user home):

. /u01/app/oracle/product/VERSION_NUMBER/xe/bin/oracle_env.sh

After this, you should be able to run SQLPlus (you may have to log out and log in again or just open a new terminal window).

[CentOS] Browse folders in same window

CentOS comes out of the box with the uber-annoying setting to open each folder in a new window; this makes the screen really messy very fast as you browse the filesystem.

To have it always use the same window when opening new folders, just alter this setting:

Edit->Preferences->Behavior->Always open in browser windows

Then log out and log in again