Category: Bash / Terminal / Scripts


in a script you can specify to save output to a file with current date/time like: LOGFILE=/path/to/logfiles/$(date ‚+%Y-%m-%d‘)_task.log echo „this script was run“ >> $LOGFILE; to cleanup regularly is important in order to ensure the harddisk does not fill up. […]

Windows Batch CMD scripts – why endless loop?

sometimes the scripts that used to work perfectly well – suddenly start to miss behave – but you HAVE NOT altered them! look closely to the directory they reside in… maybe something in the dir has changed! make sure: your […]

linux bash bc – calculating with pi

bc is cool, but it can not access shell variables directly, but you can pass them with <<< also there is no „pi“ constant in bc that you could use in interactive mode. let one assume you would like to […]


display ip and ip only of the host computer the script is running on. ifconfig eth0|grep inet| awk ‚{print $2}‘ | cut -d: -f2 root@debian9:~# IP=$(ifconfig eth0|grep inet| awk ‚{print $2}‘ | cut -d: -f2); echo $IP;


there are some special automatically set environment variabels that might be interesting to know… echo $$; # PID of currently running shell echo $?; # return error code of last run program (before echo) echo $0; # return /path/and/way the […]


vi; # create a new file with those lines #!/bin/bash COUNT=10 while (( COUNT > 0 )) do      echo -e „$COUNT \c“     sleep 1;     (( COUNT — )) done echo -e „\n\nWe have lift off!!“ ESC […]


 stat /etc/hosts   File: ‘/etc/hosts’   Size: 249             Blocks: 8          IO Block: 4096   regular file Device: 801h/2049d      Inode: 5506941     Links: 1 Access: (0644/-rw-r–r–)  Uid: (    0/    root)   Gid: (    0/    root) Access: 2017-06-06 15:37:06.896148382 +0200 Modify: 2017-06-06 15:37:04.728130437 +0200 Change: […]

apt cheat sheed

About: apt is a mainly-online-repository-based („AppStore“) software installation – package management system used by Debian and Ubuntu. But – you can also manually download a package.deb and install it with dpkg -i package.deb. What might be confusing – it consists […]


one practical usage example of xargs: … to process every file that find found further # this would backup/pack all jpg files on your system into all.jpg.tar.gz find / -name „*.jpg“ | xargs tar -czvf all.jpg.tar.gz # delete all jpg […]


what is umask? umask defines what what access rights newly created files „are born“. we are all supposed to be created equal – but depending if you are a son of Rothchild, Rockefeller or born in Namibia – your previleges […]


What is yum? yum is used under CentOS7, Fedora, RedHat RHEL, Oracle). It’s written in python and it stands for “Yellowdog Updater, Modified”, as it was originally called “yup”, the package manager for Yellow Dog Linux. In addition to rpm […]


Table 4-1. Regular expression operators Operator Effect . Matches any single character. ? The preceding item is optional and will be matched, at most, once. * The preceding item will be matched zero or more times. + The preceding item […]


vim; # create new script file #!/bin/bash while true; do echo -n "+."; done; save and quit chmod u+x; # mark it runnable nohup & # run in background htop # streeeeeeessss! it is also a harddisk-stress […]


cool apt-get install fortune cowsay; # will have to be installed first then you can let your dinosaur speak 😀  /usr/games/cowsay -f stegosaurus „Hello World“  _____________ < Hello World >  ————- \                             .       .  \                           / `.   .‘ “   […]


uname -a; # tested with Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2 (2017-04-30) i686 GNU/Linux vim /scripts/; # create new script #!/bin/bash PARTITIONS=/dev/sd* for f in $PARTITIONS do   echo "_______________________________________________________________________________"   blkid $f   hdparm -I $f | grep […]


these commands are equally valid, both commands add „content“ to the end of file – if file does not exists it will be created. ls -l . /ect > listing.txt #send the output from ls -l to a file called […]


yeah i know i sometimes make fun of distributions that have like a partition for every /root/folder but well yes it has it’s reasons. suse12 uname -a; # tested with Linux suse 4.4.21-69-default #1 SMP Tue Oct 25 10:58:20 UTC […]


there are plenty 😀 debian8.8 uname -a; # tested with Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2 (2017-04-30) i686 GNU/Linux find / -type d -iname bin /bin /usr/local/bin /usr/bin /usr/share/doc/libintl-perl/examples/simplecal/bin /usr/lib/klibc/bin suse12 uname -a; # tested with Linux suse 4.4.21-69-default […]


rpm is a powerful Package Manager for Red Hat, Suse and Fedora Linux. It can be used to build, install, query, verify, update, and remove/erase individual software packages. A Package consists of an archive of files, and package information, including […]