Frequently used Commands

This page will hold the commands that are frequented more often than not. This will be replacing the paper bound way of keeping the commands at one's disposal. To get the embedded cmds or code, change the input format to Full HTML and save it in that format (__Do not change the format to Filtered HTML or choosing enable or disable rich text at the bottom of the editor, if changed the color formating won't work and text will exeed the page width__) . The code or cmd is embedded in this blog using hilite.me or use me.  **To admin - don't use the Filtered HTML in input format**

<p><strong>sample text</strong></p>
and
<p>bash command embedded using hilite.me<p>

- To enable the disk drive checking

sudo touch /forcefsck

- To disable the auto disk checking Manipulate the /etc/fstab entry

ranjit@ranjit-laptop:~$ diff -uNa /etc/fstab.orig /etc/fstab
--- /etc/fstab.orig 2013-03-29 07:13:27.491336732 +0530
+++ /etc/fstab 2013-03-29 07:14:12.079332513 +0530
@@ -6,11 +6,11@@
#
# - file system - - mount point - - type - - options - - dump - - pass -
proc /proc proc nodev,noexec,nosuid 0 0
-/dev/sda1 / ext4 errors=remount-ro 0 1
+/dev/sda1 / ext4 errors=remount-ro 0 0
# /home was on /dev/sda2 during installation
-UUID=fa94d0c6-91ac-4659-b407-6d1e9591c676 /home ext4 defaults 0 2
+UUID=fa94d0c6-91ac-4659-b407-6d1e9591c676 /home ext4 defaults 0 0 

- To create a patch

diff -uNr oldfile newfile > patchfile
(or) 
diff -uprN 
where 
-u NUM: output NUM(default 3) lines of unified context 
-p: show which C function each change is in
-r: recursively compare any subdirectories found 
-N: Treat absent file as empty

- To start/stop/restart a service in ubuntu

There are different ways to accomplish this
- /etc/init.d/networking start/stop/restart 
- sudo invoke-rc.d networking start/stop/restart

- To copy the output of make cmd

make ARCH=um 2>&1 | tee build.out

- To monitor dmesg in real time

dmesg | tail -f 10 watch 'dmesg | tail -f 10' 
make use of xterm to run the dmesg cmd

To create ISO image from DVD/CD and burn ISO img to DVD in ubuntu

cat /dev/sr0 > ~/mrr/dvd1.iso 
(creates ISO img from DVD) 
- right click on the ISO image in the nautilus file browser 
- select the write to disc from the context menu

To recursively download all files from specific directory using Wget

wget -r -nH --cut-dirs=3 --no-parent http://svn.openmoko.org/trunk/src/host/devirginator/ 
where 
-r #recursively 
-nH #not save the files to hostname folder 
eg: svn.openmoko.org --cut-dirs=3 
#omit first 3 dirs 
eg: trunk/src/host --no-parent 
#Do not ascend to the parent directory when retrieving recursively

To elicit the linux distro information

Ubuntu
ranjit@ranjit-desktop:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
(0r)
ranjit@ranjit-desktop:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 12.04.2 LTS
Release:	12.04
Codename:	precise
(or)
ranjit@ranjit-desktop:~$ cat /etc/issue.net 
Ubuntu 12.04.2 LTS

Linux Kernel details

ranjit@ranjit-desktop:~$ uname -a Linux ranjit-desktop 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:15:33 UTC 2013 i686 i686 i386 GNU/Linux

Find the authoritative nameserver for a domain name

Using the following commands one can find ns for a domain name whois, dig, host, nslookup

ranjit@ranjit-desktop:~$ nslookup 
> set querytype=soa
> rang.net.au
Server:		127.0.0.1
Address:	127.0.0.1#53

Non-authoritative answer:
rang.net.au
	origin = ns1.nameserver.net.au
	mail addr = hostmaster.nameserver.net.au
	serial = 2016111407
	refresh = 10800
	retry = 3600
	expire = 604800
	minimum = 3600

Authoritative answers can be found from:
> set querytype=soa
> gnumen.org
Server:		127.0.0.1
Address:	127.0.0.1#53

Non-authoritative answer:
gnumen.org
	origin = ns3.zyxware.com
	mail addr = ranjit.tvm.gmail.com
	serial = 2016062601
	refresh = 7200
	retry = 7200
	expire = 7200
	minimum = 7200

Authoritative answers can be found from:
> set querytype=soa
> librelab.org
Server:		127.0.0.1
Address:	127.0.0.1#53

Non-authoritative answer:
librelab.org
	origin = ns1.afraid.org
	mail addr = ranjit.tvm
	serial = 1611280002
	refresh = 86400
	retry = 7200
	expire = 2419200
	minimum = 3600

Authoritative answers can be found from:
librelab.org	nameserver = ns3.afraid.org.
librelab.org	nameserver = ns1.afraid.org.
librelab.org	nameserver = ns2.afraid.org.
librelab.org	nameserver = ns4.afraid.org.
>

ranjit@ranjit-desktop:~$ dig ns rang.net.au

; <<>> DiG 9.8.1-P1 <<>> ns rang.net.au
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19737
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;rang.net.au.			IN	NS

;; ANSWER SECTION:
rang.net.au.		86400	IN	NS	ns2.nameserver.net.au.
rang.net.au.		86400	IN	NS	ns3.nameserver.net.au.
rang.net.au.		86400	IN	NS	ns1.nameserver.net.au.

;; Query time: 231 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Dec  6 19:21:50 2016
;; MSG SIZE  rcvd: 94

ranjit@ranjit-desktop:~$ dig +short SOA rang.net.au
ns1.nameserver.net.au. hostmaster.nameserver.net.au. 2016111407 10800 3600 604800 3600
ranjit@ranjit-desktop:~$

ranjit@ranjit-desktop:~$ host -t soa rang.net.au
rang.net.au has SOA record ns1.nameserver.net.au. hostmaster.nameserver.net.au. 2016111407 10800 3600 604800 3600

- To embed pdf file in gnumen.org and ncsu.librelab.org

In gnumen.org

<p>
<embed src="/sites/default/files/checklist.pdf" width="550" height="700">
</p>

In ncsu.librelab.org

<iframe src="http://gnumen.org/sites/default/files/mozilla.pdf" width="600" height="300"></iframe>