Linux 101 Hacks – Download Free eBook

by Ramesh Natarajan on February 12, 2009

I’m happy to announce the release of my first Free eBook — Linux 101 Hacks. There are total of 101 hacks in this book that will help you build a strong foundation in Linux. All the hacks in this book are explained with appropriate Linux command examples that are easy to follow.

This free eBook contains 12 chapters with total of 140 pages. Hacks mentioned in 6 chapters are based on the articles that I’ve already posted on my blog. Hacks mentioned in rest of the 6 chapters are brand new.

If you like this eBook, please submit this post to your favorite social-media sites and spread the news.

“Another collection of hacks? Yes! If you have just completed your first admin course or looking for better ways to get the job done the “Linux 101 Hacks” eBook is a good point to start. These useful tips are concise, well written and easy to read.

Well done – I will recommend this eBook to my students.”

– Prof. Dr. Fritz Mehner, FH Südwestfalen, Germany

(Author of several awesome Vim plugins, including bash-support Vim plugin)

Download Free eBook

Download Free eBook: Linux 101 Hacks
Password: To get the password, follow these 3 easy steps.

Linux 101 Hacks – Table of Contents

Chapter 1: Powerful CD Command Hacks

  • Hack 1. Use CDPATH to define the base directory for cd command
  • Hack 2. Use cd alias to navigate up the directory effectively
  • Hack 3. Perform mkdir and cd using a single command
  • Hack 4. Use “cd -” to toggle between the last two directories
  • Hack 5. Use dirs, pushd and popd to manipulate directory stack
  • Hack 6. Use “shopt -s cdspell” to automatically correct mistyped directory names on cd

Chapter 2: Date Manipulation

  • Hack 7. Set System Date and Time
  • Hack 8. Set Hardware Date and Time
  • Hack 9. Display Current Date and Time in a Specific Format
  • Hack 10. Display Past Date and Time
  • Hack 11. Display Future Date and Time

Chapter 3: SSH Client Commands

  • Hack 12. Identify SSH Client Version
  • Hack 13. Login to Remote Host using SSH
  • Hack 14. Debug SSH Client Session
  • Hack 15. Toggle SSH Session using SSH Escape Character
  • Hack 16. SSH Session Statistics using SSH Escape Character

Chapter 4: Essential Linux Commands

  • Hack 17. Grep Command
  • Hack 18. Find Command
  • Hack 19. Suppress Standard Output and Error Message
  • Hack 20. Join Command
  • Hack 21. Change the Case
  • Hack 22. Xargs Command
  • Hack 23. Sort Command
  • Hack 24. Uniq Command
  • Hack 25. Cut Command
  • Hack 26. Stat Command
  • Hack 27. Diff Command
  • Hack 28. Display total connect time of users

Chapter 5: PS1, PS2, PS3, PS4 and PROMPT_COMMAND

  • Hack 29. PS1 – Default Interaction Prompt
  • Hack 30. PS2 – Continuation Interactive Prompt
  • Hack 31. PS3 – Prompt used by “select” inside shell script
  • Hack 32. PS4 – Used by “set -x” to prefix tracing output

Chapter 6: Colorful and Functional Shell Prompt Using PS1

  • Hack 34. Display username, hostname and current working directory in the prompt
  • Hack 35. Display current time in the prompt
  • Hack 36. Display output of any command in the prompt
  • Hack 37. Change foreground color of the prompt
  • Hack 38. Change background color of the prompt
  • Hack 39. Display multiple colors in the prompt
  • Hack 40. Change the prompt color using tput
  • Hack 41. Create your own prompt using the available codes for PS1 variable
  • Hack 42. Use bash shell function inside PS1 variable
  • Hack 43. Use shell script inside PS1 variable

Chapter 7: Archive and Compression

  • Hack 44. Zip command basics
  • Hack 45. Advanced compression using zip command
  • Hack 46. Password Protection of Zip files
  • Hack 47. Validate a zip archive
  • Hack 48. Tar Command Basics
  • Hack 49. Combine gzip, bzip2 with tar

Chapter 8: Command Line History

  • Hack 50. Display TIMESTAMP in history using HISTTIMEFORMAT
  • Hack 51. Search the history using Control+R
  • Hack 52. Repeat previous command quickly using 4 different methods
  • Hack 53. Execute a specific command from history
  • Hack 54. Execute previous command that starts with a specific word
  • Hack 55. Control the total number of lines in the history using HISTSIZE
  • Hack 56. Change the history file name using HISTFILE
  • Hack 57. Eliminate the continuous repeated entry from history using HISTCONTROL
  • Hack 58. Erase duplicates across the whole history using HISTCONTROL
  • Hack 59. Force history not to remember a particular command using HISTCONTROL
  • Hack 60. Clear all the previous history using option -c
  • Hack 61. Substitute words from history commands
  • Hack 62. Substitute a specific argument for a specific command
  • Hack 63. Disable the usage of history using HISTSIZE
  • Hack 64. Ignore specific commands from the history using HISTIGNORE

