One Day One Cmd

Place for playing with commands…

Invitation to connect on LinkedIn

LinkedIn
From Balakrishnan Vijayabaskar

Project Engineer at Wipro
Chennai Area, India

I’d like to add you to my professional network on LinkedIn.

– Balakrishnan

Confirm that you know Balakrishnan
You are receiving Invitation to Connect emails. Unsubscribe
© 2013, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA

14k32x-hozqe2tv-12.gif

Advertisements

Day 69: Synchronize your PC with NTS

ODOC: If you want to set your system time accurate you have to install ntp for that. You can install it using following command, after then use any public time server to synchronize.

root@bala-desktop:~# apt-get install ntp
root@bala-desktop:~# ntpdate time.nist.gov

Some other public time servers:

pool.ntp.org

time.nist.gov

ntp.ubuntu.com

You have to stop the ntp server before doing the above things. you can do it by

root@bala-desktop:~# /etc/init.d/ntp stop
* Stopping NTP server ntpd                                              [ OK ]
Ex:
root@bala-desktop:~# ntpdate time.nist.gov
28 Mar 13:32:22 ntpdate[2632]: adjust time server 192.43.244.18 offset 0.027067 sec

With Regards,
V. Balakrishnan.

 

Day 68: $ Format Your USB stick to ext4 or FAT32

ODOC: Formatting Your pendrive or USB to Ext4 or FAT32 in 2 simple commands. 1. Identify your device path using fdisk -l command.

Ex:
root@bala-desktop:~# fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb9e8b9e8

 Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3060    24579418+   7  HPFS/NTFS
/dev/sda2            3061       19456   131700839+   f  W95 Ext'd (LBA)
/dev/sda5            3061        8159    40957686    7  HPFS/NTFS
/dev/sda6            8160       11346    25599546    7  HPFS/NTFS
/dev/sda7           13259       19456    49785403+   7  HPFS/NTFS
/dev/sda8           11347       11596     1999872   82  Linux swap / Solaris
/dev/sda9           11596       13258    13356032   83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 4016 MB, 4016046080 bytes
124 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

 Device Boot      Start         End      Blocks   Id  System

You can Identify your device with the help of your USB’s Size. Here my pendrive is memory of 4.GB note that device path for mine it is /dev/sdb. Unmount your device before proceeding this you done it by the following command.

root@bala-desktop:~# umount /media/KRISH/

2. Syntax for the command mkfs.ext4 -n “<label>” -I <device_path>
Type the following command to format as Ext4:

root@bala-desktop:~# mkfs.ext4 -n "Tux" -I /dev/sdb

Type the following command to format as fat32:

root@bala-desktop:~# mkfs.vfat -n "Tux" -I /dev/sdb

With Regards,
V.BalaKrishnan.

Day 67: $ Mounting an ISO image

ODOC: We can mount an ISO image without writing any CD/DVD. Also we can do it in two simple commands. So that we can browse for the files, incase some demo CD/DVD provides some guide to use some CD we can view it without Burn into the CD/DVD.

Step 1:
bala@bala-desktop:~$ sudo mkdir -p /mnt/isodir

In the first we are creating a directory name called isodir in mnt directory. For this we have used mkdir command.

Step 2:
bala@bala-desktop:~$ sudo mount -o loop ~/Downloads/Demo.iso /mnt/isodir

In the second step we are mounting the iso in isodir which was created before.
we can create the directory at any place as we need which is not compulsory in creating /mnt/ directory.

Day 66: $ Ctrl + R Command-line shortcut

ODOC: Ctrl+r can be used from command line this will help us to repeat any command that has been used in past very easily. After pressing this in your terminal, it will change your command prompt slightly.
Then start typing the letters of any word in the command that was issued previously. The command will be displayed at the command prompt.

Ex:
bala@bala-desktop:~$ ctrl + r
(reverse-i-search)`':
(reverse-i-search)`fr': import frame 1.jpg

Here i am searching for some command having character ‘fr’ i got it as import frame 1.ipg

Day 65: $ import -frame

ODOC:\$ import -frame Shot.png After this command, mouse pointer changes to set of cross-hairs; left-click & drag the mouse on screen to capture the required area. if you leave the mouse the selected are would be captured and saved in current location with default file name called 1.png

We can save the file as we need like .png,.jpg,etc.,

Ex:-  bala@bala-desktop:~$ import -frame new.jpg

Day 64: $ apt-get autoremove

