What are common tput commands?

QuestionsQuestions8 SkillsProYour First Linux LabOct, 24 2025
0175

Here are some common tput commands that you can use to manipulate terminal display and behavior:

  1. Clear the Screen:

    tput clear
  2. Set Text Color:

    • Set foreground color (text color):

      tput setaf [color_number]

      For example, tput setaf 1 sets the text color to red.

    • Set background color:

      tput setab [color_number]

      For example, tput setab 4 sets the background color to blue.

  3. Bold Text:

    tput bold
  4. Underlined Text:

    tput smul  # Start underlining
    tput rmul  # Stop underlining
  5. Move the Cursor:

    tput cup [row] [column]

    For example, tput cup 5 10 moves the cursor to row 5, column 10.

  6. Clear to End of Line:

    tput el
  7. Reset Terminal Attributes:

    tput sgr0

    This command resets all attributes to their defaults.

  8. Hide Cursor:

    tput civis
  9. Show Cursor:

    tput cnorm
  10. Enable/Disable Line Wrapping:

    • Disable line wrapping:
      tput rmam
    • Enable line wrapping:
      tput smam

These commands can be combined in scripts to create visually appealing terminal applications or to enhance user interaction. Feel free to experiment with them to see how they affect your terminal!

0 Comments

no data
Be the first to share your comment!