Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
In order to enable bash completion in Kubernetes you can usee the below command in linux bash:

source <(kubectl completion bash)


Now to test this enter the below command and you should see the completion:

kubectl cl<TAB>


It should be expanded to kubectl cluster-info.


#linux #bash #shell #kubernetes #kubectl
How tom remove dangling volumes in docker?

docker volume rm $(docker volume ls -qf dangling=true)


#docker #linux #dangling
In Dockerfile`s some people in the community use `alpine base image in order to reduce docker image size. apk is its package management tool that can be used to install OS packages. So for example if
you want to install network tools (like ping) you need to install netcat-openbsd:

apk add netcat-openbsd


You can squash your image size even further by some tips. When you install a package, linux distros first download the package and put it in a cache folder. In Alpine it is located in /var/cache/apk.
To tell the OS to delete the cache after installation you can provide --no-cache option to it:

apk add --no-cache netcat-openbsd


There are some package like g++ or git that is needed on installation of some other packages. After installation those packages is useless and just increase image size. You can remove those packages b
y using --virtual command:

apk add --no-cache --virtual .build-deps g++ \
&& # do you stuff here \
&& apk del .build-deps


Great job guys! You have reduced your alpine docker images so much :)

#docker #linux #alpine #apk #virtual #no_cache #apk_del #apk_add
pdsh: a high performance, parallel remote shell utility. Pdsh is a multithreaded remote shell client which executes commands on multiple remote hosts in parallel. Pdsh can use several different remote shell services, including standard "rsh", Kerberos IV, and ssh.

To see more about it head over to:
- https://github.com/grondo/pdsh

#linux #shell #pdsh #shell
How to recursively rename filenames?

find . -name '*txt' -exec bash -c ' mv $0 ${0/brand-/category-}' {} \;


The above command renames txt files starting with brand- to category-.

#linux #bash #find #rename #batch_rename
How to copy a file in the same path with a different name?

Well you just need to use curly braces, {}, to make it happen:

What you usually MIGHT do:

cp /usr/local/share/lib/sample.conf /usr/local/share/lib/settings.conf



You can take the smart path btw:

cp /usr/local/share/lib/{sample,settings}.conf


NOTE: if suffix of both files are different you can put that inside of curly braces too.

#linux #sysadmin #cp #copy #trick