Revanth Vermareddy

Bash Commands to Remember

1 minutes (256 words)
bash-icon

🔗Common bash commands to remember at one place

  1. Change the server language to English:

    export LC_ALL=C
    
  2. Look at the username for of who is running a process on a multi-user server:

    ps -u -p <PROCESS_ID>
    
  3. Re-authenticate with github after your PAT has expired:

    gh auth login -h [github.com](http://github.com/)
    
  4. Pip install without clogging the cache dir, add a --no-cache-dir flag to your pip install commands.

  5. Create a virtual environment with the below command.

    python -m venv <path_to_the_environment>
    
  6. Run a python script with nohup and pipe the output to a file.

    nohup python my_script_is_the_best.py &> my_scripts_output.out 2>&1 &
    
  7. Batch convert wav files to mp3 files with ffmpeg -

    for f in _.{wav,WAV}; do ffmpeg -i "$f" -c:a libmp3lame -q:a 2 "${f%._}.mp3"; done
    
  8. Append a prefix to specific files in a directory -

    for f in {0,1,2,3,4,5}.mp3; do mv "$f" "GAN_$f"; done
    

Tags: #bash #shell