#!/bin/bash# Stop all containersdocker stop $(docker ps -a -q)# Delete all containersdocker rm $(docker ps -a -q)# Delete all imagesdocker rmi $(docker images -q) First of all we need to get a list of all containers. We can get it by the command: docker ps -a -q — all and quiet. Now we need toContinue Reading
Category: Tips&Tricks
How to change permissions for file / directory recursively in Linux
Change owner for directory recursively: sudo chown -R user:group /path/to/directory Chown is a short for “change owner”, -R – means “recursively”, owner and group definition are separated by “:”. Also we need high privileges to run chown command – so we use “sudo”. Change permissions only for directories recursively: find /path/to/directory -type d -exec chmod 755 {}Continue Reading
How to install non-free video / audio codecs in Ubuntu
You can install codecs during Ubuntu installation or by using the following command: sudo apt-get install ubuntu-restricted-extras If you want to watch movies and listen music as you accustomed – you need some additional software. Basicly all movie files or audio files encoded by some algorithm. Some of them are open and free, but manyContinue Reading
Python 3 performance profiling – easiest way
Just add cProfile module to the running command: python3 -m cProfile test.py For example: $ python3 -m cProfile test.py 14 function calls in 0.000 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 test.py:1() 10 0.000 0.000 0.000 0.000 test.py:1(func) 1 0.000 0.000 0.000 0.000 test.py:4() 1 0.000 0.000 0.000Continue Reading
How to configure Qemu-KVM
At times, it is useful to have a deployed infrastructure of N machines to see how networking works, how the cluster shards on nodes, etc. From time to time I remember how I did it last time. But this time I decided to just write this simple set of commands, so as not to remember,Continue Reading
What’s new in Python 3.8: the Walrus Operator
The new operator will be available in the new version of Python. It’s called “walrus operator” because it’s like someone cosplayed a walrus: “:=”. This is similar to the normal ” =” assignment, but returns the value of the statement. So this is a C-like assignment. For eaxmple, we can use it for a one-lineContinue Reading
How to run a program as daemon without any output
Each program has a set of file descriptors. It’s like an open stream from / to file. On start program has 3 descriptors: standard input (stdin), standard output (stdout) and standard error (stderr). They has numbers: from 0 to 2. Standard input is used for reading input data from the user (from the terminal). StandardContinue Reading
How to get top 10 largest files
As we already saw, we can easily get to 10 largest directories (see “How to get top 10 largest directories in the current directory“). But there we used du utility – it shows directory size (or “estimate file space usage”). What utility shows file size? Oh… It’s just the ls! Looks easy? But we needContinue Reading
How to make an immutable file
As we already know, files have access right matrix (read more in this article: “File and directory permissions in Linux / FreeBSD / MasOS“). But that’s not all. There are more mechanisms for accessing files. For example, we can change file’s attributes. One of them is immutability attribute. Users with high capabilities can set /Continue Reading
How to get top 10 largest directories in the current directory
Sometimes it’s not obvious, which directory is too big. To find the biggest directories in you computer, you may use graphic user interface and some of supported file managers. But what will you do when you don’t have a GUI? And it’s not mythical situation. On the desktop you almost always know the biggest directoryContinue Reading