Some useful Linux Hacks

26 Sep, 2017
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) :
Paste Code: Directly paste any code/text into terminal use Ctrl + Shift + vSharing Server:  You can make a quick HTTP server for sharing in Python 2 using following command:python -m SimpleHTTPServerIncrease Speaker Volume: Increase the maximum volume of your speakers by a certain percentage (150 in this case) :pactl set-sink-volume 0 150%Fortune Messages: Make your terminal output you random fortune messages. On a ubuntu system do:sudo apt-get install fortuneand 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 .bashrcfortune | cowsayStarwars: Want to watch StarWars in terminal ? Just type:telnet towel.blinkenlights.nlShorten Lengthy Command: Have a lengthy command and want to short it down ? Use aliasesAdd 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 likealias install = 'sudo apt-get install'After saving the file and restarting the terminal you can do things likeinstall cowsay fortune figletinstead of typingsudo apt-get install fortune figlet cowsayYou 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 .Ping and traceroute together: Want to ping and traceroute/tracert at the same time. Use mtrInstall it withsudo apt-get install mtror if you aliased the command use install mtr .Usage mtrDownload files: Want to download files with a specific pattern like:File1 at http://example.com/files/file1.zipFile2 at http://example.com/files/file2.zipUse wget ( comes pre-installed on most distros ) as followingwget Page on example.comWget can be used for crawling and other awesome automated stuff.Download accelerator: Want a stable download accelerator use axel?Install with sudo apt-get install axeluse as followsaxel -aEnable 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 lockxmodmap -e 'add mod3 = Scroll_Lock' linkDownload 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.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 pipsudo apt-get install youtube-dl
OR
sudo pip install youtube-dlYour package is ready to be used. You can now use it to download videosyoutube-dl Youtube-linkChange 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-editorBe 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 thingssudo 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 usefulLaunch byobu then hollywood (just type byobu and hollywood)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_nameand voila, weather for next 3 days displayed elegantly in your terminal.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.My Personal Notes
arrow_drop_upSave
Paste Code: Directly paste any code/text into terminal use Ctrl + Shift + vSharing Server:  You can make a quick HTTP server for sharing in Python 2 using following command:python -m SimpleHTTPServerIncrease Speaker Volume: Increase the maximum volume of your speakers by a certain percentage (150 in this case) :pactl set-sink-volume 0 150%Fortune Messages: Make your terminal output you random fortune messages. On a ubuntu system do:sudo apt-get install fortuneand 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 .bashrcfortune | cowsayStarwars: Want to watch StarWars in terminal ? Just type:telnet towel.blinkenlights.nlShorten Lengthy Command: Have a lengthy command and want to short it down ? Use aliasesAdd 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 likealias install = 'sudo apt-get install'After saving the file and restarting the terminal you can do things likeinstall cowsay fortune figletinstead of typingsudo apt-get install fortune figlet cowsayYou 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 .Ping and traceroute together: Want to ping and traceroute/tracert at the same time. Use mtrInstall it withsudo apt-get install mtror if you aliased the command use install mtr .Usage mtrDownload files: Want to download files with a specific pattern like:File1 at http://example.com/files/file1.zipFile2 at http://example.com/files/file2.zipUse wget ( comes pre-installed on most distros ) as followingwget Page on example.comWget can be used for crawling and other awesome automated stuff.Download accelerator: Want a stable download accelerator use axel?Install with sudo apt-get install axeluse as followsaxel -aEnable 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 lockxmodmap -e 'add mod3 = Scroll_Lock' linkDownload 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.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 pipsudo apt-get install youtube-dl
OR
sudo pip install youtube-dlYour package is ready to be used. You can now use it to download videosyoutube-dl Youtube-linkChange 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-editorBe 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 thingssudo 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 usefulLaunch byobu then hollywood (just type byobu and hollywood)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_nameand voila, weather for next 3 days displayed elegantly in your terminal.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.
Paste Code: Directly paste any code/text into terminal use Ctrl + Shift + v
Sharing Server:  You can make a quick HTTP server for sharing in Python 2 using following command:python -m SimpleHTTPServer
python -m SimpleHTTPServer
Increase Speaker Volume: Increase the maximum volume of your speakers by a certain percentage (150 in this case) :pactl set-sink-volume 0 150%
pactl set-sink-volume 0 150%
Fortune Messages: Make your terminal output you random fortune messages. On a ubuntu system do:sudo apt-get install fortuneand 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 .bashrcfortune | cowsay
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
Starwars: Want to watch StarWars in terminal ? Just type:telnet towel.blinkenlights.nl
telnet towel.blinkenlights.nl
Shorten Lengthy Command: Have a lengthy command and want to short it down ? Use aliasesAdd 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 likealias install = 'sudo apt-get install'After saving the file and restarting the terminal you can do things likeinstall cowsay fortune figletinstead of typingsudo apt-get install fortune figlet cowsayYou 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 .
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 .
Ping and traceroute together: Want to ping and traceroute/tracert at the same time. Use mtrInstall it withsudo apt-get install mtror if you aliased the command use install mtr .Usage mtr
sudo apt-get install mtr
or if you aliased the command use install mtr .Usage mtr
Download files: Want to download files with a specific pattern like:File1 at http://example.com/files/file1.zipFile2 at http://example.com/files/file2.zipUse wget ( comes pre-installed on most distros ) as followingwget Page on example.comWget can be used for crawling and other awesome automated stuff.
wget Page on example.com
Wget can be used for crawling and other awesome automated stuff.
Download accelerator: Want a stable download accelerator use axel?Install with sudo apt-get install axeluse as followsaxel -a
axel -a
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 lockxmodmap -e 'add mod3 = Scroll_Lock' link
xmodmap -e 'add mod3 = Scroll_Lock' link
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.
wget file.link
where file.link is the link from where the file has to be downloaded.
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 pipsudo apt-get install youtube-dl
OR
sudo pip install youtube-dlYour package is ready to be used. You can now use it to download videosyoutube-dl Youtube-link
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
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
sudo apt-get install dconf-tools
dconf-editor
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 thingssudo 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 usefulLaunch byobu then hollywood (just type byobu and hollywood)
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)
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_nameand voila, weather for next 3 days displayed elegantly in your terminal.
curl http://wttr.in/your_city_name
and voila, weather for next 3 days displayed elegantly in your terminal.
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.
linux-command
Linux-Unix
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.