Alok's Blog

Linux Quick reference

1. Find which Debian or ubuntu Linux Version you are running

Ans :
cat /etc/issue
or lsb_release -a
or cat /etc/lsb-release


2. How to find motherboard (Hardware) Information
Ans :  Find man dmidecode for more info
# dmidecode –type baseboard  (debian)


3. removing previous ethernet card entry from system
Ans: edit the following file
# vi /etc/udev/rules.d/70-persistent-net.rules


4. Mounting  .iso files in a dir
#mount -o loop -t iso9660 sourse.iso dest_dir/


5. Monitor bandwidth on your linux Box

Ans iftop is a great tool for monitoring bandwidth

$sudo iftop -i eth0 -B -m 10M

#iftop -i eth0 -B -m 10M


6. Packet loss monitoring Linux 

Ans. One of the monitoring tool is mtr, It is GUI tool is vety useful for live packet loose monitor


Q. How can I compress a whole directory under Linux / UNIX using a shell prompt?

A. It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
=> Create the archive
=> Compress the archive

You need to use tar command as follows (syntax of tar command):
tar -zcvf archive-name.tar.gz directory-name

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

For example, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog

Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):
$ tar -zxvf prog-1-jan-2005.tar.gz


  • -x: Extract files

If you wish to extract files in particular directory, for example in /tmp then you need to use following command:
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -

* To extract a tar.bz2 file, use the command

$tar -jxvf filename.tar.bz2


Q.Some uses of gzip

A. Compress a file in .gz format

$ gzip -c xya.tar > xyz.tar.gz

** without decompressing any file, read the file and count the line number

$gunzip -c xyz.gz | grep “/srting/” | wc -l


Q. How to add Virtual NIC Interface in Linux 

A. Add the below line in the /etc/network/interface file

#vi /etc/network/interface

auto eth0:1
iface eth0:1 inet static

Then restart networking interface

# /etc/init.d/networking restart


Q. How to check total memory (RAM & SWAP)details on Linux


$ free -mto

             total       used       free     shared    buffers     cached
Mem:           438        426         12          0          0         88
Swap:         1906        291       1615
Total:        2344        717       1627
Q. Copying File or Folder with its Original Attribute using scp and rsync
A. Here are the important switch for scp
-p      Preserves modification times, access times, and modes from the original file.

-r      Recursively copy entire directories.  Note that scp follows symbolic links encountered in the tree traversal.
-v      Verbose mode.  Causes scp and ssh(1) to print debugging messages about their progress.  This is helpful in 
        debugging connection, authentication, and configuration problems.

$ scp -prv

Using rsync Command 
 --progress              show progress during transfer

 -v, --verbose               increase verbosity

 -r, --recursive             recurse into directories
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
 -u, --update                skip files that are newer on the receiver
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
rsync --progress -vaur --rsync-path=/usr/local/bin/rsync --rsh=ssh .

Q. http/https tunneling using SSH
$ssh -L user@computer -N
-L - port forwarding parameters (see below)
localport - local port (chose a port that is not in use by other service)
host - server that has the port (hostport) that you want to forward
hostport - remote port
-N - do not execute a remote command, (you will not have the shell, see below)
user - user that have ssh access to the ssh server (computer)
ssh_server - the ssh server that will be used for forwarding/tunneling 

Without the -N option you will have not only the forwardig port but also the remote
 shell. Try with and without it to see the difference. 

This example (see above) show you how to setup your ssh tunnel for web. It is useful to use http/https 
when you don't have direct access to the http server.
For the ASCII art and lynx browser fans here is illustrated the first example: 

   +----------+<--port 22-->+----------+<--port 80-->o-----------+
   |SSH Client|-------------|ssh_server|-------------|   host    |
   +----------+             +----------+             o-----------+
  localhost:8888              computer 

...And finally: 
Open your browser and go to http://localhost:8888 to see if your tunnel is working.
That's all folks! 


Install Nvida driver in Ubuntu 
1st Lost the driver details

# lspci -vvnn


01:00.0 0300: 10de:01d3 (rev a1) (prog-if 00 [VGA controller])

Subsystem: 1458:3470
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 16
Region 0: Memory at d1000000 (32-bit, non-prefetchable) [size=16M]
Region 1: Memory at c0000000 (64-bit, prefetchable) [size=256M]
Region 3: Memory at d0000000 (64-bit, non-prefetchable) [size=16M]
Expansion ROM at <unassigned> [disabled]
Capabilities: [60] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [78] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <256ns, L1 <4us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <256ns, L1 <4us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 128 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x16, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
Capabilities: [128 v1] Power Budgeting <?>
Kernel driver in use: nvidia
Kernel modules: nvidia_current, nouveau, nvidiafb

Or Use hwinfo (install it before if it is not there )



34: PCI 100.0: 0300 VGA compatible controller (VGA)
[Created at pci.318]
Unique ID: VCu0.YaAcwfh0Td3
Parent ID: vSkL.YpBKmP1197E
SysFS ID: /devices/pci0000:00/0000:00:01.0/0000:01:00.0
SysFS BusID: 0000:01:00.0
Hardware Class: graphics card
Model: “nVidia GeForce 7300 SE”
Vendor: pci 0x10de “nVidia Corporation”
Device: pci 0x01d3 “GeForce 7300 SE”
SubVendor: pci 0x1458 “Giga-byte Technology”
SubDevice: pci 0x3470
Revision: 0xa1
Driver: “nvidia”
Driver Modules: “nvidia”
Memory Range: 0xd1000000-0xd1ffffff (rw,non-prefetchable)
Memory Range: 0xc0000000-0xcfffffff (ro,non-prefetchable)
Memory Range: 0xd0000000-0xd0ffffff (rw,non-prefetchable)
IRQ: 16 (67566 events)
I/O Ports: 0x3c0-0x3df (rw)
Module Alias: “pci:v000010DEd000001D3sv00001458sd00003470bc03sc00i00”
Driver Info #0:
XFree86 v4 Server Module: nv
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #13 (PCI bridge)


Now install the nvida driver from nvida repo


sudo apt-add-repository ppa:ubuntu-x-swat/x-updates

sudo apt-get update

sudo apt-get install nvidia-current



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at