IMPORTANT LINUX COMMANDS man rm will give all details of rmcommand cancel command ctr+c 1. pwd( print working directory) example:"/user/manu" 2.ls (list current diretory item) 3. ~ home directory (ls ~) will list all files from hom directory 4. ls -F (list folders with sashes) 5. ls -l (list files with permissions) drwxr-x r-x 2 manu manu 4096 Oct 9 24:34 Desktop here: d -> directory rwx-> read write execute user group r-x read and execute all users r-x read and execute 6. ls -lh (list files with permissions file size in kb/mb/tb)rest same as ls -l 7. cd /home/manu/downloads passing absolute path (change directory) 8. cd downloads (if file incurrent directory and you cd into it it is relative path) 9. go to home directory by cd thats it from anywhere or (cd ~) 10. ls -a shows hidden filestoo 11. cd .. go to parent folder 12. tab competion type /h and hit tab it will complete it to /home if home if incurrent directory and only folder starting with h. 13. file fie.png will return detils about image png. 14. ls donloads document will output download and document folder files 15. ls * (list all directory files of current directory folder) download,document,desktop. 16. ls D* (list all directory files of current directory folder where directory name starts with D(capital D)) 17. ls *.txt (where files ends with txt) 18. ls ?.txt (where ends with txt but has only one charector before . like (a.txt)) 19. ls ??.txt (where ends with txt but has only two charector before . like (a1.txt)) 20. ls file[1234567890].text (will getfiles like file1.txt so it can be 1 to 9 ) 21. ls file[0-9][0-9][A-Z][a-z].text create files 22. touch /Desktop/Home/home.txt will reate txt file in home 23. echo "hello" > hello.txt will create txt file with hello printed in file. 24. mkdir ~/Downlods/box will create box folder in downloads folder. 25. mkdir -p bla/home/blam will crete all three folder bla then home then blam. 26. mkdir happy birthday will crete 2 folders happy an birthday. 27. mkdir "happy birthday" will create folder with name happy birthday 28. mkdir {jan.feb,mar,apr,may,jun,july,aug,sep,oct,nov,dec}_{2017,2018,2019,2020,2021,2022} will create folder such as jan_2017 dec_2022 mkdir same as above {2017..22} can be {A..Z} can be {1..100} mkdir folder/{0..500} will create 500 folders then create fles in 500 folders touch haystack/folder{1..500}/file{1..100} 29. touch {jan.feb,mar,apr,may,jun,july,aug,sep,oct,nov,dec}_{2017,2018,2019,2020,2021,2022}/file{1..100} touch{A,B,C}.txt will crete foldersnd 100 files in each folder 30.ls {jan.feb,mar,apr,may,jun,july,aug,sep,oct,nov,dec}_{2017,2018,2019,2020,2021,2022} so list viewof all folders and files DELETE FILE -r recursive 31. rm file.txt document/file2.txt will delete both file 32. rm -r delfolder/ "will delete folder" 33. rm -r * delets all without asking 34. rm -ri * delets all with asking before deleting eah file 35. rmdir will delete empty folders only COPY FILE 37. cp file1.txt file2.txt // will copy content of file 1 into file 2 38. cp file1.txt file2.txt destination/ // will copy content of file 1 into file 2 and put in destination folder 39. cp destination/* . copy everything from destination folder to this folder 40. cp destination/* .. copy everything from destination folder to parent folder MOVING AND RENAMING FILES 41. mv oldname.txt newname.txt ((will move file and change name)) 42. mv oldfolder/ newfolder (( changes the name of folder without canging file inside it)) 43. mv destination/* . move everything from destination folder to this folder EDIT FILES Using NANO 44. nano diary.txt (will create diary file nd open it in editor). Locate files 45. locate *.conf ( will list out all files with extention .conf) 46. locate -i *.conf ( will list out all files with extention .conf) case insensitive 47. locate -i --limit 10 *.conf ( will list out all files with extention .conf) case insensitive(returns 10 result) 48. locate -S shows database details 49. sudo updatedb (will update database and includes all new files in database). so if you create a file in system and update database file will be in database. include --existing to check if all files exists in return list Find COmmand 50. find (will display list of files and folder from current folder and childfolders) 51. find /etc (will display files and folder from etc folder and childfolder ) 52. find . -maxdepth 1 ( wil return list of folder and files current directory) 53. find . -maxdepth 2 ( wil return list of folder and files current directory nd child folder) 54. find . -type f (will return file list) 55. find . -type d (will return folder list) 56. find -name "5.txt" ( will file 5.text in current and child folders) 57. find -iname "5.txt" ( will file 5.text in current and child folders case insenstive) 58. find / -type f -size -100k (files from root where file size less than 100kb) 59. find / -type f -size +100k (files from root where file size more than 100kb) 60. sudo find / -type f -size +100k -size -5M (files from root where file size more than 100kb and less than 5 mb) add | wc -l to see file count at the end of find command 61. sudo find / -type f -size +100k -size -5M -exec cp {} /output \; will copy all files to output folder -exec stands for execute. {} stands for files so we are saying copy {} to /output exec command ends with \; if change -exec with -ok it will ask before copying each file 62. touch haystack/folder$(shuf -i 1-500 -n 1)/needle.txt (will create a file name needle inside random folder from 1 t 500) 63. less filename (will give yu pge content page by page) 64. | less in any command to see output page by page 65. | head -n 2 add in any output command will return output from top 2 lines 66. | tail -n 2 add in any output command will return output from bottom 2 lines SORT 67. sort word.txt (will return output sorted a to z) SORTS A-Z ALSO 0-9 68. sort -r word.txt (will return output sorted and reversed z to a ) 69. sort -n numbers.txt (sort by value) -nr for reverse 70. sort -u numbers.txt (sort by value) return unique nuumber after sorting -ur for reverse SEARCH FILE CONTENT 71. grep e hello.txt (Will return lines containing e in them from hello.txt) 72. grep -c e hello.txt (Will return number of lines containing e in them from hello.txt) 73. grep -i e hello.txt (Will return number of lines containing e in them from hello.txt) insensitive 74. grep -v e hello.txt (Will return lines not containing e in them from hello.txt) 75.grep e hello.txt names.txt (Will return lines containing e in them from hello.txt & name.txt)