Linux hack

Solo disponible en BuenasTareas
  • Páginas : 95 (23659 palabras )
  • Descarga(s) : 0
  • Publicado : 9 de septiembre de 2012
Leer documento completo
Vista previa del texto
Linux 101 Hacks

www.thegeekstuff.com

Table of Contents
Introduction ............................................................. 7 Foreword ................................................................. 8 Version.................................................................... 8 Chapter 1: Powerful CD Command Hacks ......................... 9
Hack 1. Use CDPATH to define the basedirectory for cd command ... 9 Hack 2. Use cd alias to navigate up the directory effectively ......... 10 Hack 3. Perform mkdir and cd using a single command ................ 13 Hack 4. Use “cd -” to toggle between the last two directories ....... 14 Hack 5. Use dirs, pushd and popd to manipulate directory stack..... 14 Hack 6. Use “shopt -s cdspell” to automatically correct mistyped directorynames on cd ......................................................... 17

Chapter 2: Date Manipulation....................................... 18
Hack 7. Set System Date and Time .......................................... 18 Hack 8. Set Hardware Date and Time....................................... 19 Hack 9. Display Current Date and Time in a Specific Format .......... 19 Hack 10. Display Past Dateand Time ....................................... 21 Hack 11. Display Future Date and Time .................................... 22

Chapter 3: SSH Client Commands .................................. 24
Hack 12. Identify SSH Client Version........................................ 24 Hack 13. Login to Remote Host using SSH ................................. 24 Hack 14. Debug SSH Client Session.......................................... 26 Hack 15. Toggle SSH Session using SSH Escape Character .............. 27 Hack 16. SSH Session Statistics using SSH Escape Character ........... 29

Chapter 4: Essential Linux Commands ............................ 31
Hack 17. Grep Command ...................................................... 31

2

Linux 101 Hacks

www.thegeekstuff.com

Hack 18.Find Command....................................................... 33 Hack 19. Suppress Standard Output and Error Message................. 35 Hack 20. Join Command ....................................................... 35 Hack 21. Change the Case..................................................... 36 Hack 22. Xargs Command...................................................... 37 Hack 23. SortCommand ....................................................... 38 Hack 24. Uniq Command....................................................... 41 Hack 25. Cut Command ........................................................ 42 Hack 26. Stat Command ....................................................... 43 Hack 27. Diff Command ........................................................ 44 Hack 28.Display total connect time of users ............................. 45

Chapter 5: PS1, PS2, PS3, PS4 and PROMPT_COMMAND....... 47
Hack 29. PS1 - Default Interaction Prompt ................................ 47 Hack 30. PS2 - Continuation Interactive Prompt ......................... 48 Hack 31. PS3 - Prompt used by “select” inside shell script............ 49 Hack 32. PS4 - Used by “set -x” toprefix tracing output .............. 50 Hack 33. PROMPT_COMMAND................................................. 52

Chapter 6: Colorful and Functional Shell Prompt Using PS1 . 53
Hack 34. Display username, hostname and basename of directory in the prompt ....................................................................... 53 Hack 35. Display current time in the prompt............................. 53 Hack 36. Display output of any command in the prompt ............... 54 Hack 37. Change foreground color of the prompt........................ 55 Hack 38. Change background color of the prompt ....................... 56 Hack 39. Display multiple colors in the prompt .......................... 57 Hack 40. Change the prompt color using tput ............................ 58 Hack 41. Create...
tracking img