Wednesday, July 19, 2017

How to get the serial number of your network device in linux?


1. sudo lshw -C network | grep -i serial
    lshw    - Command used to list the details of all available hardware in a system.
    -C      - Option used to specify hardware "class".
        network - We asked "lshw" to list only the network devices.

    grep    - Command used to print lines that matches the given pattern
    -i    - Option used to ignore case sensitivity
    serial    - Pattern used to fetch the lines that contains the word "serial"

Example:
$sudo lshw -C network | grep -i serial
[sudo] password for :
       serial: 78:f2:9e:f3:88:e7

   
2. /sbin/ifconfig | grep -i hwaddr or sudo ifconfig | grep -i hwaddr
    ifconfig-Command used to configure network devices.
    grep    - Command used to print lines that matches the given pattern
    -i    - Option used to ignore case sensitivity
    serial    - Pattern used to fetch the lines that contains the word "serial"


Example:
$/sbin/ifconfig | grep -i hwaddr
eth0      Link encap:Ethernet  HWaddr 78:f2:9e:f3:88:e7  


3. GUI Way
Applications -> System Tools -> Settings

                                  You will land in the following screen
Settings panel



Click on Network the following window will be open


Network settings panel


The green highlighted part is our interest.




Friday, May 5, 2017

6 often needed sed scripts for string processing

1. How to remove all empty lines in a file
  sed -e '/^$/d' filename.txt

2. How to remove the leading empty spaces
  (whitespace only) -> sed -e 's/^[ ]*//' /file/path/filename.txt
  (whitespace and tab \t) -> sed -e 's/^[ \t]*//' /file/path/filename.txt

3. How to add some string to starting of all lines of a file
  sed -e 's/^/string-to-add-at-starting/g' /file/path/filename.txt

4. How to add date to starting of all lines
  sed -e "s/^/$(date) /g" /file/path/filename.txt  - Note: The Double quotes.
  Before    ->    line in a file
  After    ->    Thu May  4 17:31:58 IST 2017 line in a file

5. How to add formatted date to starting of all lines
  sed -e "s/^/$(date '+%m\/%d\/%Y %H:%M:%S') /g" /file/path/filename.txt
  Example:
   Before    ->    line in a file
   After    ->    05/04/2017 17:30:50 line in a file

6. How to do multiple replace at one go
  sed -e 's/string-to-find1/string-to-replace1/g' -e 's/string-to-find2/string-to-replace2/g' /file/path/filename.txt

Some More scripts:
7. How to remove all contents after pattern match
  sed -e '/pattern/,$d' /path-to/file/filename.txt
  For Ex: To remove all contents after first empty line -> sed -e '/^$/,$d'


8. How to remove all contents before pattern match
  sed -e '0,/pattern/d' /path-to/file/filename.txt
  For Ex: To remove all contents before first empty line -> sed -e '0,/^$/d'

Wednesday, May 3, 2017

How to create printable version of a man page..?

Most of us are always feel boring to read man pages in terminal window. what if we have a printable version of a particular command's manpage.? Nice isn't it.. so, how we can create a printable version of a manpage...

Step 1: Issue the following command in terminal
$man -t > destination_file_path.ps

Ex:$man -t mkdir > ~/Desktop/mkdir_manpage_printableversion.ps

Now you got a file named " mkdir_manpage_printableversion.ps " in your Desktop :). you can now print and use it..

Note: .ps(Postscript) is the default file type used to print.  It can be opened with any PDF viewer and can be printed.

Tuesday, March 14, 2017

How to edit/Modify/Delete Bookmarks in vinagre?


Vinagre bookmarks are stored in the file vinagre-bookmarks.xml file under /home//.local/share/vinagre directory.

As all the bookmarks are stored in single line be bit more cautious before editing, otherwise you will endup mess.
(I Recommend to keep a backup of the file before editing)

All the bookmarks are starts and ends with & xml node.  So as per your wish do edit/modify the Bookmarks.

Example entry in vinagre-bookmarks.xml file: <item><item><protocol>vnc</protocol><name>Asset-Mgmt-Client-1</name> <host>10.184.48.82</host><username></username><port>5915</port> <fullscreen>0</fullscreen><width>800</width><height>600</height> <view_only>0</view_only><scaling>0</scaling><keep_ratio>1</keep_ratio> <depth_profile>0</depth_profile><lossy_encoding>0</lossy_encoding></item>

Monday, January 16, 2017

How to fix/suppress "apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1." warning message?



Warning message Before the fix:

"apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message"


Fix: 
execute the following command in terminal

echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.conf

Now restart apache server by executing the following command

sudo /etc/init.d/apache2 restart


Message after the fix:
[ ok ] Restarting web server: apache2.

Monday, January 9, 2017

How to resolve "no suitable module for running kernel found" error in virtualbox instalation in debian linux?

1. Check wheather you machine is installed with "linux-headers-, linux-image-"
by issueing the follwing command in terminal.

  $dpkg -l | grep linux

In my case my kernel version is "3.16.0-4-686-pae" so the output of the above command would be something like as follows, 


missing-linux-headers
Missing linux headers package







If you don't find any linux-headers or linux-images then you must install them first.

2. To find the your kernel version use the following command
  $uname -a

[ My output -> Linux hostname 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux ]

now install the required packages specified in step 1.

3.  Uninstall your previous virutalbox package and reinstall it.

  $sudo apt-get remove --purge virtualbox
  $sudo apt-get instlal virtualbox

4.  Restart you machine.