3.0 Linux Commands

3.1 Requirements

  • Access to the HPC or a Linux computer

3.2 Common commands

  • Change password: passwd

  • Make directory: mkdir

  • Change directory: cd

  • Remove file: rm

  • Remove directory: rmdir

  • Check logged-in users: who or w

  • Monitor system: top (press 1 for per-CPU view, q to quit)

  • Getting help on various UNIX commands: man cd or simply man

  • Search for text in files: grep 'search_term' filename

  • Process and analyze text files: awk '{print $1}' filename

  • Count lines, words, and characters in a file: wc filename

  • Display the first few lines of a file: head filename

  • Display the last few lines of a file: tail filename

  • Redirect output to a file: command > output.txt

  • Append output to a file: command >> output.txt

  • View running processes: ps aux

  • Kill a process: kill process_id