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

linux cpu stress test script
22.05.2017

Some people think it is ridiculous to measure the power consumption of computers. Imho it is important for servers but also if workstation uses 50 Watts idle or 10 can also make a difference when it is used a lot […]

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 [cc lang=”bash” escaped=”true” width=”600″] #!/bin/bash PARTITIONS=/dev/sd* for f in $PARTITIONS do echo “_______________________________________________________________________________” blkid $f hdparm -I $f | […]

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

gnu linux server and partitioning – stability and security
19.05.2017

yeah one knows sometimes making fun of distributions that have a partition for every /root/folder but well yes it has it’s reasons, like when a program accumulates to much data (mailbox full), the /root partition and the system will not […]

19.05.2017

there are plenty 😀 debian8.8 [cc lang=”bash” escaped=”true” width=”600″] 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 [/cc] suse12 [cc lang=”bash” escaped=”true” […]

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 [cc lang=”bash” escaped=”true” width=”600″] yum install psmisc # install pstree [root@centos user]# pstree systemd─┬─NetworkManager─┬─dhclient │ └─2*[{NetworkManager}] ├─agetty ├─auditd───{auditd} ├─chronyd ├─crond ├─dbus-daemon───{dbus-daemon} ├─firewalld───{firewalld} ├─irqbalance ├─lvmetad ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd───sshd───bash───su───bash───pstree │ └─sshd───sshd───sftp-server ├─systemd-journal ├─systemd-logind ├─systemd-udevd ├─tuned───4*[{tuned}] └─xinetd [/cc] debian8 [cc lang=”bash” escaped=”true” […]

05.05.2017

[cc lang=”bash” escaped=”true” width=”600″] 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 [/cc] 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

[cc lang=”bash” escaped=”true” width=”600″] 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 [/cc] this does not work […]

26.04.2017

[cc lang=”bash” escaped=”true” width=”600″] cut -d: -f1 /etc/passwd|sort|pr -2 |grep -v ‘^$’|tee userliste; # will output a nicely formatted list of all users to “userliste” but also print on screen (tee) 2017-04-26 17:09 Seite 1 at polkitd bin postfix daemon […]

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/ [cc lang=”bash” escaped=”true” width=”600″] 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 […]

26.04.2017

probably the most useless of all command combinations… but for whatever reason… like you don’t have an editor that can only write but not read files: it will just keep overwriting the file… [cc lang=”bash” escaped=”true” width=”600″] cat editor_for_poor.txt; # […]