11/28/2016

解決 apt-get install 遇到404 Not Found的問題

Ubuntu 10.4版 要使用apt-get install 安裝套件的時候遇到了404 Not Found的問題,訊息大概如下:

Err http://archive.ubuntu.com quantal/main amd64 Packages
  404  Not Found [IP: 91.189.91.15 80]
Err http://archive.ubuntu.com quantal/restricted amd64 Packages
  404  Not Found [IP: 91.189.91.15 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/quantal-security/main/binary-amd64/Packages  404  Not Found [IP: 91.189.91.15 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/quantal-security/restricted/binary-amd64/Packages  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/main amd64 Packages      
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/restricted amd64 Packages
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe amd64 Packages  
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/multiverse amd64 Packages
  404  Not Found [IP: 91.189.91.15 80]



找了一下原因與解決方法,原因大概是因為,舊版的LTS版本,ubuntu只支援5年的時間(如果不是LTS版本只支援9個月),五年後ubuntu就會把更新的Server從標準的Server "http://archive.ubuntu.com/ubuntu/dist/" (apt-get 會去找的地方),移到別的地方了。

所以解決無法apt-get install的方法有兩個:

1. 更新你的ubuntu版本,使用指令 sudo apt-get dist-upgrade 去做版本更新。

2. 另一個方法你可以不要更新,可以使用 sed command 去更改 /etc/apt/sources.list 這個檔案,我們要把source.list裡面的 "archive.ubuntu.com" 和 "security.ubuntu.com" 替換成 "old-releases.ubuntu.com",在使用替換的指令之前,請先備份一下source.list檔案,如果下面方法失敗還可以把source.list復原,接著就可以執行sed替換指令,兩個步驟(command)如下:

     一. cp /etc/apt/source.list /etc/apt/back_source.list
     二. sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com

當我們的source.list內容替換完成之後,請先執行update,update完成之後再作apt-get install 接下來應該就不會有404 Not Found的問題了! update的命令如下:

     sudo apt-get update

 source from: http://dannysun-unknown.blogspot.tw/2016_10_01_archive.html


10/14/2016

Fixed Chromebook Volume & Brightness Key


Open Keyboard > Application Shortcuts > Add





  • Increase the volume by 10%   F10
    • amixer set Master 10%+
  •  Decrease the volume by 10%   F9
    • amixer set Master 10%-
  • Sets mute on and off   F8
    • amixer set Master toggle
  • Turn Brightness Up   F7
    • brightness up
  • Turn Brightness down   F6
    • brightness down 

8/25/2016

Installation of Emacs 24.4


First off, you should download the Emacs 24.4 source tarball:
cd ~
mkdir emacs-src && cd emacs-src
wget http://mirror.team-cymru.org/gnu/emacs/emacs-24.4.tar.gz
tar xvf emacs-24.4.tar.gz
Now, you want to compile the Emacs binary. 
sudo apt-get install build-essential
sudo apt-get build-dep emacs24
cd emacs-24.4
./configure
make
sudo make install
type  "emacs-24.4" to execute the Emacs
 open /etc/bash.bashrc
add   alias  emacs='emacs-24.4'

 

8/18/2016

E: Solve the flash drive volume problem on Windows


當使用的隨身硬碟,格式化後的硬碟容量與實體不符,
打開命令提示字元。

cmd-> diskpart
list disk -> select problem FLASH DRIVE

!!MUST CHECK YOUR SELECTION DRIVE IS RIGHT!!


clean
create partition primary
then, format.

Bashrc and Profile



~/.Profile

  • profile is a document storing the enviorment value. In device the user can has a lot of shell, but need only one profile to centrally save the user setting.
~/.Bashrc
  • As above you can have more than one shell, so the bashrc is for bash shell to keep the enviorment setting.

Git Remember



1.When you do every new repos, remember to create ".gitignore" file.
  it can ignore the file which you don't want to commit.

2.git-completion.bash add in bash.bashrc
source ~/.git-completion.bash

8/15/2016

Add Keyboard Shortcut of Terminal to Xubuntu



1. Application

Application Menu -> Settings -> Keyboard

"Add" -> type "xfce4-terminal" ->press combine shortcut key "CTRL+ALT+T"  DONE.


2.  with Terminal to add the keyboard shortcut


Adding shortcut keybindings in two steps from the command line (14.04+)

Adding custom shortcuts from the command line can be done, but is a bit complicated; it needs to be done in a few steps per keybinding. On the other hand, it is pretty straightforward and can very well be scripted if you somehow want to do it from the command line (that was the question, right?).
Just like in your interface (System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts"), Custom keyboard shortcuts are made from command line in two steps:
  1. create the keybinding by editing (adding to-) the list that is returned by the command:
    gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings
    
    The returned list looks like (if it were only one shortcut currently):
    ['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']
    
    Apply the edited list by the command:
    gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "[<altered_list>]"
    
    (mind the double quotes)
    N.B. No need to say that the mention in the list (e.g. custom1, custom2) should be a unique one. If you script it, the script should prevent duplicates. In this case the edited list should look like e.g.:
    ['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']
    
    to add one keybinding: custom1
  2. set its properties:
    • name:
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name '<newname>'
      
    • command:
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command '<newcommand>'
      
    • Key combination (for example <Primary><Alt>g):
      gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding '<key_combination>'
      
Useful information can be found here

Example script to set a new custom shortcut

The script below can be used to set a new shortcut key combination from the command line. It can be used with the command (assuming the key combination is available):
python3 /path/to/script.py '<name>' '<command>' '<key_combination>'
An example:
To set a shortcut key combination to open gedit with the key combination Alt+7:
python3 /path/to/script.py 'open gedit' 'gedit' '<Alt>7'
The script:
#!/usr/bin/env python3
import subprocess
import sys

# defining keys & strings to be used
key = "org.gnome.settings-daemon.plugins.media-keys custom-keybindings"
subkey1 = key.replace(" ", ".")[:-1]+":"
item_s = "/"+key.replace(" ", "/").replace(".", "/")+"/"
firstname = "custom"
# get the current list of custom shortcuts
get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")
current = eval(get("gsettings get "+key))
# make sure the additional keybinding mention is no duplicate
n = 1
while True:
    new = item_s+firstname+str(n)+"/"
    if new in current:
        n = n+1
    else:
        break
# add the new keybinding to the list
current.append(new)
# create the shortcut, set the name, command and shortcut key
cmd0 = 'gsettings set '+key+' "'+str(current)+'"'
cmd1 = 'gsettings set '+subkey1+new+" name '"+sys.argv[1]+"'"
cmd2 = 'gsettings set '+subkey1+new+" command '"+sys.argv[2]+"'"
cmd3 = 'gsettings set '+subkey1+new+" binding '"+sys.argv[3]+"'"

for cmd in [cmd0, cmd1, cmd2, cmd3]:
    subprocess.call(["/bin/bash", "-c", cmd])
How to use:
Paste the script into an empty file, save it as set_customshortcut.py, run it as explained above.

Some of the mostly used key mentions (found experimentally, looking into the changes the GUI way made into the binding value):

Super key:                 <Super>
Control key:               <Primary> or <Control>
Alt key:                   <Alt>
Shift key:                 <Shift>
numbers:                   1 (just the number)
Spacebar:                  space
Slash key:                 slash
Asterisk key:              asterisk (so it would need `<Shift>` as well)
Ampersand key:             ampersand (so it would need <Shift> as well)

a few numpad keys:
Numpad divide key (`/`):   KP_Divide
Numpad multiply (Asterisk):KP_Multiply
Numpad number key(s):      KP_1
Numpad `-`:                KP_Subtract
etc.

8/12/2016

bash built-in "shift"

shift 是將指令列上的參數位置做移動的指令。

ex:


$0= xxx                               $0= zzz
$1= yyy              shift 2       $1= ppp
$2= bbb            ======>   $2= qqq      
$3= ppp                               $3= null
$4= qqq                               $4= null

xxx and yyy were shifted out of the order, it'd been thrown away.

ps: Linux 實戰手冊 18-3-3

8/09/2016

E:"at" command not found.



at command need "atd"

execute "sudo atd", then use "at" command

7/20/2016

E:could not get lock '/var/lib/dpkg/lock'



Error: could not get lock /var/lib/dpkg/lock
Error: Unable to lock the administration directory

當synaptic package manager 相關套件管理程式開啟時,

會無法執行upgrade,

關閉之後再執行即可。

E:mlocate/locate :can not open '~/mlocate.db' no such file or directory


sol:

第一次使用需建立db檔,

最高權限執行'updatedb'

'sudo updatedb'