These are some useful Linux Terminal Commands for productivity:
Commands using ls etc.
| use | to |
|---|---|
ls -ltr | list files in reverse modification history order with details. |
| `ls -ltr | tail -n 5` |
| `ls | head -n 5` |
rename 's/original/new/' * | To rename all filenames and directories containing “original” string to “new” string. To recursively do this in sub-directories, use **/*. See: here and here |
for dir in */; do mkdir -- "$dir"/{tmp1,foo,bar,qux}; done | To create directories within sub-directories in one go! |
ls -a | list all files, including hidden ones! |
For opening image files from Terminal
Opening files directly through the Terminal is both easy and fast. Additionally, these commands are useful to view resulting files when using subprocess.run in Python to run Terminal commands.
| use | to |
|---|---|
evince filename | open PDF files and PS document files. |
eog filename | open image files in normal image formats like JPEG, JPG, PNG etc. |
ds9 filename | open FITS format image files. Requires DS9 |
fv filename | open FITS format event lists and datasets. Requires initiation of NASA’s heasarc |
To Check File Size in directories and sub-directories
du -h d 1 | sort -hu
Ref : https://www.linuxteck.com/9-basic-du-command-in-linux-with-examples/
Custom git and ls aliases
These customization commands have been put in the ~/.zshrc or the bash script at ~/.bashrc, and enable more efficient git status checks etc.
# git aliases
alias gs="git status"
alias gb="git branch"
# ls aliases via li
alias ll="eza -l -g --icons"
alias li="eza --icons"
alias lt="eza --tree --icons -a -I '.git|__pycache__|.mypy_cache|.ipynb_checkpoints'"
alias lid="eza --icons -d */"
alias lin="eza --icons --sort newest"
alias lidn="eza --icons -d */ --sort newest"
alias lind="eza --icons --sort newest -d */"
alias lf="eza --icons *.py --sort newest"
alias lld="eza -l -g --icons -d */"
alias llin="eza -l -g --icons --sort newest"
alias llf="eza -l -g --icons *.py --sort newest"
Note:
lfif used for python files, instead oflpy, b’cuz the latter is a bit cumbersome to type out fast.
Note: Remember to source the bashrc file after any modifications.
Notes: use
ezaon a macos system ifexais decrepit.