Posts match “ Linux ” tag:

把Ubuntu的使用者目錄改回英文的script

每次安裝完新的Ubuntu都有一個很惱人的問題。那就是使用者的目錄是中文的。command line用習慣的人,都知道打命令的時候輸入中文是一件很討厭的事情。所以,弄了下面這個script來將目錄名稱換回英文的。

#!/bin/sh

# This shell script utilizes xdg-user-dir and xdg-user-dirs-update to 

# change all user dirs back to original name in English.

USER_FOLDERS="DESKTOP DOWNLOAD TEMPLATES PUBLICSHARE DOCUMENTS MUSIC PICTURES VIDEOS"
USER_HOME=`xdg-user-dir`
for USER_FOLDER in $USER_FOLDERS; do
    FOLDER_ABSNAME=`xdg-user-dir $USER_FOLDER`
    FOLDER_DIRNAME=`dirname $FOLDER_ABSNAME`
    FOLDER_BASENAME=`basename $FOLDER_ABSNAME`
    FOLDER_TARGET="$FOLDER_DIRNAME/$USER_FOLDER"
    if [ "$FOLDER_ABSNAME" = "$USER_HOME" ]; then
        # Ignore invalid folder.

        echo WARNING: $USER_FOLDER is invalid.
        continue
    fi
    if [ "$FOLDER_TARGET" = "$FOLDER_ABSNAME" ]; then
        # Ignore the folder which has been matched to target name.

        continue
    fi
    # Uncomment following lines for debugging purpose.

    #echo $USER_FOLDER $FOLDER_ABSNAME "(" $FOLDER_DIRNAME "," $FOLDER_BASENAME ")"

    # Update user dir.

    xdg-user-dirs-update --force --set $USER_FOLDER "$FOLDER_DIRNAME/$USER_FOLDER"
    # Move corresponding folder to new place.

    mv "$FOLDER_ABSNAME" "$FOLDER_DIRNAME/$USER_FOLDER"
done

建立一個支援X11的Docker

下面這個Dockerfile可以建立一個具備ssh server及X11 server的docker容器。可以在裡面執行一般的X11的程式並且透過X11 client看到畫面。

FROM centos:centos7
MAINTAINER Gary Lee <garywlee@gmail.com>

# Install ssh server.
RUN yum install -y which openssh-clients openssh-server
RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN sed -i '/pam_loginuid.so/c session    optional     pam_loginuid.so'  /etc/pam.d/sshd

# Set root's password
RUN echo "centos" | chpasswd

# Add user
RUN useradd user1 -p iamuser1

# Install system tools and libraries.
RUN yum -y install glibc.i686
RUN yum -y install libstdc++.so.6
RUN yum -y install net-tools
# Install X Window System
# yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
RUN yum -y groupinstall "X Window System" "Fonts"

# Install other tools.
RUN yum -y install xterm
RUN yum -y install gedit
RUN yum -y install gvim
RUN yum -y install okular

RUN yum -y install vim

# Expose settings.
EXPOSE 22

ENTRYPOINT ["/usr/sbin/sshd", "-D"]