Linux Terminal Commands

1 minute read


These are some useful Linux Terminal Commands for productivity:

Commands using ls etc.

ls -ltrlist files in reverse modification history order with details.
ls -ltr | tail -n 5list only the last (tailing) 5 files from the list. Change 5 to any integer.
ls | head -n 5list only the first 5 files from the list.
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}; doneTo create directories within sub-directories in one go!

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 in Python to run Terminal commands.

evince filenameopen PDF files and PS document files.
eog filenameopen image files in normal image formats like JPEG, JPG, PNG etc.
ds9 filenameopen FITS format image files. Requires DS9
fv filenameopen FITS format event lists and datasets. Requires initiation of NASA’s heasarc