This requires inotify to be installed
while true; do inotifywait -r -e MODYFY dir/home/user/test runme.sh; done;
This requires inotify to be installed
while true; do inotifywait -r -e MODYFY dir/home/user/test runme.sh; done;
Create a tar archive
tar -cf archive.tar file1 file2 ... fileN
Create tar archive from a directory
tar -cf archive.tar /path/to/directory/
Create a tar gzipp’d archive
tar -zcf archive.tar.gz file1 file2 ... fileN
Create a tar gzipp’d archive from a directory
tar -zcf archive.tar /path/to/directory/
Create multi-part tar archives from a directory
tar cf - /path/to/directory|split -b<max_size_of_part>M - archive.tar
Extract all files from a tar archive
tar -xf archive.tar
Extract all files from a tar gzipped archive
tar -zxf archive.tar.gz
Extract all files from a tar gzipped archive into a directory
tar -xzf archiv.tar.gz -C /path/to/directory/
Extract a single file from a tar archive
tar -xf archive.tar the_one_file
Sometimes we have to adjust the locales of Debian, e.g. when apt issues error messages. This can be done quickly.
localectl set-locale LANG=en_US.UTF-8
That’s it.
How much disk space takes a file or directory up?du -s -h /your/file
du -s -h /your/directory/
Get the 10 biggest files/folders for the current direcotrydu -sh * | sort -rh | head
Show free disk spacedf -h
List only directoriesls -d */
currently mounted filesystems in nice layoutmount | column -t
Mount folder/filesystem through SSHsshfs name@server:/path/to/folder /path/to/mount/point
Mount iso imagemount /path/to/file.iso /mnt/cdrom -o loop
Search your history
ctrl + r
Write something in a file
printf 'This is a test\n' > test.txt
Do this 10 times
printf 'This is a test\n' > test{1..10}.txt
quickly rename a file
mv filename.{old,new}
You can use loops in bash
for i in *.txt
do
convert $i $i.jpg
done
But maybe you want to use braces {}
Create 10 text files
touch test_{1..10}.txt
Create 3 text files
touch test_{1,3,10}.txt
$( ) gives the output of a command to previous command
touch file-$(date -I).txt
Remove all .txt files in a directory
rm $(ls *.txt)
Delete all files in a folder that don’t match a certain file extension
rm !(.foo|.bar|*.baz)
$( ) can be nested very easily
program1 $(program2 $(program3))
this command lists all containers with it’s numeric IDs:
docker ps -a -q
We add some command line magic, to stop them all:
docker stop $(docker ps -a -q)
After we’ve stopped all the containers, we can delete them. Docker only deletes stopped containers:
docker rm $(docker ps -a -q)
docker image rm $(docker images -a -q)