Facebook

StopWatch and other Hacks




Say Yes to all confirmations


So sometimes it happens that you are installing some package or compiling some source code and it asks for your confirmation
Do you want to continue (y/n)?
 so instead of pressing 'y' everytime you just can do this



$ yes | your-command-here
and if you wants to supply 'no' then type 
$ yes  n | your-command-here
Or there is just another standard method to achieve the same
$ apt-get -y install package-name
or
$ apt-get  --yes  install  package-name
This might ask for a manual confirmation if the package signature owner's public-key is not in the keyring. To overcome this you can run below command.
$ apt-get  --yes  --force-yes  install  package-name




Share files over LAN with just one command 


So you want to share files with your friend and you don't have removable disk. Don't worry at all if you can connect with each other using LAN or WAN. Here is one liner to accomplish the task.

Open the Terminal.  Go to your directory in which all files are lying which you want to share and run this command
$ python -m SimpleHTTPServer  8888
8888 is the port. This is optional. Default port is 8000.

This will start a server on your system. To access the files on your own system type in your browser's address bar
localhost:8888 
or
Your-IP : 8888 
Now ask your friend to open the same address in his browser and He can access the files.




Stopwatch using terminal 


Want to count the seconds elapsed for some activity. Wait... no need to pull out your costly smartphone. Our terminal can do that for you.

Just type this command
$ time read
Hit enter. Hit enter again when you want to stop. And it will show you the time  elapsed between two 'enters'


Ok. Now after typing the command hit enter twice. Lets see how fast you can hit it. My best was 4 milliseconds. Lets see if you can beat me.

To know what actual purpose of 'time' command is , run this
$ man time



Well formatted mount command output


mount command is used to mount a file-system. This is what man page of mount command says about it - 
All  files  accessible  in  a Unix system are arranged in one big tree, the file hierarchy, rooted at /.  These files can be spread out over several devices. The mount command serves to attach the filesystem found on some device to the  big file  tree.  Conversely, the umount(8) command will detach it again.
but when you try to run the mount command in terminal, you find that output is not well formatted. 




So to display this output in well formatted way, try this command
$ mount | column -t
and I am sure you will love the output this time.







Connecting to a Unreachable Host


So lets say there is some Host  C which can't be reached from Host A. But if the forces are in your favor than there can be a way you might reach to Host C. 

Find a Host B which is reachable from A and Which can reach to Host C. 

Now you just need to run the below command ( You are HostA)
$ ssh  -t  HostB  ssh  HostC  
To check if HostB can be reached from your system or not, Use 'Ping command'
$ ping  IP-Address-of-HostB

Press control+c after few seconds and it will report you the packets send, packets received and packets lost.






Watch Starwars in terminal

Run this command 
telnet  towel.blinkenlights.nl



32 Bit or 64 Bit? Which one is your OS?


No need to find the system manual. Nor  you need to run some large script. Information is just 22 keystrokes away. ( How much is your typing speed, depending on that 22 keystrokes should not take more than 5 seconds )
$ getconf LONG_BIT



22 Keystrokes ???

3 for cntl+shift+t to invoke terminal
7 for getconf
1 for space
1 caps_lock
9 for LONG_BIT ( _ will take 2, shift +  - )
1 for hitting enter

And you thought 22 was just a random number.



No comments:

Post a Comment