tag:blogger.com,1999:blog-71287701007060389252024-03-07T17:18:29.510+07:00MooLux GNU/LinuxLive-USB Linux Based on SlackwareMoodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comBlogger119125tag:blogger.com,1999:blog-7128770100706038925.post-10386377789716586322019-10-23T22:11:00.001+07:002010-11-07T11:39:46.498+07:00What is MooLux<div class="entry"><b>MooLux</b> is a<b> Live USB Linux</b> distribution based on Slackware that utilizes the KDE desktop environment. MooLux is a portable operating system that can be taken with you containing tools for Internet browsing, email, chat, multimedia, office and software for C, Python, Perl programming tasks. The latest version of Moolux is <b>MooLux-5.4</b><br />
<div id="preview"><a href="http://www.moolux.org/wp-content/images/snapshot1.jpg"> </a><b> </b><br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.moolux.org/2008/09/snapshot-of-moolux.html" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFHJ11lff4b2L8pCiD1Vejot_JcyGGoeia6inCEZ9IB-tfIV-3DrIAPP1qalr2i_7bNZAo0d7iEc38pgOcq0kfYowX66POMWrqlzQgWVeRhpVPssoDfidNI6sMfavl06Qv6xvnmCz-dhs/s400/snapshot1.jpg" width="400" /></a></div><div style="text-align: center;"><b><a href="http://www.moolux.org/2008/09/download-moolux.html">Download MooLux </a></b></div><br />
<br />
<b>MooLux 5.4</b><br />
Moolux is a Linux operating system providing wide colection of useful software with Xwindow system and KDE desktop environment. MooLux is designed to be a full system right out of the box. Moolux has all you need USB Disk 1GB. Now we know all you need is not always all you want. Linux is all about choices, right. Moolux can also easily expand using packages from Slackware or other Slackware 3rd party sites. Included in moolux Is a small collection of simple games. These are not meant to impress, they are just a taste of the real fun you can have with MooLux. Try MooLux for full time and see if you are not impressed with this. And if you find anything that needs improvement let we know. See <b><a href="http://www.moolux.org/2008/09/snapshot-of-moolux.html">Screenshot here.</a></b></div><div class="entry"><br />
<b>Features<br />
</b><br />
- Based on Slackware 12.2 with kernel 2.6.27.7</div>- Kernel support Aufs, squashfs, Squashfs-lzma, and Bootsplash<br />
- KDE-3.5.10<br />
- Openoffice.org-3.1<br />
- Kaffeine Media Player-0.8.8 with Full Codecs from Mplayer<br />
- Firefox-3.0.11 with Flashgot, Thunderbird-2.0.0.22, Pidgin-2.5.8 with guification<br />
- K3B-1.0.5 Grsync-3.0.2, Gftp-2.0.18, ktorrent-2.2.7<br />
- gparted-0.3.8, Gslapt-0.4.0<br />
- gimp-2.4.6, qcomicbook-0.3.4,StarDict-3.0.1<br />
- Bluefish-1.0.7,kchmviewer-3.1.2, Supertux-0.1.3<br />
- Wlassistant-0.5.7, KDEBluetooth-1.0-Beta<br />
- and many others……..(<b><a href="http://moodjair.web.ugm.ac.id/images/package.txt">see packages list</a></b>)<br />
<br />
<br />
<b>Requirement<br />
</b>These are the minimal hardware requirements to run MooLux in with correct performance (some lower configs work, but might be slow) :<br />
- PIV or better, Pentium or AMD are both OK.<br />
- 512 MB of RAM<br />
- No harddisk is required if run Live-USB.<br />
- 1GB space to install Live Mode<br />
- 3GB linux partition space to install Real Mode<br />
<br />
</div>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-38122861154602593872019-05-15T11:18:00.001+07:002019-05-15T11:18:26.078+07:00Git set Proxy in Linux<br /><br />Once you have obtained the proxy settings (server URL, port, username and password); you need to configure your git as follows:<div>
<br /></div>
<div>
<blockquote class="tr_bq">
$ git config --global http.proxy http://<username>:<password>@<proxy-server-url>:<port>
</port></proxy-server-url></password></username></blockquote>
You would need to replace <username>, <password>, <proxy-server-url>, <port> with the values specific to your proxy server credentials. These fields are optional. For instance, your proxy server might not even require <username> and <password>, or that it might be running on port 80 (in which case <port> is not required).<br /><br />Once you have set these, your git pull, git push or even git fetch would work properly</port></password></username></port></proxy-server-url></password></username></div>
Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-34744757104251774292019-05-14T11:41:00.001+07:002019-05-14T11:41:12.843+07:00How to install Opera Browser on Ubuntu 18.04 Bionic Beaver Linux<br />Add Opera browser Repository<br /><br />Let's start by adding an Opera repository and keyring. <a href="https://linuxconfig.org/how-to-open-a-terminal-on-ubuntu-bionic-beaver-18-04-linux">Open up terminal</a> and enter:<div>
<blockquote class="tr_bq">
$ wget -qO- https://deb.opera.com/archive.key | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=i386,amd64] https://deb.opera.com/opera-stable/ stable non-free"
</blockquote>
<br />Install Opera Browser<br /><br />At this stage to install the Opera browser on Ubuntu 18.04 Bionic Beaver is easy as executing the below command:</div>
<blockquote class="tr_bq">
$ sudo apt install opera-stable</blockquote>
Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-30792973452667433622019-05-14T11:32:00.002+07:002019-05-14T11:32:52.831+07:00How To Install Atom Text Editor on Ubuntu 18.04<br /><a href="https://atom.io/">Atom</a> is an open source cross-platform code editor developed by GitHub. It has a built-in package manager, embedded <a href="https://linuxize.com/post/how-to-install-git-on-ubuntu-18-04/">Git</a> control, smart autocompletion, syntax highlighting and multiple panes.<br /><br />Under the hood Atom is a desktop application built on Electron using HTML, JavaScript, CSS, and <a href="https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/">Node.js</a>.<br /><br />The easiest and recommended way to install Atom on Ubuntu machines is to enable the Atom repository and install the Atom package through the command line.<br /><br />Although this tutorial is written for Ubuntu 18.04 the same instructions apply for Ubuntu 16.04 and any Debian based distribution, including Debian, Linux Mint and Elementary OS.<br /><a href="https://linuxize.com/post/how-to-install-atom-text-editor-on-ubuntu-18-04/#prerequisites">Prerequisites</a><br /><br />The user you are logging in as must have <a href="https://linuxize.com/post/how-to-create-a-sudo-user-on-ubuntu/">sudo privileges</a> to be able to install packages.<br /><a href="https://linuxize.com/post/how-to-install-atom-text-editor-on-ubuntu-18-04/#installing-atom-on-ubuntu">Installing Atom on Ubuntu</a><br /><br />Perform the following steps to install Atom on your Ubuntu system:<br /><br />Start by updating the packages list and install the dependencies by typing:<br /><blockquote class="tr_bq">
sudo apt updatesudo apt install software-properties-common apt-transport-https wget</blockquote>
Next, import the Atom Editor GPG key using the following <a href="https://linuxize.com/post/wget-command-examples/">wget command</a>:<br /><blockquote class="tr_bq">
wget -q https://packagecloud.io/AtomEditor/atom/gpgkey -O- | sudo apt-key add -</blockquote>
And enable the Atom repository by typing:<br /><blockquote class="tr_bq">
sudo add-apt-repository "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main"</blockquote>
Once the repository is enabled, install the latest version of Atom with:<br /><blockquote class="tr_bq">
sudo apt install atom</blockquote>
Source: https://linuxize.com/post/how-to-install-atom-text-editor-on-ubuntu-18-04/Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-62807177800303000292019-03-16T08:11:00.001+07:002023-03-16T08:24:50.232+07:00Introduction to Shell Scripting in Linux<p>Shell scripting is a way to write programs that run on Unix/Linux systems. It's a powerful skill to have since it allows users to automate repetitive tasks, perform system administration, and do a lot of other things that they would otherwise have to do manually.</p>
<p>A shell script typically consists of a sequence of commands that are executed in a specific order when the script is run. The shell is the program that reads and executes the script. There are many different shells available, but the most common one used for scripting is the Bash shell (short for Bourne-Again SHell).</p>
<h3 id="creating-a-simple-script">Creating a Simple Script</h3>
<p>Let's start by creating a simple script that echoes "Hello, World!" to the command line. Open up your favorite text editor and type:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash </span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Hello, World!"</span>
</code></pre>
<p>Save the file somewhere on your computer and give it a name like <code>hello_world.sh</code>. The first line (<code>#!/bin/bash</code>) is called the shebang, and it tells the shell which interpreter to use. In this case, we're specifying the Bash shell. The second line prints out our greeting using the <code>echo</code> command.</p>
<p>By default, scripts aren't executable, so we need to change the permissions of the file to make it executable. To do that, open your terminal and run the following command:</p>
<pre><code class="lang-bash"><span class="hljs-selector-tag">chmod</span> +<span class="hljs-selector-tag">x</span> <span class="hljs-selector-tag">hello_world</span><span class="hljs-selector-class">.sh</span>
</code></pre>
<p>This will make <code>hello_world.sh</code> executable. Now we can run our script by typing:</p>
<pre><code class="lang-bash">./hello_world.<span class="hljs-keyword">sh</span>
</code></pre>
<p>This should print "Hello, World!" to the command line.</p>
<h3 id="variables">Variables</h3>
<p>One of the most powerful features of shell scripting is the ability to use variables. Variables allow us to store values that can be used throughout the script. Here's an example:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>
name=<span class="hljs-string">"John"</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Hello, <span class="hljs-variable">$name</span>!"</span>
</code></pre>
<p>In this script, we define a variable called <code>name</code> and assign it the value "John". We then use the variable within the string passed to the <code>echo</code> command using the <code>$</code> character followed by the variable name.</p>
<h3 id="loops">Loops</h3>
<p>Loops are another fundamental feature of shell scripts. They allow us to execute a sequence of commands multiple times, either a fixed number of times or until a certain condition is met. Here is an example of a loop that prints out the numbers 1 through 5:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> {1..5}
<span class="hljs-keyword">do</span>
<span class="hljs-built_in">echo</span> <span class="hljs-variable">$i</span>
<span class="hljs-keyword">done</span>
</code></pre>
<p>In this script, we're using a <code>for</code> loop to iterate through the sequence of numbers from 1 to 5. The <code>echo</code> command inside the loop prints out the current value of <code>i</code>.</p>
<h3 id="conditionals">Conditionals</h3>
<p>Conditionals allow us to execute different parts of code depending on whether a certain condition is true or false. Here's an example:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>
name=<span class="hljs-string">"Bob"</span>
<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$name</span>"</span> == <span class="hljs-string">"Alice"</span> ]
<span class="hljs-keyword">then</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Hello, Alice!"</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"You're not Alice!"</span>
<span class="hljs-keyword">fi</span>
</code></pre>
<p>In this script, we're using an <code>if</code> statement to check if the value of the <code>name</code> variable is "Alice". If it is, we print out "Hello, Alice!". If it's not, we print out "You're not Alice!".</p>
<h3 id="conclusion">Conclusion</h3>
<p>Shell scripting is a powerful tool that allows users to automate a wide variety of tasks on Unix/Linux systems. With just a few basic concepts, such as variables, loops, and conditionals, you can create powerful scripts that can save you a lot of time and effort. Happy scripting!</p>
Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-52951406456931112562019-03-16T07:56:00.001+07:002023-03-16T08:07:39.774+07:00Configuring Proxies for Yarn, NPM, Git, NVM, Yum, and Apt<p>When developing applications, it is common to interact with various tools that require a network connection to function correctly. However, many corporate networks use proxies to control access to the internet, which can cause these tools to fail if not configured correctly. In this article, we will look at how to set up and unset proxies for common tools like Yarn, NPM, Git, NVM, Yum, and Apt.</p><p><strong>Proxy Setup in Linux</strong><br />Most Linux distributions rely on either Yum or Apt as their package managers. To configure proxy settings for Yum and Apt-based systems, open your terminal and run the following commands:</p><p><strong>YUM</strong><br />Create a file called '/etc/yum.conf.proxy', which will hold your proxy configuration data:<br /><br /><code>touch /etc/yum.conf.proxy && chmod 777 /etc/yum.conf.proxy</code></p><p>Edit the newly created file by opening it using a text editor such as 'nano' and adding the following configuration data:<br /><br /><code>proxy=http://[username:password@]proxy-server-hostname:[port]/</code></p><p>Replace the bracketed terms with your proxy server's details, including your username and password (if applicable) followed by the proxy server hostname and port.</p><p>Export the HTTP_PROXY and HTTPS_PROXY environment variables so that all processes have access to the proxy settings stored in the /etc/yum.conf.proxy file, by running the following commands:</p><p><code>export http_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code><br /><code>export https_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code></p><p><strong>APT</strong><br />Edit your '/etc/apt/apt.conf.d/proxy.conf' file using a text editor such as 'nano' and add the following lines of configuration data:</p><p><code>Acquire::http::Proxy "http://[username:password@]proxy-server-hostname:[port]/";</code><br /><code>Acquire::https::Proxy "http://[username:password@]proxy-server-hostname:[port]/";</code></p><p>Replace the bracketed terms with your proxy server details, including your username and password (if applicable), followed by the proxy-server hostname and port.</p><p>Set up the HTTP_PROXY and HTTPS_PROXY environment variables so that all applications have access to the proxy settings stored in the '/etc/apt/apt.conf.d/proxy.conf' file, by running the following commands:</p><p><code>export http_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code><br /><code>export https_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code></p><p><strong>Proxy Setup in macOS</strong><br />Many developers prefer Macs for coding because the macOS provides better support and flexibility for development. macOS utilizes bash shell, so you must configure proxy settings found in the bash profile file.</p><p>Open Terminal application and edit the '.bash_profile' file by running:</p><p><code>nano ~/.bash_profile</code></p><p>Add the following entries to the file:</p><p><code>export http_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code><br /><code>export https_proxy="http://[username:password@]proxy-server-hostname:[port]/"</code></p><p>Replace the bracketed terms with your proxy server details, including your username and password (if applicable), followed by the proxy-server hostname and port.</p><p>Save the changes made in the '.bash_profile' file and then run the following command to load the new configuration values:</p><p><code>source ~/.bash_profile</code></p><p>Proxy Setup in Windows<br />Windows users have several ways to configure proxy settings. In most cases, it is essential to adjust the settings for each of the applications individually.</p><p><strong>NVM</strong><br />If you utilize NVM (Node Version Manager) for Windows, modify the registry key named 'HTTP_PROXY' and 'HTTPS_PROXY.'</p><p>Launch cmd and navigate through this path</p><p><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings</code></p><p>Right-click Internet Settings, select New -> String Value to create two new string values named HTTP_PROXY and HTTPS_PROXY that correspond to the respective environment variables.</p><p>Modify the value of HTTP_PROXY/HTTPS_PROXY appropriately, For example,</p><p><br /><code>"http://<proxy>:<port>"</code></p><p><strong>Git</strong><br />If you’re using Git for Windows, there is an easy way to configure your proxy settings globally.</p><p>Open the Git Bash application.</p><p>Use the following commands to set up your global Git proxy configuration:</p><p><code>git config --global http.proxy [username:password@]your-proxy-server.com:[port]</code><br /><code>git config --global https.proxy [username:password@]your-proxy-server.com:[port]</code></p><p><code></code><br />Replace the bracketed terms with your proxy server details, including your username and password (if applicable), followed by the proxy-server hostname and port.</p><p><strong>Yarn and NPM</strong><br />Yarn and NPM are straightforward as they inherit the environment variable configurations from the operating system's default environment variables.</p><p>Configure the proxy value by running the following command:<br /><br /><code>npm config set proxy http://[username:password@]proxy-server-hostname:[port]/</code><br /><code>yarn config set proxy http://[username:password@]proxy-server-hostname:[port]/</code></p><p>Replace the bracketed terms with your proxy server details, including your username and password (if applicable), followed by the proxy-server hostname and port.</p><p>Unconfigure by running the same command but with the word “delete” suffix:</p><p><code>npm config delete proxy</code><br /><code>yarn config delete proxy</code></p><p><!-- ####### HEY, I AM THE SOURCE EDITOR! #########-->
</p><p><strong>Conclusion</strong><br />Proxy configurations remain critical to ensuring that tools frequently used by software developers work reliably across any network environment. As we have seen above, configuring proxies for tools like Yarn, NPM, Git, NVM, Yum, and Apt is relatively straightforward once you know what to do.</p>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-70078787379942428272010-12-12T00:09:00.001+07:002010-12-12T00:11:20.173+07:00Screenshot Grabbing<b>Using imagemagick<br />
</b><br />
imagemagick is a collection of tools and libraries for image manipulation. Most distribustions come with imagemagick .<br />
To take a snapshot using Imagemagic:<br />
<blockquote>import -window root screenshot.png</blockquote>import manual page<br />
<br />
<b>Using xv<br />
</b><br />
xv is another image manipulation program that can deal with almost all file formats. xv is not included in distributions installations, but packages are available for most. Example usage:<br />
<blockquote>xv -grabdelay 2 myimage.jpg<br />
xv manual page</blockquote><b>using gimp<br />
</b><br />
To grab an image of the screen or a program in Gimp:<br />
<blockquote>File -> Acquire -> Screen shot</blockquote><b>using Framebuffer Console<br />
</b><br />
Use fbgrab to grab a screenshot in a framebuffer console.<br />
<blockquote>fbgrab filename.png</blockquote><b>using kde<br />
</b><br />
KDE comes with a handy program called ksnapshot that lets you with ease grab a screenshot of your desktop or a single window.<br />
<blockquote>scrot</blockquote>scrot is a small (66 kB) screen shot grabber based on imlib2. It has lots of options for autogenerating filenames, and can do fun stuff like taking screenshots of multiple displays and glueing them together. thanks to miztic for mentioning it<br />
<br />
<b>using xwd<br />
</b><br />
xwd (manual page) is a part of XFree, so chances are high you already have it installed. It can dump screenshots to .xwd files. This is not a common format. After taking a screenshot using <br />
<blockquote>xwd -root -out test.xwd</blockquote>the only programs I found capable of opening it were Gimp and xwud (manual page). thanks to lude for mentioning itMoodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-15894094739992714572010-12-12T00:05:00.000+07:002013-10-22T08:25:07.828+07:00Encrypt FilesystemsIf you are using modules you need to load these first:<br />
<blockquote>
modprobe loop;modprobe cryptoloop;modprobe cipher-aes</blockquote>
Basically you:<br />
<blockquote>
losetup -e aes -k 256 /dev/loop0 /dev/partition</blockquote>
You will be asked for a password. Then<br />
<blockquote>
mount /dev/loop0 /path/to/mount</blockquote>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijmcsGbdQuxiuvAAzu8bBr1OLtjRSiPDtYXJVjzhZfWjTtaZRW6q7yTf1cdzEcbCAEpbRoH4le8RNPmBqLfscKGUkWZM17h_UVCSyhIjFxXQwJlaCIKCdktc-j0jGurR4L5TDX1U4sAvg/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijmcsGbdQuxiuvAAzu8bBr1OLtjRSiPDtYXJVjzhZfWjTtaZRW6q7yTf1cdzEcbCAEpbRoH4le8RNPmBqLfscKGUkWZM17h_UVCSyhIjFxXQwJlaCIKCdktc-j0jGurR4L5TDX1U4sAvg/s1600/images.jpg" /></a></div>
Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-973775392659779972010-10-24T14:15:00.002+07:002010-10-24T14:18:28.061+07:00Kill Linux Processes with pkillOne of the best features in Linux is the way you can control processes from the command line, so if you have an application that locks up your GUI, you can always SSH over from another machine and just kill the offending process.<br />
<br />
The problem is that if you are killing the same process repeatedly, it’s very tedious to have to figure out the process ID every single time so that you can kill it… so here’s the easier way to do it.<br />
<br />
<b>The Old Way<br />
</b><br />
The classic way of killing processes meant you’d first need to use the ps command piped through grep to find the process you are trying to kill:<br />
<br />
<blockquote>$ ps -ef | grep swiftfox<br />
geek 7206 22694 0 Dec04 ? 00:00:00 /bin/sh /opt/swiftfox/swiftfox<br />
geek 7209 7206 0 Dec04 ? 00:00:00 /bin/sh /opt/swiftfox/run-mozilla.sh /opt/swiftfox/swiftfox-bin<br />
geek 7213 7209 0 Dec04 ? 00:04:29 /opt/swiftfox/swiftfox-bin<br />
geek 14863 14224 0 18:19 pts/4 00:00:00 grep swiftfox</blockquote><br />
Then to kill the process, you’d have to use the kill command:<br />
<br />
<blockquote>$ kill 7206<br />
</blockquote><b>The New Way<br />
</b><br />
Instead of going through all of that, you can simply use the pkill command if you already know the process name or part of it.<br />
<br />
<blockquote>$ pkill swiftfox<br />
</blockquote>It’s as simple as that. You should note that pkill will kill all processes matching the search text, in this case swiftfox<br />
<br />
If you want to see what process names are matched before using the pkill command, you can use the pgrep command. Passing the -l switch tells pgrep to show the process name as well.<br />
<br />
<blockquote>$ pgrep -l swiftfox<br />
7206 swiftfox<br />
7213 swiftfox-bin</blockquote>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-68186708368062254912010-10-24T14:07:00.001+07:002010-10-24T14:07:33.050+07:00Delete Files Older Than x DaysThe find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.<br />
<blockquote>find /path/to/files* -mtime +5 -exec rm {} \;<br />
</blockquote>Note that there are spaces between rm, {}, and \;<br />
<br />
The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.<br />
The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.<br />
The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-26419463807735502842010-10-24T01:42:00.001+07:002010-10-24T01:42:43.051+07:00How to use the most popular command in Unix - Grepgrep is by far the most popular command that exists in Unix. Though some may argue about that, but once you begin using grep, it would always be present in all your complex commands that you think of executing at the shell prompt. grep stands for 'global regular expression printer' . Which makes no sense to most.. In sensible words grep extracts those lines from a given text that match the conditions set by the user. <br />
<br />
Basically grep lets you enter a pattern of text and then it searches for this pattern within then text that you provide it. It would return all the lines that have the given pattern in them. grep can be used in 2 ways - Either on its own or along with pipes<br />
<br />
Using grep on its own<br />
<blockquote>$ grep '12.00' /home/david/backup/log.txt</blockquote>This command basically shows how you can use grep to extract lines containing a particular string from a text file. (Text files need not necessarily end in .txt) The above command searches for the string 12.00 in the text file specified in the command, and displays all the lines that have this string in them.<br />
The above command could be used to find out all the backups that took place at 12.00 (In case you have a log.txt file in that directory with a list of all the timings for the backups that you have made). <br />
<blockquote>$ grep -v '12.00' /home/david/backup/log.txt<br />
</blockquote>The above command would now show you all the lines in the text file except those that have the string 12.00 in them. <br />
<blockquote>$ grep -l 'delay' /code/*.c<br />
</blockquote>The above command searches for those files that end with a '.c' (within the /code directory) and in which the text 'delay' is present. It only returns the names of these files and not the lines where it found the string.<br />
<blockquote>$ grep -w '\<bay' *
$ grep -w 'watch\>' *<br />
</blockquote>The above commands search for text in a more refined way. The first command searches for those lines where any word in that line begins with the letters 'bay' and the second command searches for those lines where any word in that line ends with the letter 'watch'<br />
-<br />
<br />
Using grep with pipes<br />
<blockquote>$ ls -l | grep rwxrwxrwx</blockquote>As you must be knowing ls -l displays the directory listing for any directory. The grep rwxrwxrwx part of the command extracts only those lines which display the files having their read,write,execute permissions set for user, group and others also. Thus instead of getting a listing of all the files in the directory, you would only see those files that have their r,w,x permissions set for all everybody.<br />
<br />
The output of grep can also be piped to another program as follows<br />
<blockquote>$ du | grep 'mp3' | more<br />
</blockquote>You should be able to figure out what the above command does..<br />
<blockquote>$ grep '^#' /home/david/script1 | more<br />
</blockquote>The above command would display those lines (from the file /home/david/script1) that begin with a '#'. The term '^#' means that # should be present as the first character on a line. The more part of the command should be known to you. If not, more basically displays the output a page at a time incase the output exceeds one page.<br />
<blockquote>$ grep -v '^[0-9]' /home/david/backup/log.txt | more<br />
</blockquote>This command searches for lines having any of the numbers from 0-9 in them as the first character on the line. It then prints all the lines except the ones it found initially.<br />
<br />
Important : It's necessary to enclose patterns (as used in the above 2 commands) in single quotes so that the shell understands it correctly.Otherwise, the shell may interpret it in another method.<br />
<br />
Some extra options for grep<br />
<br />
-v<br />
Reverses the normal behaviour of the grep command - Instead of selecting lines, it rejects the lines that match the given criteria.<br />
<br />
-c<br />
It supresses the normal output and only prints the total count of matching lines instead of the actual lines.<br />
<br />
-i<br />
Ignores the case of the text when matching the given pattern.<br />
<br />
-w<br />
Checks if the given pattern is a word by itself and not a part of another word. Thus if you search for 'bay' and the word 'baywatch' is present in a file, the particular line conatining that word would not be returned in the result.<br />
<br />
-l<br />
Only gives the names of the files in which the given pattern was found.<br />
<br />
-r <br />
Checks for the given pattern , recursively within the directory that you specify after the -r option<br />
<br />
I hope this tutorial helps you get started with grep. grep is defintely one of the tools that gives Linux the advantage over other Operating Systems. Using grep effectively along with other tools gives the user a lot of power in Unix.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-28297909446952774502010-10-24T01:38:00.001+07:002010-10-24T01:38:37.140+07:00Setting the PATH in linuxThis article explains how set your PATH variable under Linux. This has the same use as that of setting the PATH variable under DOS. Under Linux too, modifying the PATH would add these new directories to your default search path. <br />
So in case you have a particular executable in a particular directory, then if you add that directory to your PATH, then you would only have to type the name of the executable at the prompt rather than then absolute path for that executable. Got it?? Read the example below to figure out what exactly I am speaking about..<br />
<br />
<br />
Assumption<br />
<br />
Suppose you have a program by the name 'tetris' in a folder called /usr/local/games . So in order to run this program you would have to type the following at the prompt<br />
<blockquote>$/usr/local/games/tetris</blockquote><br />
The above command would execute your program. But typing this every time you want to play this wonderful game makes it slightly cumbersome. It would be much better if you could only type 'tetris'.<br />
<br />
<br />
Solution<br />
<br />
A solution would be to add the /usr/local/games directory to your PATH, so that next time onwards you would only have to type 'tetris' at the prompt rather than the absolute path. <br />
<br />
To add this directory to your PATH you have to edit a file called 'bash_profile' that would be present in your Home directory (in Redhat Linux 6.2). So if there is a user by the name David then this file would mostly be found at /home/David/.bash_profile<br />
<br />
Note : The period (.) before the name of the file. This period make this file a hidden file. So remember to view hidden files also while seeing a directory listing (This option would be in some menu in X , at the prompt simply use 'ls -a' to see hidden files).<br />
<br />
This file would be having a particular line starting with the string PATH. For e.g. the file that I have on my machine has a line such as<br />
<blockquote>PATH=/optional/bin:$PATH:$HOME/bin</blockquote><br />
To add the directory /usr/local/games to this I would have to modify this line as follows<br />
<blockquote>PATH=/usr/local/games:optional/bin:$PATH:$HOME/bin</blockquote><br />
Once you have modified this file, save it and then execute it as follows <br />
<blockquote>. $HOME/.bash_profile</blockquote><br />
Note : To execute this script basically at the $ prompt type a period ' . ' leave a space and then type $HOME/ Once this is done press <Tab> key. Doing so would replace what ever you have typed with the path to your home directory. Once this happens all you have to do is append a .bash_profile to what is already present at the prompt and finally press <Enter><br />
<br />
On executing the script you wouldn't see any messages at the output, but then onwards you could simply type 'tetris' at the prompt to execute the program /usr/local/games/tetris <br />
So now you are on the right PATHMoodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-80969503206228541992010-10-19T16:27:00.000+07:002010-10-23T22:04:41.792+07:00Unmount busy drivesYou are probably all too familiar with the situation - you are trying to unmount a drive, but keep getting told by your system that it's busy. But what application is tying it up? A quick one-liner will tell you:<br /><blockquote>lsof +D /mnt/windows</blockquote>This will return the command and process ID of any tasks currently accessing the /mnt/windows directory. You can then locate them, or use the kill command to finish them off.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-77159363868826013012010-10-18T14:29:00.000+07:002010-10-23T22:04:41.814+07:00Grabbing a screenshot without XThere are plenty of screen-capture tools, but a lot of them are based on X. This leads to a problem when running an X application would interfere with the application you wanted to grab - perhaps a game or even a Linux installer. If you use the venerable ImageMagick import command though, you can grab from an X session via the console. Simply go to a virtual terminal (Ctrl+Alt+F1 for example) and enter the following:<br /><br /><blockquote>chvt 7; sleep 2; import -display :0.0 -window root sshot1.png; chvt 1;<br /></blockquote>The chvt command changes the virtual terminal, and the sleep command gives it a while to redraw the screen. The import command then captures the whole display and saves it to a file before the final chvt command sticks you back in the virtual terminal again. Make sure you type the whole command on one line.<br /><br />This can even work on Linux installers, many of which leave a console running in the background - just load up a floppy/CD with import and the few libraries it requires for a first-rate run-anywhere screen grabber.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-39092236601244800352010-10-18T14:28:00.000+07:002010-10-23T22:04:41.834+07:00Finding the biggest filesA common problem with computers is when you have a number of large files (such as audio/video clips) that you may want to get rid of. You can find the biggest files in the current directory with:<br /><br /><blockquote>ls -lSrh<br /></blockquote>The "r" causes the large files to be listed at the end and the "h" gives human readable output (MB and such). You could also search for the biggest MP3/MPEGs:<br /><br /><blockquote>ls -lSrh *.mp*<br /></blockquote>You can also look for the largest directories with:<br /><br /><blockquote>du -kx | egrep -v "\./.+/" | sort -n</blockquote>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-54074634687364672142010-10-17T19:25:00.000+07:002010-10-23T22:04:41.849+07:00Using ODBC with bindI ran into this last week, and the Google was failing me, so here's the reason why you sometimes get "Required token $zone$ not found." when debugging why bind won't start with ODBC. The answer is: because the DLZ documentation is slightly wrong. It delimits "zone" and "record" with % instead of $. That is, the directions show:<br /><br /><blockquote>{select zone from dns_records where zone = '%zone%'}<br /></blockquote>But really, it should be:<br /><br /><blockquote>{select zone from dns_records where zone = '$zone$'}<br /></blockquote>There you go. That's where that error comes from. Now hopefully the next person who hits this will be able to find an actual useful answer when they search for the error.<br /><br />source: http://ubuntulinuxtipstricks.blogspot.com/2010/10/using-odbc-with-bind.htmlMoodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-75588803552516134102010-10-17T18:33:00.000+07:002010-10-23T22:04:41.867+07:00Backing up Master Boot RecordThe MBR is a 512 byte segment on the very first sector of your hard drive composed of three parts: 1) the boot code which is 446 bytes long, 2) the partiton table which is 64 btyes long, and 3) the boot code signature which is 2 bytes long.<br />The core of the backup command is dd—which will be familiar to every system administrator, especially to those who intend to clone an entire hard disk. To see all the options type man dd. As we want to back up only the first 512 bytes we need to append some arguments to it. Here is the full command you need (and remember to run it as the root user, su (and sudo for Ubuntu users):<br /><br /><blockquote>dd if=/dev/hda of=/home/richmondg/mbr_backup bs=512 count=1<br /></blockquote>Restoring the MBR<br />You can use a live CD to access your hard drive and read the backup off any removable media such as a USB stick. Here is the command:<br /><br /><blockquote>dd if=/dev/sda/mbr_backup of=/dev/hda bs=512 count=1<br /></blockquote>Again, amend sda to read where you saved the MBR and run the command as root. If you wish to kill the MBR altogether, including the partition table, then you can overwrite it with a series of zeros:<br /><br /><blockquote>dd if=/dev/zero of=/dev/hda bs=512 count=1<br /></blockquote>If you want to kill the MBR but leave the partition table intact then simply change 512 to 446.<br />Another way to repair the mbr of your HDD device is install LILO then type (replacing x with the letter of your HDDdevice) :<br /><br /><blockquote>lilo -M /dev/sdx</blockquote>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-10860253192463849422010-10-02T18:56:00.000+07:002013-10-22T08:28:16.209+07:00Batch resize images using the command line in LinuxIf you have a ton of images that need resizing, you can do it all with the imagemagick package:<br />
<br />
<blockquote>
cd /home/user/images<br />
mkdir resized_images<br />
cp /home/user/images/* /home/user/images/resized_images</blockquote>
<br />
Now that you have a copy of the files in resized_images, time to resize them all:<br />
<br />
<blockquote>
mogrify -resize 800 *.jpg</blockquote>
<br />
This will resize them all to a width of 800px while keeping the aspect ratio. If you want a fixed image size, you can specify it like this:<br />
<br />
<blockquote>
mogrify -resize 800×600! *.jpg</blockquote>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj50xmKYp0lcv4Xjz5NmUTdBFbTiU3icUMN8l2I9dl9g3NNLw3xEmKh4baY0hN09p26HH50LrUsaP7ADAodo8kP1wRQfQNtjShckPsWKZik0dBftDnFHbpR-7XJpRYy4wkyUZTgQFavwj0/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj50xmKYp0lcv4Xjz5NmUTdBFbTiU3icUMN8l2I9dl9g3NNLw3xEmKh4baY0hN09p26HH50LrUsaP7ADAodo8kP1wRQfQNtjShckPsWKZik0dBftDnFHbpR-7XJpRYy4wkyUZTgQFavwj0/s320/images.jpg" width="320" /></a></div>
Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-54421221197688666652010-10-02T18:53:00.000+07:002010-10-23T22:04:41.918+07:00How to Find duplicate filesLet’s say you have a folder with 5000 MP3 files you want to check for duplicates. Or a directory containing thousands of EPUB files, all with different names but you have a hunch some of them might be duplicates. You can cd your way in the console up to that particular folder and then do a<br /><br /><blockquote>find -not -empty -type f -printf “%s\n” | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate</blockquote><br />This will output a list of files that are duplicates, according tot their HASH signature.<br />Another way is to install fdupes and do a<br /><br /><blockquote>fdupes -r ./folder > duplicates_list.txt</blockquote><br />The -r is for recursivity. Check the duplicates_list.txt afterwards in a text editor for a list of duplicate files.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-42567084846510785502010-10-02T18:49:00.001+07:002010-10-23T22:10:39.583+07:00Samsung has made Galaxy Tab’s launch date for the UK market official<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg866829_N_r7llCOYPAOuBbPvAVn_SQb4IBK12L9kLVrpb8dk20LCwdn2ci6Au6q__rNh49J3Vzzv_xggekR6GSbscfEqe8GgEFNjXYAWKY0sAXi1ea0ViMmZFBBLoZTFMjWcqpRb6l7o/s1600/galaxy-tab-uk.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg866829_N_r7llCOYPAOuBbPvAVn_SQb4IBK12L9kLVrpb8dk20LCwdn2ci6Au6q__rNh49J3Vzzv_xggekR6GSbscfEqe8GgEFNjXYAWKY0sAXi1ea0ViMmZFBBLoZTFMjWcqpRb6l7o/s320/galaxy-tab-uk.jpg" width="320" /></a></div><br />
Samsung has made Galaxy Tab’s launch date for the UK market official. Its first Android-powered tablet will go on sale nationwide on November 1, which also happens to be Samsung’s 41st anniversary.<br />
<br />
Samsung says the device will arrive on major networks as well as to stores like Carphone Warehouse, Dixons Store Group but has failed to mention the price except claiming to be available in “range of attractive price packages.”<br />
<br />
Full Specifications:<br />
Network: 2.5G (GSM/ GPRS/ EDGE) : 850 / 900 / 1800 / 1900 MHz; 3G (HSUPA 5.76Mbps, HSDPA 7.2Mbps) : 900 / 1900 / 2100 MHz<br />
OS: Android 2.2 (Froyo)<br />
Display: 7.0 inch TFT-LCD, WSVGA (1024 x 600)<br />
Processor: Cortex A8 1.0GHz Application Processor with PowerVR SGX540<br />
Camera: 3 MP Camera with Auto-Focus and LED Flash; 1.3MP front camera for Video Telephony<br />
Value-added Features: Android Market™ and Samsung Apps for more applications and contents; Readers Hub; Media Hub*; Music Hub*; Social Hub; *Availability will be decided by market preference.; Adobe Flash 10.1 player support; Full HD video playback; Thinkfree Office; Swype; Hybrid Widget<br />
Connectivity: 30 pin connector<br />
WiFi 802.11n / Bluetooth® 3.0<br />
Sensor: Gyroscope sensor, Geo-magnetic sensor, Accelerometer, Light sensor<br />
Memory: 16G / 32G internal memory with up to 32G external memory slot<br />
RAM: 512 MB<br />
Size: 190.09 x 120.45 x 11.98mm, 380g<br />
Battery:4,000mAh (7 hour movie play)<br />
<br />
source: http://www.samsunghub.com/2010/10/01/galaxy-tab-coming-to-uk-on-november-1/Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-25617334573153752332010-05-25T09:51:00.000+07:002010-10-23T22:04:41.977+07:00Slackware 13.1 ReleasedGreat news!!! Slackware 13.1 has been officially released. In the last few days, there has been no activity in -Current tree and they have prepared to put the ISO into replication phase which will be used for pre-orders in Slackware Store.<br /><br />As usual, you will not find official ISOs in any mirrors now, but eventually there will be an ISO on the mirrors site within few days. For now, get the ISOs from torrents located in the main page of Slackware.<br /><br />Read the <a href="http://slackware.com/announce/13.1.php">ANNOUNCEMENT</a> or the <a href="http://slackware.com/releasenotes/13.1.php">RELEASE NOTES</a> and also <a href="http://slackware.osuosl.org/slackware-13.1/CHANGES_AND_HINTS.TXT">CHANGES_AND_HINTS</a>Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-36751995894286395262010-05-02T14:28:00.000+07:002013-11-21T08:31:26.928+07:00block consecutive IP address using scriptsHow to block long list of consecutive IP address?<br />
How to call linux route command inside a script?<br />
How to block consecutive IP address using bash script or perl script?<br />
How to block local IP address permanently?<br />
<br />
The are times that a server does not need to listen and process any <b>TCP/UDP</b> request for a long list of consecutive local IP addresses.<br />
<br />
This blog entry provides a starting point of creating server scripts to block a long list of consecutive <b>IP address</b> from the server for permanent blocking.<br />
<br />
To start, launch your fave editor and create a <b>IPblock.sh</b> bash script like with contents similar to the next few lines. This blog entry assumes that you have bash shell and perl currently installed from the machine.<br />
<!-- adsense -->From below example, we are permanently <b>blocking IP address</b> from<br />
<blockquote>
192.168.0.10 to 192.168.0.254.</blockquote>
Here's a simple sample script that does the job.<br />
<blockquote>
#!/bin/bash<br />
echo Blocking started ...<br />
<br />
for ((i=10;i<=254;i=i+1)); do /sbin/route add -host 192.168.0.$i reject done echo Done</blockquote>
This can also be accomplished using perl script which does the same function. Create a separate IPblock.pl perl script like so.<br />
<blockquote>
#!/usr/bin/perl -w<br />
<br />
my $i;<br />
for ($i=10; $i<=254; $i++ ) { system ("/sbin/route del -host 192.168.0.$i reject"); } } </blockquote>
Make sure these scripts are root executable like so<br />
<blockquote>
# chmod 700 IPblock.sh<br />
# chmod 700 IPblock.pl</blockquote>
Now, to execute individually<br />
<blockquote>
# ./IPblock.sh<br />
# ./IPblock.pl</blockquote>
Additionally, the above scripts can be scheduled for regular execution if you need them so by using crontab utility.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahoXp32ZwA9tXUd8LdY1lp-jsKOBWl_dNjehWzY279ze8xVGuroBfZ-LmFL5v9lZMcN0A-Lhf8YzyInjVgvkl06XnthNTFd49O0a3ZBlYt74DxC1HjJ0bBDSI-JhXMBMuA-FNFqT5vK4/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgahoXp32ZwA9tXUd8LdY1lp-jsKOBWl_dNjehWzY279ze8xVGuroBfZ-LmFL5v9lZMcN0A-Lhf8YzyInjVgvkl06XnthNTFd49O0a3ZBlYt74DxC1HjJ0bBDSI-JhXMBMuA-FNFqT5vK4/s320/images.jpg" width="320" /></a></div>
<br />Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-20700824797202023012010-05-02T14:22:00.000+07:002013-10-22T08:18:48.350+07:00du - the disk usage linux commanddu stands for disk usage. This simple linux command provides a summary of harddisk or storage space disk usage. It has many parameter arguments that can provide results in many screen format. du command can also summarize files and directories in a recursive manner.<br />
<br />
Here are several usage of to use the du (disk usage) command.<br />
<blockquote>
# cd /home/vertito</blockquote>
<!-- adsense -->To list the files and directories from there<br />
<blockquote>
# ls -la<br />
-rw-r--r-- 1 root root 29 2007-08-11 11:57 file.txt<br />
drwxr-xr-x 2 root root 4096 2007-08-11 11:57 folder1</blockquote>
Show summary in bytes<br />
<blockquote>
# du -b<br />
4096 ./folder1<br />
8221 .<br />
# du -a<br />
4 ./file.txt<br />
4 ./folder1<br />
12 .</blockquote>
Now, let us get a more human readable results<br />
<blockquote>
# du -ah<br />
4.0K ./file.txt<br />
4.0K ./folder1<br />
12K .</blockquote>
The above shows that my file.txt has about 4K of filesize rounded to nearest power of 1024K including . an .. <br />
<br />
<blockquote>
Now, let us it in bytes<br />
# du -ab<br />
29 ./file.txt<br />
4096 ./folder1<br />
8221 .</blockquote>
The above is the same results you get from issuing ls -la command. 8221 is . and .. <br />
<br />
Now let us do it once again in human readable form<br />
<blockquote>
# du -abh<br />
29 ./file.txt<br />
4.0K ./folder1<br />
8.1K .</blockquote>
You can also exclude file glob pattern or shell expression for files like so<br />
<blockquote>
# du -abh --exclude='file.txt'<br />
# du -abh --exclude='*.txt'<br />
4.0K ./folder1<br />
8.0K .</blockquote>
Recursive directory disk usage summary can also be achieved by doing the default usage without any parameters<br />
<blockquote>
# cd /home<br />
# du</blockquote>
You can also limit the recursive search dept like so<br />
<blockquote>
# du --max-depth=2</blockquote>
which search on the 2nd level of directory only and ignores any folder found above the 2nd level folders.<br />
<br />
Getting the summarized return in a human readable form<br />
<blockquote>
# du -sh</blockquote>
Alternatively if you wish to get the last time modification<br />
<blockquote>
# du -ah --time<br />
4.0K 2007-08-11 11:57 ./file.txt<br />
4.0K 2007-08-11 11:57 ./folder1<br />
12K 2007-08-11 11:57 .</blockquote>
<br />
If you are using mbox type of mail storage handling, these commands can be handy checking and reporting partition and/or folder disk usage when incorporated inside a shell scripts. Furthermore, you can create and generate your TOP 10 users with largest mails on monthly or weekly basis that could give you more detailed email report and alerts from it.. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6yTs4dG1gXBCP-LhwhPwEVDBbBb81Ov7dtp4ExiJDwfyWSeXUpoVbHtDOTI2RjxrPR0vTke2HQGIeE-hIX9NgVXEaN0anX9J6XjeWTl7WXODMI9sPCJdUfCb4MxhxDw4qWNS8MyU_Gqk/s1600/images.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6yTs4dG1gXBCP-LhwhPwEVDBbBb81Ov7dtp4ExiJDwfyWSeXUpoVbHtDOTI2RjxrPR0vTke2HQGIeE-hIX9NgVXEaN0anX9J6XjeWTl7WXODMI9sPCJdUfCb4MxhxDw4qWNS8MyU_Gqk/s1600/images.jpg" /></a></div>
<br />
<br />
At regular interval and again using a script, you can also watch and monitor folder/partition usage changes and alerts you for certain specified thresholds like for /home or /var/ftp or /tmp.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-4233037039110876342010-05-02T14:15:00.001+07:002010-10-24T00:20:38.975+07:00Insert a file at a specific line and columnHow to insert the complete contents of a text file at a specific row and column of another text file.<br />
<br />
If we are merely concerned with inserting after a specific line, it can be readily achieved with a number of Linux tools. For example, to insert file1.txt after the second line of file2.txt, any of the following commands will do:<br />
<blockquote>$ sed -i '2r file1.txt' file2.txt<br />
$ awk '{print} NR==2 {while (getline < "file1.txt") print}' file2.txt</blockquote>Unlike the previous sed command which modifies file2 in-line, the above awk command writes the desired output to standard output only.<br />
<blockquote>$ emacs -batch +3 file2.txt --insert file1.txt -f save-buffer -kill</blockquote>This uses the batch capability of the emacs text editor. The command opens file2 at line 3, inserts file1, saves and then exits.<br />
<blockquote>$ vi +2 file2.txt << DELIM > :r file1.txt<br />
> :wq <br />
> DELIM<br />
Vim: Warning: Input is not from a terminal</blockquote>Note that after you enter the first line ("vi +2 ..."), you will be prompted for more input. At that time, you enter the next three lines (:r, :wq, DELIM)<br />
While Linux has many utilities to manipulate text (sed, perl, awk, cut, python), the easiest way I can think of to accomplish my objective to insert at a target line and column is using emacs.<br />
<blockquote>$ emacs -batch -Q +2:3 file2.txt --insert file1.txt -f save-buffer -kill 2>/dev/null</blockquote>The key is +2:3 which directs the editor to open the file at line 2 column 3. <br />
<br />
Two other components in the above emacs command warrant some explanation. First, -Q means quick startup. Quick, because emacs won't load any init file, or any splash file. Second, the last part of the command pipes any standard error output from the emacs editor to the null device.<br />
<br />
I don't doubt that sed, awk or perl can do the job. If you have a simple solution, please share with us via the comment feature of this web page. Many thanks.Moodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.comtag:blogger.com,1999:blog-7128770100706038925.post-15432379895399342952010-05-02T13:47:00.000+07:002013-12-20T07:36:49.915+07:00Keeping Command History across Multiple SessionsThe bash shell maintains a history of the commands you entered. You can re-execute a command by recalling it from the history, without having to re-type it.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhQ5mHLpBry8chkO7fkjePixXU9Tbtsoxhb_DSEjVLMpB2TuPQCgO3N2xmPJBxKAuIHUdM_pOa6mDgyDxWlMGiHyDG_C6JSi-F-1aKSjcv41n8pOxTW9fGY8YaeEzk9NyC3hgRVdKbfnk/s1600/images.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhQ5mHLpBry8chkO7fkjePixXU9Tbtsoxhb_DSEjVLMpB2TuPQCgO3N2xmPJBxKAuIHUdM_pOa6mDgyDxWlMGiHyDG_C6JSi-F-1aKSjcv41n8pOxTW9fGY8YaeEzk9NyC3hgRVdKbfnk/s320/images.png" width="320" /></a></div>
<br />
<br />
The command history is stored in a file, specified by an environment variable. <br />
<blockquote>
$ echo $HISTFILE<br />
/home/peter/.bash_history</blockquote>
The maximum number of commands that it will save depends on the value of this environment variable:<br />
<blockquote>
$ echo $HISTSIZE<br />
500</blockquote>
Life is simple if we operate on a single shell session at any given time. If you have 2 simultaneous sessions, you may be surprised that the history does not have the commands you expect.<br />
<br />
The default behavior is that the command history is saved ONLY on session exit. Moreover, the existing contents in the history are overwritten by the new contents.<br />
<!-- adsense -->Assuming you already have a session running, opening a second session will not have the latest commands from the first session. This is because the first shell hasn’t exited yet. Ultimately, the contents of the history file depends on which session exits last, hence overwriting the commands from the session that finishes earlier.<br />
<br />
This can become quite confusing.<br />
The remedy is simple. Change the history behavior as follows:<br />
Append commands to the history file, rather than overwrite it.<br />
<blockquote>
$ shopt -s histappend</blockquote>
Save each command right after it has been executed, not at the end of the session.<br />
<blockquote>
$ PROMPT_COMMAND='history -a'</blockquote>
<br />
Insert the 2 statements into ~/.bashrc<br />
<blockquote>
shopt -s histappend<br />
PROMPT_COMMAND='history -a'</blockquote>
<br />
Note: If the PROMPT_COMMAND is already initialized, then you probably want to concatenate the <br />
<blockquote>
history -a part to what is already there.</blockquote>
To determine if PROMPT_COMMAND has a value:<br />
<blockquote>
echo $PROMPT_COMMAND</blockquote>
To concenate:<br />
<blockquote>
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"</blockquote>
source: http://linuxcommando.blogspot.comMoodjairhttp://www.blogger.com/profile/04981061197793498876noreply@blogger.com