Skip to content
SaeHie Park edited this page Jun 20, 2023 · 104 revisions

256 color

add this to top of .profile file.

export TERM="xterm-256color"
  • to make tmux color working

check

$ tput colors
256

Network address

/etc/network/interfaces

example

auto enp0s5
iface enp0s5 inet static
	address 1.2.3.4
	netmask 255.255.255.0
	network 1.2.3.0
	broadcast 1.2.3.255
	gateway 1.2.3.1
	dns-nameservers 164.124.101.2 8.8.8.8

Initial programs

sudo apt-get update
sudo apt-get install ssh vim samba git build-essential 
sudo apt-get install cmake pkg-config autoconf libtool
sudo apt-get install xutils-dev ifconfig
sudo apt-get install tree htop tmux

SSH KEY Init

ssh-keygen -t rsa

Add client id_rsa.pub content to server ~/.ssh/authorized_keys

And fix file attribbute

chmod 600 ~/.ssh/authorized_keys

Time zone

sudo timedatectl set-timezone Asia/Seoul

Check

timedatectl

New storage disk

# partition
sudo fdisk /dev/sdb
# in fdisk
n: new partition
p: primary
1: partition 1
# and then First sector 2048, Last sector some number
w: write table to disk and exit

# format
sudo mkfs.ext4 /dev/sdb1

# /etc/fstab for mount
/dev/sdb1 /home/maxwell/u ext4 defaults 0 2

# mount all
sudo mount -a

show disks

lsblk -o +UUID,MODEL,MOUNTPOINT,SIZE

Swap on Ubuntu 18.04

# make 8G swap
sudo dd if=/dev/zero of=/var/swapfile bs=2048 count=4194304
sudo chmod 600 /var/swapfile

sudo swapoff -a
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
grep SwapTotal /proc/meminfo

Edit /etc/fstab to reflect above changes

Swap on Ubuntu 22.04

swapfile in roots is managed by system daemon

sudo systemctl status swapfile.swap

to disable

sudo systemctl mask swapfile.swap

to enable

sudo systemctl unmask swapfile.swap

current

$ sudo systemctl status swapfile.swap
○ swapfile.swap
     Loaded: masked (Reason: Unit swapfile.swap is masked.)
     Active: inactive (dead)

force fsck on reboot

sudo touch /forcefsck

and reboot

Samba

sudo smbpasswd -a maxwell
# don't copy above line. "-" is not what you are looking at.
sudo vi /etc/samba/smb.conf

For smb only accounts

# add dummy account
sudo adduser --no-create-home --disabled-password --disabled-login smbusername
# add smb account 
sudo smbpasswd -a smbusername

fix to preserve file attributes

add to global

[global]

nt acl support = no

add to share folder

[...]

map archive = no

fix execute file from windows

add to share folder

[...]

acl allow execute always = True

fix huge dir size in windows

add to global

[global]

allocation roundup size = 4096

from https://ubuntuforums.org/showthread.php?t=2268135

how to get block size ?

sudo dumpe2fs /dev/sda1 | grep -e 'Block size'

restart samba

sudo systemctl restart smbd

problem with Windows connect

(1) update global item with

usershare allow guests = no

(2) connect with \\WORKGROUP\user

NFS

reference

nfs server

install package

sudo apt-get install nfs-kernel-server

/etc/exports file setting

/home/maxwell/usbdisk      192.168.1.0/255.255.255.0(rw,sync,no_subtree_check,no_root_squash)

where set 192.168.1.0 to your client IP sub net

If you want to make the client write as UID/GUID(1000/1000) of the NFS server which has different UID/GUID in the client

/home/maxwell/usbdisk 192.168.1.0/255.255.255.0(anonuid=1000,anongid=1000,rw,sync,no_subtree_check,no_root_squash,all_squash)

Add anonuid=1000,anongid=1000,all_squash

service check, start if not running

sudo service nfs-kernel-server status
sudo service nfs-kernel-server start

reload configuration

sudo exportfs -r

check status

rpcinfo -p

nfs client

package

sudo apt-get install nfs-common

mount

sudo mount 192.168.1.10:/home/maxwell/usbdisk /home/maxwell/usbdisk

where change 192.168.1.10 to your NFS server IP

NTP time sync

install package

sudo apt-get install ntpdate

sync time

sudo ntpdate ntp.ubuntu.com

Boot X, Non-X ubuntu 16.04

Text

sudo systemctl set-default multi-user.target

X dm

sudo systemctl set-default graphical.target

Get

sudo systemctl get-default

Reinstall

sudo apt-get install --reinstall ubuntu-desktop

Web server

https://www.stewright.me/2012/09/tutorial-install-apache-php-and-mysql-on-raspberry-pi/

sudo apt-get install apache2 apache2-doc apache2-utils
sudo apt-get install libapache2-mod-php php php-pear
sudo apt-get install php-mysql
sudo apt-get install mysql-server mysql-client

for Raspbian

sudo apt-get install apache2 apache2-doc apache2-utils
sudo apt-get install php php-pear
sudo apt-get install php7-mysql libapache2-mod-php7 php7-xcache
sudo apt-get install mysql-server mysql-client

Bigger font size for mobile view of directory listing

  1. Add mobile.conf at conf-available folder with
    IndexHeadInsert "<meta name='viewport' content='width=device-width, initial-scale=1'>"
    
  2. Make an alias of this file in conf-enabled folder
  3. restart apache2

