Replace string to $HOME by sed

sed "s/HOME/$HOME/g" t
# sed: -e expression #1, char 9: unknown option to `s'

Why? The $HOME contains ‘/’, It is in conflict with separating character. So, change the separating character to ‘|’.

sed "s|HOME|$HOME|g" t
# Passed!

Over!

为什么 Linux 用户每次登录都要求修改密码?

最近在制作 Linux 操作系统的升级还原系统镜像文件,在测试安装后,创建的用户每次登录都要求修改密码。就很是郁闷。

经过调查发现是由于机器的硬件时钟不对,导致了此用户的密码过期,从而强制修改密码。

于是登录 root 用户,重新设置了正确的时间,用户的过期时间仍然是在旧时刻,这样就永远不会不过期了……

Google 找到系统中有个简单的工具 chage 可用户修改账户定期相关的设置。我的目的是将用户的账户和密码都设置为永远不过期:

chage -I -1 -E -1 loongson

关于 chage 的更多用法,请参考 man:

man chage

Over!

Build adb for Loongson(MIPS)

Henceforth it will be more easy to debug Android device on Loongson. I will tell you how to build adb for Loongson (MIPS).

Step 1: Clone source code from git repos

git clone https://android.googlesource.com/platform/system/core.git

Step 2: Write a standalone Makefile

vim core/adb/Makefile
# Makefile for adb
 
SRCS+= adb.c
SRCS+= adb_client.c
SRCS+= commandline.c
SRCS+= console.c
SRCS+= file_sync_client.c
SRCS+= fdevent.c
SRCS+= get_my_path_linux.c
SRCS+= services.c
SRCS+= sockets.c
SRCS+= transport.c
SRCS+= transport_local.c
SRCS+= transport_usb.c
SRCS+= usb_linux.c
SRCS+= usb_vendors.c
SRCS+= utils.c
 
VPATH+= ../libcutils
SRCS+= abort_socket.c
SRCS+= socket_inaddr_any_server.c
SRCS+= socket_local_client.c
SRCS+= socket_local_server.c
SRCS+= socket_loopback_client.c
SRCS+= socket_loopback_server.c
SRCS+= socket_network_client.c
 
VPATH+= ../libzipfile
SRCS+= centraldir.c
SRCS+= zipfile.c
 
CPPFLAGS+= -DADB_HOST=1
CPPFLAGS+= -DHAVE_FORKEXEC=1
CPPFLAGS+= -DHAVE_SYMLINKS
CPPFLAGS+= -DHAVE_TERMIO_H
CPPFLAGS+= -D_GNU_SOURCE
CPPFLAGS+= -D_XOPEN_SOURCE
CPPFLAGS+= -I.
CPPFLAGS+= -I../include
CPPFLAGS+= -I../../../external/zlib
 
CFLAGS+= -O2 -Wno-unused-parameter
LDFLAGS= 
LIBS= -lrt -lpthread -lz
 
TOOLCHAIN= mipsel-unknown-linux-gnu-
CC= $(TOOLCHAIN)gcc
LD= $(TOOLCHAIN)gcc
 
OBJS= $(SRCS:.c=.o)
 
all: adb
 
adb: $(OBJS)
	$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
 
clean:
	rm -rf $(OBJS)

Step 3: Build

cd core/adb
make

Over!

How to force HTC Desire CDMA in CDMA 1x mode?

1. Backup old rom via ClockMod recovery.
2. Flash to Offical stock rom. (I’m using ‘2.11.573.5_USCC’ without radio)
3. Input ‘##778#’ at dial pad to run ‘EPST’ in this ROM.
4. Select ‘Edit mode’.
5. Input password, default is ‘000000’.
6. Go to ‘Modem Settings’.
7. Set ‘Preferred Mode’ = ‘CDMA only’.
8. Set ‘HDR Hybrid Preferred’ = ‘Disable’.
9. Press the ‘Menu’ button at bottom of phone.
10. Tap on ‘Commit Modifications’.
11. Press ‘OK’ to reboot phone.
12. Restore ‘CM’ rom.

Over!

Change login (gdm) background picture or color in GNOME 3

1. Switch to gdm user.

sudo su - gdm -s /bin/bash

2. View dbus information

dbus-launch
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-eu0FhGDTaj,guid=88e71479abc78714c0d182840000018f
DBUS_SESSION_BUS_PID=1428

3. Set environment variables

export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-eu0FhGDTaj,guid=88e71479abc78714c0d182840000018f
export DBUS_SESSION_BUS_PID=1428
export GSETTINGS_BACKEND=dconf

4. Run ‘dconf-service’

/usr/lib/dconf/dconf-service &

5. Get current picture path and color

gsettings get org.gnome.desktop.background picture-uri
gsettings get org.gnome.desktop.background primary-color

6. Set new picture or color

gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/hello.jpg'
gsettings set org.gnome.desktop.background primary-color '#3465a4'

Over!