2021年5月20日 星期四

Ubuntu 18.04 : How to connect Hinet pppoe ADSL

$ nmcli  con edit  type pppoe  con-name my_hinet_adsl
## it will open  an interactive prompt .
  set pppoe.username  xxx@hinet.net
  set pppoe.password  password
  save 
  quit

標籤: , , , ,

2021年5月19日 星期三

ubuntu 記住最後一次開機選項

$ sudo gedit /etc/default/grub
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved

標籤: , ,

2021年5月18日 星期二

如何 重置 usb drive , 而不用 手動插拔

from https://marc.info/?l=linux-usb&m=121459435621262&q=p3

/* usbreset -- reset a USB device */
/*
$ gcc usbreset.c -o usbreset
$ sudo mv usbreset /usr/local/bin/
$ lsusb
Bus 001 Device 004: ID .....
$ sudo usbreset /dev/bus/usb/001/004
*/

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <linux/usbdevice_fs.h>

int main(int argc, char *argv[])
{

if (argc != 2) {
    fprintf(stderr, "Usage: usbreset device-filename\n");
    fprintf(stderr,"\
$ lsusb\n\
Bus 001 Device 004: ID .....\n\
$ sudo usbreset /dev/bus/usb/001/004\n\
");
    return 1;
}

const char *filename = argv[1];

int fd = open(filename, O_WRONLY);
if (fd < 0) {
    perror("Error opening output file");
    return 1;
}


printf("Resetting USB device %s\n", filename);
int rc = ioctl(fd, USBDEVFS_RESET, 0);
if (rc < 0) {
    perror("Error in ioctl");
    return 1;
}
printf("Reset successful\n");

close(fd);
return 0;

}

標籤: , , ,

2021年5月16日 星期日

列出 apt 的歷史操作記錄

列出 apt 的歷史操作記錄

$ (zcat $(ls -tr /var/log/apt/history.log*.gz); \
 cat /var/log/apt/history.log) 2>/dev/null | \
egrep '^(Start-Date:|Commandline:)' | \
grep -v  aptdaemon | \
egrep '^Commandline:'

標籤: , ,

2021年5月5日 星期三

build geany from geany.git

OS: Ubuntu 18.04  64bit

### ### ###
### install from geany ppa too
$ sudo add-apt-repository ppa:geany-dev/ppa
$ sudo apt-get update
$ sudo apt-get install geany geany-plugins

### end session



### ### ###
### build from source code : geany.git
###
$ cd ~/jeffer
$ git clone https://github.com/geany/geany.git
$ cd geany
$ git reset 1.37.1
~/jeffer/geany$ ./autogen.sh 

**Error**: You must have `intltool' installed.
**Error**: You must have `glib' installed.
You must have pkg-config installed to compile .
$ sudo apt-get install pkg-config
$ sudo apt install intltool
$ sudo apt install libglib2.0-dev
$ ./autogen.sh
$ apt search libgtk-3   

###  libgtk-3-dev
$ sudo apt install libgtk-3-dev
$ ./autogen.sh

configure: error: Documentation enabled but rst2html not found.

#### open another terminal to another directory
#### from https://pypi.org/project/rst2html/
#### download rst2html-2020.7.4.tar.gz (1.5 kB)
$ tar xvf rst2html-2020.7.4.tar.gz
$ sudo pip install rst2html

The directory '/home/jeffer/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/jeffer/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting rst2html
  Downloading https://files.pythonhosted.org/packages/29/8e/050653d3f88c7c0ef3ba6df84421dc022d84f152e2c84fc23d49b2d60d1f/rst2html-2020.7.4.tar.gz
Collecting docutils (from rst2html)
  Downloading https://files.pythonhosted.org/packages/4c/5e/6003a0d1f37725ec2ebd4046b657abb9372202655f96e76795dca8c0063c/docutils-0.17.1-py2.py3-none-any.whl (575kB)
    100%  
Installing collected packages: docutils, rst2html
  Running setup.py install for rst2html ... done
Successfully installed docutils-0.17.1 rst2html-2020.7.4

####
#### back to /geny  folder terminal
####
$ ./autogen.sh
.......
Install Geany in                   : /usr/local
Compiling Git revision             : 26f4813f
Using GTK version                  : 3.22.30
Enable binary relocation           : no
Build with plugin support          : yes
Use (UNIX domain) socket support   : yes
Use virtual terminal support (VTE) : yes
Build HTML documentation           : yes
Build PDF documentation            : no
Build API documentation            : no
Generate GtkDoc header             : no
Configuration is done OK.
Now type 'make' to compile.
$ ./configure
    ### Makefile  use GCC flag  use  -O0 -g3 to maximize debug info
$ make
### whereis execute file .../geany/src/.lib/geany
$ sudo make install

### $ make clean   ### to make sure clean
### entry point is main.c main()
### I untar  eclipse-cpp-2021-03-R-linux-gtk-x86_64.tar.gz  to a  folder , run eclipse, import geany project , It can debug.

標籤: , , ,

2021年5月4日 星期二

Markdown to html python commandline transfer tool

sudo apt update
sudo apt install python-pip
# cd to your workspace directory , below will lay down git folder from github

git clone https://github.com/Python-Markdown/markdown.git
cd markdown
pip install markdown

python -m markdown --help
echo "Some **Markdown** text." | python -m markdown > output.html
python -m markdown input_file.txt > output2.html

標籤: , , , ,

2021年5月3日 星期一

Install newer version(PPA) geany & plugin for unbuntu 18.04LTS

### Install  newer version(PPA) geany & plugin  for  unbuntu 18.04LTS ###
sudo add-apt-repository ppa:geany-dev/ppa
sudo apt-get update
sudo apt-cache policy geany
sudo apt-get install geany
sudo apt-get install geany-plugins
apt-cache search geany

標籤: , ,

Installing Python 3.8 on Ubuntu 18.04 from Source

### Installing Python 3.8 on Ubuntu 18.04 from Source ###
$ sudo apt update
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

$ wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz
$ tar -xf Python-3.8.10.tgz
$ cd Python-3.8.10
$ ./configure --enable-optimizations
$ make -j cpu-core_number  ### use what your cpu core#
$ sudo make altinstall
$ python3.8 --version

標籤: , , ,

2021年5月1日 星期六

linux 快速 cd ../../.......

在 ~/.bash_rc 內加入以下 function
即可在新開的 terminal 中, 用 .. N 快速切換到祖先目錄.
FYI: cd -  可以來回切換前後目錄.

 
toN()  # toN num default
{
    test ${1} || return ${2}
    if [[ ${1} = *[[:digit:]]* ]] ; then
return ${1}
    else
return "0"
    fi
}
..() {
    toN "$1" "1"
    num=$?
    if [[ $num -gt 0 ]] ; then
      seq=`seq $num`
      next=`printf '../%.0s' {$seq}`
      cd $next
    else
echo "Usage: .. [1..N]"
echo "     to change to previous N level directory"
echo "*** ${BASH_SOURCE}  ${FUNCNAME}():${LINENO} th line ***"
    fi
}

標籤: , , ,

ubuntu 如何用最新版本的 git

$git --version
$sudo  add-apt-repository ppa:git-core/ppa
$sudo  apt-get update
$sudo  apt-cache policy git
$sudo  apt-get install git
$sudo  apt-cache policy git
$git --version

標籤: , , , ,