Most used Linux commands

Published by

on

The following are the most commonly used command in Linux.

  • ls – list the files and directories in the folder
  • ls -a List all files and directories along with hidden files
  • ls -l List all files and directories in long format
  • ls -lh List all files and directories with size in human readable format
  • ls -t Sort by time (newest first)
  • ls -t Sort in reverse order (oldest first)
  • ls -lrth – list the files and directories in the folder in long format and sorted reverse by time, and size in human readable form
  • man command To see manual for a particular command (Eg: man ls)
  • cat /path/to/filename Read the file
  • grep -rni 'search string‘ Search for the string within all files in current directory
  • grep -rni '/path/to/filename.txt' Search for string in the particular file
  • file ./ -name '*string*' Search for the file name
  • history Prints the previously used commands

Shortcuts in terminal

  • Ctrl + R – Search previous commands
  • Ctrl + W – Delete a word
  • Ctrl + right arrow – Move the cursor by word right side
  • Ctrl + right arrow – Move the cursor by word left side
  • Up arrow – Show the previously used command

PS: The above command and shortcuts are mostly used by me, this blog I wrote to keep note of the same for my personal use and might be useful for someone.

Leave a comment