Some useful Linux Hacks

3.8

Linux is the best-known and most-used open source operating system. As an operating system, Linux is software that sits underneath all of the other software on a computer, receiving requests from those programs and relaying these requests to the computer’s hardware.

For the purposes of this page, we use the term “Linux” to refer to the Linux kernel, but also the set of programs, tools, and services that are typically bundled together with the Linux kernel to provide all of the necessary components of a fully functional operating system. Some people, particularly members of the Free Software Foundation, refer to this collection as GNU/Linux, because many of the tools included are GNU components. However, not all Linux installations use GNU components as a part of their operating system. Android, for example, uses a Linux kernel but relies very little on GNU tools.

Here are some of my favorites LINUX HACKS (in no particular order) :

    1. Paste Code: Directly paste any code/text into terminal use Ctrl + Shift + v
    2. Sharing Server:  You can make a quick HTTP server for sharing in Python 2 using following command:
      python -m SimpleHTTPServer
    3. Increase Speaker Volume: Increase the maximum volume of your speakers by a certain percentage (150 in this case) :
      pactl set-sink-volume 0 150%
    4. Fortune Messages: Make your terminal output you random fortune messages. On a ubuntu system do:
      sudo apt-get install fortune

      and add fortune to the last line of your .bashrc if you are using Bash (default in my linux distros ). If you love cows then you can install cowsay pipe the output of fortune to cowsay , add following line to the end of your .bashrc

      fortune | cowsay
    5. Starwars: Want to watch StarWars in terminal ? Just type:
      telnet towel.blinkenlights.nl
    6. Shorten Lengthy Command: Have a lengthy command and want to short it down ? Use aliases
      Add all aliases to your .bashrc so that they remain permanent. Like we used sudo apt-get install to install packages we can slim it done by defining an alias in our bashrc like

      alias install = 'sudo apt-get install'

      After saving the file and restarting the terminal you can do things like

      install cowsay fortune figlet

      instead of typing

      sudo apt-get install fortune figlet cowsay

      You can do it for many commands with the syntax  alias short-name=’long command’.
      # Notice there is no space between long command and equal sign ( = ) Plus some commands are pre-aliased like la is an alias for ls -a. You can this out by typing la in your terminal .

    7. Ping and traceroute together: Want to ping and traceroute/tracert at the same time. Use mtr
      Install it with

      sudo apt-get install mtr

      or if you aliased the command use install mtr .
      Usage mtr

    8. Download files: Want to download files with a specific pattern like:
      File1 at http://example.com/files/file1.zip
      File2 at http://example.com/files/file2.zip
      Use wget ( comes pre-installed on most distros ) as following

      wget Page on example.com

      Wget can be used for crawling and other awesome automated stuff.

    9. Download accelerator: Want a stable download accelerator use axel?
      Install with sudo apt-get install axel
      use as follows

      axel -a
    10. Enable Scroll lock: Scroll Lock is disabled by default in Linux Distros. Even though the Scroll Lock doesn’t serve much of a purpose in the modern day applications. But still we might need it for some purposes like toggling the back light on our illuminated keyboards. To enable scroll lock
      xmodmap -e 'add mod3 = Scroll_Lock' link
    11. Download files using the command line : This one is pretty common. wget is used to download files using the command line via HTP, HTTPS and FTP.
      wget file.link
      where file.link is the link from where the file has to be downloaded.
    12. Download YouTube videos: You can also download YouTube videos straight from the command line using a package by the name of youtube-dl. First install the package using apt-get or pip
      sudo apt-get install youtube-dl
      OR
      sudo pip install youtube-dl

      Your package is ready to be used. You can now use it to download videos

      youtube-dl Youtube-link
    13. Change terminal look and feel: If you want to edit the way your terminal looks, or the font sizes and other features. You have two options. gsettings or dconf. In layman terms gsettings uses the command line whereas dconf uses a GUI called dconf-editor. First we need to install dconf.
      sudo apt-get install dconf-tools
      dconf-editor
    14. Be a bond: You want to look like a badass hacker ? (Kind of)
      Install hollywood, your terminal will split and look like you’re doing a lot of cool things

      sudo apt-add-repository ppa:hollywood/ppa
      sudo apt-get update
      sudo apt-get install hollywood
      sudo apt-get install byobu #Used to split your terminal, very useful

      Launch byobu then hollywood (just type byobu and hollywood)

    15. Current Weather: What about the knowing the current weather of any city around the world.
      In your terminal, just type:

      curl http://wttr.in/your_city_name

      and voila, weather for next 3 days displayed elegantly in your terminal.

    16. Same command at same time: Want to run a command you ran yesterday at a point of time?
      Try Ctrl-R(recursive search) and then type a subset of characters in your command and boom you accessed a recent history without pressing key many times.

    Thanks..

    This article is contributed by Vikas Acharya. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

    GATE CS Corner    Company Wise Coding Practice

Recommended Posts:



3.8 Average Difficulty : 3.8/5.0
Based on 10 vote(s)










Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.