Thursday, February 3, 2011

Ubuntu commands

I am user of Ubuntu. I am writing this post to help people like me who forgets the stuff they used before.

How to check Installed Ubuntu version and its Codename
lsb_release -a

How to check Disk Space:
$ df -Th

Video editor in Ubuntu:
$ avidemux

To Upgrade Ubuntu Version Online:
Press ALT+F2 , then type "update-manager -d" without quotes and hit Enter key.


Mounting ISO image as a drive on Ubuntu:
$ sudo mount -o loop  ~/Desktop/filename.iso  /media/cdrom0


HOWTO: Move the Minimize/Maximize/Close Buttons back the Right Side
Hit ALT - F2
Type gconf-editor
Go to the following:
apps --> metacity --> general
Find the button_layout parameter, right mouse click, and select Edit Key
Change the value to the following:
menu:minimize,maximize,close
Don't forget the colon on the left side of the text. "menu" is not necessary.


To change scree resolution from Command prompt:
$ xrandr -s 1024*768


How to change MAC address of NIC card in Ubuntu:
Type following command either in /etc/rc.local file or at command prompt:

      ifconfig eth0 down
      ifconfig eth0 hw ether NEW_MAC_ADDR
      ifconfig eth0 up


Alternate way :
  1. Install "macchanger"
  $ sudo apt-get install macchanger
  2. Bring down the interface whose MAC addr you want to change
  $ sudo ifconfig eth1 down
  3. Assign random or your choice of MAC
  $ sudo macchanger -r eth1

To determine a folder's size from the command line:
$ du  -sh  "/path/to/folder"
For example, to check the size of current directory du -sh . .


To view or cancel print Job on  Unix Printer
1. Login as a user or super-user to unix computer.
2. Use "lpq -Pprinter"  command to view printer queue.
    $ lpq -Ppsc011
3. Use "lprm -Pprinter [user_id] to cancel your job
    $ lprm -Ppsc011 g0xyzqwe

 Public key error while trying to run update command
$ sudo apt-get update
gives following error :
W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D2B5F4E7C3BB95BB

Solution: Take last 8 characters in the key and run following command
$ gpg --keyserver keyserver.ubuntu.com --recv-keys C3BB95BB
$ gpg --export -armor C3BB95BB | sudo apt-key add -

To download the key on another computer and then to run on your computer :
$ gpg --keyserver keyserver.ubuntu.com --recv-keys C3BB95BB
$  gpg --export -armor C3BB95BB > key.asc

Now Copy key.asc file on your computer and run following command:
$ cat key.asc | sudo apt-key add -


To reflect the changes done in ~/.bashrc file without restarting your Terminal window:
$ source ~/.bashrc


To get Ubuntu Command prompt:
press : Ctrl + Alt + F2    or
  Ctrl  +  Alt  + F5

and to get back GUI screen (Xserver):
press:  Ctrl + Alt + F7


What to do if ubuntu hangs? Or how to restart Xserver:
press : Ctrl + Alt + Backspace
or press: Alt + Backspace
This usually restarts xserver. You need to login again to the system.

Using Bash History Effectively:
Type the following command to get a list of all related commands with their history numbers:
$ history | grep -i "search string"
Once you've found the command you want, you can execute it specifically by its number
$ !<history_command_number>


How to prevent Auto Locking the computer Screen:
1. Open file "/etc/default/acpi-support" and comment following line:

    # Comment this out to disable screen locking on resume
     LOCK_SCREEN=true

2.  Open "System > Preferences > Screen Saver" and uncheck following option:
     Lock screen when screensaver is active


How to Merge Multiple PDF files into single PDF file:
Steps:
1. Install two pacakeges GhostScript and PDFtk tools.
 $ sudo apt-get install gs pdftk

2. Use following command to combine multiple files into single PDF file. The output file name is "singleCombinedPdfFile.pdf". The input file names are all files in the current directory, bcoz we used "*.pdf".

$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH *.pdf

If you want to join PDF files in specific order then you can also use file names. 
$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH 1.pdf 2.pdf 3.pdf


Wireless Networks: "Wireless is disabled"
$ rfkill  list all
You should see both the soft blocked and hard blocked as no. If either of them is yes then the connection would not be enabled. To enable type the following:
$ rfkill unblock wifi
Hard blocked: yes
This suggests that the wireless button is not switched on.


NetworkManager UI doesn't work:
1. sudo emacs /etc/NetworkManager/NetworkManager.conf
2. Set managed=true
[ifupdown]
managed=true


How to get HostName from IP address?
 $ nmblookup -A 10.X.Y.Z


How to convert image into anotherformat using Command line and add border frame with color of your choice:
$ gm convert -mattecolor "#697B8F" -frame "6 6" k.jpg icon.png

Counter all lines of code including subdirectories:
find  .   -name   '*.c'   |   wc   -l


How to recover/reset forgotten Gnome Keyring Password?
$ rm ~/.gnome2/keyrings/login.keyring

How to find out the maximum RAM capacity and the number of RAM slots available in the Computer?
$ sudo dmidecode -t 16

To see complete memory information, including the info displayed by above command along with currently installed memory information (RAM speed, size, etc.), use:
$ sudo dmidecode -t memory

No comments:

Post a Comment