Recent Comments

Breaking News
Loading...

Alert

style="display:inline-block;width:468px;height:60px"
data-ad-client="ca-pub-2653565209371687"
data-ad-slot="4940986142">
Tuesday 21 January 2014

Seven Useful Tips For Linux Terminal Users

10:24
We look at some handy tips that will make your life easy while working on a Linux terminal. 

The Linux terminal has much more to offer than simply typing commands into it. You can master these tricks and become adept at using the Bash shell, which is used as default on majority of Linux distributions. So here are seven tricks that have been outlined below mainly for the less experienced users. 



1. Tab Completion – This helps in saving time and is quite useful if you are unsure about a file or a command’s precise name. For instance, if there is a file with a really lengthy name and you want to delete it, you will need to type the file name escaping the space characters properly i.e you need to (insert the \ character before each space).

If you type rm r and press Tab, the Bash will instantly fill the file’s name for you. In case of many files beginning with the letter r, Bash will not be able to identify the one you need. 

2. Pipes – This allows you to send the output of a command to a different command. According the UNIX every program is a small utility, which specializes in doing one thing. For instance, the ls command is used to list the files in the current directory and the grep command is used for searching its input for a specific term.

If you combine these with pipes then you can conduct search for a file in the current directory. 
ls | grep word

Must Check : 5 DEADLY LINUX COMMANDS

3. Wild Cards - The * character (the asterisk) is a wild card that can be used for matching anything. For instance, if you wish to delete both the long file name and we wanted to delete both the “really long file name” and “really very long file name” from the current directory, you can run the command:
rm really*name

4. Output Redirection - The > character can be used to redirect a command’s output to a file in place of another command. For instance, the line below runs the ls command to list the files in the current directory. However, in place of printing that list to the terminal, it prints the list to a file named “file1” in the current directory:
ls > file1

5. Command History – The Bash can recall a history of the commands typed into it. You can make use of the up and down arrow keys for scrolling through the commands that have been used by you recently. The history command prints out a list of these commands to pipe it to grep to search for commands used recently.
~, . & ..

The ~ character called the tilde symbolizes the current user’s home directory. In place of typing cd /home/name for going to home directory, you can type cd ~ instead.

6. Run a Command in the Background – As a standard Bash executes each command that is run by you in the current terminal. It’s okay but what about when you want to launch an application and continue using the terminal. By typing firefox for launching Firefox, this will take over your terminal and show error messages and other output till you close it. By adding the & operator to the end of the command for allowing Bash to execute the program in the background use:
firefox &

7. Conditional Execution – Bash can be used for running two commands in sequence. The second command can only be executed once the first command is completed successfully. For doing this you need to put both commands on the same line and separate it by a &&, or double ampersand.

For instance, the sleep command obtains a value in a matter of a few seconds, counts down, and completes successfully. It’s not useful by itself but can be used for running another command after a delay. The command given below will wait for five seconds and launch the gnome-screenshot tool:
sleep 5 && gnome-screenshot

0 comments:

Post a Comment

 
Toggle Footer