Chapter 9: System Administration Tasks

  • Hack 65. Partition using fdisk
  • Hack 66. Format a partition using mke2fsk
  • Hack 67. Mount the partition
  • Hack 68. Fine tune the partition using tune2fs
  • Hack 69. Create a swap file system.
  • Hack 70. Create a new user
  • Hack 71. Create a new group and assign to an user
  • Hack 72. Setup SSH passwordless login in OpenSSH
  • Hack 73. Use ssh-copy-id along with ssh-agent
  • Hack 74. Crontab
  • Hack 75. Safe Reboot Of Linux Using Magic SysRq Key

Chapter 10: Apachectl and Httpd Examples

  • Hack 76. Pass different httpd.conf filename to apachectl
  • Hack 77. Use a temporary DocumentRoot without modifying httpd.conf
  • Hack 78. Increase the Log Level temporarily
  • Hack 79. Display the modules inside Apache
  • Hack 80. Show all accepted directives inside httpd.conf
  • Hack 81. Validate the httpd.conf after making changes
  • Hack 82. Display the httpd build parameters
  • Hack 83. Load a specific module only on demand

Chapter 11: Bash Scripting

  • Hack 84. Execution Sequence of .bash_* files
  • Hack 85. How to generate random number in bash shell
  • Hack 86. Debug a shell script
  • Hack 87. Quoting
  • Hack 88. Read data file fields inside a shell script

Chapter 12: System Monitoring and Performance

  • Hack 89. Free command
  • Hack 90. Top Command
  • Hack 91. Ps Command
  • Hack 92. Df Command
  • Hack 93. Kill Command
  • Hack 94. Du Command
  • Hack 95. lsof commands.
  • Hack 96. Sar Command
  • Hack 97. vmstat Command
  • Hack 98. Netstat Command
  • Hack 99. Sysctl Command
  • Hack 100. Nice Command
  • Hack 101. Renice Command

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 58 comments… read them below or add one }

1 Administracion Debian February 12, 2009 at 2:30 am

Hi Ramesh.

Thanks for the ebook, i think is very interesting.
I hope to read it entirely and comment it again when I do.

2 Alexei Korobkin February 12, 2009 at 7:01 am

Cool stuff, thanks. I like it.

There are some typos like “ip-addres”, and links that are only available in electronic version. In other words, if you print the book, you will never know where a link is pointing to. It would be nice to add a footnote with target URL to each hyperlink.

And it would be great to explain why would somebody want to use particular command. For example, what’s the point of using xargs in find if i can just do -exec and any command I want? it is not mentioned anywhere that xargs helps to overcome the limit of command line arguments in shell (see xargs –show-limits).

In “Create a new user” section you do “useradd” and then suddenly “adduser” which is completely different command. You don’t explain when would one want to use useradd or adduser.

Btw, usermod -G will replace all supplementary groups. You need usermod -a -G most of the time.

Anyway, thanks for the great work you’ve done!

3 Binny V A February 12, 2009 at 12:44 pm

Nice job – I’ll write a post about this in my blog soon.

4 Gullit February 12, 2009 at 3:08 pm

Thanks for sharing!
I’ll share it with some friends of mine, of course it’ll be very helpful, thanks!

5 Roshan Bhattarai February 12, 2009 at 11:16 pm

great work man…I really have to appreciate your hard work………..

6 Joseph February 13, 2009 at 1:06 am

Thank you for sharing with us.

7 Willie February 13, 2009 at 1:32 am

Awesome man!

8 Muhammad Samir February 13, 2009 at 1:49 am

Thanks for sharing your knowledge, great book.

9 Flipouk February 13, 2009 at 3:25 am

Thanks! I have only browsed through the Table of Content so far and I have already found interesting bit and pieces. You’re a star :)

10 Pablo February 13, 2009 at 6:21 am

Thank you very much for this book! I’m downloading it right now

11 Raphael February 13, 2009 at 8:24 am

Great, thanks Ramesh.

12 Dave Van February 13, 2009 at 8:16 pm

Thanks, I’ll be using this a lot. I’m glad to see that it is more than just basics. Dave

13 oseb February 14, 2009 at 2:22 am


14 Gagan Brahmi February 14, 2009 at 8:11 am

Nice stuff dude..

Hack 28 needs to mention what part of the package is the “ac” command. It is does not mention that is a part of psacct utility.

I am in the process of going through the others.. will provide you if I some more stuff in that.. I hope you don’t mind.

And not to mention, it is a indeed a nice collection.

15 Joao Trindade February 14, 2009 at 11:36 am

Thanks for sharing your knowledge! :)

16 Kiruguiru February 14, 2009 at 12:44 pm

Thanks very much for your excellent work

17 eric February 14, 2009 at 8:30 pm


18 Dafero February 15, 2009 at 6:30 am

Thanks!! It looks very good!
Thanks a lot from Spain!

