Category: Bash / Terminal / Scripts

22.05.2017

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 […]

22.05.2017

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

22.05.2017

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 >  ————- \                             .       .  \                           / `.   .‘ “   […]

21.05.2017

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/partitions_overview.sh; # create new script #!/bin/bash PARTITIONS=/dev/sd* for f in $PARTITIONS do   echo "_______________________________________________________________________________"   blkid $f   hdparm -I $f | grep […]

19.05.2017

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 […]

19.05.2017

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 […]

19.05.2017

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 […]

19.05.2017

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 […]

16.05.2017

messing with text files test content # test if /path/file contains SEARCH_PATTERN if grep -q SEARCH_PATTERN „/path/file“; then cat /path/file; # do something fi paste basically line-wise combines two files into one. (first line of two files will end up […]

16.05.2017

Mac OS X Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages: brew install proctools # to install pgrep, pkill, etc. brew install pstree # to be able to use pstree brew install […]

16.05.2017

CentOS7 yum install psmisc # install pstree [root@centos user]# pstree systemd─┬─NetworkManager─┬─dhclient         │                └─2*[{NetworkManager}]         ├─agetty         ├─auditd───{auditd}         ├─chronyd   […]

14.05.2017

ps -eo size,pid,user,command –sort -size | awk ‚{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }’| head -10    1243.09 Mb /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib/mysql/plugin –user=mysql […]

05.05.2017

fallocate -l 1G 1GBybe.testfile; # with fallocate dd if=/dev/urandom of=1GBybe.testfile bs=64M count=16 iflag=fullblock; # generate 1GByte test file that contains random data https://www.cyberciti.biz/faq/howto-create-lage-files-with-dd-command/ https://superuser.com/questions/470949/how-do-i-create-a-1gb-random-file-in-linux

03.05.2017

tested and works accross the following systems: uname -a Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) i686 GNU/Linux uname -a Linux centos 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux uname -a Linux suse […]

03.05.2017

setterm -blength 0; # turns off nerve wrecking "BELL" echo ’setterm -blength 0; # turns off nerve wrecking "BELL"‘ >> /etc/bash.bashrc; # make the changes permanent/survive boot and for all users this does not work for X11 terminals such as […]

26.04.2017

based on preparation of: dwaves.de/2017/04/26/linux-bash-searching-and-colorful-highlighting-of-text-patterns-in-files-with-grep-regular-expressions/ wc -w; # basically starting wc in "interactive" mode, quit with Ctrg+Z joe is very hungry today 5 wc -w < termine; # word count, count the words in that file 10 cat artikel.txt termine […]