Search This Blog

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

04 January, 2022

tmux enabling mouse interaction

Add the below line to the ~/.tmux.conf

setw -g mouse on

save the file and exit from the tmux shell, you should be able to use your mouse to resize the windows


10 August, 2021

tmux saving the scrollback content to a file

Follow as below, i tried this in Ubuntu 18.04 LTS

All commands to be execute without quotes 

1) Use "prefix + :"

2) Type "capture-pane -S -5000 + Return"

Replace -5000 with the number of lines you'd like to save, or with - for all lines. This copies those lines into a buffer.

3) To save the buffer to a file, type "prefix + :"

4) Type in "save-buffer filename.txt + return".

By default Prefix is Ctrl+B for tmux

22 August, 2020

How to enable Remote Desktop in Ubuntu

Below tested on Ubuntu 18.04

 

Refer the Screenshot, by default Ubuntu uses vino-server

 

1) Click on Ubuntu Settings

2) Click on Sharing

3) Click on the screen sharing

4) turn on the screen sharing button on the pop up window

5) set the options as shown above, set a password for the connection

6) disable encryption

 sudo gsettings set org.gnome.Vino require-encryption false



13 June, 2020

Ubuntu 18.04 running script at boot

Ubuntu 18 is using systemd, and there are three things we need to do 

1) Create a service file and put it in /etc/systemd/system/
  let say the file be board-init.service, with the below content


[Unit]
Description=Board initializations
DefaultDependencies=no

[Service]
Type=oneshot
ExecStart=/etc/board-init.sh

[Install]
WantedBy=sysinit.target

2) create your board-init.sh script file, and put it in /etc/

3) Create a soft link in the /etc/systemd/system/sysinit.target.wants to the service file w created

cd /etc/systemd/system/sysinit.target.wants
ln -s /etc/systemd/system/board-init.service board-init.service

reboot the board. To see the output of the script type 

journalctl -u board-init -b

13 March, 2019

20 December, 2016

Mysql Uninstall from Ubuntu 16.04

Follow the steps

1) sudo apt-get remove dbconfig-mysql
2) sudo apt-get remove --purge mysql-server mysql-client mysql-common

06 December, 2016

iperf3 compilation for ARM in Ubuntu

For compiling for ARM target board

Get the cross compiler details and pass it as argument to the configure script. I used iperf-3.1.3
Below method is for building iperf3 as static, so that we need to push only the iperf3 binary , without any shared libraries

First this assumes you had set the ARM compiler in the path

cd iperf-3.1.3/

1) ./configure --host=arm-linux-gnueabi CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ CFLAGS=-static CXXFLAGS=-static --enable-static --prefix=`pwd`/output

2) make install


the binary will be available inside output/bin/

22 September, 2016

Increasing the linux terminal console column width and number of rows

very useful tip for embedded Linux engineers and those who work with Linux Console using minicom or teraterm


very useful tip for embedded Linux engineers and those who work with Linux Console using minicom or teraterm

normally if we type ps in serial console, it will show the process , if the length is more than 80 character(which is default) we cannot see the string after 80 characters in the consol,

with the below command you can adjust the width of the terminal with cols argument and number of rows using the  argument rows to the command stty

stty cols 160 rows 40

this can be used separate also
stty cols 160
stty rows 50

Hope this help in ps and htop command when u run and other applications


02 September, 2016

accessing serial port in linux/ubuntu as a normal user

For accessing serial port in linux/ubuntu as a normal user,
we need to add the user to the dialout group
follow the below commands 
 
sudo adduser second_user dialout
or 
sudo adduser `whoami` dialout 


28 August, 2016

Linux File Permission in octal format in terminal or command line

To see the file permission in Linux terminal use the below command

stat -c "%a %n" *

* = will list and show all files , replace with the fie name if you want to know only for one filename

16 August, 2016

virtual machine shared folder permission


When using Ubuntu on Virtual Box, you can share a folder between Windows Hosta and Ubunut Guest, after doing the sharing, you need to set the permission so that it can be accessed using the normal user login



You need to type the followinf command to add the permission for the normal user to access it

sudo usermod -aG vboxsf <youruser_name>

or

sudo usermod -aG vboxsf `whoami`


Wi-Fi command line commands

Wi-Fi(IEEE 802.11) command line useful commands

Wi-Fi AP Mode
1) Scan the network

iw dev wlan0 scan or
iw dev wlan0 scan ap-force


2) Connected Devices to the Wi-Fi Access Point (wifi AP mode)

Using hostapd cli:  hostapd_cli all_sta
using iw: iw dev wlan0 station dump


Wi-Fi Station/Client Mode

1) To Scan network

iw dev wlan0 scan 

to show only the SSID from the ouput
iw dev wlan0 scan | grep SSID






23 July, 2016

ubuntu showing menu always

15.04 and baove has the ability to toggle the global menu as well as the local integrated menus (Via System Settings - Appearance - Behaviour tab) to be permanently on or off.

If you are running a fully up-to-date version of 14.04, this same ability has been backported.

To switch on permanently:

gsettings set com.canonical.Unity always-show-menus true

To switch off i.e. to autohide:

gsettings set com.canonical.Unity always-show-menus false

24 June, 2016

Highlighting or making prominent the active Terminal tab in Ubuntu Linux

For highlighting or making prominent the active tab of the Terminal in Ubuntu Linux

 create a file named ~/.config/gtk-3.0/gtk.css

and paste the below content, You can change the color as you want. Hope this helps


TerminalWindow .notebook tab:active {
    background-color: #b0c0f0;
}


18 September, 2015

end of line sequences in different OS

end of line sequences
Windows end of line sequence:  \r\n
Unix end of line sequence: \n
Mac end of line sequence: \r

11 September, 2015

Recovering moved or deleted files in Linux

I was developing one C program which I spend 1 day writing with around  500 lines of code in Ubuntu 12.04 

for compiling in GCC, I used the below command

# gcc server.c -o server.c

instead of giving gcc server.c -o server 

now my whole source code was replaced with the binary file :( :(  , a simple mistake which caused my whole source code got deleted or replaced. I had a habit of pressing for auto completing the file names. 

After searching for some time googling, i got a solution which worked for me and saved my 9 hours of work.

I got the help form this below link
http://www.cyberciti.biz/tips/linuxunix-recover-deleted-files.html

repeating what is said there and which i tried and worked for me

in the console with sudo permission
sudo grep -a -B[size before] -A[size after] 'filename or unique content' /dev/[your_partition] > file.txt

-i : Ignore case distinctions in both the PATTERN and the input files i.e. match both uppercase and lowercase character.
-a : Process a binary file as if it were text
-B Print number lines/size of leading context before matching lines.
-A: Print number lines/size of trailing context after matching lines.


my command was
sudo grep -a -B10 -A1000 'UNIQUE_SERVER_IP' /dev/sda1 > file.txt

UNIQUE_SERVER_IP was the #define i did it in my source code. After the command is over, open the file.txt with vi or any text editor and search for the string 'UNIQUE_SERVER_IP'. you should find your source code around the string, copy paste and save to the required file name

I got the my source code back in some time.



09 September, 2015

counting number of lines in c and include files in Linux

After writing source code in Linux, if you want to count the number of lines in .c and .h files

find . -name '*.c' -o -name '*.h' | xargs wc -l

Converting IP Address from string in dot format to 32 bit integer

C program to convert IPv4 address from String formatted in dat notation like "10.0.0.1" to a 32 bit integer in Linux

#include<stdio.h>
#include <arpa/inet.h>

main()
{

    uint32_t ip;
    struct in_addr ip_addr;

    ip = inet_addr("10.0.0.1");
    printf("IP Integer: %d\n", ip);
    ip_addr.s_addr = ip;
    printf("The IP address is: %s\n", inet_ntoa(ip_addr));

}

06 August, 2015

Turning off expandtab in VIM for editing makefile

if you had set the .vimrc to change the tab to spaces for C programming, it will be difficult to edit or create makefiles,

 i had trouble creating makefile , i was getting the below error

Makefile:18: *** missing separator.  Stop.


after googled little and  found the  solution, edit the .vimrc file like below



let _curfile = expand("%:t")
if _curfile =~ "Makefile" || _curfile =~ "makefile" || _curfile =~ ".*\.mk"
set noexpandtab
else
set expandtab
set tabstop=4
set shiftwidth=4
endif

07 July, 2015

Using arrow keys in insert mode shows characters in vi editor

while using vi in Oracle virtual box with Ubuntu 12.04 as the guest OS with Windows 7 as the host, when we press arrow keys in insert mode, it used to print B, A, D, C

to fix this add the below line to the .vimrc file, if  it is no file create it

set nocompatible

after this setting if you open the vi , the problem should not come

tmux enabling mouse interaction

Add the below line to the ~/.tmux.conf setw -g mouse on save the file and exit from the tmux shell, you should be able to use your mouse to ...