19 T.D.S February 15, 2009 at 2:10 pm

Thanks for sharing , this stuff talk about important things , thanks again dude .

20 k'echa February 15, 2009 at 5:57 pm

bad karma

Title: Linux 101 Hacks – Free eBook
Author: Ramesh Natarajan
Creator: Acrobat PDFMaker 7.0 for Word
Producer: Acrobat Distiller 7.0 (Windows)
Created: Mon Feb 09 03:14:50 CET 2009

21 SattaM ALotaiBI February 16, 2009 at 2:48 am

Hi, i upload it to ARCHIVE

have fun :)

22 Phil February 16, 2009 at 6:10 am

Thank you so much XD

23 Ajith Edassery February 16, 2009 at 7:22 am

Congrats on your eBook release, Ramesh. Really good work.

I have stumbled the post…


24 Peter February 16, 2009 at 10:18 am

Great book, but why do you use a password?

Best regards,

25 Sourav Mohanty February 17, 2009 at 7:08 am

Thnks for Ebook……….
Great work..

26 Juan Carlos February 17, 2009 at 9:30 am

Excellent!! Thanks!!

27 Arda February 18, 2009 at 8:33 am

Very cool of you to share your knowledge. Thanks a lot!

28 jcp February 18, 2009 at 6:37 pm

Thank you very much. It’s greatly appreciated.

29 Chaitanya Junghare February 18, 2009 at 7:38 pm

Great work Ramesh! I’m in love with the book. So many great ideas. Thanks a lot.
Dont stop here, we expect more such good stuff from you :)

30 TheEvilAbu February 19, 2009 at 3:06 pm

Thank you very much, I started using Linux not long ago (Gentoo) and this will definitively very useful :)


31 Mahen February 20, 2009 at 11:12 pm

Thanks A lot Ramesh,….

The book is outstanding … It delivers the linux commands and with ace of simplitcity.. clear example. Any body having a little knowledge in linux. can get a lot help from the book.

Every linux beginner.. at least should go through the book once.. It will definitely enhance their skill and expertise …
Again thanks a lot to author …


32 hawkmk67 February 21, 2009 at 6:50 am


33 Ashraf February 22, 2009 at 4:33 am

Thanks for sharing your knowledge

34 Nycrican2 February 27, 2009 at 8:12 pm

Great book. A student of mine alerted me to your book. I have looked through it and feel that this will be very useful for my college students. Thanks so much for sharing your knowledge with others.

35 lunajr April 1, 2009 at 9:23 pm


36 vancrof April 11, 2009 at 9:27 am

I need this….. jeje…. thanks

37 abdel April 24, 2009 at 10:23 am

Thanks for the ebook, i think is very interesting. and helpfull

38 fburgos May 19, 2009 at 2:29 pm

excelent book

39 zion May 28, 2009 at 11:59 pm


40 Jisty June 25, 2009 at 5:20 am


41 David June 25, 2009 at 10:00 am

Great, thanks Ramesh.

42 eric July 13, 2009 at 11:39 am

this book is great

43 mg October 28, 2009 at 10:28 am


44 mgxx November 18, 2009 at 1:40 am

great,thanks alot

45 wanyce ahoura December 12, 2009 at 8:47 am

hi the most greating book is this
so thank you for all who work on this book

46 akshy December 14, 2009 at 2:16 am

i got the book its really coollllllllllllllllllllllllllllllllll

47 Pri2sh December 23, 2009 at 9:52 am

thanks for the info, some commands can be used in ubuntu also.

48 ahmad khan January 5, 2010 at 2:05 am

hi this is good way to share your knowledgd u r a great guy.

49 Kevin March 3, 2010 at 2:47 am

it really nice book, thx

50 cmcanulty June 13, 2010 at 3:59 pm

I read your book and see it as very useful but what I need is something between Beginning Ubuntu Linux and your book. I run several machines at our local library on Ubuntu Lucid and 2 machines at home. But I need an intermediate book, thank you

51 Armando November 24, 2010 at 12:19 pm


52 seba March 4, 2011 at 9:57 am

is this just the 1st release of the book? is there a 2nd release? Thanks! You are awesome!

53 Abdelhak May 14, 2011 at 9:54 am

Hi Ramesh,
Thank you for this ebook.
Can you make available the LaTeX code of the book please (or at least, the minimum code so that someone can produce documents like this one)? It’s awesome.
Please, email me.
Thank you in advance.

54 johnp October 7, 2011 at 9:21 am


55 Enzo March 30, 2012 at 12:20 pm

HI Ramesh,

Your books sound very interesting, i’m definetely going to read it. Thank you very much!

56 khurshid June 11, 2012 at 9:43 pm

HI All
I want a good Linux book with backhand command.

57 GamaZz January 7, 2013 at 3:25 pm

Thank you :)

58 SathishKumar October 8, 2013 at 4:35 am

I like this website because i find difficult to get the books about linux always. Really this website helped me alot

Leave a Comment

Previous post:

Next post: