Showing posts with label tricks and tips. Show all posts
Showing posts with label tricks and tips. Show all posts

Tuesday 28 February 2012

Reloading The Page Using Javascript

If you wish to put a nice little Reload this page link in your page, the javascript provides a reload() method that you can use for reloading the page.

The reload() method in window.location can be used to reload the page and works well in most of the browsers. An example snippet is shown below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
 <title>Reload example</title>
 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
 <meta name="generator" content="Geany 0.20" />
</head>

<body>
 <iframe height="300" width="300" src="http://wwwindow.location.reload(true)w.google.com"></iframe>
 <a href="javascript:window.location.reload(true);">Reload this page</a>.
</body>

</html>

I hope this comes useful sometimes.


Read more...

Sunday 19 February 2012

Delete All X-Chat Logs From Ubuntu

If you want to clear all the channel and personal chat logs from the X-Chat, this is a small piece of information on how to do that. In this example, I am showing how to delete the X-chat log in ubuntu and similar distributions.

Well I connect to IRC channels so often using X-chat gnome client that my chat windows are usually filled up with older chats. Also, for some unknown reason, unchecking Log Conversations checkbox in the Edit - Preferences is not working for me. And I usually hate the old chat logs coming up and of course, due to privacy concerns, I regularly delete the channel logs of X-Chat. All the chat logs in x-chat2 are recorded in the ~/.xchat2/scrollback/ folder with network names as the sub folders. So to delete the logs, all you have to do is use the rm command as below:

rm -rf ~/.xchat2/scrollback/*

This will delete all the chat logs but in case you want to delete logs of specific networks or channel or user, just navigate to the scrollback directory and choose the network you wish to delete and issue the rm command for that network.

*Note: This little FYI guide was written by taking the version I've as the reference. Your version could even have the option for clearing the logs but I'm not aware of any such functionality in my version. I hope this helps :)


Read more...

Friday 17 February 2012

5 Cool and Useful Linux Command Line Tricks

Well using linux is fun and working on linux terminal is even more fun. Learning to use linux terminal and commands can prove very useful for personal as well as enterprise purpose. Today I'm going to talk about few cool and crazy linux commands that are less likely to be known by the average computer user.

1) The !$ trick: The !$ is a type of event designator that is present in bash as the feature. I'm not sure if other shells support it but bash does, for sure(I heard event designators are bash-specific). Anyway, !$ saves the last string from the previous command you've entered. The session in bash below shows what it actually does:

samar@Techgaun:~/Desktop$ mkdir test
samar@Techgaun:~/Desktop$ cd !$
cd test
samar@Techgaun:~/Desktop/test$

So when we give the mkdir test command, the !$ holds the value test So when we do cd !$, !$ is replaced by the string test which is the last string in last entered command.

2) The Don't Save This Command trick: Prepending your command with one or more space(<space>command) will not save the command in the bash history. This trick can be quite useful while doing password related stuffs and while sneaking in your friend's laptop.

3) The Oh! I forgot sudo trick: Well this is one of my favorite tricks and I named it so because I tend to forget to put sudo while running many commands and then I use this trick to prepend sudo at the beginning of the command. Below is the session when I used this trick recently.

samar@Techgaun:~$ cat /etc/sudoers
cat: /etc/sudoers: Permission denied
samar@Techgaun:~$ sudo !!
sudo cat /etc/sudoers
[sudo] password for samar:

*** Content Snipped to preserve length ***

As shown above, the !! is just another event designator. The !! actually holds the last used command and this can be alternatively specified as !-1. The !-1 version can be actually generalized to traverse back to history i.e. you can get any command in your history by using !-n convention.

4) The Clean up Terminal trick: Sometimes you open the binary and gibberish data and your terminal looks so ugly and needs some cleanup. In such cases, the command reset can be used which actually does is initialize the terminal.

5) Run previous command by replacing one string with another: Using the syntax ^abc^xyz^, you can run the previous command by replacing the string abc by the string xyz. The example below shows how I used the cat command after using the ls command. Its just an example, you could really make use of this trick for longer commands.

samar@Techgaun:~/Desktop$ ls /etc/hosts
/etc/hosts
samar@Techgaun:~/Desktop$ ^ls^cat^
cat /etc/hosts


Read more...

Sunday 12 February 2012

Determine All Internet Connections And Corresponding Running Processes In Linux [How To]

Sometimes you might want to see all the internet connections being made by the running processes in the linux system. I am writing this small commandline trick to view all the internet connections using the lsof command.

lsof command is used to all the open files and the processes opening those files. All kind of resources such as disk, network connections, pipes, etc. are actually implemented as files in linux and the lsof command allows you to get the report regarding the opened files.

To view all the internet connections and the corresponding processes, we can simply use the -i switch as below:

samar@Techgaun:~$ lsof -i

The above command runs fine but is a little bit slow since it tries to resolve the network addresses to host names and port numbers to port names. So you might wish to use the command below for faster response from the lsof command.

samar@Techgaun:~$ lsof -i -Pn

Also, running the lsof command as the root(i.e. sudo lsof | grep -i listen or sudo lsof -i | grep -i listen) will give more extra outputs esp. the "LISTEN" ones i.e. the processes that are listening for incoming connections. This piece of information might be useful in determining the backdoors and rootkits but I've not yet explored into that.

I hope this little trick comes useful sometimes.


Read more...

Saturday 11 February 2012

Useful Twitter Search Tips and Tricks

Lately I've been using twitter a lot and since I love to dig inside stuffs, I thought to learn what features twitter search gives to its user and I found that twitter search is also powerful and supports some handy search operators similar to google(but less than that of google). Here I will list few of the search techniques that you can employ in twitter.


Twitter's search algorithm is pretty decent and it uses an algorithm that determines the quality of the Tweet by letting users interact with it the way they normally do. Anyway lets see few search techniques that will be useful while using twitter.

a) Exact phrase search: Wrapping your search text with double quotes(eg. "cricket nepal") will let you to search for exact phrase in twitter. Note that the exact phrase search also enlists the tweets with special characters such as #, :, etc.(eg. tweets with #cricket #nepal are also seen while searching as "cricket nepal").

b) Using OR operator: OR operator allows you to search for all the tweets containing either of the keywords. An example search would be like politics OR crime.

c) Exclude tweets with certain keywords: If you want to omit the tweets containing certain words, the minus sign can be used to exclude the tweets containing those keywords. For example, the search cricket -india will exclude the tweets containing the word india(Btw, no offense meant).

d) Tweets from specific user: To view the tweets sent by someone, you can simply use the from keyword. For example, from:techgaun would list all the tweets I've sent.

e) Tweets to specific user: You can also view the tweets sent to the specific user i.e. mentions by using the to keyword. For example, to:techgaun would list all the tweets mentioning me.




f) Location based search: Twitter allows you filter your search based on the location. The near keyword can be combined with your search query which can be used to search for results near us. Example searches are near:dhulikhel and resort near:dhulikhel

g) Location + Range search: We can also search twitter within specific distance from a specific location. The within keyword can be combined with the near keyword for this kind of search. Example search queries are near:kathmandu within:10km and near:kathmandu within:10mi

h) Date based search: We can use the twitter's date based search to narrow down our search. The two keywords since and until can be used for date based search in twitter. To search all the tweets about nepal after february 01, 2012 I would do nepal since:2012-02-01 and to search all the tweets about Nepal before 2012 January, I would do nepal until:2012-01-01. For some reason, the until search does not seem to work, at least for me however twitter help shows this keyword in the list.

i) Searching tweets containing URLs: So you might want to search for the useful URLs other people tweet on the twitter. Twitter allows to do such search by using filter keyword. For example, I could find links about web development by the search query web development filter:links.

j) Searching questions: You can use twitter search to find the tweets that are questions. THe ? keyword is used for this purpose. An example search query is social media ? which would result in the tweets containing questions related to social media.

You can combine one or other search techniques to narrow down your search. Also, the advanced twitter search is available HERE. I hope this information becomes useful for you. :)


Read more...

Thursday 9 February 2012

Useful Twitter Keyboard Shortcuts

Twitter allows number of keyboard shortcuts to be used and those shortcuts are quite handy while using twitter. Those shortcuts provide easy, fast and alternative way to do different things in twitter.

Note that these shortcuts work on twitter.com website and will not work on other twitter clients(unless those clients have implemented keyboard shortcuts). I hope the keyboard shortcut lovers will definitely find this list useful. The image below lists all the possible shortcuts that can be used in twitter.



Read more...

Thursday 2 February 2012

How To View Actual Full URL Of bit.ly URLs

URL shortenings are being widely used these days however one problem with them is possibility that the actual link might be some kind of malware or spam. So it is always a good practice to know the actual URLs the bit.ly URLs are pointing to. I am writing this post to share a short tip on how to view the actual URL of bit.ly shortened URLs.

The process is pretty simple and all you have to do is add a + character at the end of the bit.ly URL and open it in the browser. For example, if I have a URL http://bit.ly/xsbGUp, I will change it to bit.ly/xsbGUp+ and open this new URL in the browser. Then I'll be able to get information regarding this particular URL including the actual long link of that shortened URL. Alternatively, you can load bit.ly/info/xsbGUp to get the same information regarding the shortened URL. I hope this post becomes useful for you. :)


Read more...

Monday 16 January 2012

Things I Use CLI Rather Than GUI For

Today I am sharing the things I do not use or do not like to use graphical user interface(GUI) instead I stick to command line. I use the following commands instead of their graphical counterpart as the command line way is faster and easier.


1) Combine MP3 files(songs)
I frequently combine mp3 files into a single one to hear what I record in my laptop. The cat command is enough to combine two or more MP3 files into a single one. Below is a sample command:

cat input1.mp3 input2.mp3 > output.mp3

2) Monitor Memory Usage
I usually find myself typing top command in the terminal instead of opening system monitor when I need to see what is clogging up my CPU. I also use powertop command to view power consumption of my laptop so that I can get suggestions to increase the battery life.

3) Resize images
This is another thing I use command line instead of GUI, for. I find using the mogrify and convert commands from imagemagick packages easier than graphical interface esp. when I need to batch resize the images to a specified size. Please refer to my blog post in these commands.

4) Video Conversion Using ffmpeg
I frequently convert the videos using the commandline ffmpeg utility. The general syntax is quite easier to remember. An example below will clarify things.

ffmpeg -i inputvideo.mp4 outputvideo.avi

Play with different video formats as per your requirement.

5) Edit Text Files
I usually find myself opening nano editor while editing the text files. Of course, using the lightweight GUI tools like gedit would be more easier and reliable. However, maybe due to the fact that I work a lot of times over SSh, I find using nano to edit textual files.

nano file.txt

6) Install Softwares and Perform Updates and Upgrades
Whenever I need to install a software, or perform updates and upgrades, I am used to with the command line apt-get utility.

Install a software package
sudo apt-get install package1 package2 ... packagen

Perform release upgrade
sudo do-release-upgrade

7) Mirror A Website
Mirroring a website is a lot easier with wget command and I frequently use this. The simplest form is as below but be sure to check the MAN page and help for wget command to know more options available.

wget -mk -w 4 http://www.site.com/

In the above example, m means mirror and k refers to local hyperlinking and w is for maintaing proper delay time so that the remote server does not get overloaded.

So these are some of the stuffs I like to do using command line rather than GUI. Share yours...


Read more...

Sunday 15 January 2012

Converting PDF Files To Text Or HTML From Linux Terminal

Earlier, we saw how we can merge or combine PDF files from terminal. Now, I am sharing two command line tools to convert PDF files to text or html files.

Poppler Utils is a great package of PDF rendering and conversion tools and should be installed before we convert PDF files to text or html files. You can install the poppler-utils issuing the following command in debian based distro. You can install them in your favorite distros using their corresponding package installers.

sudo apt-get install poppler-utils

Now that poppler-utils is installed, we will be able to convert PDF files to text and HTML using pdftotext and pdftohtml command-line tools.

PDF to Text


To convert a PDF files to text, we should use pdftotext command. Following is the simplest form of the command for converting a PDF file to text file.

pdftotext file.pdf file.txt

This command also allows you to preserve the original layout in the pdf file using the -layout switch as below:

pdftotext -layout file.pdf file.txt

Similarly, if you wish to convert pages of specific range, you can use -f and -l switches to specify the first and last page to convert to text file. An example below would clarify things where I've choosen to convert pages from 4 to 8 into text.

pdftotext -f 4 -l 8 file.pdf file.txt

Check the man page of pdftotext and also see the help for the tool to explore other options as well.

PDF to HTML


To convert a PDF file to HTML file, you can use the pdftohtml tool available in the poppler package. Before that, I will show how to use pdftotext command to convert the PDF file to HTML file.

pdftotext -f 4 -l 8 -htmlmeta file.pdf file.html

Now, using the pdftohtml tool is not that different than pdftotext. A simplest form would be as below:

pdftohtml file.pdf file.html

You can use the same arguments as in the pdftotext for this tool as well for specifying the range. However, -htmlmeta and -layout are only available in pdftotext. I would let you explore more on the pdftohtml tool.

I hope this information is useful for you. :)

Read more...

Merge/Combine PDF Documents In Linux From Terminal

Hi everybody, I was inactive for a while due to some health problems(chronic sinusitis, to be specific) and would like to apologize for not writing. This time, I am writing about how you can easily combine pdf files into a single pdf file using a linux terminal.

pdftk is a small but powerful handy PDF manipulation tool with many useful features to work with PDF files. The MAN page for pdftk says, "If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents."
You can use it to:

* Merge PDF Documents or Collate PDF Page Scans
* Split PDF Pages into a New Document
* Rotate PDF Documents or Pages
* Decrypt Input as Necessary (Password Required)
* Encrypt Output as Desired
* Fill PDF Forms with X/FDF Data and/or Flatten Forms
* Generate FDF Data Stencils from PDF Forms
* Apply a Background Watermark or a Foreground Stamp
* Report PDF Metrics such as Metadata and Bookmarks
* Update PDF Metadata
* Attach Files to PDF Pages or the PDF Document
* Unpack PDF Attachments
* Burst a PDF Document into Single Pages
* Uncompress and Re-Compress Page Streams
* Repair Corrupted PDF (Where Possible)

Today I'll show you how to combine or merge two or more pdf documents to a single PDF document using this tool. Navigate to the folder containing the PDFs you want to merge and then type the following command:

pdftk *.pdf cat output outputfile.pdf

The above command will take the PDF files in the alphabetical order and if you want to have your own order of the PDFs, say for an example, I have two PDFs a.pdf and b.pdf and I want pages from b.pdf to appear before a.pdf then I would simply do:

pdftk b.pdf a.pdf cat output outputfile.pdf

The pdftk is not limited to this simple merging method only, it has very powerful capabilities for merging documents. Below is an example of how I merged page 1-5 of first pdf and 10-15 of another pdf.

pdftk A=a.pdf B=b.pdf cat A1-5 B10-15 output outputfile.pdf

Below example shows how I can merge even pages from first pdf and odd pages from second pdf.

pdftk A=a.pdf B=b.pdf cat Aeven Bodd output outputfile.pdf

You can make numerous other variations and looking the MAN page for pdftk would be a good idea to explore more options. So why would we need heavy graphics based PDF editor when things can be done by a small commandline utility like pdftk.

I hope this post is useful to you. :)


Read more...

Saturday 31 December 2011

Details On The CON Issue In Windows

We can not create a folder with its name as "Con" in windows and many people are unaware of this fact and the reason behind this. So I am here to clarify everything about the CON issue in windows. I will also discuss about the way to create such folders in windows.

If you haven't tried yet, try creating the folder with the name con and you will find that the folder can not be renamed to con. This is not the only name that shows such unique behavior. Other such names that can not be the name of folders are CON, PRN, AUX, CLOCK$, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9(list taken from Wikipedia).

These words are the reserved words and date back to old MS-DOS days. These names were reserved for MS-DOS device files and hence to prevent any kind of ambiguity, these names are not allowed for normal files and folders.

But there's way. Now comes the role of Universal Naming Convention(or Uniform Naming Convention) commonly known as UNC which specifies a common syntax to describe the location of a network resource, such as a shared file, directory, or printer.

The UNC syntax for windows system is as below:

\\ComputerName\SharedFolder\Resource

You can read about UNC in the wikipedia entry.

UNC was introduced after the introduction of MS-DOS so MS-DOS systems do not understand the UNC naming i.e. it is not backward compatible to MS-DOS. That said, we can create folders with special names in our local system using the UNC syntax. The single dot (.) is used to indicate the local system as per the UNC definition.

Now to create a folder with any of the reserved words, we will use mkdir command. For example, to create a CON folder in my friend's laptop's Desktop folder, I typed the following command in the command prompt.

mkdir \\.\C:\Users\suman\Desktop\con

This creates a con folder in our desktop. Now try to delete it using GUI or from command prompt by issuing rmdir con command. It will give you an error. So to delete the folder, you can use the same UNC syntax as below:

rmdir \\.\C:\Users\suman\Desktop\con

On issuing this command, your con folder should be gone. You can try the same with the other reserved file names. Also, check the following screenshots for clarity.




Some of you might think Whats the use of all this stuff?: I don't know if there's any serious use of this stuff but its kinda cool to know these kind of stuffs for tech-freaks. If there can be any good use of this trick, please share over here. I hope this stuff is useful. Happy New Year 2012 :)


Read more...

Friday 30 December 2011

Download Your Facebook Information [How To]

Well you might want to download your facebook information as an offline archive just like you would like to have backup of your other information. In this How To, I am sharing a helpful information on how you can backup your facebook information easily.

You can download following information from your facebook profile.
- Any photos or videos you've shared on Facebook
- Your Wall posts, messages and chat conversations
- Your friends' names and some of their email addresses

1) Login to your facebook account.

2) Click on Account option on the right top corner of your facebook page and then click on Account Settings from the dropdown menu.




3) Now click on the Download a copy link.





4) On the next page, click on the Start My Archive button.




5) A new pop-up will appear and again click on the Start My Archive button from the pop-up.




6) You will receive an email when your archive is ready for download. This may take some time. You can check your inbox later to view and download the archive containing your facebook information.

For more information about downloading information, check the Facebook Help page.

I hope it becomes useful for you. :)


Read more...

[FIX] Android XML Layout and Resource Design View Not Working In Eclipse

Hi sometimes XML views for your layouts and resources such as strings do not appear in the design view and you might be getting frustrated why this is happening. This post mentions a quick tip on how you can regain your original XML layout and/or resource design views.

The trick is simple. All you have to do is right click the layout or resource file in the "Package explorer" and then use the option "Open With" to open the file with the correct editor. In case of XML layouts, choose the Layout Editor option and in case of XML resources like strings, choose the Resource Editor option. Eclipse automatically saves your last choice so everything should work fine after doing these steps. I hope it comes useful sometimes. :)


Read more...

Thursday 29 December 2011

How To Get Timeline In Your Facebook Profile

Earlier, many people were wondering how can they get timeline for their facebook page when they were helping us with votes in the library so I thought why not make a blog post so that it would help people out there to get the timeline feature in their profile.

What is timeline?: Who would better explain than facebook itself regarding its feature... Read about timeline.

Now to get timeline, go to Introducing Timeline page and if you are not already using timeline, a bottom footer will appear with the Get Timeline button at the right side.





All you have to do is click on that link to get timeline for your facebook. Timeline will be activated and you will be redirected to your timeline. I hope this helps you. :)


Read more...

Wednesday 28 December 2011

Adding Regular User To Sudoers File In Linux

Hi everybody, this time I am writing about the different command line methods of adding regular user to the sudoers file in linux or in more obvious way, giving access to root privilege to certain regular users. The sudoers file(located at /etc/sudoers by default[in my distro i.e. ubuntu]) contains the information of groups and users who can execute commands with root privilege. I'll list 3 ways of adding users to the sudoers list so continue reading the post.

Method 1
The first way is to use the usermod command to append the user to the admin group. Since the admin group has the privilege of executing commands with sudo privilege, adding the user to the admin group is one easy way to add regular user to the sudoers file. The example command is as below(Replace user with the proper username which you want to add to sudoers list):

sudo usermod -a -G admin user

Method 2
This method is similar as above however the command is adduser this time and the command is even more simpler to remember. Just specify the respective user to be added to the admin group as below:

sudo adduser user admin

Method 3
The last method I'm writing about is the safe way of editing sudoers files. Linux advises to use visudo command to edit /etc/sudoers so that possible errors while writing in sudoers file can be avoided. Typing just visudo would open the /etc/sudoers file for editing, and in case, if you want to edit sudoer file in alternate location, type visudo -f sudoer_with_path. Anyway, to add new user to the default sudoers file, type sudo visudo and add the line as below(Replace user with the proper username to whom you want to give sudo privilege) at the end of file:

user ALL = (ALL) ALL

I hope these methods come useful for you.


Read more...

Saturday 24 December 2011

Hiding Information In Text Files Using Notepad [Windows]

Hi everybody, I had long ago read about hiding information inside text files using notepad and today I suddenly remembered while doing some other task. So I am sharing this little trick of hiding information inside the text file using notepad.

Open command prompt (Run-> Cmd) and then navigate to the directory (using cd command) where you want to save your text file. Now, type the following command:

notepad file.txt:mypassword


Replace filename part and password with yours as shown in the screenshot above and then you will be asked if you wish to create a new file or not(See the screenshot below) and then click on Yes to create the file.



Now enter your secret information in the file and save the file. Close the file and if you need to access the contents later, you will have to use the exact command you used while creating the file. If you or someone else edits your file without giving the password, your original hidden content will not be erased and you can still access the content with your original command.

I hope this trick is new for you. :)


Read more...

Thursday 22 December 2011

First Thing To Try When Encountered An Odd Error In Eclipse

Hi everybody, this is always worth trying when you encounter some unknown and odd error while developing applications with Eclipse IDE. You may encounter errors even though every line of your code is syntactically correct and still you can't find what exactly is the error. Sometimes you might spend hours trying to find error but actually there might be no error in your application.

To clean the current project in Eclipse, go to Project -> Clean and it will clean all the compiled stuffs and will give you a fresh start for the compilation. Keep in mind this little trick and you might find useful several times while you are working on Eclipse.


Read more...

Sunday 18 December 2011

Copying Files From Remote Server Using SCP In Linux

Hi everybody, sometimes you need to copy files from remote server and only thing you have access to might be SSh. If you can access remote server via SSh, then you can copy files from the remote server using scp(secure file copy). This short tip will help you copy files from remote server using scp.

Scp is remote secure file copy program that makes use of SSh for the data transfer and uses the SSh authentication. The general syntax is as below:

scp -P ssh_port user@server:remote_file_path local_file_path

Following was the command I used to copy a file from remote server to my computer. It will then ask for the password for the corresponding user before you can copy the file.

scp -P 222 netadmin@192.168.0.1:/home/kubh/Desktop/torrent_trackers_list.txt /samar/torrent_trackers.txt

Also, there are GUIs for this purpose as well such as WinSCP for windows and Krusader file manager and gftp for linux distros. GUI would make things easier but still I am used to with command lines and I hope you are as well.

I hope this helps. :)

Edit(Dec 19): Paths with whitespaces must be escaped with \ character. An example of this is as below:

samar@Techgaun:~$ scp -P 222 "netadmin@192.168.0.1:/home/netadmin/Downloads/Hostel\ Part\ III\ \(2011\)\ DVDRip\ 400MB/HOST.DVD_urgrove.com.mkv.002" /samar/Moviez/Hostel1.mkv.002

Read more...

Friday 16 December 2011

Useful Aliases To Make Things Easier In Linux

In this post we will see some of the useful aliases that I have made to work faster while I'm working in my system. From that, you can figure out such useful aliases for yourself. With this little customization, you will find so much ease and speed in doing different tasks you need to perform repeatedly.


Either you are a regular linux user or system administrator or tech-geek, you will want to make use of alias to makes several things shorter and easier.

Temporary aliases can be created using the alias command in the terminal. So to test the aliases I've posted below, you can type them in the terminal to see the effect temporarily. If you want to make aliases permanent, you can edit ~/.bashrc file and add those aliases inside this file. Even better, to separate aliases from the .bashrc file, you can put all your aliases by creating a new file ~/.bash_aliases and paste all your aliases in this file. Either way, you'll achieve the permanent aliases for yourself and you'll be finding things going easy and fast for you.

Quick Directory Jumps

alias www='cd /opt/lampp/htdocs/' #Navigating to my web root using www command(actually alias)
alias moviez='cd /samar/data/gallery/movies/' #Navigating to my movies folder by typing moviez

Getting out from deep directory structure

alias cd1='cd ..'
alias cd2='cd ../..'
alias cd3='cd ../../..'
alias cd4='cd ../../../..'
alias cd5='cd ../../../../..'
alias cd6='cd ../../../../../..'


The above aliases can help you while you are inside deep directory structure and want to get out to certain outer level in the same structure.

Shortcuts To Frequently Used Commands

alias runlampp='sudo /opt/lampp/lampp start' #run lampp server bundle
alias stoplampp='sudo /opt/lampp/lampp start' #stop lampp server bundle
alias checkmail='grep -in "Subject:" /var/mail/$USER' #overview of mail
alias myserverlogin='ssh netadmin@192.168.0.1 -p 222 -X' #ssh login to server
alias rootnaut='sudo nautilus /' #open root nautilus file explorer

With this post, what I would like to say is that there is no limit in making these aliases, eventually you will find the necessary aliases for yourself. If you have any other useful general purpose aliases, please feel free to share as the comment.

Read more...

Fast Switching To Previous Directory In Linux Terminal

I had a scenario in which I had to switch between two directories frequently while I was working on the remote server over SSh. Typing the directory paths frequently was getting so tedious that I had to know some way to switch between two directories with a single short command. Here is a small tip that will be useful in such cases.

I am presenting my scenario and you'll be able to adapt with your own scenario. So following are two directories I keep on working always.

/opt/lampp/htdocs/
and
~/gateway/bandMan/

So I have the scenario something like below.

cd /opt/lampp/htdocs/

I cd to the first directory with the command above and then perform series of numerous commands and then suddenly I've to go back to the second directory. And I do so by following command:

cd ~/gateway/bandMan/

Again, after changing the directory, I perform several commands and after finishing my tasks on this folder, I need to switch back to previous directory. And I type the following command:

cd -

How it works
This information is for the tech enthusiasts who like to know how it works. When I navigate to another directory from the shell for the first time, a new environment variable OLDPWD is set which stores the path for previous directory before the last cd command was executed. Now what cd - does is switch to the path that OLDPWD variable is storing. If OLDPWD is empty, you will see the "bash: cd: OLDPWD not set" error.

Isn't it so simple? I hope you like this small tip. :)


Read more...