background preloader

8 Useful and Interesting Bash Prompts

8 Useful and Interesting Bash Prompts
Many people don’t think of their command prompt as a particularly useful thing, or even pay it much attention. To me, this is a bit of a shame, as a useful prompt can change the way you use the command line. Well I’ve scoured the Interwebs looking for the best, most useful, or sometimes most amusing bash prompts. Here, in no particular order, are the ones I’d be most likely to use on my computers. Note – to use any of these prompts, you can copy & paste the “PS1=” line directly into your terminal. 1. This prompt is probably the most amusing one on the list, but remains useful. Example: Code: 2.Change color on bad command Here’s one of my favorites. 3. If you’re the type who wants to pack your prompt full of information, then here’s the one for you. 4. There’s nothing particularly fancy about this prompt, other than the good use of color to separate the different pieces of information. 5. This one’s a nice, clean, minimal 2-line prompt (plus a blank line at the top). Code: 6. 7. 8.

Malicious Linux Commands - From (This article was originally published in Ubuntu Forums but was removed there. Ubuntuguide feels that knowledge about these risks is more important than any misguided attempts to "protect the public" by hiding their potential dangers or protect the (K)Ubuntu/Linux image. The original article has therefore been re-created (and subsequently edited) here.) ATTENTION: It is worthwhile to have some basic awareness about malicious commands in Linux. It is also worthwhile to always enable a Kubuntu screensaver or Ubuntu screensaver with a password so that a casual passerby is not able to maliciously execute one of these commands from your keyboard while you are away from your computer. When in doubt as to the safety of a recommended procedure or command, it is best to verify the command's function from several sources, such as from readily available documentation on Linux commands (e.g. manpages). Here are some common examples of dangerous commands that should raise a red flag. rm -r In Perl

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 . .

How to Be Faster at the Linux Command Line | HACKTUX Want to be faster at the Linux command line interface? Since most Linux distributions provide Bash as the default CLI , here are some Bash tricks that will help cut down the amount of typing needed to execute commands. Feel free to comment and share your own speed tricks. Control-R Through Your History Use History Expansion Use History Quick Substitution Use Vi or Emacs Editing Mode Use Aliases and Functions This is my most used shortcut. For instance, type the following and hit . grep root /etc/passwd Then hit and begin to type 'grep'. (reverse-i-search)`gre': grep root /etc/passwd When you see the original command listed, hit to execute it. Bash's command history can be referenced using the exclamation mark. date If you are interested in more than just the last command executed, type to see a numbered listing of your Bash's history. history 39 grep root /etc/passwd 40 date 41 date 42 history Since is command number 39, you can re-execute it like so: ! export HISTSIZE=1000 history -c ^passwd^group

Android Tools Project Site micha's resty at master - GitHub Speaking UNIX: 10 great tools for any UNIX system Much like a vernacular, the universe of UNIX tools changes almost perpetually. New tools crop up frequently, while others are eternally modernized and adapted to suit emerging best practices. Certain tools are used commonly; others are used more infrequently. Some tools are perennial; occasionally, some are obsoleted outright. To speak UNIX fluently, you have to keep up with the "lingo." Table 1 lists 11 of the significant packages previously discussed in the Speaking UNIX series. Table 1. This month, let's look at 10 more utilities and applications that expand or improve on an existing or better-known UNIX package. In some cases, depending on your flavor of UNIX, you will have to install a new software package. Find a command with apropos UNIX has so many commands, it is easy to forget the name of a utility—especially if you do not use the tool frequently. $ apropos calculator bc (1) - An arbitrary precision calculator language dc (1) - An arbitrary precision calculator Back to top

Tutorial - Learn Python in 10 minutes | Stavros' Stuff NOTE: If you would like some Python development done, my company, Stochastic Technologies, is available for consulting. This tutorial is available as a short ebook. The e-book features extra content from follow-up posts on various Python best practices, all in a convenient, self-contained format. All future updates are free for people who purchase it. Preliminary fluff So, you want to learn the Python programming language but can't find a concise and yet full-featured tutorial. Properties Python is strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you don't have to declare variables), case sensitive (i.e. var and VAR are two different variables) and object-oriented (i.e. everything is an object). Getting help Help in Python is always available right in the interpreter. >>> help(5)Help on int object:(etc etc) >>> dir(5)['__abs__', '__add__', ...] >>> abs. Syntax Python has no mandatory statement termination characters and blocks are specified by indentation. Strings

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

Custom Toolbar Buttons Maker Knowing that installing a huge amount of buttons is not exactly everyone's preference, here is a simple way of making a version of it that has just what you want; thus, keeping the file size as small as possible. Just tick the check boxes, hit Submit, and you have a customized version of Toolbar Buttons for your very own. The extensions generated here no longer match the latest version of Toolbar Buttons. Using Toolbar Buttons version 0.6.0.8 released Aug 26th 2009. Toolbar Buttons should not be installed at the same time as an extension created here.

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

Related: