<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; .bashrc</title> <atom:link href="http://www.ghacks.net/tag/bashrc/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 09:52:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Dealing with bash history</title><link>http://www.ghacks.net/2010/11/03/dealing-with-bash-history/</link> <comments>http://www.ghacks.net/2010/11/03/dealing-with-bash-history/#comments</comments> <pubDate>Wed, 03 Nov 2010 18:06:52 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[.bashrc]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[bash history]]></category> <category><![CDATA[command-line]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=36507</guid> <description><![CDATA[If you are a Linux user who frequents the command line, you will most likely have heard of the bash history. This is a special system that keeps a history of all commands run from bash. This has many pros and only a few cons. One of the cons is that, if you are logged [...]]]></description> <content:encoded><![CDATA[<p>If you are a Linux user who frequents the command line, you will most likely have heard of the bash history. This is a special system that keeps a history of all commands run from bash. This has many pros and only a few cons. One of the cons is that, if you are logged onto your machine, someone can see your command line history. There are plenty of situations where you might not want this to happen. In that case, you have to delete your history.</p><p>Let&#8217;s take a look and see how this is done.</p><p><span
id="more-36507"></span><strong>Before we start&#8230;</strong></p><p>There is always a &#8220;before&#8221; right? In this case I wanted to touch base with everyone to make sure it is know how you can work with the bash history. There is one way the bash history is immediately useful to the user. The bash history makes it easy for recalling the last commands run. If you open up a terminal window and start hitting the up arrow on your keyboard you can run through all of the commands contained in your bash history.</p><p>So all you need to do is keep hitting the up arrow until you see the command you wanted to run. This will save you time by keeping you from having to type long commands over and over. It can also help you troubleshoot by showing you what commands you have recently run, which will allow you to deduce what has happened to your machine.</p><p><strong>How to delete the history</strong></p><p>There are two steps to deleting your bash history. The first step is to delete the <strong>~/.bash_history</strong> file. This won&#8217;t work completely because there will still be a history stored in RAM. So, to get rid of THAT history you have to run the command <em>history -c</em>. Once that command is issued, your bash history will be completely clear.</p><p><strong>Not keeping your history</strong></p><p>What if, for whatever reason, you do not want your bash history to be retained at all? You can do this. You can do this for either all users or specific users. To turn off bash history for all users you would need to issue the command:</p><p><code>echo "unset HISTFILE" &gt;&gt; /etc/profile</code></p><p>To turn off bash history for a single user issue the command:</p><p><code>echo "unset HISTFILE" &gt;&gt; /home/USER/.bash_profile</code></p><p>Where USER is the user you want bash history turned off.</p><p>Once you&#8217;ve done either of the above, bash history will be turned off for good.</p><p><strong>History size</strong></p><p>Remember, you can control the size of your bash history by editing the lines in your <strong>~/.bashrc </strong>file:</p><p>HISTSIZE=1000</p><p>Change the entry to match the amount of commands you want to retain in your history.</p><p><strong>Final thoughts</strong></p><p>Bash is an amazing and powerful tool for any and all Linux users. Although you do not have to ever touch the command line, in modern Linux desktops, you may someday have to use the command for either a server or remote access to another desktop. For whatever the reason, you will want to either take advantage of the bash history.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2010/11/03/dealing-with-bash-history/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Save Your Skin by Customizing Your Bash Prompt</title><link>http://www.ghacks.net/2009/01/06/save-your-skin-by-customizing-your-bash-prompt/</link> <comments>http://www.ghacks.net/2009/01/06/save-your-skin-by-customizing-your-bash-prompt/#comments</comments> <pubDate>Tue, 06 Jan 2009 20:21:28 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Advanced]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[.bashrc]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[bash customization]]></category> <category><![CDATA[terminal]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=9685</guid> <description><![CDATA[If you do much work at the Linux command line then you know the bash prompt can offer you a lot of information. But by default the prompt itself isn&#8217;t too useful.  What you might not know is that you can customize the bash prompt in many ways. From configuring colors to the information bash [...]]]></description> <content:encoded><![CDATA[<p>If you do much work at the Linux command line then you know the bash prompt can offer you a lot of information. But by default the prompt itself isn&#8217;t too useful.  What you might not know is that you can customize the bash prompt in many ways. From configuring colors to the information bash reports, there are so many variations on the bash prompt you could play for days.</p><p>But there is one configuration you can do that is more helpful than any other. Have you ever accidentally issued a standard user command as the root user only to find yourself really regretting that command a millisecond later? It&#8217;s a common new Linux user mistake, but one that can be prevented. You&#8217;ll learn how to help yourself out here.</p><p><span
id="more-9685"></span>Before we get into the actual configuration (and how you can help yourself), let&#8217;s take a look at some basics. From your command line issue the following command <em>echo $PS1</em>. What you should see is the string that comprises your current default bash prompt. When I issue this command I see <strong>[\u@\h \W]\$</strong> and my prompt looks like <strong>[jlwallen@localhost ~]$</strong>. Let me explain what the components of the string are.</p><p>[ - When used alone this is simply a printed character.</p><p>\u - This prints out the current username.</p><p>@ - When used alone this is simply a printed character.</p><p>\h - This prints out the hostname of the machine up to the first dot.</p><p>\W - This prints out the basename of the current working directory (with the users home directory represented by the "~" character.</p><p>] &#8211; When used alone this is simply a printed character.</p><p>\$ &#8211; If root user this prints a &#8220;#&#8221; character, otherwise it prints a &#8220;$&#8221; character.</p><p>So let&#8217;s say you want to be clever and have a prompt that looks like <strong>URHERE (~):</strong></p><p>To create this issue the command:</p><p><em>PS1=&#8221;URHERE (\W): &#8220;</em></p><p>What the above command does is temporarily set your bash prompt. This prompt will last until you close out your terminal window. When you open a new terminal your default prompt will return.</p><p>To make this permanent you will need to open up your <strong>.bashrc</strong> file and add the line you entered as a command. The default <strong>.bashrc</strong> file might look like:</p><p><em># .bashrc</em></p><p><em># User specific aliases and functions<br
/> ? () { echo &#8220;$*&#8221; | bc -l; }</em></p><p><em># Source global definitions<br
/> if [ -f /etc/bashrc ]; then<br
/> . /etc/bashrc<br
/> fi</em></p><p>If you want to make this permanent add the line <em>PS1=&#8221;URHERE </em>(\W): &#8220;<em> </em>right under the <em># .bashrc</em> line. Save that file and open up a new prompt. Voila!</p><p><strong>Adding Color</strong></p><p>Okay, let&#8217;s take it to 11. One trick I like to employ is configuring the root prompt to be a different color than the standard user prompt. This way, if I see a red prompt, I instantly know I am dealing with the root user. Here is the trick with adding color. First you have to use a special string to indicate the beginning of a color. That string is:</p><p><em>\e[</em></p><p>Now to end a color you use the special string:</p><p><em>\e[m</em></p><p>For the color red you would use the string:</p><p>1;31m</p><p>So if you want the string <em>URHERE</em> to show up in red and the directory to remain the default white you would enter into the root user&#8217;s .bashrc file:</p><p>PS1=&#8221;\e[1;31mURHERE\e[m (\W): &#8221;</p><p>Here are the various colors you can use.</p><ul><li>0;30 &#8211; Black</li><li>0;31 &#8211; Red</li><li>0;32 &#8211; Green</li><li>0;33 &#8211; Brown</li><li>0;34 &#8211; Blue</li><li>0;35 &#8211; Purple</li><li>0;36 &#8211; Cyan</li></ul><p>The 0 equals the dark variation of the color and a 1 equals the lighter variation of the color.</p><p><strong>Final Thoughts</strong></p><p>You can really get creative with the bash prompt. With the basics you have learned here you can make your prompt both unique and helpful. If you come up with something really incredible post it here for all to enjoy!</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/01/06/save-your-skin-by-customizing-your-bash-prompt/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> </channel> </rss>
