# checkallserviceslikepsauxservice--status-all# Processesusingmost CPU or RAMps-eopid,comm,%cpu,%mem--sort=-%cpu|head-n5# Toseetop4memoryconsumingprocessisps-eopid,comm,%cpu,%mem--sort=-%mem|head-n5Where,\-e :Thisflagisusedtoselectallprocess\-o :Thisflagisusedtoformatas user-defined.pid :Thisargumentusedforshowingpidcomm:Thisargumentusedforshowingcommandnameonly.Togetfullcommanduseargs,cmdorcommand%cpu:Thisargumentshowsthepercentageofcpuutilizationoftheprocessin"##.#"format.Herepcpucanalsobeused.%mem:Thisargumentshowstheratiooftheprocess's resident set size to the physical memory on the machine, expressed as a percentage. Here pmem can also be used.\--sort:Specifysortingorder.After=the-signisusedtosorthighestvalueatthetopwherethedefaultoptionwhichis+istolistincreasingnumericalorder \[i.e0ton\].#Listopenfilelsof/var/log/syslog #-> check which proccess is using a filelsof-i TCP:22 #->whatprocessusesaparticularTCPportlsof-p890 #->youneedtoknowwhatfilesaparticularprocesshasopen# SeeopenfilesandexecutedscriptsbyPIDsudolsof-p329953
Working with Files
# findfolderstoragesize.Change1,with2or3forsubfolderssudodu-hd1/home/dimitar# Livetail,showlast100resultstail-100f/var/log/mylog.log# Searchefortextinsidefiles,recursively (itwillchecksubfolderstoo)grep-Hrn'search term'path/to/files### youcanusealsogrep-Rnw'/path/'-e'patern'# Toparseallinstancesofthewordserrororfailurein/var/log/cfn or /var/log/cloud-init files,run the following command:grep -ni 'error|failure' $(sudo find /var/log -name cfn\* -or -name cloud-init\*)To parse only in one file:grep -ni 'error|failure' /var/log/cfn-init.log# Find file only,recursively (it will check subfolders too)find/path/to/file-name"DetailsMessage.php"# Deletefoldercontentincludinghiddenfilessudorm-rfFolderName/.\[^.\]\*# Copyfilesincludinghiddenones (withdot).Don't specify the files, (Note that /home/FolderToPaste must not exist already, or else it will create /home/FolderToCopy inside itcp-r/home/FolderToCopy/home/FolderToPate# findfullpathofafile.Usefullwhenwanttocopy/pastefilepathinsideterminalrealpathfile.txt # output/home/dimitar/downloads/file.txtorreadlink-ffile.txt # sameas realpath