ODOC: apt-get  autoremove <package name> autoremove option is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.

To see the difference between the remove and autoremove option just execute these 2 commands.

[1] bala@bala-desktop:~$ sudo apt-get remove vlc
[2] bala@bala-desktop:~$ sudo apt-get autoremove vlc

[1]
bala@bala-desktop:~$ sudo apt-get remove vlc
[sudo] password for bala: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libxcb-keysyms1 libcddb2 libdvbpsi5 libvlc2 vlc-nox libupnp3 libiso9660-7
 liblua5.1-0 vlc-plugin-pulse vlc-data libtar libvlccore2 libvcdinfo0
 libebml0 libmatroska0
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
 vlc
0 upgraded, 0 newly installed, 1 to remove and 178 not upgraded.
After this operation, 3,883kB disk space will be freed.
Do you want to continue [Y/n]?
[2]
bala@bala-desktop:~$ sudo apt-get autoremove vlc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
 libcddb2 libdvbpsi5 libebml0 libiso9660-7 liblua5.1-0 libmatroska0 libtar
 libupnp3 libvcdinfo0 libvlc2 libvlccore2 libxcb-keysyms1 vlc vlc-data
 vlc-nox vlc-plugin-pulse
0 upgraded, 0 newly installed, 16 to remove and 173 not upgraded.
After this operation, 37.0MB disk space will be freed.
Do you want to continue [Y/n]?

From [1] and [2] you can notice that size of package is increased when autoremove option is used it is because of removing their dependencies too. Thats the fact…

Day 63: $ apt-get remove

ODOC: apt-get  remove <package name> remove is identical to install, except that packages are removed instead of installed. Note the removing a package leaves its configuration files in system.

For Ex:
bala@bala-desktop:~$ sudo apt-get remove vlc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libxcb-keysyms1 libcddb2 libdvbpsi5 libvlc2 vlc-nox libupnp3 libiso9660-7
 liblua5.1-0 vlc-plugin-pulse vlc-data libtar libvlccore2 libvcdinfo0
 libebml0 libmatroska0
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
 vlc
0 upgraded, 0 newly installed, 1 to remove and 238 not upgraded.
After this operation, 3,883kB disk space will be freed.
Do you want to continue [Y/n]?

Info:
To Install or Remove more than one package enter the package names followed by keyword “install” as well as the “remove”.

Ex: 
bala@bala-desktop:~ sudo apt-get install vlc bpython gtk-recordmydesktop
bala@bala-desktop:~ sudo apt-get remove vlc bpython gtk-recordmydesktop

Day 62: $ apt-cache search

ODOC: apt-cache  search <related package name> Search for software packages to Debian based package management system. It will list out related words to your search.

For Ex:
bala@bala-desktop:~$ apt-cache search gammu
gammu - mobile phone management utility
gammu-smsd - SMS message daemon
geoclue-gsmloc - Position server for GeoClue (GSM)
gmobilemedia - GTK+ application used to browse a mobile phone filesystem
libgammu-dbg - mobile phone management library (debugger symbols)
libgammu-dev - mobile phone management library (development files)
libgammu7 - mobile phone management library
libgsmsd7 - SMS daemon helper library
python-gammu - Python module to communicate with mobile phones
python-gammu-dbg - Python module to communicate with mobile phones (debug version)
python-gammu-doc - Documentation for Python module to communicate with mobile phones
wammu - GTK application to control your mobile phone
libgammu-i18n - mobile phone management library (i18n files)

See this is very useful to find the perfect name of package.

Day 61: $ apt-get install

ODOC: apt-get  install <related package name> Installs software packages to Debian based package management system from Internet. Install is followed by one or more packages desired for installation. Each package is a package name, not a fully qualified filename (for instance, in a Debian GNU/Linux system, libc6 would be the argument provided, not libc6_1.9.6-2.deb). All packages required by the package(s) specified for installation will also be retrieved and installed.

Ex: 
bala@bala-desktop:~$ sudo apt-get install vlc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
 vlc-nox vlc-plugin-pulse
Suggested packages:
 mozilla-plugin-vlc videolan-doc
The following packages will be upgraded:
 vlc vlc-nox vlc-plugin-pulse
3 upgraded, 0 newly installed, 0 to remove and 236 not upgraded.
Need to get 4,454kB of archives.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]?

Here terminal window will wait for getting your acknowledgement to install the software if you press “Y” means it will starts to install if you press “N” means it will abort it.