Pygmentize Styles

2020-07-26 1 min read Learning

I have recently started using pygmentize for looking at my code in terminal. A very good and native way to do this is to use pygmentize. If you do not know about pygmentize then

Highlight the input file and write the result to . If no input file is given, use stdin, if -o is not given, use stdout.

So, you can simply pass the script or source code through pygmentize and get a lovely color output with code highlighting in the terminal and this can be very useful.

Continue reading

libvirt- Create virtual machine with text console only interface

2019-05-27 1 min read Linux Vurtualization

virt-install is an amazing tool to create VMs. If you have created a config file (Kickstart file – ks.cfg), then its only one line un-attended install. If you are using this on remote host with ssh and unluckily cannot export display – what do you do. Do a non-graphical install. There are only minor changes in the command to tell the installer that there is no graphics available and it is amazing, is it not 🙂

Continue reading

Get the information on all the rpms installed on the system

2010-07-23 1 min read Fedora Linux

Here’s a one-liner to get the info on all the packages installed on your system.

rpm -qa –info |tee All_rpms_Info

This is what it does, when you query the rpm database with the –info parameter, then the output looks something like the below, which is quite helpful.

Name        : rpm                          Relocations: (not relocatable)
Version     : 4.6.0                             Vendor: Fedora Project
Release     : 0.rc3.1.fc10                  Build Date: Sat 13 Dec 2008 12:38:24 AM IST
Install Date: Tue 13 Jan 2009 09:22:50 PM IST      Build Host: x86-5.fedora.phx.redhat.com
Group       : System Environment/Base       Source RPM: rpm-4.6.0-0.rc3.1.fc10.src.rpm
Size        : 3662666                          License: GPLv2+
Signature   : DSA/SHA1, Tue 06 Jan 2009 08:20:24 PM IST, Key ID bf226fcc4ebfc273
Packager    : Fedora Project
URL         : http://www.rpm.org/
Summary     : The RPM package management system
Description :
The RPM Package Manager (RPM) is a powerful command line driven
package management system capable of installing, uninstalling,
verifying, querying, and updating software packages. Each software
package consists of an archive of files along with information about
the package like its version, a description, etc.

Continue reading

Solaris one liners

2010-06-29 11 min read Solaris

http://www.unixguide.net/sun/sunoneliners.shtml

Unix/Solaris: One-Liners

Source: http://www.kevlo.com/~ebs/unix_commands.txt

Listed here are a bunch of unix commands.

–> change file date stamp

touch –t 199906042020 filename

–> move partitions

ufsdump 0f – /dev/rdsk/c0t0s0s0 | (cd /home; ufsrestore xv -)

–> lay down file system with 1% minfree and inode density

newfs –m1 –i81920 /dev/rdsk/c0t0d0s0

–> check file system

fsck /dev/rdsk/c0t0d0s0

Q: starting sybase

login as sybase, run: ./install/RUN_SYBASE

Q: logging in as sybase sa

isql -U sa

Continue reading

remove/replace text/path in config file.

2010-06-25 1 min read Bash

Lot of times I end up changing a particular text in config file to some other text. And when I have to do it for multiple files, all files having the text in multiple places, I end up opening the files in vim and then doing a globlal replace. But this is not efficient so I cam up with some one liners to do this for me. For removing any occurance of text in all files in the directory :

Continue reading

create SQL-statements from textfile with awk

2010-03-08 1 min read Linux

<a href="http://feedproxy.google.com/~r/Command-line-fu/~3/lz9uEhVxEEk/create-sql-statements-from-textfile-with-awk">create SQL-statements from textfile with awk

  <td>
    <div class="text codecolorer">
      $ $ awk \'{printf "select * from table where id = %c%s%c;\\n",39,$1,39; }\' inputfile.txt
    </div>
  </td>
</tr>
1

inputfile.txt is a space-separated textfile, 1st column contains the items (id) I want to put into my SQL statement.

39 = charactercode for single tick \’

    <td>
      <div class="text codecolorer">
        1 = first column
      </div>
    </td>
  </tr>
</table>

If inputfile.txt is a CSV-file separated by \”,\” use FS= to define your own field-separator:

Continue reading

Execute mysql command from shell

2010-02-04 1 min read Database

phpMyAdmin is a very slow application if you want to execute a query on your database. If you know the name of the database then any GUI tool is an overhead. So I have written a one liner shell script to do that for me 🙂

Here&#8217;s the script:

echo &#8221;select * from table where field like &#8221;%$1%&#8221;&#8221;|mysql -h doamin.com -u amit -p -D amit -r –password=hello

When run with one argument it will execute the sql query directly without asking for password also.

Continue reading
1