• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Discuss

Wordpress Research & Analytic

  • Submit
  • Disclaimers
  • About
  • DMCA
  • Privacy Policy
  • Contact

April 3, 2012 by [post_author_posts_link_outside_loop] Leave a Comment

Become a Linux Terminal Power User With These 8 Tricks

There’s more to using the Linux terminal than just typing commands into it. Learn these basic tricks and you’ll be well on your way to mastering the Bash shell, used by default on most Linux distributions.

This one’s for the less experienced users – I’m sure that many of you advanced users out there already know all these tricks. Still, take a look – maybe there’s something you missed along the way.

Tab Completion

Tab completion is an essential trick. It’s a great time saver and it’s also useful if you’re not sure of a file or command’s exact name.

For example, let’s say you have a file named “really long file name” in the current directory and you want to delete it. You could type the entire file name, but you’d have to escape the space characters properly (in other words, add the \ character before each space) and might make a mistake. If you type rm r and press Tab, Bash will automatically fill the file’s name in for you.

Of course, if you have multiple files in the current directory that begin with the letter r, Bash won’t know which one you want. Let’s say you have another file named “really very long file name” in the current directory. When you hit Tab, Bash will fill in the “really\ “ part, since the files both begin with that. After it does, press Tab again and you’ll see a list of matching file names.

Continue typing your desired file name and press Tab. In this case, we can type an “l” and press Tab again and Bash will fill in our desired file name.

This also works with commands. Not sure what command you want, but know it begins with “gnome”? Type “gnome” and press Tab to see a list.

Pipes

Pipes allow you to send the output of a command to another command. In the UNIX philosophy, each program is a small utility that do one thing well. For example, the ls command lists the files in the current directory and the grep command searches its input for a specified term.

Combine these with pipes (the | character) and you can search for a file in the current directory. The following command searches for the word “word”:

ls | grep word

Wild Cards

The * character – that is, the asterisk – is a wild card that can match anything. For example, if we wanted to delete both “really long file name” and “really very long file name” from the current directory, we could run the following command:

rm really*name

This command deletes all files with file names beginning with “really” and ending with “name.” If you ran rm * instead, you’d delete every file in the current directory, so be careful.

Output Redirection

The > character redirects a command’s output to a file instead of another command. For example, the following line runs the ls command to list the files in the current directory and, instead of printing that list to the terminal, it prints the list to a file named “file1” in the current directory:

ls > file1

Command History

Bash remembers a history of the commands you type into it. You can use the up and down arrow keys to scroll through commands you’ve recently used. The history command prints a list of these commands, so you can pipe it to grep to search for commands you’ve used recently. There are many other tricks you can use with Bash history, too.

~, . & ..

The ~ character – also known as the tilde – represents the current user’s home directory. So, instead of typing cd /home/name to go to your home directory, you can type cd ~ instead. This also works with relative paths – cd ~/Desktop would switch to the current user’s desktop.

Similarly, the . represents the current directory and the .. represents the directory above the current directory. So, cd .. goes up a directory. These also work with relative paths – if you’re in your Desktop folder and want to go to the Documents folder, which is in the same directory as the Desktop folder, you can use the cd ../Documents command.

Run a Command in the Background

By default, Bash executes every command you run in the current terminal. That’s normally fine, but what if you want to launch an application and continue using the terminal? If you type firefox to launch Firefox, Firefox will take over your terminal and display error messages and other output until you close it. Add the & operator to the end of the command to have Bash execute the program in the background:

firefox &

Conditional Execution

You can also have Bash run two commands, one after another. The second command will only execute if the first command completed successfully. To do this, put both commands on the same line, separated by a &&, or double ampersand.

For example, the sleep command takes a value in seconds, counts down, and completes successfully. It’s useless alone, but you can use it to run another command after a delay. The following command will wait five seconds, then launch the gnome-screenshot tool:

sleep 5 && gnome-screenshot

Do you have any more tricks to share? Leave a comment and help your fellow readers!

READ NEXT

  • › How to Install a Video Doorbell
  • › How to Share Your Digital Photos with Your Grandparents
  • › 6 Ways to Improve Battery Life on Windows Laptops
  • › What Is the Deep Fusion Camera on the iPhone 11?
  • › How to Disable Google Chrome’s Tab Hover Cards

  • How to communicate from a Linux shell: Email, instant messaging
  • Farewell, Apple. Hello Linux Mint!
  • Should users be allowed to supply their own computers?
  • Five tips to make Nautilus file management even better
  • How to create a self-signed certificate to use on Apache2
  • Chromebooks: The smart person's guide
  • How to safely root the Verizon Samsung Galaxy S4
  • Smart TVs: Everything You Need to Know
  • Use Microsoft Remote Desktop from a Mac with CoRD
  • SolutionBase: Make image-based backups of your servers
Become a Linux Terminal Power User With These 8 Tricks have 1010 words, post on www.howtogeek.com at April 3, 2012. This is cached page on WP Discuss. If you want remove this page, please contact us.

linux terminal commands pdf, stryker power pro xt user manual, install printer on terminal server for all users, most powerful linux laptop

Primary Sidebar

RSS Recent Stories

  • How to Display Full Size Images in WordPress (4 Methods)
  • Best WordPress Themes for Dentists & Dental Clinics 2021
  • Did You Know About Reusable Blocks?
  • How to Add Your Social Media Feeds to WordPress (Step by Step)
  • What’s Coming in WordPress 5.7 (Features and Screenshots)

Sponsored Links

  • After U.S. talks, Sudan sees path to lifting sanctions soon
  • Man charged in murder of Harris County Sheriff’s deputy
  • U.S. special envoy to Ukraine resigns
  • Tesla and CEO Elon Musk violated federal labor law, judge rules
  • U.S. special envoy to Ukraine resigns amid impeachment inquiry
Copyright © 2021 WP Discuss. Power by Wordpress.