Linux
update-alternatives
Set default editor in Ubuntu To change vi editor run root@backup:~# update-alternatives –config vi There are 2 choices for the alternative vi (providing /usr/bin/vi). Selection Path Priority Status ———————————————————— * 0 /usr/bin/vim.basic 30 auto mode 1 /usr/bin/vim.basic 30 manual mode 2 /usr/bin/vim.tiny 10 manual mode Press to keep the current choice[*], or type selection number: … Read more
tmux
To attach to a specific session, run tmux a -t SESSION_ID CTRL+B % Split window vertically CTRL+B “ Split window horizontally CTRL+B c Create new window CTRL+B d Detach tmux session CTRL+B $ Rename session CTRL+B n Next window. CTRL+B p Previous window. CTRL+B arrow keys switch between panes. .tmux.conf .tmux.conf file is used to … Read more
apt doesn’t support architecture i386
After adding facebook hhvm repository on Ubuntu 16.04, i get following error when running “apt update” command. root@backup:~# apt-get update Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] Hit:4 http://ftp.osuosl.org/pub/mariadb/repo/10.1/ubuntu xenial InRelease Ign:5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 InRelease Get:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] Hit:7 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease Hit:8 … Read more
add-apt-repository
add-apt-repository command can be used to add repository in ubuntu. To install, run apt-get install software-properties-common python-software-properties Example apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94 add-apt-repository https://dl.hhvm.com/ubuntu
rsync
rsync command with exclude option, full server backup to a remote server. Transfer a file I normally use scp to do single file transfer. It may be better to it with rsync as you will be able to resume. -P == –partial –progress If you use non standard SSH port, then replace -e ssh with … Read more
smartctl
To check hard disk for errors, run /usr/sbin/smartctl -q errorsonly -H -l selftest -l error /dev/sda Here is an example of HDD with errors # smartctl -q errorsonly -H -l selftest -l error /dev/sda ATA Error Count: 8259 (device log contains only the most recent five errors) Error 8259 occurred at disk power-on lifetime: 8324 … Read more
gzip
Enable Gzip in Amazon Linux How to enable gzip on Plesk Nginx To check if a web site have gzip enabled, run curl -I -H ‘Accept-Encoding: gzip,deflate’ https://YOUR_DOMAIN.EXTN When you have no GZIP enabled, you will see error as follows boby@hon-pc-01:~$ curl -I -H ‘Accept-Encoding: gzip,deflate’ https://serverok.in curl: (7) Failed to connect to serverok.in port … Read more
systemctl
Service files To list all services run To list failed services List all enabled services List timers See all running services See see dependency for a package, run Service file location service files are located in /usr/lib/systemd/system Systemd unit types
Install shadowsocks on Ubuntu
Install ShadowSocks server on Debian 10install ShadowSocks client in Ubuntu 18.04 On the Server, install shadowsocks with Create config file for server Add Replace SERVER_IP and PASSWORD in above config. Start server with Example Shadowsocks client Shadowsocks have clients for different operating systems. Some are GUI. On Ubuntu, i install CLI version, that is part … Read more
Monitor redis with redis-cli
On Ununtu/Debian, install it with To get stats, run If your redis on differnt sevrer or use non standard port, then use Example INFO If you want to see info about clients, run Monitor To see what redis is doing, run If your redis is running on remote server, then use Get redis config details
Connect to redis from PHP
To connect to redis, first install php-redis apt install php-redis Now create a php file with following code root@ip-10-0-0-31:/var/www/html# cat 2.php