Pages

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Monday, 13 April 2020

Change linux hostname Cent OS/RHEL/Oracle Linux (proper way)

While requesting linux virtual machine at a vps provider I forgot to set the hostname I wanted it to have. As a result it got a default hostname which was a combination of date and time. Following google findings I changed the hostname in /etc/hosts and by executing hostname NEW_HOSTNAME. I tried hostnamectl set-hostname NEW_HOSTNAME too. That didn't work! I didn't have any other choice as going to the documentation. Then I realised I should have set the type of hostname I am setting up. Quick note from docs:

The static (configured) host name is the one configured in /etc/hostname or a similar file. It is chosen by the local user. It is not always in sync with the current host name as returned by the gethostname() system call. If no host name is configured this property will be the empty string. Setting this property to the empty string will remove /etc/hostname. This hostname should be an internet-style hostname, 7bit ASCII, no special chars/spaces, lower case.

The transient (dynamic) host name is the one configured via the kernel's sethostbyname(). It can be different from the static hostname in case DHCP or mDNS have been configured to change the name based on network information. This property is never empty. If no host name is set this will default to "localhost". Setting this property to the empty string will reset the dynamic hostname to the static host name. If no static host name is configured the dynamic host name will be reset to "localhost". This hostname should be an internet-style hostname, 7bit ASCII, no special chars/spaces, lower case.

The pretty host name is a free-form UTF8 host name for presentation to the user. UIs should ensure that the pretty hostname and the static hostname stay in sync. I.e. when the former is "Lennart's Computer" the latter should be "lennarts-computer". If no pretty host name is set this setting will be the empty string. Applications should then find a suitable fallback, such as the dynamic hostname.



Here I used static type: hostnamectl set-hostname NEW_HOSTNAME --static

Thursday, 27 February 2020

How to send command to specific pane in tmux

I was looking for a way of launching process in tmux split screen mode where one part of the terminal shows log entries and another starting sequence. I found a script in internet but was having problems locating a pane. So first I had to figure out correct pane locations. To do this execute following command:


tmux list-panes –a

This gave me indication that window id is equal 1 and not 0 as indicated in tmux status bar.

Then it went easy, just go with following bash script:

#!/bin/bash
session="my name"
window=${session}:1
pane=${window}.1
echo $pane
tmux send-keys -t "$pane" C-z 'test cmd 1' Enter
tmux send-keys -t "$pane" 'test cmd 2' Enter

Thursday, 20 February 2020

Linux how to check progress of DD

Few days ago I decided to install linux on Lenovo Yoga 1051f which is a Windows 10 tablet. First I wanted to create backup of existing system. This tablet has only 1 micro USB port so I had to use USB hub. I executed DD command for entire disk, that was about 32GB.

dd if=/dev/sdb of=/dev/sdc
After an hour or so I became curious about the progress. I expected this to be quick thing while it was very slow. Probably I should have done something like this:
dd if=/dev/sdb of=/dev/sdc status=progress
Copying was in progress and I didn't want to abort it. After doing some research I found a comment saying that I can open another terminal window and execute kill command there, then terminal where DD is running would show the progress. This indeed worked. In theory this should work too:
sudo kill -USR1 $(pgrep ^dd)

Happy dd-ing!

Saturday, 1 February 2020

How to change Time Zone on Oracle Linux (Working)

I tried multiple commands from different posts which ran correctly but didn't change Time Zone permanently. I figured out following steps in order to change Time Zone info on Oracle Linux:

1. Run tzselect (this will return timezone name)
2. Run timedatectl set-timezone OUTPUT_OF_ABOVE

Then execute date to confirm if it worked.