29 Daily Use Linux Commands for Beginners

29 Daily Use Commands

Daily Use Linux Commands

  1. cat – display or concatenate files
  2. cd – change directory
  3. chmod – change the permissions on a file or directory
  4. compress – compress a file
  5. cp – copy a file
  6. date – display the current date and time
  7. diff – display differences between text files
  8. echo – echo arguments to the standard
  9. output file – determine the type of a file
  10. find – find files of a specified name or type
  11. finger – display information about a user
  12. ftp – file transfer program
  13. grep – searches files for a specified string or expression
  14. kill – kill a process
  15. lpr – print out a file l
  16. s – list names of files in a directory
  17. man – display an on-line manual page
  18. mkdir – make a directory
  19. more – scan through a text file page by page
  20. mv – move or rename files or directories
  21. nice – change the priority at which a job is being run
  22. passwd – change your password ps – list processes
  23. pwd – display the name of your current directory
  24. quota – disk quota and usage
  25. rm – remove files or directories
  26. rmdir – remove a directory
  27. sort – sort and collate lines
  28. talk – talk to another user
  29. wc – display a count of lines, words and characters

How to Get Two Top Duplicate Records

I have been asked the same question in an interview. How to get 2 top duplicate records?

Sort file1 |unique -d | head -2

What this command does…

  • Sorts File
  • Display duplicate records
  • Top 2 duplicate records

Count Number of Lines in a List of Files Using For Loop

#!/bin/bash 
if [ $# -lt 1 ]
then
echo "Usage: $0 file ..."
exit 1
fi
echo "$0 counts the lines of code"
l=0
n=0
s=0
for f in $*
do
l=wc -l $f | sed 's/^\([0-9]*\).*$/\1/'
echo "$f: $l"
n=$[ $n + 1 ]
s=$[ $s + $l ]
done
echo "$n files in total, with $s lines in total"

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.