background preloader

Bash Hackers Wiki Front page [Bash Hackers Wiki]

Bash Hackers Wiki Front page [Bash Hackers Wiki]
Related:  LinuxBash & Terminal

Cheat Sheet: Crontab by Example Today's article may be pretty basic for regular readers but hopefully some may find it useful. This article will cover creating a crontab entry and show some examples of common crontabs. The Cron daemon is a service that runs on all main distributions of Unix and Linux and specifically designed to execute commands at a given time. These jobs commonly refereed to as cronjobs are one of the essential tools in a Systems Administrators tool box. Creating crontabs is something every level of Unix/Linux Sysadmin should know like the back of their hand. Creating a New Crontab Before I start showing examples of crontabs I want to cover how to create a crontab from scratch. A crontab file is essentially a regular file located within /var/spool/cron/crontabs/. # ls -la /var/spool/cron/crontabs/ total 12 drwx-wx--T 2 root crontab 4096 Aug 12 15:30 . drwxr-xr-x 5 root root 4096 Jul 15 19:30 .. Example (As the user): username@workstation:~$ crontab -e Example (As root user): Crontab Syntax Asterisk Example:

20 amusing Linux commands to have fun with the terminal The linux terminal is not always dull and boring. There are commands to make it do some funny acts to entertain the user. Here is a small collection of such commands. 1. Cowsay Install cowsay with apt. $ sudo apt-get install cowsay Cowsay is a talking cow that will speak out anything you want it to. $ cowsay "Hi, How are you" _________________ < Hi, How are you > ----------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || Don't like cows ? $ cowsay -l Cow files in /usr/share/cowsay/cows: apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey turtle tux unipony unipony-smaller vader vader-koala www Dragons, elephants, koalas and lot others. 2. 3. sl - Steam Locomotive 6. banner 10.

Examples of small bash programs Back to Main Page Here is a set of small scripts, which demonstrate some features of bash programming. //=================================================================================== // set new prompt //=================================================================================== PS1=">" PS1="[${LOGNAME}@$(hostname)] # " PS1="[${LOGNAME}] # " PS1='$PWD $ ' //=================================================================================== // set (and automatically create) shell variable //=================================================================================== $ test="test" $ homedir='pwd' string="The man said \" hello \"." //=================================================================================== // To use the variable within the shell, it is preceded by a $ //=================================================================================== homedir=$HOME cd $homedir #--------------------------------------------------- # print current shell name ???

Redirection [Bash Hackers Wiki] - Iceweasel - Article pages now have a discussion option at the bottom (moderated/captcha, but no registration needed) Fix me: To be continued Redirection makes it possible to control where the output of a command goes to, and where the input of a command comes from. It's a mighty tool that, together with pipelines, makes the shell powerful. Under normal circumstances, there are 3 files open, accessible by the file descriptors 0, 1 and 2, all connected to your terminal: The terms "monitor" and "keyboard" refer to the same device, the terminal here. Both, stdout and stderr are output file descriptors. Whenever you name such a filedescriptor, i.e. you want to redirect this descriptor, you just use the number: # this executes the cat-command and redirects its error messages (stderr) to the bit bucket cat some_file.txt 2>/dev/null Whenever you reference a descriptor, to point to its current target file, then you use a "&" followed by a the descriptor number: Valid redirection targets and sources Here strings

The H: Open Source, Security and Development How to Learn bash shell and scripting – The best tutorials for bash beginners Bash (Bourne-Again SHell) is a Linux and Unix-like system shell or command language interpreter. It is a default shell on many operating systems including Linux and Apple OS X. If you have always used a graphic user interface like KDE or Gnome or MS-Windows or Apple OS X, you are likely to find bash shell confusing. Here are a list of tutorials and helpful resources to help you learn bash scripting and bash shell itself. 1. 2. 3. 4. 5. 6. 7. 8. bash -- Standard Shell : A thorough understanding of bash programming for Gentoo developers by Gentoo project. 10. 11. 12. 13. 14. 15. Have a favorite online bash tutorial or new books?

Find & Scan Wireless Networks from the Command Line in Mac OS X A long hidden airport command line utility buried deep in Mac OS X can be used to scan for and find available wireless networks. This powerful tool is very helpful for network admins and systems administrators, but it’s handy for the average user to help discover nearby wi-fi routers as well. Accessing the Wi-Fi Utility in OS X Command Line To use this tool to find nearby wifi networks, the first thing you’ll want to do is create a symbolic link from the airport utility to /usr/sbin for easy access. The command for this varies per version of OS X in use, select which is relevant to your OS X version on the Mac in question. Launch the Terminal and type the following command: Making a symbolic link for airport tool in OS X El Capitan, Yosemite, and latersudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport Make a symbolc link for airport tool in OS X Mavericks, Mountain Lion, Snow Leopard airport -s

Awk - A Tutorial and Introduction - by Bruce Barnett Your browser does not have Javascript enabled. I use Javascript for analytics, and to show ads which pay for the maintenance Last modified: Thu Apr 23 16:37:47 EDT 2015 Part of the Unix tutorials And then there's My blog Table of Contents Copyright 1994,1995 Bruce Barnett and General Electric Company Copyright 2001, 2004, 2013, 2014 Bruce Barnett All rights reserved You are allowed to print copies of this tutorial for your personal use, and link to this page, but you are not allowed to make electronic copies, or redistribute this tutorial in any form without permission. Original version written in 1994 and published in the Sun Observer Awk is an extremely versatile programming language for working on files. The examples given below have the extensions of the executing script as part of the filename. Why learn AWK? In the past I have covered grep and sed. AWK - the (very old) original from AT&T NAWK - A newer, improved version from AT&T GAWK - The Free Software foundation's version Basic Structure

Scripting with style [Bash Hackers Wiki] - Iceweasel - Article pages now have a discussion option at the bottom (moderated/captcha, but no registration needed) continue These are some coding guidelines that helped me to read and understand my own code over the years. This is not a bible, of course. Some good code layout helps you to read your own code after a while. Indention guidelines Indention is nothing that technically influences a script, it's only for us humans. I'm used to use the indention of two space characters (though many may prefer 4 spaces, see below in the discussion section): it's easy and fast to type it's not a hard-tab that's displayed differently in different environments it's wide enough to give a visual break and small enough to not waste too much space on the line Speaking of hard-tabs: Avoid them if possible. Breaking up lines Whenever you need to break lines of long code, you should follow one of these two ways: Indention using command width: activate some_very_long_option \ some_other_option Indention using two spaces: #!

zenhabits Getting Started with Weave and Docker on Ubuntu • Weave - All you need to connect, observe and control your containers What You Will Build Weave provides a software network optimized for visualizing and communicating with applications distributed within Docker containers. Using tools and protocols that are familiar to you, Weave’s network topology lets you to communicate between containerized apps distributed across multiple networks or hosts more quickly and efficiently. With Weave you focus on developing your application, rather than your infrastructure. As demonstrated in this tutorial, Weave works seamlessly with other tools such as Vagrant. Specifically, in this example: You will create a simple application running in two containers on separate hosts. This tutorial uses simple UNIX tools, and it doesn’t require any programming skills. This example will take about 15 minutes to complete. What you will use What You Need to Complete This Guide Install and configure the following separately before proceeding: Let’s Go! The code for this example is available on github. cd guides/ubuntu-simple vagrant up Summary