Archive for January 2020

Progress bar in command line

Copying files using rsync with progress bar apt-get install rsync; rsync -ah –progress /path/to/source /path/to/destination Run sql script to restore db with progress bar apt-get install pv; pv script.sql | mysql -h hostname -u username -p password database

How to use screen utility which is better than nohup

Step 1. As a result of running the command it takes you inside newly created session screen -S sessionname Step 2. Run your command and then press the combination below to exit the screen Ctrl+A then D (after releasing Ctrl + A) Step 3 screen -ls Output: There is a screen on: 3132.sessionname (01/27/2020 05:50:32 […]

How-to get size of some folder

du -sh /var du -sh mysql/* du -sh .

Docker if you need to edit file on stopped docker

I had a problem with a container which wouldn’t start due to a bad config change I made. I was able to copy the file out of the stopped container and edit it. something like: docker cp test-mysql:/etc/mysql/my.cnf . Edit it and copy back docker cp my.cnf test-mysql:/etc/mysql/my.cnf docker start mysql docker exec -ti mysql […]

Git reset local master to match remote master

git reset –hard origin/master

Build and run container from Dockerfile

Step 1 – Dockerfile FROM debian:jessie MAINTAINER user@server.com RUN apt-get update RUN apt-get install -y vim RUN apt-get install -y apache2 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server RUN apt-get install -y php5 RUN apt-get install php5-mysql RUN apt-get autoremove   ENV APACHE_RUN_USER www-data ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 ENV APACHE_PID_FILE /var/run/apache2.pid […]

How to mount and unmount remote directory

Mounting mkdir ~/remoteDir ssh-keygen -t rsa ssh-copy-id -i .ssh/id_rsa.pub user@hostname sudo apt install sshfs sshfs user@hostname:/ ~/remoteDir Unmounting fusermount -u ~/remoteDir

Apt sources.list to add or remove deb installation repositories

vi /etc/apt/sources.list