All articles



Crontab commands

Edit user’s crontab

crontab -e

List user’s crontab

crontab -l

Delete user’s crontab

crontab -r

Crontab examples

On every minute

* * * * * /scripts/

On every 5 minutes

*/5 * * * * /scripts/

At midnight on first day of every month

0 0 1 * * /scripts/

On every 30 seconds

* * * * * /scripts/
* * * * * sleep 30; /scripts/

At night on last day of every month

0 3 28-31 * * test $(date -d tomorrow +%d) -eq 1 && /scripts/

Configuring Ubuntu server


Upgrade the system

apt update
apt upgrade

Show the current timezone ~~~timedatectl~~~

Change it to UTC

timedatectl set-timezone UTC

Change root password


Delete user ubuntu created by who knows

deluser --remove-home ubuntu

Add a new regular user

adduser yournickname

Add it to the sudo group.

usermod -aG sudo yournickname

Switch to that user

su yournickname

Install your favourite text editor

sudo apt install emacs-nox

Install htop

sudo apt install htop

Create a ssh key (with a passphrase) for pushing stuff to github

ssh-keygen -t rsa -b 4096 -C "user@host"

Add the public key to the SSH keys in github/bitbucket account settings.

Sending files by SCP (secure copy)


Send the whole current directory to a remote server

scp -r * username@hostname_or_ip:/home/username/directory/

Download a directory to the current directory

scp -r username@hostname_or_ip:/home/username/directory/ .


grep -rw “lol” *.rb

Find “lol” in ruby files in the current directory.

  • -r - recursive
  • -w - whole words

Finding files


List every files and directories (with relative paths) in the current directory and all its subdirectories.

find .

Or just


Same but just files.

find -type f

Just directiories.

find -type d

Search in the home directory (and all its subdirectories).

find ~

In the /mnt and /media directories.

find /mnt /media

Find something named “config”.

find -name "config"

Find all ruby files in the home directory.

find ~ -type f -name "*.rb"

Find all ruby files in the home directory, but not if they have letter “a” or “e” in their names.

find ~ -type f -name "*.rb" -not -name "*a*" -not -name "*e*"


find ~ -type f -name "*.rb" ! -name "*a*" ! -name "*e*"

Using 7z


Split a file to 500 MB parts with no compression.

7z a -v500m -mx0 movie.7z movie.mp4



Creating an archive from a directory.

tar -czvf archive.tar.gz directory/

Or just

tar czf archive.tar.gz directory


tar -xzvf archive.tar.gz

Or even without the file format option.

tar xf archive.tar.gz

To use bzip2 instead of gzip use j option instead of z. For bzip2 the file extension convention is “.bz2”.

List (test) the content of the archive.

tar tf archive.tar.gz