background preloader

Bash

Facebook Twitter

Mapreduce

Command line tricks for smart geeks. Everyone knows the answer to the question of life, the universe and everything is "42", but for the first time we can reveal the question. It is this: how many command-line tricks must a man memorise? You see, graphical user interfaces are all well and good, but when you want to get real work done it's time to switch to the terminal. And so, we squeezed our brain cells, dug through dusty piles of old issues of Linux Format, and sat reflecting quietly over many a pint of ale, all with the goal of bringing you this: 42 awesome new command line tricks we think you ought to commit to memory. We've tried to include a few that are easier for our, er, less-experienced readers to enjoy, but we think even the most hardened Linux veteran will learn something new over the next 12,000 words.

So, strap yourself in and get ready for command-line heaven: it's time to kick ass and chew bubble gum, and we're all out of gum... Make your own Bash wormholes cat /var/log/messages | less Remote control MPlayer . . Advanced Bash-Scripting Guide. 8 Useful and Interesting Bash Prompts. Many people don’t think of the command line prompt as a useful element, or even pay it much attention. However, a useful prompt can change the way you use the command line, and by extension, your system.

This article shows you a number of useful and interesting Bash prompts with examples. Note that we begin with the prompts themselves, then offer some further instructions on how to work with them. Here we offer a few Bash prompts, and not all will be serious. Also read: Basic Bash Commands for Linux Newbies 1. This prompt is amusing yet useful! In contrast, when a command fails, you’ll see a sad kaomoji. To apply this, use the following code: PS1="\`if [ \$?

This may look confusing, but we’re using if statements to determine whether the command is good or bad. Also read: How to Use Emacs As a USENET Reader With Gnus 2.Change the Bash Prompt’s Color When the Terminal Issues a Bad Command Arguably, this prompt is the most useful on the list. PROMPT_COMMAND='PS1="\[\033[0;33m\][\!]

3. 4. 5. 6. Micha's resty at master - GitHub. Get sed savvy - part 3. We will learn about the sed delete (d), read (r) and write (w) commands today to round out your sed toolbox. The major parts I am covering should help you through 99% of the cases where sed is your best option. Soon we’ll be looking at awk and other tools to continue the quest for command-line fluency. If you haven’t already, install Cygwin and check out part 1 and part 2. Tutorial One of the best ways to crank out code quickly is by using templates. Suppose we have a template HTML file that we want to reuse often. Now we want to replace ”%%CONTENT%%” with the contents of an HTML Fragment file.

The above script will append the contents of fragment.htmlf immediately after ”%%CONTENT%%”. This might seem slightly useless, but the power here is in the simplicity. OK, now for one more command: write (w). Now numbers.csv will contain all rows that the last cell containing numbers, and so on for letters.csv and symbols.csv. Other Examples Conclusion. Unix Toolbox. Hardware | Statistics | Users | Limits | Runlevels | root password | Compile kernel | Repair grub | Misc Running kernel and system information # uname -a # Get the kernel version (and BSD version) # lsb_release -a # Full release info of any LSB distribution # cat /etc/SuSE-release # Get SuSE version # cat /etc/debian_version # Get Debian version Use /etc/DISTR-release with DISTR= lsb (Ubuntu), redhat, gentoo, mandrake, sun (Solaris), and so on.

See also /etc/issue. # uptime # Show how long the system has been running + load # hostname # system's host name # hostname -i # Display the IP address of the host. Hardware Informations Kernel detected hardware # dmesg # Detected hardware and boot messages # lsdev # information about installed hardware # dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8 # Read BIOS Linux FreeBSD Load, statistics and messages The following commands are useful to find out what is going on on the system.

Users Limits Per shell/script Per user/process System wide. BASH/Bourne-Again Shell. Computerworld is undertaking a series of investigations into the most widely-used programming languages. Previously we spoke to Alfred v. Aho of AWK fame, and in this article we chat to Chet Ramey about his experience maintaining Bash. Bash, or the Bourne-Again Shell is a Unix shell created in 1987 by Brian Fox. According to Wikipedia, the name is a pun on an earlier Unix shell by Stephen Bourne (called the Bourne shell), which was distributed with Version 7 Unix in 1978.

In 1990, Chet Ramey, Manager of the Network Engineering and Security Group in Technology Infrastructure Services at Case Western Reserve University, became the primary maintainer of the language. Computerworld tracked down Ramey to find out more. How did you first become involved with Bash? In 1989 or so, I was doing network services and server support for [Case Western Reserve] University (CWRU), and was not satisfied with the shells I had available for that work.

Advanced Bash-Scripting Guide.