Change logon welcome message

cd /etc/update-motd.d/

Edit whatever the files inside

Adding new user

sudo adduser newuser

Development tools

sudo apt-get install cmake ninja-build
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
sudo apt-get install libxml2-dev libxml2-utils python2.7-dev
sudo apt-get install swig libunwind8-dev liblttng-ust-dev uuid-dev
# clang
sudo apt-get install clang-3.9 liblldb-3.9-dev
# sudo apt-get install clang-3.8 lldb-3.8-dev

# for arm
sudo apt-get install binutils-arm-linux-gnueabihf
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
# for armel
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
sudo apt-get install binutils-arm-linux-gnueabi

Python 2.x, 3.x use both

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 20

# choose
sudo update-alternatives --config python

Sites

When something goes wrong with package install

sudo dpkg --configure -a
sudo dpkg -P --force-depends [package] [package] ...
sudo apt clean
sudo apt -f install
sudo apt install [package] [package] ...

Drivers

nvidia

Check this: nvidia page

annoying things

Storage is keep doing things...

sudo chmod -x /etc/cron.daily/mlocate

disable auto update

sudo apt-get remove unattended-upgrades

sudo touch /etc/cloud/cloud-init.disabled

To disable ALT or Window key to show search menu

  • http://askubuntu.com/questions/122209/how-do-i-modify-or-disable-the-huds-use-of-the-alt-key
    • Settings > Keyboard > Shortcuts > "Key to show the HUD" >> "BACKSPACE" to disable it
    • Search "compizconfig-settings-manager" in software center
      • Ubuntu Unity Plugin > "Key to show the menu bar while pressed" >> disable it
      • And in Launcher tab, "Key to show the Dash, Launcher and Help Overlay" >> disable it
      • To disable, click on the button and uncheck "Enabled" checkbox
    • Reboot

DNS settings

  • edit /etc/resolvconf/resolv.conf.d/head file
  • update resolve file
sudo resolvconf --enable-updates
sudo resolvconf -u
  • check
nslookup
> server

updatedb.mlocate

Running in my Linux... and makes my HDD busy...

  • updatedb - update a database for mlocate
  • locate - find files by name

CUPS printer server

Refer http://blog.pi3g.com/2013/08/using-the-raspberry-pi-as-cups-print-server-for-windows-and-apple-mac-airprint/

Remove old kernel packages

dpkg --list | grep linux-image
sudo apt-get --purge remove linux-image-4.4.0-2*
...
sudo apt-get --purge remove linux-image-extra-4.4.0-2*
...
sudo update-grub2
sudo systemctl reboot

Remove programs eating up memory

sudo apt-get remove gnome-software
sudo apt-get purge gnome-software

# can remove in 16.04
sudo apt-get remove evolution-data-server
# desktop logged on but no app running and ssh connected
$ free
              total        used        free      shared  buff/cache   available
Mem:        4037772      361320     3157348       11612      519104     3404660
Swap:       4192252           0     4192252

For Raspberry Pi 2 running Ubuntu 16.04

sudo apt-get remove snapd

coredump in some other folder

echo '/home/maxwell/u/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern

Reference

Server in text mode

To change text console size... open /etc/default/grub and

GRUB_CMDLINE_LINUX_DEFAULT="text"  
GRUB_CMDLINE_LINUX="text"  

and then run update-grub and reboot

sudo update-grub
sudo reboot

gdb segment fault in Ubuntu 16.04 ARM

(gdb) r
Starting program: /home/.../hello 

Program received signal SIGSEGV, Segmentation fault.
0x76fd9822 in ?? () from /lib/ld-linux-armhf.so.3

Need to install libc debug files

sudo apt-get install libc6-dbg

JDK

First, download the JDK

Then, Install

sudo mkdir -p /usr/lib/jvm
cd /usr/lib/jvm
sudo tar xvf ~/Download/jdk-8u144-linux-x64.tar.gz 

sudo ln -s jdk1.8.0_131 jdk
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk/bin/javac" 1
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk/bin/java" 1

Add to envioronment

export JAVA_HOME=/usr/lib/jvm/jdk

Proxy

environment

vi ~/.profile
export HTTP_PROXY=http://127.0.0.1:8080/
export HTTPS_PROXY=http://127.0.0.1:8080/

why HTTPS_PROXY=http:// ?

apt

vi /etc/apt/apt.conf.d/90proxy
Acquire::http::proxy "http://127.0.0.1:8080/";
Acquire::https::proxy "http://127.0.0.1:8080/";
Acquire::ftp::proxy "ftp://127.0.0.1:8080/";

wget

vi ~/.wgetrc
use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080

ref: https://stackoverflow.com/questions/11211705/setting-proxy-in-wget

git

git config --global https.proxy http://127.0.0.1:8080/
git config --global http.proxy http://127.0.0.1:8080/

Tweaking

Caps lock to Ctrl

sudo apt install gnome-tweak-tool
Gnome Tweaks -> Keyboard & Mouse -> Additional Layout Options -> Caps Lock key behavior.

Disable USB automounting

https://help.ubuntu.com/community/Mount/USB

1 Run

dconf-editor

2 Open

  • org - gnome - desktop - media-handling

3 Turn off/on switch

Corporate certificate

  • Go to /usr/local/share/ca-certificates/
  • Copy the .crt file
  • Permissions 644
  • sudo update-ca-certificates
Clone this wiki locally